04-12-2013 07:22 PM
There are many discussion forums articles about how to transmit various data types - Binary, Hex, Ascii, over a standard PC RS232 serial port. None of the articles and the solutions in them seem to meet my 'need'.. which is:
If a user will type a HEX character into a Control String (0-9, A-F) then the following will be xmitted over the 232 signal:
'0000' if 0 was entered
'1000' if 1 was entered
'0001' if 8 was entered
'0101' if A was entered
'1111' If F was entered.
bit ordering is not important as I can manipulate it.
What functions are avail to me to accomplish that?
Closest thing I found in the forums is an example in that link. But it is kind of goofy and impractical.
http://digital.ni.com/public.nsf/allkb/2FA318A7B669954E86256FBE007FAA4E
Thanks
04-12-2013 08:20 PM
So you want to transmit ASCII "1" "0" "0" "0" for a 1?
I would start with a numeric control, not a string control. Use U8 representation. Set display format to to Hex and data entry to limit values to 0..15. Then use Format into String with "%04b" as the format string. Connect the output to the input of the VISA Write.
Note that this produces the reverse bit order from your example.
Lynn
04-13-2013 11:22 AM
taking Lynn's approach to the end.
04-15-2013 03:55 PM
Thanks Lynn and Jeff.
Jeff - I could not obtain the result you did when I implemented your picture into a VI.
It took me a little while to find the Sort 1D-Array function(?) For the sample in your post, I am getting 0001 for '2'.
Must be something I am not configuring right in that function or elsewhere...
I am attaching the VI I created, if you could please check it out.
Also, when using Lynn's version toI xmit the resulting 0s and 1s binary string, it seems that the Visa Write function converts them BACK to ASCII, as with a scope probe on the COM port's TxD line I see bunch of '0000_0011' which IS ASCII for 0...
In the block diagram I am expanding the type to U64 and the format string to %048b so I can send the following binary string for example: 110089ABCDEF, hoping to see the following on the scope as the bits roll by: 1000_1000_0000_0000_0001_1001_0101_1101_0011_1011_0111_1111, or something similar.
04-15-2013 04:02 PM
@DaniDin wrote:
It took me a little while to find the Sort 1D-Array function(?) For the sample in your post,
I think that's the Reverse 1D Array
04-15-2013 07:16 PM - edited 04-15-2013 07:19 PM
@crossrulz wrote:
@DaniDin wrote:
It took me a little while to find the Sort 1D-Array function(?) For the sample in your post,
I think that's the Reverse 1D Array
Yes that is reverse array not sort array.
That thing there is actually a "code snipette." Drag or copy it to your desktop then drag it onto an empty LabVIEW Block Diagram. Identical code will be generated
Yeah, its really cool
If you need to build bytes out of your nibbles we can use a "Locical shift" and an AND to merge nibbles
04-15-2013 07:31 PM
Worked fine once I replaced the sort array with reverse array!!
Thanks Jeff