03-06-2019 01:37 AM
Hi All,
I am trying to control an engine dyno test stand with some simulation software via a MyRio - 1900, effectively hardware in the loop.
Via the MyRio, I want to send two 0-5 V signals to control the throttle position of the engine and torque applied by the dyno. This is controlled via shared variable from another piece of code and works fine.
However, I also need to read the speed of the engine. This will be a square wave pulse. I have followed examples online and written the attached code. The MyRio is currently connected to a function generator for testing. As you can see I have tried three ways to measure the frequency of the signal, and all were unsuccessful.
What is confusing me, is that I can clearly see the data on the graph, but neither the frequency or amplitude have been measured.
I read in some other threads about changing the sampling time, but I couldn't see in the block how to change this.
Any help would be greatly appreciated.
Cheers,
Pete.
03-06-2019 01:48 AM
Hi Pete,
oh wonders of those ExpressVIs: they surely make a quick start, but they also hide the basic details!
As can be seen in your image you are reading a single sample from your AI. That single sample is displayed in a chart, using the chart history to show the - ehm - history of that signal.
That single sample also is fed into more ExpressVIs to analyze frequency and duty cycles: what result do you expect from analyzing a single sample?
Converting that single sample into an array using one more ExpressVI doesn't help as can be seen on "Frequency 2".
When you want to analyze the frequency you need to provide a waveform (aka an array of samples). What about reading more than just one sample from your AI?
What about collecting samples in an array?
03-06-2019 02:15 AM
Hi GerdW,
Thanks for your prompt reply. So if I understand what you have said correctly.
The AI block is currently set-up to just read the voltage at that particular point in time, and then passing that to the tone/timing measurements. Therefore analysis of this would always yield the results that I am getting.
Please can you give me hint on how to increase the number of samples?
Used to simulink where you can double click a block and edit all parameters from there!
Cheers,
Pete.
03-06-2019 02:26 AM
Hi Pete,
Please can you give me hint on how to increase the number of samples?
Didn't I hint to use more than one sample for frequency analysis before?
Again: Change the AI-Read function or collect samples in an array…
Used to simulink where you can double click a block and edit all parameters from there!
Have you tried the same with those ExpressVIs?
03-08-2019 03:53 AM
Hi,
I've made some progress. I now have a loop to sample my data into an array before passing to the tone measurements.
The frequency that the pulse generator is running at is 20 Hz. As you can see from the image that is not the frequency displayed in the 'frequency' indicator. I suspect that I need to tell the Build Waveform block the correct 'dt'.
How, can I find out what the sampling rate is from the AI to pass this to the Build Waveform block?
Is this likely to be a constant or variable?
The curious thing is that as I increase the frequency on the pulse generator the frequency from my code decreases! Can't understand why this would be.
CHeers,
Pete.