Go Down

Topic: multiple maxbotix LVEZ on one UNO? (Read 6319 times) previous topic - next topic

TeslaIaint

Quote


No daisy-chain, I am simply using your code, and separate sonars. If you check your original code
with my editing, you'll see tx,rx are just your same pins:

int SonarR = 5;
int TriggerR = 2;
int SonarL = 3;
int TriggerL = 4;

How are your sensors wired? I have only four wires coming from each sensor. For example the right sonic has +, -, RX to pin 2, and PWM to pin 5. Is that how your sensors are connected?

Quote

  pinMode(rxpin, INPUT);

Why is rx pin an input? Shouldn't it be an output just to trigger the sensor into reading?

Quote
if(countL>prevCountL&countL>maxCountL){

s/b:

    if( countL > prevCountL && countL > maxCountL ) {

or as I prefer:

    if( (countL > prevCountL) && (countL > maxCountL) ) {

Were you going to change this in your code? It seems to work both ways, but it shouldn't since the single "&" is for binary.

Also I'm not getting the nine values in the array that get converted into mode even when I un-comment the "void printArray" part of the code. I am only getting the mode for each of the sensors.
if you could copy and paste the code as you are using it with your modifications it would be a big help. Thanks.

oric_dan


If you check my code in post #20 you'll see:
Code: [Select]

  read_sonar( TriggerR, SonarR, rangevalueR, arraysizeR);
..........

/**********************************************************/
void read_sonar(int txpin, int rxpin, int* ary, int asiz)
{


Also, must be "&&" in the other, I forgot to fix it in post #20 code. It doesn't matter in regards
the 2nd sonar, 1st sample problem.

TeslaIaint

Why do you have TX and RX in your code? Do you have TX wired up to something? And Why is RX an input instead of output? I'm missing something.

oric_dan

Local [temporary] variables are visible only inside the function, call them whatever you like.
I modified this to reflect the other changes I mentioned.

Code: [Select]

/**********************************************************/
void read_sonar(int trigpin, int pulsepin, int* ary, int asiz)
{
  pinMode(pulsepin, INPUT);

  for(int i = 0; i < arraysizeL; i++) {    
    digitalWrite(trigpin, HIGH);
    delay(20);
    digitalWrite(trigpin, LOW);
    ary[i] = pulseIn(pulsepin, HIGH) / 147;
    delay(100);
  }
}

TeslaIaint

#34
Mar 18, 2012, 04:15 am Last Edit: Mar 18, 2012, 04:28 am by TeslaIaint Reason: 1
That makes more sense to me now. Thanks. But unfortunately the code only works good for a stationary robot ranging a stationary target (21" x 21" box. There's a 4-5 second lag to change the led's to reflect the change in range if I move the robot closer or farther away.  I changed some of your delays to delayMicroseconds and still get ok results. Still some spikes, though.  I think the main problem is with the inherent limitations of the sensor. It's fairly accurate but the accuracy isn't very repeatable (precise).
Quote
void read_sonar(int trigpin, int pulsepin, int* ary, int asiz)
{
 pinMode(pulsepin, INPUT);

 for(int i = 0; i < arraysizeL; i++) {                         
   digitalWrite(trigpin, HIGH);
   delayMicroseconds(20);
   digitalWrite(trigpin, LOW);
   ary = pulseIn(pulsepin, HIGH) / 147;
   //delay(100);
 }
}


I also tried it with the baud rate set to 57600 got the same results. The data sheet for the Maxsonar says 9600 baud, but it works ok anyway.  
The parallax ping sensor seems to be more accurate and precise, but it's footprint is so narrow that it's worthless for my robot. I might have to rethink my whole approach to my project.

oric_dan


I think the 4-5 sec delay on Leds you mention is simply because your range check covers 14 - 36".

I wouldn't remove the delay, but you might shorten it to 50-msec - per the EZ datasheet.

Also, the Maxsonar 9600 bps is only if you use the RS232 mode output, which you're not using.

TeslaIaint

#36
Mar 18, 2012, 07:01 am Last Edit: Mar 18, 2012, 07:13 am by TeslaIaint Reason: 1
Quote
I think the 4-5 sec delay on Leds you mention is simply because your range check covers 14 - 36".


Can you elaborate on this?



The following code cuts the delay to about 2 seconds from the longer delay. I don't care about the LED's but at the moment they are simulating motors.

Code: [Select]
 for(int i = 0; i < arraysizeR; i++)
 {    
   digitalWrite(TriggerR, HIGH);
   delayMicroseconds(200);
   digitalWrite(TriggerR, LOW);
   pulseR = pulseIn(SonarR, HIGH);
   rangevalueR[i] = pulseR/147;
   delay(50);
   


Do you agree with these delays?


oric_dan

Delays look good.

Quote

But unfortunately the code only works good for a stationary robot ranging a stationary target (21" x 21" box. There's a 4-5 second lag to change the led's to reflect the change in range if I move the robot closer or farther away.


I guess I didn't understand what this meant.


Iolanda

Hello! I am working on a project on human presence detection. I have ordered 2 maxbotix ez3 an arduino uno and a buzzer. I want my sensors to detect presence one at a time so that I can detect when the person is inside a room. I can't find the tutorial where I connect the to sensors to the Arduino Uno. Please, can you help me?

TeslaIaint

It depends on what mode you want to connect them.
Read through the Product Documentation links from this link: http://www.maxbotix.com/products/MB1030.htm

And another:  http://www.arduino.cc/playground/Main/MaxSonar

If you just want to detect the presence of a person, passive infrared sensors are made just for that. Ultrasonic sensors are made for sensing distance. What exactly are you trying to accomplish? If you are more specific, we could be of more help.

Iolanda

I want to put the two sensors on each side of the door.If a person comes inside the room, sensor 1 will detect motion and then sensor 2. If the person comes out of the room the motion will be detected by sensors 2 1. Unfortunately, I found out late that it was much easier to use a PIR sensor. My coordonator told me to use ultrasonic sensors.So I have to use them for my project. And I can't change the sensors now because I have only 2 weeks until I have to present my project.

TeslaIaint

the maxbotix sensors will work, and if they are on opposite sides of the doorway they won't interfere with each each other. check the links from my last post. Get them wired up and write some code. Post a schematic and your code here, and I'll check back to help you.

Iolanda

here is the sketch I've done. I'm not sore if it's correct. I've used daisy chaining.I'll work tonight on the source code. Is the sketch ok?

TeslaIaint

#44
Jul 01, 2012, 07:41 am Last Edit: Jul 01, 2012, 07:51 am by TeslaIaint Reason: 1
very good sketch! I think you should try to use the pwm mode of the maxbotix sensor. It's not much different from what you are doing now. You don't have to daisy chain it either. They won't interfere. They are on different sides If the door right? I'll walk you through it. Just post some code using the links I gave you. If you don't understand I'll help you. I know it's frustrating, but I'm here to help. We'll make it happen.  

Go Up