MaxSonar Chaining not working

Hi,

I am trying to use 6 Maxsonar ez1 ultrasonic sensors chained in daisy chaining fashion working in constant looping. I can get the analog values which change with the change in sensor distance but the problem is that these values are incorrect. Even if i cover the sensor it still gives an output of 65mV which translates to 5.98inches. I am unable to figure out the problem. If there is anyone who can help, please jump in and give some suggestion.

Waiting for kind solutions.

Best Regards,
Rafid

anyone there?

Any code here?
Any schematic?

I am using the standard wiring of 'daisy chaining' of Max Sonar sensors

http://www.maxbotix.com/uploads/Chaining_Application_Notes__AN_Output_Constantly_Looping_.pdf

and simple code, just for testing:

float an0 =0;
float an1 =0;
float an2 =0;
float an3 =0;
float an4 =0;
float an5 =0;

void setup() {
  pinMode(ledPin, OUTPUT);  
  Serial.begin(9600);
  digitalWrite(9,HIGH);
  delayMicroseconds(50);
  digitalWrite(9,LOW);
}

void loop() {
  // read the value from the sensor:
  //an0 = (analogRead(0)*(5000.0f/1024))*0.26;
//an1 = (analogRead(1)*(5000.0f/1024))*0.26;
//an2 = (analogRead(2)*(5000.0f/1024))*0.26;
//an3 = (analogRead(3)*(5000.0f/1024))*0.26;
//an4 = (analogRead(4)*(5000.0f/1024))*0.26;
//an5 = (analogRead(5)*(5000.0f/1024))*0.26;
an0=analogRead(0)*4.88/9.8;
an1=analogRead(1);
  an2=analogRead(2);
  an3=analogRead(3);
  an4=analogRead(4);
  an5=analogRead(5);
  
Serial.print(an0);
Serial.print('\t');
Serial.print(an1);
Serial.print('\t');
Serial.print(an2);
Serial.print('\t');
Serial.print(an3);
Serial.print('\t');
Serial.print(an4);
Serial.print('\t');
Serial.print(an5);
Serial.print('\t');
Serial.println(' ');

  delay(100);                  
}

Even if i cover the sensor it still gives an output of 65mV which translates to 5.98inches

What is the minimum range of this particular sonar?

To do this, pull the RX pin high on the first sensor for at least 20uS. Then the micro controller will have to return it's pin to a high impedance state so that the next time around the TX output from the last sensor will make it's way to the RX of the first sensor

Well i dont think there is any minimum range limit for such sensors because i had used single of them in the past and they return 0 if thing is too close but here we are talking about 65mv which is almost 6 inches because scale of the sensor is 9.8mV/inch at 5V Vcc. Vcc is stable at 5.0V.

Yes i applied the 20us (also tried 50us,20ms,500ms) high on RX to start the loop in the 'setup' function and this is the reason they are working but incorrectly which is the problem.

And the high Z state?

what do you mean by Z-state?

I have noticed another thing that might help in finding the problem. It doesn't care which digital pin i connect its strobe and keeps on behaving the same manner. It only stops working if i disconnect the RX of the first sensor but otherwise it works although it is extremely incorrect. It mean that it is getting something from the digital pins on which i am not even sending any information.

it stops responding if i use 'pinMode(9,OUTPUT)' in the setup. So then to make it work i have to strobe repeatedly in the loop. but still problem remains. just this means that it needs a constant pulse which is strange.

void loop() {
  // read the value from the sensor:
  //an0 = (analogRead(0)*(5000.0f/1024))*0.26;
//an1 = (analogRead(1)*(5000.0f/1024))*0.26;
//an2 = (analogRead(2)*(5000.0f/1024))*0.26;
//an3 = (analogRead(3)*(5000.0f/1024))*0.26;
//an4 = (analogRead(4)*(5000.0f/1024))*0.26;
//an5 = (analogRead(5)*(5000.0f/1024))*0.26;
digitalWrite(9,HIGH);
  delayMicroseconds(30);
  //delay(100);
  digitalWrite(9,LOW);
an0=analogRead(0)*4.88/9.8;
an1=analogRead(1);
  an2=analogRead(2);
  an3=analogRead(3);
  an4=analogRead(4);
  an5=analogRead(5);
  // turn the ledPin on
  Serial.print(an0);
Serial.print('\t');
Serial.print(an1);
Serial.print('\t');
Serial.print(an2);
Serial.print('\t');
Serial.print(an3);
Serial.print('\t');
Serial.print(an4);
Serial.print('\t');
Serial.print(an5);
Serial.print('\t');
Serial.println(' ');
  // stop the program for for <sensorValue> milliseconds:
  delay(100);                  
}

Then the micro controller will have to return it's pin to a high impedance state

it stops responding if i use 'pinMode(9,OUTPUT)' in the setup

what do you mean by Z-state?

No, "high Z state", aka "high impedance".

I have figured out that these sensors actually have a lower limit but still the chaining is not working. If i am not mistaken, in daisy chaining constant looping it should not need strobe again and again but if i just strobe it for 20us in the setup once then it doesn't work so i have to put 20us ping in the loop of the code. After observing the values of the sensor it seems as if it is still intercepting the signal from other sensors. e.g.
143.46 17.77 52.05 77.44 140.92 44.43
143.46 17.77 49.51 77.44 77.44 44.43
143.46 17.77 49.51 77.44 77.44 44.43

sensor '5' seem to be picking the signal from sensor '4' because after series of 140.92 it receives 77.44 for some time.

void setup() {
  // declare the ledPin as an OUTPUT:
  //pinMode(ledPin, OUTPUT);  
  Serial.begin(57600);
  pinMode(9,OUTPUT);
  
  digitalWrite(9,HIGH);
  //delayMicroseconds(20);
  delay(250);
  digitalWrite(9,LOW);
  delay(250);
}
void loop() {
digitalWrite(9,HIGH);
  delayMicroseconds(30);
  digitalWrite(9,LOW);
delay(50);
an1 = (analogRead(1)*(5000.0f/1024))*0.26;
an2 = (analogRead(2)*(5000.0f/1024))*0.26;
an3 = (analogRead(3)*(5000.0f/1024))*0.26;
an4 = (analogRead(4)*(5000.0f/1024))*0.26;
an5 = (analogRead(5)*(5000.0f/1024))*0.26;
Serial.print(an0);
Serial.print('\t');
Serial.print(an1);
Serial.print('\t');
Serial.print(an2);
Serial.print('\t');
Serial.print(an3);
Serial.print('\t');
Serial.print(an4);
Serial.print('\t');
Serial.print(an5);
Serial.print('\t');
Serial.println(' ');
}

Hi,
have you already try with one sonar?
Does it works?

Marsangola

Thanks, yes i tried with the one sonar and it works. Even the chaining works but with errors like randomly one sensor stops responding and starts to give lower values. Really a pain to chain these sensors.

Some sensors just stick to a certain value, it is mostly around 30 (e.g. 38,29,32...). I am not sure what could be the problem. If there is any sensor defective then still it is not easy to figure out. I have checked the wiring also and it seems ok.

Have you tried doing two readings per sensor, discarding the first?