PDA

View Full Version : Maximum square wave frequency with adjustable on/off time...



fiveslo
08-09-2008, 11:38 AM
I trying to construct a "if you could call it" function generator that will allow me to output a square wave, or at least close to it, adjustable via programming, or what I'd like to do is update it via pushbutton via another Stamp pin to increment the frequency. I have researched the PULSOUT command but not sure if I'm reading the specs correctly from the BS2 documentation manual.. I think that PULSOUT will give me maximum of 500kHz output frequency? Not sure if I'm reading, or figuring that correctly.... If the PULSOUT will give me a max of 500kHz, that would be more than adequate for what I'm trying to accomplish.. also how would I go about changing the on and off times of the square wave at lets say 100Hz and then at 200kHz... Thanks.. Rob

Mike Green
08-09-2008, 11:55 AM
The BS2 does about 4000 byte code instructions per second of which PULSOUT is one. Even though you can adjust the pulse width, the repetition rate is 4KHz max. (roughly). The only way you're going to get a higher frequency would be to use some kind of external hardware adjusted by the BS2. The FREQOUT statement is used for generating audio tones and uses PWM with a little filtering to produce near sine waves, but nowhere near the frequencies you're interested in.

fiveslo
08-09-2008, 01:09 PM
Mike:

Do you know if the SX is capable of the higher frequencies.. this is option since I have an SX key to program the SX with????? 4kHz is definitely not enough... was hoping for at least 300kHz.... if the SX can do it, do you know of an "external" IC and/or circuit that can get me up to the 300kHz level... input would greatly be appreciated... Rob

Mike Green
08-09-2008, 08:07 PM
Either the SX or the Propeller is capable of that sort of frequency. In both cases, they'll do great with symmetric square waves. For variable on/off times, it depends on how fine a control and how much range you want. The SX can handle a clock up to 50MHz and that sets the granularity. The Propeller has a clock up to 80MHz and can use one of its built-in video generators to produce a variable width pulse at a specific repetition rate well into the MHz range depending on the resolution needed for the on/off widths.

Post Edited (Mike Green) : 8/9/2008 1:35:15 PM GMT

Tracy Allen
08-10-2008, 12:19 AM
The Stamp can output a high single frequency using the PWM command,
PWM 0,128,255
and on the original Stamp that is a square wave at 111.3 kHz. The frequency is higher on the speedier Stamps like the BS2p and 'px. It was not clear from your message if you need variable duty cycle. Or is it just to switch the cycles on and off, or alternate between one high and one low frequency? It is possible to achieve 100 Hz frequency with a program loop.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com (http://www.emesystems.com)

fiveslo
08-10-2008, 04:42 AM
Tracy Allen said...
The Stamp can output a high single frequency using the PWM command,
PWM 0,128,255
and on the original Stamp that is a square wave at 111.3 kHz. The frequency is higher on the speedier Stamps like the BS2p and 'px. It was not clear from your message if you need variable duty cycle. Or is it just to switch the cycles on and off, or alternate between one high and one low frequency? It is possible to achieve 100 Hz frequency with a program loop.



Tracy:
I'm going to use a BS2p and would like to "see" 5kHz to 300kHz, a close to true 50% duty cycle square wave... for starts that is, from what I read in your response the 300kHz is probably pushing it beyond its means, what is the maximum the BS2p will give in a square wave 50% duty cycle? For now its time to hit the Pro Dev Board to see what kind of nightmare I can create...

fiveslo
08-11-2008, 01:25 AM
I tried using the command that Tracy gave:

PWM 0,128,255

with a BS2p, and from what I saw on the o-scope, the results came back with 200KHz, or close to it, does this sound right? It is a 50% duty cycle square wave, with some "ringing", however this is tolerable... My serial SX-Key went south, since it gets warm now and won't allow me to communicate with the SX thru my Pro dev board... oh well, Ordered the new USB version.. hopefully to try what kind of results I'll get from a SX28...