03-24-2009 01:42 PM
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
03-24-2009 01:59 PM - edited 03-24-2009 02:00 PM
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.
Blog for (mostly LabVIEW) programmers: Tips And Tricks
03-25-2009 06:46 AM
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?
03-26-2009 10:49 AM - edited 03-26-2009 10:50 AM
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.
03-26-2009 11:12 AM
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.
Blog for (mostly LabVIEW) programmers: Tips And Tricks
03-26-2009 01:48 PM
03-26-2009 02:03 PM
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).
Blog for (mostly LabVIEW) programmers: Tips And Tricks
03-26-2009 02:07 PM
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.
Blog for (mostly LabVIEW) programmers: Tips And Tricks
03-26-2009 02:16 PM
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.
Blog for (mostly LabVIEW) programmers: Tips And Tricks
03-27-2009 09:52 AM
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).
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.
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.