I’ve the DFRobotShop rover assembled and a range of sensors installed (2 x Sharp IR sensors, 1 x SRF05 UltraSound in Mode 2, 1 x Lynxmotion Line Tracking Sensor). All is working well, sensors giving reasonable values and moving nicely.
[ATTACH]271[/ATTACH][ATTACH]272[/ATTACH]
However there seems to be a noise problem in the trigger line for the SRF05 - the red LED that indicates a reading blinks randomly and almost constantly when the motors are running. Looks like motor noise showing up as pulses on the trigger/output line.
Rerouting wires helps a bit, wire routed well out of way has only little noise running motors forward but loads when running backwards. Tried setting the pin to both input and output modes when not taking readings but that doesn’t help. I’m guessing its going to upset the measurements if noise pulse occurs when doing a genuine reading. Common problem?
Update: Haven’t got on very well with the Arduino SDK so moved to AVR in Eclipse today, given that I use Eclipse all day at work I’m biased but its a much nicer environment. Plus it found the solution to this problem; I wasn’t setting the pin to output mode (I thought I was but I returned from the function before setting it, which Eclipse warned me about!). Setting the pin to output seems to do the trick, I presume this means that it is being pulled low and hence not suffering from noise.
For those who hit same issue, right way to take a reading with SRF05 in mode 2 seems to be:
[FONT=“Fixedsys”]unsigned long ultrasoundReading() {
// Send a pulse
pinMode(ultrasoundSensor, OUTPUT);
digitalWrite(ultrasoundSensor, LOW);
delayMicroseconds(2);
digitalWrite(ultrasoundSensor, HIGH);
delayMicroseconds(10);
digitalWrite(ultrasoundSensor, LOW);
// Record input pulse from same pin
pinMode(ultrasoundSensor, INPUT);
unsigned long reading = pulseIn(ultrasoundSensor, HIGH);
// Then switch back to ouput to avoid noise
delayMicroseconds(10);
pinMode(ultrasoundSensor, OUTPUT);
return reading;
}[/FONT]
Hi Mikey,
Welcome to the RobotShop Forum. We are happy you were able to diagnose and resolve the issue you encountered. Our suggestions would have been power (to ensure that there is sufficient power for the microcontroller, motor controller and sensors to work simultaneously), noise and of course code. We also appreciate the images of the setup and hope to perhaps see some video too?
Sincerely,