04-08-2022 11:56 AM
I do not want square signal. I am using analog input to read the signal, but somehow I kept getting square wave looking signal. I tried to play with scaling; I kept getting same results.
This below is what I am getting:
I want curvy/smooth signal similar to this one below:
Thanks in advance for your help guys!
Solved! Go to Solution.
04-08-2022 12:09 PM - edited 04-08-2022 12:12 PM
Right click on the plot then in visible items select plot legend, then right click on the plot legend and select common plots and select one that shows the points.
Then you can see where all the samples are. You can also adjust the interpolation style from the plot legend menu.
04-08-2022 12:15 PM - edited 04-08-2022 12:19 PM
We cannot know how things are hooked up and how the signal actually looks like. These steps are so small that you are probably looking at the digitizer quantization.
(Sorry, I don't have your drivers. Do you have documentation? What MCC device do you use for AI?)
Your code has still glaring problems:
04-08-2022 12:41 PM - edited 04-08-2022 01:16 PM
I believe I pointed this out before. I don't believe this will work the way you think it will.
You will probably have a race condition between which VI will run first Set duty cycle or Digital read...
Because as I said the Arduino is neither multi threading nor multitasking.
Try this:
Since your program is one big loop you are speed limited by the slowest part of that loop.
An Arduino running Linx has loop rate somewhere around 200 loops per second maybe even lower depending on Linx code complexity.
You can't expect 200Hz sampling to make a smooth sinewave graph unless the signal frequency is < 20Hz.
See Nyquist–Shannon sampling theorem and Aliasing
04-08-2022 01:03 PM
Can you leave all that arduino stuff out and create a simple program using only the MCC device. Can you create a waveform manually somehow and use it as input?
04-08-2022 01:43 PM - edited 04-08-2022 01:46 PM
For a laugh you can try this, some smooooth plots : )
04-08-2022 01:50 PM - edited 04-08-2022 01:52 PM
As others have mentioned there are going to be timing issues running everything in one loop. You can separate out the MCC Daq from the Arduino stuff to get faster readings on the MCC Daq. It looks like you also want to see the PWM signal, but the rate at which the serial communication for that happens it's not going to be meaningful data (might see half a dozen points per second).
Here's a better program structure to start with. UI and Linx are handled in the top loop. The MCC Daq runs separately in the lower loop.