LF Sine waves

Ian C

New Member
Is it possible to generate low frequency sine waves (say 50 to 300 Hz) using a Picaxe?
I need to amplify and send to a speaker to generate Chladni patterns on corrugated board.
 

moxhamj

New Member
Not directly - a picaxe is not fast enough. But you could use a dedicated low distortion sine wave chip (eg the XR2206) and drive the VCO from a picaxe to set the frequency.
 

premelec

Senior Member
Two more possibilities are - a wein bridge oscillator with LDRs to tune the frequency - you change fqy with light on the LDRs with PWMOUT to LEDs.

Also weighted resistors on the output of a ring counter can be made to approximate a sine wave - This is described in a book "CMOS Cookbook" [p327] using 4013s or 4018s - then you vary the frequency of to the counter ot vary the sine aprox fqy. This book has a table of values and harmonics...

Whatever works! good luck...
 

womai

Senior Member
An overclocked 28X1 running at 20 MHz executes about 10000 lines of code per second. That means about 33 statements per cycle of a 300 Hz sine wave. Using a lookup table you should thus be able to modify a PWM output several times per cycle. With suitable low-pass filtering (multipole low-pass filter set to slightly above 300 Hz) you should be able to get a decent sine wave output. A bit tricky I admit, but I believe it could be done. If you want to be fancy then use a programmable resistor (e.g. from Maxim or Microchip) to move the filter cutoff frequency in lockstep with your sine wave frequency.

Wolfgang
 

womai

Senior Member
Well, thinking about it a bit more - if you have a low-pass filter with steep cutoff (that's why it has to be multi-pole) slightly above your desired sine wave frequency, then you can simply send in a square wave, and get out a sine wave, since the filter will remove all higher harmonics. And a square wave can be produced easily - just toggle one of the output pins in regular intervals... You still need to be able to adjust the LPF's cutoff frequency.

Wolfgang
 

BCJKiwi

Senior Member
The other thing to remember when working with pwmout and 28X1 is that once the pwmout is set up, you can change just the duty with the pwmduty command which is much more efficient as it does not stop/reprogram/restart the PWM circuitry but just changes the duty on the fly - also works for hpwm!

e.g.
Code:
' pwmout 2,249,512 ' establish pwm pin, Period(frequency), Duty.
 hpwm 0,0,%1000,249,512 ' mode(0=single),polarity(0=H),setting(%1000=D - Output4/Leg25),period(frequency),duty
.
.
.
' set w1 to represent new value for duty 
.
pwmduty 2,w1
Either remmed or live code function the same
 

moxhamj

New Member
Or you could use 'magic sine waves' http://www.tinaja.com/magsn01.asp, although this needs a fast micro - a pic rather than a picaxe. These are pwm waveforms where the pusle widths are tweaked to cancel out harmonics.

If an accurate frequency is needed, you could use an XR2206 producing a sine wave and take the square wave output and measure the pulsewidth using pulsin and use that to adjust the frequency accurately via the VCO. It depends how accurate the frequency needs to be.
 

premelec

Senior Member
DrAc that reminded me of the 1 Bit sound generator -
www.romanblack.com/picsound.htm

I still think the weighted resisitor unit menitoned in CMOS Cookbook with a
modest filter would work ok... Don Lancaster has been a long time inspiration
to me in innovative circuitry...

There's probably a very simple DDS chip that does the job well but I've only encountered the HF fractional resolution types... which work well but are relatively expensive.
 
Top