Duty Cycle Q
Archiver
Posts: 46,084
I want to setup a BS2 to measure/compute duty cycle on 4 different signals.
I would also like to do this accurately, and the duty cycles of the 4
signals change basically continuously. Application is automotive related.
My understanding is that the SERIN command would be used, triggered on a
positive swing, to measure the on time. Then another SERIN command would
measure the off time, triggered on a negative swing. The duty cycle is then
= (on/(on+off)).
That sounds great, but I am concerned about the timing and how the commands
are executed. Does the first SERIN command have to be completed before the
second SERIN command runs? If so, how do I ensure accuracy of the duty
cycle? What's bothering me is that I think the first SERIN command will run
against one cycle, and the second SERIN command will run against a different
cycle, since by the time the next SERIN instruction is read, the pulse edge
has come and gone. With a steady state signal, this is not a problem, but
with dynamic signals it seems that I would always have at least some error.
Any thoughts?
Thanks,
Rob Weinstock
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com
I would also like to do this accurately, and the duty cycles of the 4
signals change basically continuously. Application is automotive related.
My understanding is that the SERIN command would be used, triggered on a
positive swing, to measure the on time. Then another SERIN command would
measure the off time, triggered on a negative swing. The duty cycle is then
= (on/(on+off)).
That sounds great, but I am concerned about the timing and how the commands
are executed. Does the first SERIN command have to be completed before the
second SERIN command runs? If so, how do I ensure accuracy of the duty
cycle? What's bothering me is that I think the first SERIN command will run
against one cycle, and the second SERIN command will run against a different
cycle, since by the time the next SERIN instruction is read, the pulse edge
has come and gone. With a steady state signal, this is not a problem, but
with dynamic signals it seems that I would always have at least some error.
Any thoughts?
Thanks,
Rob Weinstock
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com
Comments
SERIN usually doesn't measure pulse widths, I think you mean PULSIN, right?
Yes, the first command must run to completion before the second command can
execute. The Stamp is single tasking. However, have a look at
http://www.al-williams.com/awce/pak7.htm -- this chip will measure high and
low going pulses continuously on 8 channels with 5uS resolution.
Using two PULSINs will give you every other cycle (at best) which is OK for
many applications. However, you can still only measure one at a time.
Regards,
Al Williams
AWC
* Expand your Stamp I/O: http://www.al-williams.com/awce/pak3.htm
consider using the PULSEIN instruction as part of your solution. I can see
comparing the result to the time between two state changes as being somewhat
easier to do than with SERIN.
Chris
>
Original Message
> From: Rob Weinstock [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=x-v22EfUeebLo07AMaQddsgoQnZFlHn9kgPE7Cath79_qCpkThYAFTXp0O0wtOYhwBmxaeCVr9Q1OPTC]weinstro@h...[/url
> Sent: Wednesday, February 28, 2001 4:51 PM
> To: basicstamps@yahoogroups.com
> Subject: [noparse][[/noparse]basicstamps] Duty Cycle Q
>
>
> I want to setup a BS2 to measure/compute duty cycle on 4
> different signals.
> I would also like to do this accurately, and the duty cycles of the 4
> signals change basically continuously. Application is
> automotive related.
>
> My understanding is that the SERIN command would be used,
> triggered on a
> positive swing, to measure the on time. Then another SERIN
> command would
> measure the off time, triggered on a negative swing. The duty
> cycle is then
> = (on/(on+off)).
>
> That sounds great, but I am concerned about the timing and
> how the commands
> are executed. Does the first SERIN command have to be
> completed before the
> second SERIN command runs? If so, how do I ensure accuracy of
> the duty
> cycle? What's bothering me is that I think the first SERIN
> command will run
> against one cycle, and the second SERIN command will run
> against a different
> cycle, since by the time the next SERIN instruction is read,
> the pulse edge
> has come and gone. With a steady state signal, this is not a
> problem, but
> with dynamic signals it seems that I would always have at
> least some error.
>
> Any thoughts?
>
> Thanks,
>
> Rob Weinstock
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.com
>
>
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
>
>
>I would also like to do this accurately, and the duty cycles of the 4
>signals change basically continuously. Application is automotive related.
>
>My understanding is that the SERIN command would be used, triggered on a
>positive swing, to measure the on time. Then another SERIN command would
>measure the off time, triggered on a negative swing. The duty cycle is then
>= (on/(on+off)).
>... snip
>
>has come and gone. With a steady state signal, this is not a problem, but
>with dynamic signals it seems that I would always have at least some error.
Another solution would be a toggle flip flop between your signals and
the Stamp input pins. You can get 4 D flip-flops in one dip package.
A flip-flops divides the input signal /2, so the Stamp measures the
time of the whole cycle. The BS2 command is PULSIN (not SERIN). It
measures time intervals up to 0.131070 seconds, resolution 2
microseconds. True, the 4 channels woul have to be done in
sequence. Maybe Al's PAK7 could give you practically simultaneous
readout. What is the time scale of the events and dynamics you will
be looking at?
>the Stamp input pins. You can get 4 D flip-flops in one dip package.
>A flip-flops divides the input signal /2, so the Stamp measures the
>time of the whole cycle. The BS2 command is PULSIN (not SERIN). It
>measures time intervals up to 0.131070 seconds, resolution 2
>microseconds. True, the 4 channels woul have to be done in
>sequence. Maybe Al's PAK7 could give you practically simultaneous
>readout. What is the time scale of the events and dynamics you will
>be looking at?
Time interval (period) would range from 7ms to 80ms. Duty cycle for a given
period can change nearly instantaneously. Period can go from min to max in
about 1 second.
I know I have to measure the 4-channels sequentially. I'm more concerned
about measuring the time-on, and the time-off within the same period,
otherwise the duty cycle can change, but the BS2 will miss it.
I downloaded the PAK VII materials earlier -- will look them over tonight.
Thanks,
Rob
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com