11-22-2010 12:04 PM - edited 11-22-2010 12:06 PM
Broken arrow is right. I should be using a queued state machine architechture to design my program. Again I am very new to LabVIEW and everyday I'm faced with bottlenecks, yet I learn something new.
I am using an RS-485 connection hooked up to 2 communications control boards in series and via one cable and one com port. I'm writing my program using LAbVIEW 9 full development system installed in a Windows XP SP3 operating system.
To give you a brief description of our apparatus. There are essentially 2 communication control boards Node Address 00 and 01 (hex) that control 2 banks, Bank A and Bank B. Each communication control board is hooked up to 6 module control boards which controls 6 distinct modules. Each module has 4 "Ballasts" and 8 Lamps. Each ballast controls 2 lamps. Our lamps are aged for a certain number of hours and go through "on/off" cycles. The hours are recorded and this is what I want my LabVIEW program to do.
Back to software, I have been to handshake with our apparatus using labVIEW. At 28 byte hexadecimal string is sent to the VISA write and in return the communication control board sends an 85 byte hexadecimal string back. Each sent byte has a certain function. For example byte 1 (3A) starts the receiving of the 85 byte string from the communication control board. Byte 2 addresses the Node Address for either Bank A (00) or Bank B (00). Byte 7-12 adjusts for the power level for module 1-6. Byte 28 is the checksum and is the last 2 digits of the sum of byte 1 thru 27. A correct checksum with the 28 byte string must be sent to the communication control board in order to get a correct 85 byte string back. Please see attached word document.
The received 85 byte string shows the on/off "status" of the "ballasts" and "lamps". I have successfully interpreted this string as shown in my attached VI.
An example VI that uses a QSM that uses concatonated strings to write to VISA would help me immensely in devopling my program.
I hope this clarifies a few things about my design.
Thanks a trillion for reading
mhaque
11-22-2010 12:58 PM
Excellent, lots of info to work with. In XP, there are tons of RS-232/485 resources out there in software and hardware form, giving you more options.
One question I have is, about your control boards, are they in computer, or is there one serial line coming from your computer to the control boards...this will absolutely affect the answer.
11-22-2010 01:05 PM
The control boards are NOT in the computer but in one serial line outside. To help you visualise
Computer<---->com port<---->CCB1<---->(daisy chain)<---->CCB2
Thanks
mhaque
11-22-2010 04:38 PM
ooops I forgot to attach the communication protocols
11-23-2010 09:07 AM
I think you are sitting pretty great with that chart that expands the comms packets out bitwise. First of all, Broken Arrow is correct about doing things sequentially, that means no serial port access simultaneously. Here is a code pattern that is cleaner;
| ---- Initialize------- | ------- Main running routines ------------- | ------- Closing ---------- |
| | | |
|--- Open Visa ----- | ------- Read (or write) Visa -----------------| ---- Close Visa ---------|
Use the Open visa VI to set all of the attributes for your session, those will not change during program run, for clean code practice use the Close Visa VI at the end of your program.
The middle section is mainly up to you, depending on your programming experience, but sequential is (probably) the best format. Also, place a timer(pause) with each read or write that you do (or any of the other VISA operations), this will prevent collisions on your computer's serial port. You do only need one Visa Open call, (one VISA), and use your protocol to correctly route messages on your daisey chain, it seems you may understand that part.
To answer your original question, VISA is designed to be a sort of unique communications address, that gets set once and used as many times as needed. It can be used, and wired into, any of the structure types: Sequential, While, For, etc... In your case, you only need one VISA, and your protocol does the routing. Technically, the VISA becomes your serial com port that LV uses as a nice clean way to access the real hardware.
But also, view the Serial VISA examples available online.