Maxbotix MaxSonar EZ1

This untrasonic range finder has serial, analog voltage and pulse width ouputs and I can't understand how to use any of them properly.

The serial output apparently gives data in RS232 format (what is that?) and when I just send the data to my computer I get lots of -1 and a few other numbers occasionally.

The analog output is apparently (vcc/512) per inch about 9.8mV per inch for 5v but how can I code fot this?

The pulse width output is 147uS per inch but I would also have no idea of how to code this.

Can anyone help?

Mowcius

The analog output is apparently (vcc/512) per inch about 9.8mV per inch for 5v but how can I code fot this?

The pulse width output is 147uS per inch but I would also have no idea of how to code this.

http://arduino.cc/en/Reference/PulseIn

Dig around the forum - these are common devices, and these questions have been asked before.

I had a look through the forums and found a bit. I was more interested in using the serial but I haven't found anything on using that.

Mowcius

There was a recent thread about that too, IIRC.

Do you know where that thread would happen to be? I have had a long hard search and I cannot find it...

Don't know - I seem to remember a discussion about logic levels and whether or not the levels were RS232 compatible or not.

The search facility sucks badly.

http://www.robotshop.us/PDF/LV-MaxSonar-EZ1-Datasheet.pdf

The section on the serial i/f suggests that simple mods (inversion) to the software serial library would allow communication with the device.

This thread is half a year old... still, I wanted to share the info here. At first, I had thought about using one inverter and MAX232 to go from the EZ3 to RS232 levels and another MAX232 to go back to Arduino levels, but then I decided to try what AWOL suggested and modify some code from SoftwareSerial. They work great now! The code is here:

http://giesler.biz/~bjoern/blog/?p=201

My only worry is that serial communication at 9600bps is actually pretty slow. It takes more than 4ms to get one measurement from an EZ3!

Got it working first try, but that's got to be beginner's luck.

the hardware interface is extremely simple:
gnd, 5v and wire the PW pin on the EZ-1 to digital pin 5 on the Arduino.

Here's the code:

/*
MaxSonar_EZ1 Test
 SummitBid Technologies 2010
 */
const int sonarSensorPin = 5;
const int ledPin = 13;

long value = 0;
int cm = 0;
int inches = 0;

void setup()
{
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);

}

void loop()
{
  // Read the value from the sensor pin
  value = pulseIn(sonarSensorPin, HIGH);
  cm = value / 58;    // pulse width is 58 microsecs per cm
  inches = value / 147;     // which is 147 microeconds per inch 
  Serial.print("cm : inches = ");
  Serial.print(cm);
  Serial.print(':');
  Serial.println(inches);
  digitalWrite(ledPin, HIGH);
  delay(cm * 10);
  digitalWrite(ledPin, LOW);
  delay (cm * 10 );
  delay(20);

}

So far the only issue I have is with some false positives. Working on it.