LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

PID autotunning

Hi,

 

I am currently using the Agilent 3649A to power a fan, and the Pico Log USB TC08 to record a temperature.

 

I have installed heaters next to the thermocouple, and I am using the fan to cool them down.

 

Yet, I am struggling to have an autotune PID controller (I prefer to auto tune it, as I have been struggling to tune it in first place. Then, I will keep the autotuned values as standard values).

 

I haven't been really able to get my head around the auto tuning vis, so I was wondering if someone in here could replace my standard pid to an autotunning pid (with temperature) in my attached vi.

 

Thanks for help 🙂

 

Kentmey

Kentmey
0 Kudos
Message 1 of 10
(2,790 Views)

OK the first thing that you need to do is rework your code. You need to look at a producer consumer example and see what it is all about. This will make you code better more efficient and easier to read.

 

You should also look into statemachines. They will really make a difference here. I think that you are having so much trouble tuning your system because of all of the pauses and waits that you have that keep ther rest of the code from working. The producer consumer will help with that. Ideally your code should never stop exicuting even for a wait step.

Tim
GHSP
0 Kudos
Message 2 of 10
(2,784 Views)

Good suggestions, I just had a look into them, and will have a deeper look next week.

 

I assume the driver from Pico is in the producer (and same for the Agilent driver), and the PID is in the consumer loop? Or is the

 

For the state machine, is it for things such as stopping, initializing... ?

 

I wouldn't mind more details on how to do it 🙂

 

Thanks,

 

Kentmey,

Fuel Cell research Engineer,

UCL

Kentmey
0 Kudos
Message 3 of 10
(2,780 Views)

@Kentmey wrote:

Good suggestions, I just had a look into them, and will have a deeper look next week.

 

I assume the driver from Pico is in the producer (and same for the Agilent driver), and the PID is in the consumer loop? Or is the

 

For the state machine, is it for things such as stopping, initializing... ?

 

I wouldn't mind more details on how to do it 🙂

 

Thanks,

 

Kentmey,

Fuel Cell research Engineer,

UCL


 

I think I would make a loop for each device that I am trying to talk to. One for the PICO and one for the Agilent driver. The consumer should take all of the data from these two loop and do the rest. Process, display and save etc...

 

Once you get here then we can talk about how to run your code with out waits and timers that stop the code.

Tim
GHSP
0 Kudos
Message 4 of 10
(2,777 Views)

One question about consumer producers : can send data from the consumer to the producer ? put controls in consumer loop...? and how?

Kentmey
0 Kudos
Message 5 of 10
(2,753 Views)

You have three ways to get data from the producer to the consumer and maybe more.

 

Local Variables - you need to be very careful here that you are only reading the values. You can create a chase condiditon very easy with this option but it is the easiest way.

 

Que - You can set up a que and send data back and forth using the que.

 

Events - You can fire events where you pass the data back and forth from one loop to the other.

Tim
GHSP
0 Kudos
Message 6 of 10
(2,746 Views)

Tim,

 

Here is the new version of my VI.

 

I don't know how to do :

 

- Set the loop of the 3649A as Producer (I just set it as a normal loop, and send data to it using local variable, which does work fine actually). Or maybe if It works fine, I don't need to, do I?

- Get rid of the two wait in this loop (the vi is directly the one of Agilent...)

- Set the statemachine in there as well.

 

Any clues?

 

Yet, this VI is already a lot more efficient, and processes faster, which is great, thanks :).

 

Kentmey
0 Kudos
Message 7 of 10
(2,731 Views)

Update on this topic :

 

I have configured the state machine, and I am using a consumer producer structrure.

 

Though, I am not sure about a few things.

 

I have three loops : one producer (with temperature data coming from the pico)

one consumer, processing the temperature data, and creating the voltage data

one last loop (don't know whether it is a consumer or producer actually), where it is sending the voltage data to the Power Supply I am using (Agilent 3649E).

 

What is the best way to deal with these three loops?

 

Kentmey
0 Kudos
Message 8 of 10
(2,710 Views)

Kentmey,

 

Exactly what is your question?  What problems are you havig "dealing with these three loops"?

 

When running parallel loops, each loop must have some kind of Wait or delay to allow CPU sharing among the loops.  The bottom loop has this, but it is not clear whether the other loops do. If you need those loops to run as fast as possible, put a Wait (ms) function in each and wire 0 ti the input.  This will not cause a significant delay but will allow the sharing.

 

You have quite a bit of duplicated code which could be cleaned up.  The enums for state or mode selection should be made into typedefs.  The sequence structures in the top loop are unnecessary.  Wire the error terminals to create data dependencies. The inner structure could probably be replaced with a for loop.

 

Another queue for the Ch 1 and Ch 2 array might be better than the local variable.  Index array is expandable.  You do not need a separate one for each element.

 

Just wire the array directly to the waveform chart terminal in the middle loop. No need for the Index Arrays and the Merge Signals.

 

Lynn

0 Kudos
Message 9 of 10
(2,697 Views)
Well, you got the main idea in my question : is there a proper (and cleaner) way to do what i did:)

1) can you be more clear for the top loop?

2) i think i did change the state machine on friday ( but it is on another computer, and ended with 3 states in both). Yet, what do you mean enums into typedef?

3) how can i have the same index for both elements? I don't get that (third loop, right?)
Kentmey
0 Kudos
Message 10 of 10
(2,689 Views)