LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Creating a string of bits to send out through VISA Serial questions, complete noob here...

Solved!
Go to solution

Hello all,

I'm trying now to scan through the values I have on my GUI clusters, and with those, construct a message to send through VISA.

 

I have the NI usb-> rs232 cable, and I've attached a connector to it, with pins 2 and 3 tied together so I can loopback and see the messages I'm sending.

 

I'm supposed to (from the instructions I'm reading on a design doc)  to send out a message 24 bits long.

And please bear with me, I've never worked on this low of a level before, nor with serial interfaces, so I may be completely off on how I"m trying to do it....and this is my

first stint really with LabView for this project.

 

I have a while loop executing every 20ms.

 

I have an event structure looking for user actions on my front panel.

 

I have also within that while loop, a flat sequence structure.....my assumption was, every 20ms, the flat sequence structure would execute, unless interrupted by an event....which would fire off, and then continue with the flat structure...

 

I saw the VISA write (and read) took a string.

 

So, I started the flat structure with constructing my outgoing bit/byte string....first section is hard coded, and then, through the next two sequences, it loop through,and based on the values of controls within each cluster, I concatenate to my outgoing string......at which case, I send it through the visa through the loopback, and display it on the message indicator.

 

It appears, that I can only send out 8 bits at a time through VISA...so, I'm trying to figure out (and I'm asking the people with the req about this part) why they said to send out such a long string....or, am I supposed to send out each 8 bit message, one at a time?

 

If the one 8 bit message at a time, I'm wondering how I let it know when I'm done?  I've heard and read things about start and stop bits, but I don't know where to put those.

 

Also, is the string what I'm supposed to be putting together to send for something expecting serial bit/byte data? I'd seen one reference to a byte string while researching, but I coulnd't find a byte string component on the palletes.

 

And when I run this (a simpler example of my real app, just showing here the parts I'm trying to figure out)....the message echoing back to me is:

 

111000010000\n

 

When if I have all tubes with a value in them....that I'd get something back like:

 

1110000111111110111111110\n

 

I'm also observing that the messages don't seem to be transmitting every 20ms....only seem to get a message back when when I trip an event, like the enable LEDs button.

 

Anyway, I'm confused I think, on some basic principals, and hope someone can maybe send me some links or give me some pointers on where I'm going so seriously wrong....

 

Is my string message construction the correct way to go?

Is something wrong with the program flow...the events + flat sequence structure?

 

I've gotten this far by searching forums and other NI papers, but I'm kind of stuck and confused I think on some concepts with VISA read/writes...and possible my flow control.

 

Any suggestion and/or links GREATLY appreciated.

 

Thank you,

 

cayenne

 

ps. some have asked to save for older versions, so I'm attaching a copy saved to v10 in addition to 2011

Download All
0 Kudos
Message 1 of 29
(5,531 Views)

You're misunderstanding some things. Event structures wait until events happens, thus your loop wont spin until an even happens ...

You can wire the 20 to the event timeout and place your communication in the timeout case, then it'll wait 20ms, perform the visa stuff, and if another thing happens while waiting it'll be performed.

 

//Y 

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 2 of 29
(5,513 Views)
Ah, thank you. Ok, so I wire to the event 20ms....and move my looping to build the message section in there...I'll look into that. Thank you. Anyone else...with regard to the building of the bits into a string to send out over the usb to serial cable that I currently have in loopback mode? My questions on that with regard to am I building a binary message right (concatenating into one big string....and why I'm seeing what I am echo'ed back)? Thank you, cayenne
0 Kudos
Message 3 of 29
(5,489 Views)

You also don't understand the difference between bits and bytes. You state you have to send out 24 bits but your code does not reflect that. Your very first frame in that needless sequence structure builds a string with 8 characters. Each character is a single byte. so what you are sending there is 64 bits. The character '1' is not at all the same thing as a single '1' bit.

 

p.s. And please, learn a little about for loops and arrays. The indexing you are doing is all wrong. Simply wire in the array so that it autoindexes.

Message 4 of 29
(5,482 Views)

This post is basically a re-hash of another of his post on the same topic  http://forums.ni.com/t5/LabVIEW/Any-good-examples-of-constructing-and-parsing-byte-data/m-p/2051636

0 Kudos
Message 5 of 29
(5,469 Views)
Solution
Accepted by cayenne