Can anyone point me to a spin object to output x pulses over a period of y seconds?
youngdave
Posts: 70
Can anyone point me to a spin object to output x pulses over a period of y seconds?
TIA David Young
TIA David Young
Comments
You don't really need an object for this, it can easily be accomplished with a watchdog cog, a REPEAT loop, and WAITCNT or you could use a timer for PWM. If you are really looking for an object, search the OBEX for PWM.
Bruce
Application Notes with sample code and excellent documentation.
http://www.parallaxsemiconductor.com/an001
Forum sticky - scroll down to PE Kit Tools -> Transmit Square Wave Frequencies
Propeller Education Kit Labs, Tools,·and Applications
Here's a link to a post with code I use to flash LEDs.
This is the method that does all the work.
The object lets you any number of the IO pins. I wrote this so I could flash multiple LEDs (up to 32) at different rates using one cog. Since it's written in Spin and test each pin to see if it's an active pin, it's relatively slow (but fast enough for flashing LEDs).
The object I linked to lets you set the on time, off time and how many times you want the LED/pin to turn on and off. It should be easy to modify to use time as a parameter instead of the number of pulses.
Let us/me know if you need help converting it to your needs (assuming it's fast enough for the pulses you want to make).
Here is a quick and easy example of using a timer.