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: 

How to implement multiple tasks(e.g. PID) in parallel?

Solved!
Go to solution

Hi, 

 

I know there must be some questions like this in this board, and I've tried to find for a while but got few what I'd like. My project is a little urgent so that I'm posting this question for some instant suggestions...

As the topic says, I have multiple devices, say power suppliers, and I have to tune their power automatically and independently.

Although the number of the devices are eight for now, but I do not prefer to fix the number, that is, I'd like to scale or expand the device number dynamically.

At first, I'm very stupid to put the PID.vi into the for loop...

20150714001.PNG

I wondered if the parallelism-enabling can deal with my problem, but soon I knew the data spaces of each calling VI are mixed up...

I'm getting stuck about how to reserve the dataspace of the reentrant data...

The last on my mind is the open VI externally at the beginning of control, and take the advantage of the VI's references..

But I've not implemented the method, perhaps there is other tricky issue on that way...

Is there a way to sovle this kind of problem? 

 

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

hi william,

 

i think producer-consumer pattern would fit here as well.

have asynchronous vis for every device (producers) and a control vi (consumer), with which you can start/shutdown/ctrl each asynch-vi.

 

the for-loop looks very wrong to me .. it might work, but i think having real while loops in the asynch vis is more manageable (and you can have timed-loops)

 

at least thats what i am doing 😉

 

the tricky part for the producer-consumer pattern with Queues is to build you messages.

you should have at least messages that can shutdown the producers

 

good luck


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
0 Kudos
Message 2 of 6
(3,499 Views)
Solution
Accepted by topic author William1225

Hi William,

 

the PID functions support multiple control loops, just read the help for the functions!

 

No need for that FOR loop (which is plain wrong here)!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 6
(3,473 Views)

Hi, jwscs,

 

Very thanks to your immediate reply,

I'm a little confused how can I implement the indetermined device numbers in the producer-consumer pattern.

I have eight power suppliers and have to control their power simultaneously by PID toolkit.

Probably, I have ten power suppliers next time...

What does the real while loop means in your second paragraph?

 

 

 

0 Kudos
Message 4 of 6
(3,468 Views)

in my proposition you would have to start a new asynch vi for each additional pid,

but GerdW's suggestion might be even more to your liking.

 

you could have one loop, and an array of inputs to your PID (one entry for each of your devices),

i haven't used it this way so i cannot comment further,

but it looks like you only have to be sure of the order in your array.


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
0 Kudos
Message 5 of 6
(3,455 Views)

Thanks GerdW,

 

I must gonna get a better glasses @@...

Thanks your direction, I'll do it right away.:)

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