Pages: [1]   Go Down
Author Topic: Vex Ultrasonic Range Finder  (Read 3206 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm new to Arduino so please bear with me. I just aquired an Arduino Mega 2560 and I wondered if it's possible to use the ultrasonic range finder from my Vex kit (http://www.vexrobotics.com/276-2155.html) as input for my arduino.

Has anyone been successful in connecting this device to an Arduino? If so would you mind giving me an idea of how to wire it up and what kind of coding is necessary?

Thanks.

As an aside, has anyone been successful in using the Vex motors in conjunction with Arduino?

Thanks.
Logged

Denmark
Offline Offline
Jr. Member
**
Karma: 0
Posts: 72
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi!

Welcome to Arduino-land smiley

Im pretty sure that you can:

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1294974346

Regarding to this:

http://content.vexrobotics.com/docs/inventors-guide/vex-robotics-ultra-sonic-5-2-06.pdf

The connector labelled “INPUT” is the trigger output of the Vex microcontroller; the ultrasonic module receives a start signal from the Vex microcontroller on this line. The connector labelled “OUTPUT” is the echo response from the ultrasonic detector; this is the line through which the Vex microcontroller receives output from the detector, indicating that it has picked up an echo

Also see this tutorial, it contains the library the guy in the first link uses:

http://iteadstudio.com/application-note/arduino-library-for-ultrasonic-ranging-module-hc-sr04/

From the product-site:

Outputs   3-Wire Cable
Connect to a interrupt port.
Echo response from the ultrasonic sensor .
Black:ground
Red:+5V
Orange/Yellow:control signal
 
So:

Orange: (echo)
Yellow: (trig)
Red: 5V
Black: Ground

I think that is all you need!

Remenber... In Arduino-land, Google really is your best friend!  smiley-wink
Logged

Denmark
Offline Offline
Jr. Member
**
Karma: 0
Posts: 72
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

... And for your motors

http://mykola.bilokonsky.net/2010/12/controlling-a-vex-motor-with-an-arduino-microcontroller/
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Outstanding! Thanks for the help. I needed a kickstart to get me going.

My goal is to replace the Vex module in my robot with the Arduino. The Vex controler is lovely but it's very limiting.

My ultimate goal is to have a robot which I can use in similar fashion to the Mars Rovers (I can use the Vex video transmitter without the Vex module). When I aquire a wireless shield I will be able to remotely reprogram the robot in similar fashion to how the Mars Rovers are given commands on a daily basis. This was simple not possible with the Vex.

If anyone's interested I'll keep you guys updated on my progress (in the appropriate forum of course). 
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have hooked up the sensor (see the image) and written some very bare bones code. Essentially all the code really does is set pin 13 high for a short period of time and then polls pin 10. Pin 10 goes high instantly (for three cycles of the loop) and then stays low forever. I expected pin 10 to be low initially and then go high for a very short period of time and then low again.

Any ideas what I'm doing wrong here?

Code:
/*
Uses the Vex Range Finder in conjunction with
Arduino Mega 2560
Pin 13 Triggers the Pulse (Yellow lead)
Pin 10 Recieves the Echo  (Orange lead)
*/

const int pulse_pin =  13;   // pin for triggering pulse
const int echo_pin = 10;     // pin for recieving echo
int pulse_state ; // 0 (no pulse recieved) 1 (pulse recieved)
int port_10_value;


void setup() {
  Serial.begin(9600);
  Serial.println ("Starting");
  // initialize the pulse pin as output:
  pinMode(pulse_pin, OUTPUT);     
  // initialize the echo_pin pin as an input:
  pinMode(echo_pin, INPUT);     
 
  //test code to be removed
}

void loop(){
   pulse_state = 0;
    port_10_value = 0;
    digitalWrite(pulse_pin, LOW);
    delayMicroseconds(2);

    digitalWrite(pulse_pin, HIGH); // send the pulse
    delayMicroseconds(5);
    digitalWrite(pulse_pin, LOW);  //wait and shut it down

 
    Serial.println("in main loop");
   
   while (pulse_state==0)
   {
      port_10_value = digitalRead (echo_pin);
      Serial.println("port 10 value");
      Serial.println(port_10_value,DEC);
      // will stay here forever because pulse_state is not changed
   }
   



Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Solved.

Changed pins and code as follows. Works flawlessly.

Code:
/*
Uses the Vex Range Finder in conjunction with
Arduino Mega 2560
Pin 13 Triggers the Pulse (Yellow lead)
Pin 10 Recieves the Echo  (Orange lead)
*/

const int Trig_pin =  22;   // pin for triggering pulse
const int Echo_pin = 24;     // pin for recieving echo
long duration;


void setup() {
  Serial.begin(9600);
  Serial.println ("Starting");
  // initialize the pulse pin as output:
  pinMode(Trig_pin, OUTPUT);     
  // initialize the echo_pin pin as an input:
  pinMode(Echo_pin, INPUT);     
 
  //test code to be removed
}

void loop(){
  digitalWrite(Trig_pin, LOW);
  delayMicroseconds(2);
  digitalWrite(Trig_pin, HIGH);
  delayMicroseconds(10);
  digitalWrite(Trig_pin, LOW);
  duration = pulseIn(Echo_pin,HIGH);
   
   
   
   Serial.println("Duration:  ");
   Serial.println(duration, DEC);

}
Logged

Pages: [1]   Go Up
Jump to: