View Full Version : Ultrasonic Sensor output
Dillon Compton
23-01-2006, 23:34
Hi All,
I'm going to post this here because we are coding in easyC this year, so i'd like a usable code snippet if someone posts one...
We're using ultrasonic sensors for our autonomous mode this year, and I was wondering what type of data they output. I assume that it is probably the standard PWM 0-255; if this is the case, what is the correlation between distance and value? If it is another type of output, what is it?
I suppose I could slap it on last years robot (or an old RC) and do some tests, but I figured I would run it by the experts 'round these parts first!
Thanks in advance for any help,
Dillon Compton.
BradAMiller
24-01-2006, 08:12
Hi All,
I'm going to post this here because we are coding in easyC this year, so i'd like a usable code snippet if someone posts one...
We're using ultrasonic sensors for our autonomous mode this year, and I was wondering what type of data they output. I assume that it is probably the standard PWM 0-255; if this is the case, what is the correlation between distance and value? If it is another type of output, what is it?
I suppose I could slap it on last years robot (or an old RC) and do some tests, but I figured I would run it by the experts 'round these parts first!
Thanks in advance for any help,
Dillon Compton.
EasyC has a block built in for the VEX/Daventech ultrasonic sensor. The help file tells how to connect it. EasyC will return the distance in inches. The Ultrasonic sensor can be:
Started: the sensor starts pinging and computing the distance to the nearest object in its field of view.
Stopped: where the pinging is stopped
Get: where you read the most recent distance that it measured is returned to your program.
You use the same block for each of those operations. When you drag the block into the program select the option that you want. In the case of Get you need to supply a variable for the result.
The way it works (internally) is that one connection goes to a digital output and the other to an interrupt pin (digital inputs 1-6). The sensor is sent a pulse on the digital output that causes it to transmit a burst of ultrasonic sound. When the sound reflects off of an object, it returns and causes a signal on the digital input (interrupt) pin. EasyC computes the round trip time of the sound and converts that time to inches based on the speed of sound.
Dillon Compton
24-01-2006, 12:23
EasyC has a block built in for the VEX/Daventech ultrasonic sensor. The help file tells how to connect it. EasyC will return the distance in inches. The Ultrasonic sensor can be:
Started: the sensor starts pinging and computing the distance to the nearest object in its field of view.
Stopped: where the pinging is stopped
Get: where you read the most recent distance that it measured is returned to your program.
You use the same block for each of those operations. When you drag the block into the program select the option that you want. In the case of Get you need to supply a variable for the result.
The way it works (internally) is that one connection goes to a digital output and the other to an interrupt pin (digital inputs 1-6). The sensor is sent a pulse on the digital output that causes it to transmit a burst of ultrasonic sound. When the sound reflects off of an object, it returns and causes a signal on the digital input (interrupt) pin. EasyC computes the round trip time of the sound and converts that time to inches based on the speed of sound.
Man... EasyC really does take all the fun* out of coding...
Anyways, thanks for your help Brad.
-Dillon
*By fun I mean sleepless nights of checking syntax and stressful days of trying to write an autonomous a day before ship, when you've finally gotten your hands on the robot for more than 5 minutes.
Kingofl337
24-01-2006, 14:15
Fun* is overrated. :)
Glad you got it working. Make sure when you do your final program the assignments are correct in the "Main" function for the inputs and output. Also don't use ports 1-6 as an output as it will use a valuable interrupt. Ports 10-18 are already assigned outputs FYI.
Erics626
01-02-2006, 18:14
Does anyone know if you can use the Parallax ultrasonics using EasyC. We are having some difficulty getting them to work.
Kingofl337
03-02-2006, 10:20
Does anyone know if you can use the Parallax ultrasonics using EasyC. We are having some difficulty getting them to work.
Only the VEX/Daventech are currently supported in EasyC.
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.