Sending two different bytes of data to Labview via USB

Tips, Tricks and methods for programming, learn ways of making your programming life easier, and share your knowledge with others.

Moderators: Benj, Mods

Post Reply
paulm
Posts: 36
Joined: Mon Mar 28, 2011 9:37 pm
Contact:

Sending two different bytes of data to Labview via USB

Post by paulm »

Hi,

I'm using the ECIO_28 to measure the frequency of a waveform using interrupt RBO to reset Timer1, which is 16 bit timer, on a rising edge clock edge.

I want to send the contents of Timer1 just before resetting it to Labview using the USB slave component by sending the contents of tmr1h and tmr1l continually to Labview (i.e. two consectutive bytes).

My question is when sending two consectutive bytes continually to Labview how do I get Labview to identify which byte is which, so that tmr1h is not mixed up with tmr1l?

The reason I'm sending the timer1 information to Labview is that I'm doing the frequency calculation in Labview based on the value of Timer1.

I could do the frequency calculation in the ECIO_28 but I would want to create an integer to get enough frequency range on the measurement and I don't know how to do a USB slave transfer of an integer. The examples only show it for bytes. If somebody knows how to transfer the contents of an integer via USB I would welcome any suggestions. I think I'm back to the problem where I would have to parse the integer into two bytes anyway and send them consectutively.

Rgds,
Paul

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Sending two different bytes of data to Labview via USB

Post by Benj »

Hello,

The USB slave component can be setup to transfer a 16-bit Int or other combination of values. Have you looked at the USB slave help file it should hopefully help you to get started.

paulm
Posts: 36
Joined: Mon Mar 28, 2011 9:37 pm
Contact:

Re: Sending two different bytes of data to Labview via USB

Post by paulm »

Hi Ben,

where can I find the help file that explains how to do this?

Rgds,
Paul

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Sending two different bytes of data to Labview via USB

Post by Benj »

Hi Paul,

Go into the USB slave component properties window and click help.

You can send a 16-bit value as an int or as two bytes.

To move from an int to two bytes you would do this.

byte0 = int & 0xff
byte1 = (int >> 8 ) & 0xff

The actual data sent through the USB is an array of bytes so either will give the same result.

In Labview you will have to combine the two bytes back into an int. I think there are basic icons to do this for you or you can simply multiple byte1 by 256 using a 16-bit variable to hold the result and then add byte0.

Post Reply