rc_time function has the jitters
iseries
Posts: 1,490
I built an application using a joy stick and capacitor and wanted to measure how long it took to charge the capacitor.
The rc_time function does that for you but I found that it wavers somewhat up and down and doesn't stick to a couple of values.
I found if I use an MCP3202 Analog to Digital converter however the values only waver by about +-1.
Why is that? Is there some timing problem with the rc_time function?
Mike
The rc_time function does that for you but I found that it wavers somewhat up and down and doesn't stick to a couple of values.
I found if I use an MCP3202 Analog to Digital converter however the values only waver by about +-1.
Why is that? Is there some timing problem with the rc_time function?
Mike
Comments
Hey! No knocking go carts, they're great. Most fun I ever had behind the wheel was racing sprint carts ;-)
It would be worth your time pursuing improving the R-C design for the purpose of understanding some aspects of analogue engineering. The immediate issue of a significant peak to peak noise has a lot to with the board layout and component performance - things like component and track proximity and track lengths and relative ordering of components. Different types of capacitors and resistors behave differently at different frequencies.
All of this sort of general analogue knowledge really helps build your confidence with every electronic circuit you look at.
I see the numbers jump all over the place by 10 to 20 units and the higher the resistance gets the more it jumps.
If this is truly the case then using and RC circuit for measurement with any accuracy is not possible and you should always use an Analog to Digital converter which by the way does the same thing internally.
I want to make sure that the underlining code the propeller uses to monitor the pin state is not corrupted.
Mike
I see that one of your tags says C language but the concept has to be similar.
Both rcTime and mcp3202 fluctuate. One option is to 'average' those numbers.
Another way is to use a 'range' of numbers. For example: "If mcp3202 is between 19 and 23 print 20" or "If mcp3202 is between 19 and 23 do something else"
It is easy enough to measure, the details of where the noise can come from matter.
That does not mean much, what is the percentage of variation ?
It makes sense that the higher the resistance gets the more it jumps,as there are double effects at play
* The impedance has got larger, which makes it more sensitive to stray Mains etc pickup
* The numbers are larger too, so even same % jitter, will be larger numbers.
Actually, no.
ADCs do not "do the same thing internally"
Using RC time on a Prop, uses the pin threshold as a comparator, which means power supply noise contributes.
The node impedance is not low, which means stray pickup is an issue.
If you want to explore the limits of RC time, I'd suggest you use a HC4538 (which is a precision monostable designed for RC timing) and a Prop, and try the same test values on each.
Start with fixed R & C on each, with short leads & good Vcc decooupling on each.
To get more stability, you could try larger C and a Shift-right, and also if you think Mains pickup may be an issue, try measure (sum) of many times over a whole mains-period, and see if that improves jitter.