I have been pottering on with the 1DUltraBot for the Acoustics Project14 activity and now having a working chassis. I decided that rather than try to make my own chassis to follow the 5 foot ruler that I would adapt an existing child's small toy car. I was originally just going to use the axles and wheels but on closer inspection of the toy car decided that it would be even better and simpler to just 3D print some parts that fitted onto the base of the toy car without the need for any alterations. After a couple of days of measuring and making mistakes with measuring I managed to produce three printed parts:
1) The bottom guide for the ruler
2) The micro servo motor holder,
3) A triangular piece to hold the micro servo motor in place.
The challenge with these pieces was to get the servo motor to the correct height. When the chassis is placed over the ruler the wheel on the continuous rotation servo motor must touch the ruler with just enough force to provide the friction so that it will move along but not so low that it lifts the existing chassis wheels away from the ground. After a couple of failed attempts (caused by my inability to read the distance from a ruler thingy) I managed to print out an acceptable set of parts.
The picture below shows the guide fixed in place on the bottom of the toy car.
This is a side view showing the micro servo (just visible) and the triangular fixing plate that holds the battery.
The electrical connections are very simple
Vbat to Nano Vin and +V of the micro servo motor
Vgnd to Nano GND and ground of the micro servo motor
D2 of the Nano to the PWM connection of the micro servo motor.
At the moment I am using my own micro servo motor pulse function, just to have more control, but I plan to move to an interrupt version later if needed.
void myservo(int select_servo, int servo_value, int servo_period)
// servo_value must be between 0 and 2000
if (servo_value < 0)
servo_value = 0;
if (servo_value > 2000)
servo_value = 2000;
for (index = 0; index < servo_period; index++)
digitalWrite(select_servo, HIGH); // Start the servo pulse
delayMicroseconds(500); // Basic pulse period part
delayMicroseconds(servo_value); // Additional delay for servo position
digitalWrite(select_servo, LOW); // End the servo pulse.
delayMicroseconds(2000 - servo_value);
delay(18); // wait for the pulse space
} /* for */
I just put this function into a simple infinite while loop to get it to move forwards and backwards. Nothing complicated, just enough to check everything is working.
// Just going forwards and backwards
myservo(fl_shoulder, 0, 300);
myservo(fl_shoulder, 2000, 300);
} /* while */
The video below shows the chassis moving as required and is actually better than I was expecting with no wheel slip at all.
Next, adding the ultrasonic rangefinder.