I've been using ultrasonic sensors to calculate position from one Arduino to the other.
My ultrasonic tx runs at 40MHz(optimal freq.).
The problem is the functions pulseIn() and AnalogRead() need atleast 10usec and 100usec to read the signal.
I was using a 4bit binary counter to send 12 pulses(which = .3usec).
But to obtain atleast 10usec, I would need to send atleast 400 pulses.
Unless I buy an 8 bit and use ripple carry or a 12 bit binary counter, I'm not sure how I can achieve 10 usec.
Anything that can be done with the Arduino or software coding?
Any help would be appreciated.
Yikes...I just noticed the mistake.
It runs at 40KHz which makes a big difference.
But I'm still having a hard time getting the signal from the sensor being read by the arduino.
I'm trying to stop a timer when the signal is read.
When I hookup the ultrasonic receiver to the oscilloscope I see a voltage in the range of millivolts.
I'm assuming if I set pulseIn(port#, HIGH), that it wouldn't obtain the signal because the voltage is below 2V which is considered LOW.
You need to find out what the digital '1' threshold (it is usually expressed as a fraction of the supply voltage in the AVR datasheet) is, and offset your received signal by slightly less than it.
Obviously, you'll need to use direct port manipulation to get the speed.
Use a simple comparator - put your pulse on the +pin, put the -pin just above ground level, whenever the pulse exceeds the -pin the output will go high.
Read it with a regular digital pin.
Running on an Uno? U1A does the same thing, comparing Vin/2 against 3.3V.