Variable frequency output
Captain Blammo
Posts: 3
I'd like to make an LED flash at a rate controlled by a couple of pots (one for frequency, the other for pulse width), but I've got a bit stuck on how to accomplish this with a BS2SX.
I'd just use FREQOUT, but it seems that it generates a sine wave, where I'd really want a square wave. The PWM command doesn't give you neatly divided on/off time, so that's out. If I was going to use a fixed pulse width, I could just use PAUSE and PULSOUT, though this would still limit me to around 1kHz maximum.
So I suppose my question is: How do you generate a square wave with easy-to-specify frequency and pulse width? Is there an easy way that I don't know about?
Thanks for any help!
CB
I'd just use FREQOUT, but it seems that it generates a sine wave, where I'd really want a square wave. The PWM command doesn't give you neatly divided on/off time, so that's out. If I was going to use a fixed pulse width, I could just use PAUSE and PULSOUT, though this would still limit me to around 1kHz maximum.
So I suppose my question is: How do you generate a square wave with easy-to-specify frequency and pulse width? Is there an easy way that I don't know about?
Thanks for any help!
CB
Comments
Bean.
Take a look at the PWMPAL chip from parallax.
http://www.parallax.com/detail.asp?product_id=28020
Or you could do it with the SX chip and SX/B, but you would need the SX-Key programmer.
Bean.
·
My brain is a little sleepy from an all-you-can-eat pancake feed this morning, so maybe I'm not catching what you are trying to do. But.. I think the following is what you describe
Fudge is used to compensate for the execution overhead in the loop. Depending on how accurate the timing needs to be you'll have to twiddle fudge to make the loop come out right. But once set you shouldn't have to change it unless you move it to another model of stamp.
Jim
added: Obviosuly the above is just a control snippet. You've have to work in getting the pot settings and their affect on the timing loop, etc.
Post Edited (Jim McCorison) : 1/23/2005 7:48:03 PM GMT