Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

serial communication

How to i know what HEX string is being sent serially from LabView  to represent a duty cycle.  I need
to be able to accept this string with a microcontroller and based on this HEX value i know what duty cycle
i need to put the signal out at.  (assuming that is at same frequency).

I also need to read in that data back into labVIew to check and see if the porper duty cycle is being obtained.  can i send this signal like this
back into labView serially the same way.  so then the question is does it accept HEX values back in labView as well.  And can i with labView code be able to calculate this HEX to check if duty cycle is the same.

I am assuming right now that is i put in 15 as the duty cycle i should get a binary  1111 = and HEX = F.  Is this correct.

and how do i know when i have completely got the data that i need?  Can you program stop bits and start bits in LabView to accomplish this?

0 Kudos
Message 1 of 2
(3,055 Views)

If you want to send hex, change the display format of the string control/indicator. You do this by right clicking on it and selecting 'Hex Display'. In the normal display, if you enter 15, that is the ASCII characters '1' and '5' which is hex 3135. Another way to do this is to have a numeric array into which you enter the hex values. Create an array with U8 as the data type and set the format and precision to hex. Then you can use the Byte Array to String function and wire the output of this to the VISA Write. Doing a VISA Read, you can use the opposite function of String to Byte Array to get the numeric. Type Casting of the string can also be done. Search this board for 'hex' and you will find numerous examples.

Programming stop and start bits has nothing to do with knowing whether you have all of the data that is in the serial buffer. Start and stop bits assure you that each data packet is interpreted correctly. You would use the VISA Bytes at Serial Port to know how many bytes are available. Wire the output of this to the byte count input of VISA Read. When doing hex communication, be sure that you do not set VISA Configure Serial Port to use a termination character.

0 Kudos
Message 2 of 2
(3,048 Views)