Society of Robots - Robot Forum
Electronics => Electronics => Topic started by: GrooveHolmes on December 16, 2010, 11:49:11 PM
-
Something really strange is afoot; I was just tinkering with some really simple IR/servo code when my IR sensors started returning "0". I thought maybe my sensor died, or the cats munched a cable when I wasn't looking (even though there was no visible damage), but i swapped out the sensor with a second brand new unit, and replaced the cable anyways and the problem persists.
I've switched ADC ports, and even connected up a second sensor just to test if my sensor crapped.
i setup the simplest test code I could and still, "0".
Here's the code:
#include "sys/axon2.h" // I am using an Axon2
#include "uart.h"
#include "rprintf.h"
#include "Sensors/Distance/Sharp/GP2.h"
Sharp_GP2Y0A02YK myDistanceSensor = MAKE_Sharp_GP2Y0A02YK(ADC10); //Create IR Sensor and name it
Sharp_GP2D120 myDistanceSensor2 = MAKE_Sharp_GP2D120(ADC2);
void appInitHardware(void){
uartInit(UART1, 115200);
rprintfInit(&uart1SendByte);
}
TICK_COUNT appInitSoftware(TICK_COUNT loopStart){
return 0; // dont pause after
}
TICK_COUNT appControl(LOOP_COUNT loopCount, TICK_COUNT loopStart){
rprintf("Hello world\n");
distanceDump(myDistanceSensor);
distanceDump(myDistanceSensor2);
rprintf("\n");
return 1000000; // wait for 1 second before calling me again. 1000000us = 1 second
}
and the output:
Hello world
(0 cm)(0 cm)
Hello world
(0 cm)(0 cm)
Hello world
(0 cm)(0 cm)
Hello world
(0 cm)(0 cm)
Hello world
(0 cm)(0 cm)
Hello world
(0 cm)(0 cm)
Hello world
(0 cm)(0 cm)
Hello world
(0 cm)(0 cm)
Hello world
(0 cm)(0 cm)
Hello world
(0 cm)(0 cm)
So now i'm wondering what would cause this. Wondering if this *might* be damage due to static from a cat (fur discharge) walking on my desk while I was working and/or not looking.
Any way to test this? Or otherwise troubleshoot this? Thanks!
-
You forgot to read the sensor value before dumping it :P
this:
distanceDump(myDistanceSensor);
distanceDump(myDistanceSensor2);
should be this:
distanceRead(myDistanceSensor);
distanceRead(myDistanceSensor2);
distanceDump(myDistanceSensor);
distanceDump(myDistanceSensor2);
-
Hehe, yeah.. this one turned out to be a problem between the keyboard and chair. :)
Axon seems fine, sensors too. The tinkering continues....