peter howarth
New Member
can any of the picaxes be programmed to give any squarewave,50% duty cycle, at any frequency between 500 hz and 2500 hz?can anyone give any examples please.
#picaxe 08m2
#no_data
setfreq m8
symbol opin = c.2 ; Only pin for an 08m2
symbol pulswid = w1
symbol period = b0
for pulswid = 500 to 100 step -2
period = pulswid / 2 - 1
pwmout pwmdiv16, opin, period, pulswid
pause 2000 ; Step once per second
next
setfreq m32 ; 1 PIC instruction = 0.125 us, pulses at 2kHz = 250 us = 2000 ICs
for w1 = 4800 to 0 step -10 ; min loop =~2000 PIC instructions max = 8000
time = 0
do
toggle opin ; Any output port.pin
pauseus w1
loop while time = 0
next
just want to design square wave frequencies,50% duty cycle/symettrical,in the audio spectrum say 500 hz to 2500 hz, then just convert the squarewaves to sinewaves using passive capacitor resistor network, so that i can then decode using ne567 tone decodersThe all picaxe are quite capable of producing frequencies and duty cycle you specify either in software or using pwmout, it just depends on how critical you're application is and how much accuracy you require, using pwmout.
500Hz & 32mHz axe clock pwmout pwmdiv64, B.1, 249, 500
2.5kHz & 32mHz axe clock pwmout pwmdiv16, B.1, 199, 400
The same could be done in software toggling a pin with the same on and off time.
The fly in the ointment is the time software takes to execute causing delays and the pwmout command may not produce the exact frequency you require if you require a particular range of frequencies within your'e specified limits. What is the project you have in mind?