10-08-2015 11:08 AM
I looked at the 7833R manual:
Glitch energy at midscale transition.......................±200 mV for 3 μs
http://www.ni.com/pdf/manuals/372492c.pdf, page 3.
Since the input looks so good with a 1uSec delay, I don't think the averaging is that important. Averaging is only to clean up any noise that would still be in the data.
Since the output isn't rated to get within +/-2LSB within less than 3 uSec, I recommend changing the delay to 3uSec. That will do well for a 1kHz signal, but if you really need better, 2uSec would be a fair compromise. Most PID controls don't need updates faster than 1mSec, so once you're done testing, you may be able to raise the delay quite a bit. And you could add electronic filtering to the output to reduce the +/-200mV glitch more. Or, (if your design allows it), avoid the 0V crossing, and just use 0..10V instead.
10-08-2015 11:30 AM
Might be worth writing LabVIEW code generate the waveform and see how the output looks, instead of trying to duplicate the input on the output.
10-09-2015 12:33 AM - edited 10-09-2015 12:34 AM
Dear ZX81,
Thank you so much for your solution. Actually I checked and found that the glitch is in the order of 200 mV and when I zoomed the time scale it took about 2.5 seconds. I could not believe such a big glitch is software based. For my application, an allowed glitch of plus or minus 10 mV is acceptable. This is because my setpoint will be a value close to zero and such a glitch will greatly affect my results.
I made a quick search on the web and found out that one of the ways to minimize glitches is by using a deglitching filter (http://digital.ni.com/public.nsf/websearch/9B13E25B0B0EC197862562B4007D2E33?OpenDocument). Now am clueless on how to implement this at all.
See the attached files below.
I also changed the delay to 3 uSec and attached find the output.
Thank you.
Kind Regards,
Opuk
10-09-2015 01:29 AM
10-09-2015 02:01 AM
Hi GerdW,
Thanks for the correction. Am sorry iits not in the magnitude of seconds
10-09-2015 08:14 AM
--- As far as implementing a solution for the output glitches:
1. The simplest approach would be an R-C filter (output goes through a Resistor to a Capacitor, then to 0VDC; use the signal between R & C). You can use two stages for even better clean-up.
2. You could also use a little circuitry to shift the voltage from 1..9V to -4..4V, and avoid the glitch. But it looked like there's another (smaller) glitch at a higher value, likely +/- 2048 in the raw value. So you may need to avoid that, too.
3. You could use two outputs, and use a resistor divider between them (that can be combined into an R-C filter, too). One output could be 0.1..10V, and the other -10..0.1V. The average would be -4.95..+4.95V. The software would need to output positive values on one channel, while keeping the other at -0.1V, and vice-versa for negative values.
If you have an R-C filter, and need high frequency outputs (R-C filters attenuate/reduce high frequency signals), you can pre-filter the output to amplify the higher frequency. It's been 20 years since I've made a compensating filter, and don't remember most of the details--it resembles a high-pass filter, but adds the unfiltered signal, too (i.e. out[n] = y[n] + a*(y[n]-y[n-b]), where 'a' and 'b' are found experimentally).
--- As far as the noisy input:
I'm shocked that it would be that noisy. A little noise isn't much of a problem for most PID applications (unless you are driving a valve). But that much is ridiculous. Especially with filtering (7X box filter). (by the way, the FPGA usage will be a little lower if you use 8 instead--1/8 is a simpler binary value).
Could you add the original (unfiltered) input to the chart? I don't think there is anything wrong with the math, but there is a small chance. There may be a clue how to fix it, too. Sometimes an occasional bad value can be filtered better using the Median instead of Mean/Average, or by removing the min & max, then averaging the rest.
With the triangle wave, it looked like adding a 1uSec delay fixed it... That isn't a great surprise, since a lot of A/D Converters behave poorly when they are polled too quickly. 3uSec ought to have done as well or better. It makes me suspicious that 3uSec has a similar problem. Please try a few different delay periods, and see if anything cleans up the signal. I couldn't find any clues in the documentation, but didn't look very hard, either.
10-13-2015 08:23 PM
Dear ZX81,
Thanks for the marvelous suggestions. I am sorry for late response. I am now working on these suggestions and will get back to you on the outcome soonest. I am not good in electronics though based on my background, but am doing more research on filter design. Thank you.
Best Regards,
Opuk
10-13-2015 08:54 PM
Dear ZX81,
Thanks for the marvelous suggestions. I am sorry for late response. I am now working on these suggestions and will get back to you on the outcome soonest. I am not good in electronics though my background being mehanical, but am doing more research on filter design. Thank you.
Best Regards,
Opuk
10-15-2015 08:30 AM
Hi ZX81,
I designed a band pass filter using resistors and capacitors and am glad my output signal is very clean now. See the attachment. Thank you for your suggestions. I now want to check about the noise on the signal.
Thank you.
Best Regards,
Opuk