Code for measuring duty cycle?
Roboron
Posts: 9
I want to look at encoder signals with a duty cycle spec of 50% +/- 5%.· If the duty cycle is out of spec I would like to display the duty cycle of the + pulse.· What commands would be good for this?
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
I Am currently·working on a basic encoder on a mill to measure spindle position and speed(tach) using a bs-2. Its a rough project when your not a elct. enginr. So there's a lot of research and trail & Error. But I love DIY, Everything from scratch if educationally possible!
thanks
From the high and low times you can calculate the duty cycle. It is also possible to do that in code if necessary.
I am wondering why you want to do this? The important thing with an incremental encoder is the phase relationship between channel A and channel B, not the absolute accuracy of the pulse widths.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Post Edited (Tracy Allen) : 2/8/2010 12:52:19 AM GMT
I am doing this for two purposes; 1. school project and 2. I can use it to test some encoders at work. I have found some encoders with poor symmetry that don't function well.
I am extremely new to PBASIC and BASIC STAMPs...After two days of searching I figured out the PULSIN command. I have been struggling with the learning curve.
When you say "pwA1 units of 2us" does that mean that the number returned for pwA1, for example, is multiplied by 2 to get the real duration in u sec?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Thanks.
It is one of the SEROUT modifiers and makes the Stamp send 11 spaces (ascii code 32) in a row. Used to indent the display.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
_____|XXXXX|_______First Pulse
________|XXXXX|_______Second pulse
| | 90 degrees (how can I measure this?)
"90 degrees" means that the transitions on one channel happen 1/2 way through pulses on the other channel, and vice versa. If the encoder turns slowly and evenly, the following PBASIC should output numbers for two phases. If they are at 90 degrees, the numbers should be equal.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
http://www.parallax.com/tabid/774/Default.aspx
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
MOORE'S LAW: The capabilities of electronics shall double every 18 months.
cloyd's corollary: Hardware is easy, software is hard.