2400hz?
Paul
Posts: 263
I would like to output a 2400.0 Hz signal on an output pin of a BS2. The best I can get is 2011.96 HZ using the simple program as follows:
Yes, a 555 timer is cheaper but I need to switch between 300, 360 and 2400 HZ and RC circuits are temperature sensitive. A faster BS2P is too expensive. A 50-50 duty cycle is not required. I've tried FOR/NEXT and DO/LOOP but nothing seems to loop faster. Any ideas (or undocumented code? ) Thanks, Paul
OUTPUT 8 J60: PULSOUT 8,1 GOTO J60
Yes, a 555 timer is cheaper but I need to switch between 300, 360 and 2400 HZ and RC circuits are temperature sensitive. A faster BS2P is too expensive. A 50-50 duty cycle is not required. I've tried FOR/NEXT and DO/LOOP but nothing seems to loop faster. Any ideas (or undocumented code? ) Thanks, Paul
Comments
If it DOES need to be PWM, one option is that you can use a 555 with an adjustable resistor (digital pot). Have your BS2p sample the 555's output (see the COUNT command) and make adjustments to the digital pot until you're at the right frequency. This would also compensate for temperature. You could even get 2 digital pots in series: one for course, large steps, and another for fine tuning. I think the BS2p's oscillator is very stable over it's operating temp range, so the COUNT command should be accurate over a wide temp range also.
Another option is that maybe you could use the freqout command to a 555 in monostable mode to trigger when a threshold is reached. (I think you can do that, right?) Maybe use double the frequency and only trigger on the Vmax portion of the wav.
Hope that helps,
Dave
If you need dead-on accuracy then you may want to invest in an SX kit -- with SX/B you can compile BASIC and could, if you like, use an ISR to toggle an output in the background while your foreground program handles frequency selection.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA
This "might" run a little faster.
OUTPUT 8
LOW 8
J60: 'Caution Endless loop!!!
TOGGLE 8
GOTO J60
...or....
OUTPUT 8
LOW 8
FOR Cycles=1 to NCycles ' A FOR/NEXT provides some means for escape
TOGGLE 8
NEXT
LOW 8
Another method might be a clever use of SEROUT with ASCII characters of 85 or 170
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe - Mask Designer III
National Semiconductor Corporation
(Communication Interface Division)
500 Pinnacle Court, Suite 525
Mail Stop GA1
Norcross,GA 30071
Dave: The digital pot controlling the 555 seems intriguing.
Jon: I don't know anything about the SX/b so maybe now is a good time to look into it!
Beau: Yes, I've tried the 'toggle' method but as Jon pointed out the BS2 is limited by the time it takes to read and execute the GOTO. This looks to be about 0.5 Mseconds. (a.k.a 2000Hz) And this is the same for any LOOP function.
Thanks for the advice.
Paul
Dave
Check out these digital pots:
MCP41010
MCP41100
They're SPI interface at 10k and 100k respectively. $1.27 each at Mouser. 256 taps, or about 39/391 ohms per increment. Put them in parallel with another fixed-value resistor between pins 7 and 6/2 of your 555, and you can cut the increment much lower if you need more precise tuning.
Dave
J60:
PULSOUT 8,168 ' about 1200 Hz for loop, 336 us pulse per loop.
GOTO J60
Trouble is, there is no exit. The FOR:NEXT construct is slow, with a minimum time of around 825 microseconds per iteration. The minimum time to interpret an IF: THEN label is around 360 microseconds, the same as it would be to evaluate a WHILE in a DO:LOOP WHILE. Too slow.
Achilles03 had the good suggestion for PBASIC only
FREQOUT 8,duration,2400
which would be just fine I think if you can run the frequency output into an RC or LC lowpass filter and then through a comparator. The comparator could be as simple as the threshold of a logic gate or mosfet, maybe with a little hysteresis. That would allow an squarish wave output at your desired frequencies, and controlled durations in units of one millisecond up to 65 seconds.
Edit: Oops. Sorry. I didn't look at the date on this thread and I don't know how it happened to be open in my browers. Old threads never die.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Post Edited (Tracy Allen) : 6/6/2009 12:06:06 AM GMT