40 KHZ pulse train

I need to generate a 40khz pulse train for an ultrasonic device. I need in phase 7 out of phse outputs, obviously using 2 pins. I am using a 28x @ 4mhz
Options include pwmout or pulsout commands. From the look of it pwmout will not be quick enough. Does anyone know how fast it will go? That leaves the pulsout.
Code would be;
pulsout 1,1
pulsout 2,1
That should give 10usec pulse on pins 1&2
Do the instructions run concurrently?, or does the 28x do the first command 7 then the second instruction?

Gonzo
 

Dippy

Moderator
Well it'll certainly do 38kHz.
Have a look at the calculations in the Basic Manual. Dig out you calculator and work it out. It may do 40KHz +/- a bit.

High frequency pulse trains with pulsout are a bit tricky due to relative slowness of interpreter - depends on the effective duty cycle you wish.
Buy an oscilloscope and try it.
 

hippy

Ex-Staff (retired)
PWMOUT should do 40kHz, or ner enough. To get the out-of-phase signals you will need to use hardware to invert the signal outside teh PICAXE.

The PICAXE executes all instructions sequentially ( except SERVO and PWMOUT which run in the background ), so consecutive PULSOUT commands will have something like 250uS between them at 4MHz.
 

mattrich

New Member
This gives a pretty reliable 40KHz pulse-train @ 4MHz

PWMOut x, 24, 50 ' 40.0 kHz, x is your pin

Cheers
PicMatt
 
Last edited by a moderator:

womai

Senior Member
To get better frequency resolution, you can always overclock the Picaxe (provided it is an 28X or 40X) by using a faster crystal, e.g. to 16 MHz instead of 4 MHz. Of course only important if you can't get exactly 40 kHz PWM at 4 MHz clock rate. (I did not run the numbers to see how close you can get).

Wolfgang


Edited by - womai on 19/06/2006 19:08:00
 

Jeremy Leach

Senior Member
My guess is that you won't want a continuous pulse train. Won't you just want a burst of 40kHz, and then wait for the reflection??
 
Top