Registered Users          New User?
Picture of Erik Gutierrez
Front Sensor Intermittent - XIP Robot
by Erik Gutierrez - Tuesday, December 8, 2009, 08:46 AM
Having issues during the front sensor testing on the XIP SUMO Robot configuration. I initially used the legacy front sensors (red, yellow, black wiring) but there was no response to the input. I then decided to connect the newer sensor (purple, blue, green wiring) and still had issues. I tried several values, 50, 150, 250, 350, 450, 600. I had intermittent success with 50, sometimes it would detect the object other times, it wouldn't. I would also jiggle the wire and it would give me intermittent results dependent on the movement of the wire with the 50 value used for detection. I suspect it’s a hardware issue but I’ll try another sensor on Wednesday. Any suggestions or recommendations?
Picture of Sam Christy
Re: Front Sensor Intermittent - XIP Robot
by Sam Christy - Wednesday, December 9, 2009, 05:04 AM
  Erik,

Can you give me the model of the sensor? It is written on top of the sensor body.

Sam

Picture of Sam Christy
Re: Front Sensor Intermittent - XIP Robot
by Sam Christy - Wednesday, December 9, 2009, 05:31 AM
  Erik,

Can you also tell me the order of the wires at both ends of the cable?

Thanks,
Sam

Picture of Erik Gutierrez
Re: Front Sensor Intermittent - XIP Robot
by Erik Gutierrez - Wednesday, December 9, 2009, 03:46 PM
Looking at sensor with dot near the left of the sensor.
smile. smile
G B P

G P B
(LHE)
Picture of Erik Gutierrez
Re: Front Sensor Intermittent - XIP Robot
by Erik Gutierrez - Wednesday, December 9, 2009, 03:41 PM
I tried two different Sharp sensors (GP2D15 F 93).




Picture of Erik Gutierrez
Re: Front Sensor Intermittent - XIP Robot
by Erik Gutierrez - Wednesday, December 9, 2009, 09:26 PM
I looked up the data sheet for the Sharp sensor and the wiring seems to be correct. I then decided to try different sensor values in the code and it seems to work consistently with values ranging from 1 to 50 with detection ranges of about 5ft.- 5in., respectively. Sensor values above 60 cannot detect any objects in front of the sensor.

Hope this info helps.
Picture of Sam Christy
Re: Front Sensor Intermittent - XIP Robot
by Sam Christy - Thursday, December 10, 2009, 06:29 PM
  Erik,

You definitely have a digital sensor. You can use the following code to control them. They should be connected to the digital port of the Master Module. 0..5 corresponds to the digital port number etched on the cover. Depending on your application you might want to change the comparison from LOW to HIGH. Let me know how this works.

if (digital_read(0) == LOW)

{
//do something
}
else if (digital_read(1) == LOW)

{
//do something
}
Picture of Erik Gutierrez
Re: Front Sensor Intermittent - XIP Robot
by Erik Gutierrez - Sunday, December 13, 2009, 07:42 PM
Sam,

The code you gave me is for the down sensors, Port 1, 0. The sensor I'm having issues with is the forward looking sensor and its only connected to one port. Nonetheless, I tried hooking up the front sensor to a digital port in this case, and it is not responding properly.

Here's the code i used.

#include <machinescience.h>
#include <mastermod.h>

int main(void)
{
servo_control(ENABLE);
while(1==1)
{
if (digital_read(5)==HIGH)
{
servo_robot(STOP, 0);
delay_ms(2000);
}
if (digital_read(5)==LOW)
{
servo_robot(FORWARD, 100);
}
}
}

Picture of Sam Christy
Re: Front Sensor Intermittent - XIP Robot
by Sam Christy - Monday, December 14, 2009, 07:42 AM
  Erik,

Do you have a multimeter (or voltmeter)? I would like to confirm that the senor you have is working properly before diagnosing the problem further.

With the sensor facing you, connect the right most wire (follow it from the sensor all the way to the end) to 5 Volts. Connect the middle wire to ground. Connect left most wire to the positive lead of the multimeter AND to 5V through a 10K resistor.

You should now see a change on the voltmeter when you move your hand in front of the sensor.


Picture of Erik Gutierrez
Re: Front Sensor Intermittent - XIP Robot
by Erik Gutierrez - Monday, December 14, 2009, 08:42 AM
I'll try that check tonight and let you know.
Picture of Sam Christy
Re: Front Sensor Intermittent - XIP Robot
by Sam Christy - Monday, December 14, 2009, 02:40 PM
  Erik,

If you sensor is marked GP2D15 it is digital and if it is marked 2Y0A21 than it is analog.

Assuming that it is digital and that it is working the following code can be used to test it. Connect the sensor to Digital Port 3 of the Master board in the following manner. With the sensor facing you connect the right most pin of the sensor to the middle of the three pins on Port 3. Connect the middle pin of the sensor to the lowest pin (nearest the PCB) of Port 3. Connect the left most pin of the sensor to the highest pin (farthest from the PCB) of Port 3.

Compile and download the following code.

#include <machinescience.h>
#include <mastermod.h>

int main(void)
{
servo_control(ENABLE);
while(1==1)
{
if (digital_read(3) == HIGH)
{
servo_robot(REVERSE, 100);
}
else if (digital_read(3 ) == LOW)
{
servo_robot(FORWARD, 100);
}
}
}

If this does not work than there is something wrong with the sensors.

Sam

Picture of Erik Gutierrez
Re: Front Sensor Intermittent - XIP Robot
by Erik Gutierrez - Monday, December 14, 2009, 09:35 PM
Its a digital sensor. Copied the code above and connected as instructed to digital port #3. No response, same issue.
Picture of Erik Gutierrez
Re: Front Sensor Intermittent - XIP Robot
by Erik Gutierrez - Monday, December 14, 2009, 09:37 PM
Checked the sensor with meter, sensor is working fine, measured these voltages while moving object in and out of sensor. Seems like the master module is not doing anything with the Vo inputs. Couple of our students also tried the digital sensor port/code with no success.

Vcc = 4.95V
Voh = 4.94V
Vol = .444 V



Picture of Sam Christy
Re: Front Sensor Intermittent - XIP Robot
by Sam Christy - Tuesday, December 15, 2009, 10:53 AM
  Erik,

I realized the problem is that the digital sensors need a pull-up resistor. This is enabled using the following command for each port.

digital_port(0, INPUT);

I tested this on a robot here and it worked fine. Here are a couple of things to be careful about.
1) Make sure the correct wire is in the correct part of the port (ground, power, signal). We have some legacy cables and the wires cross from the sensor to the connector, so make sure you follow the wire from the sensor so that it is correctly attached.
2) Make sure you using the correct port. The count starts at 0 so Port 3 is the fourth one from the bottom.

#include <machinescience.h>
#include <mastermod.h>

int main(void)
{
servo_control(ENABLE);

digital_port(0, INPUT);
digital_port(1, INPUT);
digital_port(2, INPUT);
digital_port(3, INPUT);

while(1==1)
{
if (digital_read(2) == HIGH)
{
servo_robot(REVERSE, 100);
}
else if (digital_read(2 ) == LOW)
{
servo_robot(FORWARD, 100);
}
}
}

Picture of Sam Christy
Re: Front Sensor Intermittent - XIP Robot
by Sam Christy - Tuesday, December 15, 2009, 10:53 AM
  Erik,

I realized the problem is that the digital sensors need a pull-up resistor. This is enabled using the following command for each port.

digital_port(0, INPUT);

I tested this on a robot here and it worked fine. Here are a couple of things to be careful about.
1) Make sure the correct wire is in the correct part of the port (ground, power, signal). We have some legacy cables and the wires cross from the sensor to the connector, so make sure you follow the wire from the sensor so that it is correctly attached.
2) Make sure you using the correct port. The count starts at 0 so Port 3 is the fourth one from the bottom.

#include <machinescience.h>
#include <mastermod.h>

int main(void)
{
servo_control(ENABLE);

digital_port(0, INPUT);
digital_port(1, INPUT);
digital_port(2, INPUT);
digital_port(3, INPUT);

while(1==1)
{
if (digital_read(2) == HIGH)
{
servo_robot(REVERSE, 100);
}
else if (digital_read(2 ) == LOW)
{
servo_robot(FORWARD, 100);
}
}
}

Picture of Erik Gutierrez
Re: Front Sensor Intermittent - XIP Robot
by Erik Gutierrez - Tuesday, December 15, 2009, 01:04 PM
I'll try this tonight. But a follow-on question arises, how does this affect the down sensors since they are currently working in the digital ports with out the pull-up resistor being enabled? Do we just enable the pull-up resistor for the port specific to the front sensor?