LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Ensuring 2 blocks are sequential within parallel commands

Solved!
Go to solution

Hi all,

 

I am using labview to drive some haptic controllers over an I2C interface. Because these controllers all have the same slave address I am using a I2C multiplexer to give be able to activate them separately. I want to be able to run the activation of them in parallel to each other (so that there is overlap between them but not necessarily starting at the same time.) However, since I am going through the a multiplexor, in each haptic command I have 2 write commands (one to multiplexer to tell it which controllers to write to, followed by another command to send to the haptic controller. How do I ensure that these 2 labview blocks are done sequentially? e.g. I do not want the second haptic controller to send the command to the multiplexer in-between the first one sending its command to multiplexer but before it broadcasts an I2c message to the slave device?

I hope this makes sense, and help is greatly appreciated as I am still relatively new to Labview Coding

 

Regards,

Ben

0 Kudos
Message 1 of 5
(2,149 Views)

Hi Ben,

 

Because these controllers all have the same slave address I am using a I2C multiplexer to give be able to activate them separately. I want to be able to run the activation of them in parallel to each other (so that there is overlap between them but not necessarily starting at the same time.)

Some questions just to get things right:

So you are using just ONE I2C bus? With a multiplexer to send commands to several receivers? And you want to make sure those commands to multiplexer and receiver are send in sequential order?

And at the same time you want to send commands to several receivers in parallel - with just ONE I2C bus? (How should this be possible with a shared resource?)

 

I suggest to use a queue-driven state machine: send your commands using a queue to a state machine. Have the state machine process these commands in sequential order. Always send command combinations like "set multiplexer", followed by "set receiver"…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 5
(2,143 Views)

HI GerdW,

 

Thanks for your help. Depending on the commands I send the multiplexer, it opens and closes the different the pathways to the different receivers. So when I send a command I tell the multiplexer to open up channel 1, then when I send the next I2c command it will flow through the channel 1. When I tell the multiplexer to only have channel 2 and 3 open, whenever I send the next I2c command it will flow through to both channel 2 and 3 at the same time. This is why it is important the the multiplexer command and receiver command do not get separated. 

0 Kudos
Message 3 of 5
(2,127 Views)
Solution
Accepted by topic author BenSF

Put your "Set Multiplexer" and your "Send Command" code in one SubVI. As a non-reantrant SubVI can only not be executed in parallel you ensure that these two steps always run in sequence.

 

Regards; Jens

Kudos are welcome...
Message 4 of 5
(2,124 Views)

Thanks Jens, that makes sense and it sounds like it should work for what I need

 

Ben 

0 Kudos
Message 5 of 5
(2,114 Views)