02-10-2012 12:17 PM
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
02-10-2012 01:30 PM
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.
02-10-2012 01:49 PM
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
02-10-2012 01:55 PM
@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.
02-13-2012 05:23 AM
One question about consumer producers : can send data from the consumer to the producer ? put controls in consumer loop...? and how?
02-13-2012 07:35 AM
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.
02-13-2012 10:46 AM
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 :).
02-18-2012 06:18 AM
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?
02-18-2012 08:32 PM
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
02-19-2012 02:18 AM