From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial Com - Sending commands via port RS232 etc

Hi,

 

I am looking to create a vi that is able to read ASCII commands from the instrument and write commands. I have looked at different examples and i think i have an idea on how to go about creating the communication. But i am trying to create sequence structure because there will be different commands the operator will be inputting. The problem is some of the commands that are being put in are a little long, there is a checksum included but i believe that the checksum is actually being done, by the module so i don't think ill need to create a checksum vi. ill have  a snippet of some of the commands, hopefully that'll give you some idea of what I am looking at. i just want to bounce ideas off and maybe get some idea of the best way to go about creating different commands that work in the same vi.

0 Kudos
Message 1 of 6
(3,460 Views)

1. I like to make libraries and/or classes for my instruments.  In these, you can have a different VI for each command/query.

2. You will probably need to make a checksum VI.  You did not include any information on the messages you will send, but at the very least you will want it to verify you got a proper message.

3. No need for a Sequence Structure here.  Proper error handling will create the data flow you need to sequence your code.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 6
(3,455 Views)

I believe that is what I will have to do. Sorry i should've attached it, its attached now. can you elaborate on what "proper error handling"  would look like? Regarding the Vi's why do you think ill need a checksum vi? the device that i am sending these commands to already has a checksum calculation in it.

0 Kudos
Message 3 of 6
(3,447 Views)

You have to calculate the checksum and put it in your message.  That is how the instrument knows it got a valid message.  It is clearly there in the protocol.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 4 of 6
(3,443 Views)

So I have the checksum calculation working correctly, but im running into a problem. What i am trying to do is let the user pick between different commands and based on those commands the system is able to adjust to it. For example, i would the user to be able to click on the position control mode, that would then input the % that would allow them to regulate where the position *i have attached the vi* i would like some pointers on how to do that. Also if you have any advice on my current setup i would be more then willing to correct it !

0 Kudos
Message 5 of 6
(3,385 Views)

1. No need for ANY of those local variables.  Use wires.  This will also remove the need for the sequence structure.

2. Again, make a VI for each command you want to send.

3. Use an Event Structure.  This way you only have to send the commands when something actually changes.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 6 of 6
(3,382 Views)