Discussion:
how to output binary data to VISA
(too old to reply)
fsdfer
2008-08-10 20:40:04 UTC
Permalink
i am interfacing labview with pic microcontroller through serial port using VISA. it is a stream of digital data which is being tranmitted ,stored in microcontroller and then retransmiited by microcontroller to other device...problem is when that data is converted to string to be given to VISA it makes 16bytes out of 16bits...for example if data was "11110000" (1byte) after converted to string it becomes 8 bytes and my microcontroller thibk that 8 bytes are coming................ please kindly tell me how to transmit binary data over serial port so that bit remains a bit dont become byte............................ data is 99bytes but after passing through VISA it become "99x16"bytes........ please help me
regards
umair
Dennis Knutson
2008-08-10 20:40:05 UTC
Permalink
It sounds like you are converting the numeric to a binary string with the wrong function. You don't mention how you are converting it but all you need to do is a type cast. If the numeric data is an array of U8, then you can use the Byte Array to String function.
 
<img src="Loading Image..."> Message Edited by Dennis Knutson on 08-10-2008 02:32 PM


Send Serial as Byte.PNG:
http://forums.ni.com/attachments/ni/170/348118/1/Send Serial as Byte.PNG
fsdfer
2008-08-11 03:40:04 UTC
Permalink
actually i have string of data avilable which i am catenating into&nbsp; array by "build array" function after converting them to 16bit integer word.i have attached the vi for your further kind assistance....when that function passes&nbsp; through visa 16 bit integer(2 bytes ) become 16 bytes. please have a look. what i want is that after passing through VISA bit should remain a bit


problematic.jpg:
Loading Image...
Dennis Knutson
2008-08-11 04:10:04 UTC
Permalink
What you are doing is a bit confusing. I don't think you need any of that Boolean conversion stuff/division by data bits, etc. and you should not be using the Format Value function. That is what is causing your problem. You are converting some number to ASCII. Originally, you said you were sending a single byte. If you are sending 2 bytes, split them them and use one of the functions I mentioned above.&nbsp;Try taking the 3 I16, convert them into 6 U8, and send them all at once with the Byte Array to String. Six bytes in, six bytes out and written.
fsdfer
2008-08-11 07:40:07 UTC
Permalink
ok i got ypur point a little.................... let say that i have a number "32768"&nbsp; .its binary conversion is "100000000" (2 bytes) whta i actually want is when i transmitt "32768" it get transmitted over RS-232 cable as two bytes............. just tell me how can i do that as simple as possible. i have applied one technique i have split number into two bytes (hi and lo)
then then i append high and low byte into array then i used byte array to string convertor ,let say for example hi byte was "65" and lower one ws "67"&nbsp; after converting to string the corrosponding ASCII&nbsp; were "A" and "C" and they get transmiited as sinle byte each .what i want is data to become binary version of 65 (which is"1000001") but still be transmitted as one byte and read as 1000001 on the hyperterminal of other PC through PIC microcontroller.i hope i have made my point clear .. i am working on my project which has a dead line soon i am stuck here i would be very tankfull if u can kindly farword me your e-mail ID for further assistance i would be very thankfull 2 you
Dennis Knutson
2008-08-11 14:10:07 UTC
Permalink
The attached example in 8.0 converts a U16 into two U8, builds an array and with the Byte Array to String, converts to the hex string 8000 (two bytes). Note that the string indicator is configured for Hex Display (right click option).
Now, when you say you want to see '1000001 on the hyperterminal of other PC', you are contradicting yourself. Hyperterminal cannot be set for binary display so if you want to see '10000001' in Hyperterminal, then you need 8 bytes (one for each ASCII character).
I hope I have made myself clear.


U16 to Hex String.vi:
http://forums.ni.com/attachments/ni/170/348250/1/U16 to Hex String.vi
Continue reading on narkive:
Loading...