LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Engine Dynamometer Brake Control, DAQ & LabVIEW PID


nathand wrote:

el bob wrote: 
It can be seen that the control output currently looks more like a rapidly-changing on/off switch instead of a continuously variable analog control signal.  I'm not really sure what's causing this, but I would like to find out.

Are you certain your PID tuning parameters are good?  If you've gone through a tuning process such as Ziegler-Nichols and you're still getting odd behavior, make sure you've got the units right - your integral and derivative parameter should be in minutes, even though the dt input is in seconds.


 

I didn't specifically try the Ziegler-Nichols method, but I will try it this week.  I was confused by the units of the integral and derivative terms. I'll have to read more about it.  I had thought they would be unitless, normalized 0-1 scalars.

 

Thank you all for the help

 

Rob 

 

0 Kudos
Message 11 of 43
(3,692 Views)

I'm a little unclear on the details here as I remember the Nyquist theorem lessons talking about sampling at 10 times the greatest frequency of the signal to be measured.

No, Mr. Nyquist says that you have to sample at a minimum TWO times the highest frequency contained in the signal, or you will have errors (aliases, etc.).

 

The "10" is an old rule of thumb that if you want a graph of the waveform to look decent, sample at 10 times the BASE frequency of the signal.

IOW, if you're looking at a 100-Hz triangle wave, sample it at 1000 Hz to make a decent looking graph.  But the 100 Hz triangle contains components which are higher than that.  If you want to catch a triangle wave perfectly, you have to sample at twice the highest component frequency.

Message Edited by CoastalMaineBird on 03-24-2009 02:00 PM
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 12 of 43
(3,689 Views)

boxcar = low pass in its simplest..... moving average. Any lowpass will do here. I prefer the simplest that's warranted because of low loads on processing time.

 

Also consider your want for high Nyquist numbers. How high a freq do you really need / want to measure?

 

Labview 8.5
Meas Studio 2008
0 Kudos
Message 13 of 43
(3,665 Views)

CoastalMaineBird wrote:

I'm a little unclear on the details here as I remember the Nyquist theorem lessons talking about sampling at 10 times the greatest frequency of the signal to be measured.

No, Mr. Nyquist says that you have to sample at a minimum TWO times the highest frequency contained in the signal, or you will have errors (aliases, etc.).

 

The "10" is an old rule of thumb that if you want a graph of the waveform to look decent, sample at 10 times the BASE frequency of the signal.

IOW, if you're looking at a 100-Hz triangle wave, sample it at 1000 Hz to make a decent looking graph.  But the 100 Hz triangle contains components which are higher than that.  If you want to catch a triangle wave perfectly, you have to sample at twice the highest component frequency.

Message Edited by CoastalMaineBird on 03-24-2009 02:00 PM
 

 

Sorry, my mistake.  Thank you for the explanation and example with the triange wave.  That makes a lot of sense.

 


walter-donovan wrote: 

boxcar = low pass in its simplest..... moving average. Any lowpass will do here. I prefer the simplest that's warranted because of low loads on processing time.

 

Also consider your want for high Nyquist numbers. How high a freq do you really need / want to measure?

 


 Ah, understood, thanks.  I searched boxcar filter on Google and found this thread on the Lavag forum.  It looks like some developers choose to write their own boxcar code.  I had planned to check out what was available prepackaged first.  I guess I can put something custom together too if necessary.

 

walter-donovan wrote: 

boxcar = low pass in its simplest..... moving average. Any lowpass will do here. I prefer the simplest that's warranted because of low loads on processing time.

 

Also consider your want for high Nyquist numbers. How high a freq do you really need / want to measure?

 


 The highest RPM the engines will reach is 3600RPM.  Due to the setup of the VR sensor, trigger wheel and signal conditioner, this means that highest base signal frequency seen by the counter input is 3600Hz.  So it seems that I need to sample at 7200Hz.

 
I'm not 100% sure of how the counter works though.  I think the DAQ hardware uses an internal timebase to counting TTL pulses per unit time, and then the TargetRPM VI simply queries it each time it goes through its while loop, which currently operates at 20Hz.  This is the part I'm a little stuck with.  It seems like theirs two sampling operations running at the same time.  The DAQ sampling the TTL signal and the LabVIEW VI sampling the DAQ counter.  Is that an accurate description?
Message Edited by el bob on 03-26-2009 10:50 AM
0 Kudos
Message 14 of 43
(3,639 Views)

 The highest RPM the engines will reach is 3600RPM.  Due to the setup of the VR sensor, trigger wheel and signal conditioner, this means that highest base signal frequency seen by the counter input is 3600Hz.  So it seems that I need to sample at 7200Hz.

 
I'm not sure how you arrived at that number.  If your engine is running at 3600 RPM, that's 60 Hz. If you sample at 7200 Hz, that's 7200 / 60 = 120 samples per rev.
If you're interested in artifacts within a rev, pressure changes, temp changes, force changes, etc. then you're not sampling high enough to really catch them.  Explosions happen quickly, if you're interested in them, then sample a good bit higher.
 
OTOH, if you're only interested in average torque vs. average speed, then you have way more data than you need. Averages for 3-4-5 cycles ought to be sufficient.
 
Aside from that, consider the idea of synchronous sampling.  Using an external clock signal, derived from your 60-tooth gear, gives you sampling at every 6 degrees of rotation, regardless of speed. That's very useful for chasing events within a cycle, though I don't know if it's useful to you here.  I've typically used a 512-line encoder attached to the shaft, for that sort of thing.

 
 
 
I'm not 100% sure of how the counter works though.  I think the DAQ hardware uses an internal timebase to counting TTL pulses per unit time, and then the TargetRPM VI simply queries it each time it goes through its while loop, which currently operates at 20Hz.  This is the part I'm a little stuck with.  It seems like theirs two sampling operations running at the same time.  The DAQ sampling the TTL signal and the LabVIEW VI sampling the DAQ counter.  Is that an accurate description?
 
Counters work in different ways, depending on what you need.  You can either count clock ticks between your signal's edges, or count signal edges in a given time period.  BOth have their uses. 
 
For measuring speed, in a fast-changing engine, you do not want a long averaging time.  You want to count clock ticks between 2 consecutive (or 60 consecutive) signal (tooth) pulses, that lets you track the engine speed accurately.  You need clean signals to do it though.
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 15 of 43
(3,632 Views)
Thank you Steve.  I was confusing engine revolutional frequency with trigger wheel tooth-passing frequency.  I got the 7200RPM number as you guessed, by doubling the tooth-passing 3600Hz frequency.  For this project, there is not an need to analyze engine events within a revolution.
 
If the maximum engine revolutional frequency is 60Hz, then following the 2x Nyquist premise, sampling should be done at 120Hz.

It sounds like I need to input each RPM sample into a three element FIFO buffer and read RPM as the average of the current three RPM values, for each iteration of the TargetRPM IV while loop.  Each new iteration will kick out the third element of the buffer, shift element 1 -> 2 and element 2 -> 3, and input the latest DAQ counter sample into the first element.  The average of these three numbers are then read as the RPM value for this iteration of the while loop.  Does that sound about right?

I can't open up the VI and check right now, but I believe I have the counter set up to count signal edges in a given time period.  The engine will change speeds in a power sweep (or Torque Map) at an operator defined rate somewhere between 200RPM/s and 600RPM/s.  I'm not sure if this qualifies as a relatively long averaging time.

I appreciate your help.  It's helping me break different bits of the system down into understandable, basic parts.

Rob
0 Kudos
Message 16 of 43
(3,621 Views)

If the maximum engine revolutional frequency is 60Hz, then following the 2x Nyquist premise, sampling should be done at 120Hz.

 

I still don't think you have it.

The Nyquist theorem says:

 If you want to capture ALL the important information about a signal, then you MUST sample at a rate TWICE the HIGHEST FREQUENCY component in that signal.

The fact that your engine is rolling at 60 Hz DOES NOT MEAN that the highest frequency component in any signal you get out of that engine is 60 Hz. 

 

If you are looking at cylinder pressure, for example, the highest frequency component will likely be 60000 Hz, because the pressure gradient is extremely fast when the spark plug goes pop and the fuel goes boom.

The fact that the compression pulse doesn't last for a whole cycle is irrelevant. It has a high frequency.  If you sample too slowly, you will miss it.

 

If you're making a torque map, though, you don't care about such things. You want average torque (over a cycle or three) and the fact that torque changes within the cycle is not important to you (I assume).

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 17 of 43
(3,618 Views)

It sounds like I need to input each RPM sample into a three element FIFO buffer and read RPM as the average of the current three RPM values, for each iteration of the TargetRPM IV while loop.  Each new iteration will kick out the third element of the buffer, shift element 1 -> 2 and element 2 -> 3, and input the latest DAQ counter sample into the first element.  The average of these three numbers are then read as the RPM value for this iteration of the while loop.  Does that sound about right?

 

The idea is exactly right, although there might be more efficient ways to do it.  You have a constant N, say 3.

You create an array of N elements.

You have an index I, starting at 0

For each reading, you put the reading into the array at index I.

You add 1 to I, and if I = N, you set I = 0. 

You average the whole array and that's your current speed.

There's less shifting around that way, and if you decide to change N to 4 or something, you have only one number to change.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 18 of 43
(3,615 Views)

The engine will change speeds in a power sweep (or Torque Map) at an operator defined rate somewhere between 200RPM/s and 600RPM/s.  I'm not sure if this qualifies as a relatively long averaging time.

 

But you see the idea I'm getting at, I hope.  If you averaged for 1 second, and get an answer of 1000 RPM, you don't know what the current speed is.

It could have been 1000 RPM for the whole second.  It could have ramped from 700 to 1300 RPM and you would still get 1000.  It could have ramped from 1300 to 700 RPM and you would still get 1000. You just don't know.

 

For that reason, I suggest that you NOT count teeth per unit time, but time per tooth.  If you get an answer of 0.0001 second per tooth, then you know that you are rolling at 166.6 RPM. But you have a new reading for every tooth that passes.  FOr noise reasons, you can still average those readings, but you are averaging REVs.  The faster the engine, the faster your readings update.  There's no guesswork.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 19 of 43
(3,611 Views)

CoastalMaineBird wrote:

If the maximum engine revolutional frequency is 60Hz, then following the 2x Nyquist premise, sampling should be done at 120Hz.

 

I still don't think you have it.

The Nyquist theorem says:

 If you want to capture ALL the important information about a signal, then you MUST sample at a rate TWICE the HIGHEST FREQUENCY component in that signal.

The fact that your engine is rolling at 60 Hz DOES NOT MEAN that the highest frequency component in any signal you get out of that engine is 60 Hz. 

 

If you are looking at cylinder pressure, for example, the highest frequency component will likely be 60000 Hz, because the pressure gradient is extremely fast when the spark plug goes pop and the fuel goes boom.

The fact that the compression pulse doesn't last for a whole cycle is irrelevant. It has a high frequency.  If you sample too slowly, you will miss it.

 

If you're making a torque map, though, you don't care about such things. You want average torque (over a cycle or three) and the fact that torque changes within the cycle is not important to you (I assume).


 
I'm really batting a thousand here.  🙂  I see what you're saying, my mistake.  According the Nyquist theorem, if I wanted to capture all the important information, every last force change event within a single rev, I would have to identify the highest component frequency of the force signal and then sample at twice that rate.  I must apologize to Mr Nyquist, I really messed that one in my previous posts.
 
Since I'm not interested in intra-rev data, I can sample once per rev.  I have an option to sample at a fixed 60Hz, or possibly use synchronous sampling to time each sample with one complete rev, 60 pulse edges from the trigger wheel counter input.  It seems like a matter of project preference, but there might be something I'm missing that makes this a more clear cut choice.
 

Is it accurate to say that the Nyquist theorem isn't immediately important to infrequent (max component freq >> sample freq) signal averaging data acquisition?  I got caught up earlier mistakenly thinking that any signal to be sampled of a frequency x had to be sampled at 2x regardless of the required quality of signal capture.  This is how I came up with the incorrect 120Hz sampling frequency number. 

 


CoastalMaineBird wrote: 

It sounds like I need to input each RPM sample into a three element FIFO buffer and read RPM as the average of the current three RPM values, for each iteration of the TargetRPM IV while loop.  Each new iteration will kick out the third element of the buffer, shift element 1 -> 2 and element 2 -> 3, and input the latest DAQ counter sample into the first element.  The average of these three numbers are then read as the RPM value for this iteration of the while loop.  Does that sound about right?

 

The idea is exactly right, although there might be more efficient ways to do it.  You have a constant N, say 3.

You create an array of N elements.

You have an index I, starting at 0

For each reading, you put the reading into the array at index I.

You add 1 to I, and if I = N, you set I = 0. 

You average the whole array and that's your current speed.

There's less shifting around that way, and if you decide to change N to 4 or something, you have only one number to change.


 

 

Hooray, something I've put together is not rubbish. There's hope here yet. 😄
 
Thanks, your way would definitely be more efficient.  I'm assuming I can do something similar with the force readings.

 

 

 


CoastalMaineBird wrote: 

The engine will change speeds in a power sweep (or Torque Map) at an operator defined rate somewhere between 200RPM/s and 600RPM/s.  I'm not sure if this qualifies as a relatively long averaging time.

 

But you see the idea I'm getting at, I hope.  If you averaged for 1 second, and get an answer of 1000 RPM, you don't know what the current speed is.

It could have been 1000 RPM for the whole second.  It could have ramped from 700 to 1300 RPM and you would still get 1000.  It could have ramped from 1300 to 700 RPM and you would still get 1000. You just don't know.

 

For that reason, I suggest that you NOT count teeth per unit time, but time per tooth.  If you get an answer of 0.0001 second per tooth, then you know that you are rolling at 166.6 RPM. But you have a new reading for every tooth that passes.  FOr noise reasons, you can still average those readings, but you are averaging REVs.  The faster the engine, the faster your readings update.  There's no guesswork.


I was having trouble seeing how a counter itself was doing averaging.  I think I get it now.  The counter is counting pulse edges generated by the trigger wheel per unit time.  If the unit time is one second and the counter counts 1700 pulses, then we know the RPM is 1700 pulses divided by 60 pulses per rev, equals 28 1/3 revs, times 60 revs per minute, equals 1700 RPM.  Like you said though, there's no way to know if the engine spent the first half of the second at 2000RPM or 1400RPM.
 
I'll be testing the TargetRPM VI on the dyno tomorrow.  The two VI changes I'm planning to make at the moment are to switch Sampling Time to 60Hz from 20Hz (while loop timer, 50ms --> 16.6ms), and to add the above averaging algorithm inline between the counter input and PID process variable input.  I will try the Zieger-Nichols tuning strategy and see what can be done about the PID output response.
 
Thank you for your help.  If there are other parts of the VI that could use review and change as well, it would be great to hear about it.

 

 

0 Kudos
Message 20 of 43
(3,563 Views)