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
Sending two different bytes of data to Labview via USB
- 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
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: Sending two different bytes of data to Labview via USB
Hi Ben,
where can I find the help file that explains how to do this?
Rgds,
Paul
where can I find the help file that explains how to do this?
Rgds,
Paul
- 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
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel