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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

command generator

Good Morning All

 

I'm seeking some advice with regards to the attached vi. I have strpped out all the code that handles RS232 communication and other extraneous wiring simply because it is not relevant to my query. Tha's why the vi code looks incomplete, but I think I've left enough to explain the process.

 

The vi contains a case structure whereby each case contains a string command. The string command is communicated to a motor controller board(s) and acted on.

 

For example.....case 2.....the command is !a64\r. This command will cause a motor to begin turning. If the command !a00\r is now sent, the motor stops turning....get the picture?

 

Now look at case 17.....the command is (first one in the array) !D1\s3\r......a command which will set a digital output from the controller. To reset the same digital output, the command !D0\s3\r is sent.

 

 

The vi contains 20 or so of these cases with dissimilar command sets. The case is selected by a number arriving from a HID....all this is working fine.

 

There are 7 serially connected boards which the commands are sent to based on the input from the HID.

 

My query is this....

 

If I want case 19 (and this is fixed due to the HID output) to be the case seleceted to either stop a motor or reset a digital output, AND with so many cases with different commands, what would be the best method of coding case 19 to handle the many different commands, without having to create a command for every different case.... like a bulk broadcast to all the controlers.....not very nice?

 

I hope that explanation is clear, but please feel free to ask for clarification.

 

Thanks and best regards

Ray

 

 

 

Download All
0 Kudos
Message 1 of 6
(2,242 Views)

Ray,

 

I am not sure I understand your question.

 

Do you want case 19 to stop whatever was going on such as motor running or digital output?  For all motor boards, some of which may be executing different commands?  How are the different boards selected/addressed/identified?

 

One thought which occurs to me is to keep the most recent command in a shift register.  Then in case 19 use the value in the shift register to select (via another case structure) the command which needs to be reset/stopped.

 

Lynn

0 Kudos
Message 2 of 6
(2,237 Views)

Hello Lynn

 

Yes, you've correctly identified my requirements.

 

The motor controllers are all connected via an RS232 serial port. The controller boards each have two channels and the channel mnumber is inherent in the command.

 

e.g. hte command !D0\s3\r means reset digital output 3....whereas !D1\s2\r means set digital output 2...and so on.

 

I did think of using a shift register, but I am trying to use just the case 19 frame to do all the work.....I'd rather not write code for all the command permutations.

 

Thanks Lynn

 

Regards

Ray

0 Kudos
Message 3 of 6
(2,226 Views)

Ray,

 

How many different reset commands are there? You mentioned the !a00\r and the !D0\sx\r commands.  If sending a reset to a device already in that state does not cause any problems, then just send all resets to all devices.

 

In looking at your VI I noticed that cases 3, 8, and 21 have two copies of command set for write.vi with no data dependency between them.  This means that either one could execute before the other.  Is that what you intend?  Also the string arrays in cases 17, 20, and 21 have an empty string at the end of the arrays while the arrays in other cases do not.  It probably makes no difference, but it caught my attention.

 

Lynn

0 Kudos
Message 4 of 6
(2,209 Views)

Hello Lynn

Yes, I thought of broadcasting a command set to all the boards on the system, but this may interrupt onging actions which need to be maintained.......such as a digital output condition. It could get messy.

 

I was aware of the empty array elements, and they don't make any difference. It was just a matter of getting the big issues dealt with first and then doing a clean up of the code.

 

There are quite a lot of commands that have a counter-command, and it looks like I might have to bite the bullet and do it the long way.

 

The problem is that the HID, on the press of a button, sends a string which is the button ID...and the "stop" button (case 19 in the vi) is for the user to stop or reset upto about 20 different operations

 

The use of a shift register looks the most promising. The only problem with this, as I see it, that whenever the "stop" button on the HID is used, this is the next entry in the shift register which on the next loop iteration will create a wrong command b eing issued.

 

Thanks again

Regards

Ray

0 Kudos
Message 5 of 6
(2,199 Views)

Ray,

 

"The use of a shift register looks the most promising. The only problem with this, as I see it, that whenever the "stop" button on the HID is used, this is the next entry in the shift register which on the next loop iteration will create a wrong command b eing issued."

 

I do not understand your concern here. In case 19 you could put nothing into the shift register or some kind of "null" command if you do not want the stop command to be in the shift register on the next iteration. It should not matter since the only time the shift register is used is in case 19 to determine which devices need to be reset.

 

Lynn

0 Kudos
Message 6 of 6
(2,195 Views)