Detecting two pulses using a single cog.
Hugh
Posts: 362
Hi,
I currently have two cogs that detect different pulses using waitpe and waitpne and put the measured frequencies into hub ram. These work well but I have run out of cogs and, if possible, would like to combine the two.
One signal is approx 120 Hz; the other circa 1 Hz but of relatively short (TBC) pulse width.
My working assumptions are:
(The pulse width is TBC awaiting inf from the vendors)
Thanks
Hugh
I currently have two cogs that detect different pulses using waitpe and waitpne and put the measured frequencies into hub ram. These work well but I have run out of cogs and, if possible, would like to combine the two.
One signal is approx 120 Hz; the other circa 1 Hz but of relatively short (TBC) pulse width.
My working assumptions are:
- It is not possible to 'OR' pins using waitpe
- Waitpe reacts very quickly
- Using Spin to compare the current state of the pin with the previous state is going to take a while.
(The pulse width is TBC awaiting inf from the vendors)
Thanks
Hugh
Comments
Launch ctra and ctrb from any cog, including main, or a single cog. This is a crude example, it will need tweaking to stagger the reads better.
Thanks T Chap. I haven't used CTRA / CTRB before so I'll go off and read the manual..
Cheers
Hugh
but looks like there is lots of time ..
waitpe and waitpne: take a MASK
so you can write a mini state machine
and waitne with the current state of A and B.
on each state change you can log cnt and restart waitne with new current state.
And of course on each state change you do what needs to be done ... write to HUB etc...
If I follow T Chap's suggestion would this be how I set up ctrA for pin 17?
Thanks for bearing with me!
-Phil
Thank you all. It's easy when you know how.
For a really low-latency low-power way to read the high and low pulse times on all of the I/O pins (or any subset thereof) check out the ReadPulseWidths.Spin file in the Eddie Firmware.
— David Carrier
Parallax Inc.