Hi, I need a continuous signal for exciting my ultrasonic sensors, but i dont know how to do that with Arduino. I have thought of using a loop of HIGH and LOW voltage of a pin, but then the program may get stuck inside that loop and does not execute other commands.
While I can't provide any other solution than what you have suggested, can I ask you why would you want to drive a continous signal? You won't be able to use the sensor for ranging if you do so (the reciever won't be able to separate the echoes as they are continous). There is a medical application, called continous wave Doppler ultrasonography, which works by this principle but you can only detect the presence of Doppler frequency shift, you can't determine the origine or distance of the signal.
You need to describe the signal you need more correctly.
Specify a frequency and duty cycle and waveshape type, none of which you have identified.
Too request is simply too vague..
raschemmel:
You need to describe the signal you need more correctly.
Specify a frequency and duty cycle and waveshape type, none of which you have identified.
Too request is simply too vague..
@raschemmel I need a 40kHz square wave signal to drive the transducer, so i guest 50% duty cycle is fine for me.
On any of the standard PWM outputs, one of the timers can be set up to generate a continuous signal at 40 kHz, while the processor does other things. See this for example: Arduino Playground - Timer1
raschemmel:
You need to describe the signal you need more correctly.
Specify a frequency and duty cycle and waveshape type, none of which you have identified.
Too request is simply too vague..
@raschemmel I need a 40kHz square wave signal to drive the transducer, so i guest 50% duty cycle is fine for me.
It does not work this way. The 40Khz is the frequency that the sensor/transducer operates.The 40khz is the frequency of your generated sound (hence the name ULTRA SONIC > 22Khz). To generate that impulse you don't need a 40Khz signal. You need to provide whatever the data sheet/documentation sais about that sensor/transducer. If you have a build it module then most likely you need to generate an impulse (5 V) for more than 10uS. This is how most of the SFR/HC sensors work.