Having made the Crawling Worm Robot kit ( Worm Robot | element14 | Dubbie Dubbie ) which doesn't have any form of controller, the obvious next step is to add a controller and then see what might be achievable, so that is what I have done.
I have added an ATtiny85 microcontroller, mainly because that is the device I have been playing with recently and I only need a couple of digital outputs, plus a DRV8833 dual H bridge driver, using only one bridge, to control the DC motor. From my experiments with the ATtiny85 I have discovered that it needs at least 2.8V to work reliably so rather than use the existing 2 x AA battery module I added a 3.7V LiPo battery instead, ,just to give that little bit of extra confidence. It is a simple circuit and is shown below:
I have used a small protoboard to hold the ATtingy85 and DRV8833 PCBs during this initial development stage, as shown below. I can always make these connections more permanent if it seems to work out OK.
At present it is all just held together with Bluetac and a wire tie as illustrated in the picture below. Assuming all goes well I have plans to 3D print a framework for an updated Crawling Worm Robot.
I wrote a simple programme that just turns the motor on for two seconds, then waits for 0.5 seconds, when it reverses the motor for another 2 seconds and turns off the motor with another 0.5 second delay. The programme is based on the one used in the Sand Cat Detector with a few simplifications. Rather than deleting the unwanted statements I have commented out the statements controlling the second H bridge in the DRV8833 just in case I ever try a version of this with two DC motors. There is also a function for implementing PWM control of the motor which I am saving for future experiments. The programme is listed below.
/* Dubbie Dubbie
* The Worm Mobile Robot
* Controls one DC motor and varies the speed
*
* Dec'20
* Just for Fun
*/
#define leftforward 5
#define rightforward 2
#define leftbackward 3
#define rightbackward 4
#define motor1A 3
#define motor1B 2
#define motor2A 1
#define motor2B 0
#define go LOW
#define stop HIGH
#define text_delay 500
#define cm10 3300 // Should be the delay for 10 cm travel
void setup(void)
{
pinMode(motor2B, OUTPUT);
pinMode(motor2A, OUTPUT);
stopmotor(); // Make sure both motors are stopped
delay(100);
} /* setup */
void loop(void)
{
char value;
int accel;
accel = 0;
value = 100;
while (1)
{
forward();
delay(2000); // Forward
stopmotor();
delay(500);
backward();
delay(2000); // Backwards
stopmotor();
delay(500);
} /* while */
} /* loop */
void DCmotorpwm(int mark, int total, int count, int inhigh, int inlow)
{
int countindex, pwmindex;
countindex = 0;
pwmindex = 0;
digitalWrite(inhigh, HIGH); // Set the motor direction
digitalWrite(inlow, LOW);
for (countindex = 0; countindex < count; countindex++)
{
for (pwmindex = 0; pwmindex < mark; pwmindex++)
{
digitalWrite(inhigh, HIGH);
delayMicroseconds(10);
} /* for */
for (pwmindex = mark; pwmindex < total; pwmindex++)
{
digitalWrite(inhigh, LOW);
delayMicroseconds(10);
} /* for */
} /* for */
//digitalWrite(inhigh, LOW); // Set the motor off
//digitalWrite(inlow, LOW);
} /* DCmotorpwm */
void forward(void)
{
// digitalWrite(motor1A, HIGH);
// digitalWrite(motor1B, LOW);
digitalWrite(motor2A, HIGH);
digitalWrite(motor2B, LOW);
} /* forwardboth */
void backward(void)
{
// digitalWrite(motor1A, LOW);
// digitalWrite(motor1B, HIGH);
digitalWrite(motor2A, LOW);
digitalWrite(motor2B, HIGH);
} /* backwardboth */
void stopmotor(void)
{
// digitalWrite(motor1A, LOW);
// digitalWrite(motor1B, LOW);
digitalWrite(motor2A, LOW);
digitalWrite(motor2B, LOW);
} /* stopmotor */
I wanted to check that changing the direction of the DC motor would also change the direction the Crawling Worm Robot would move. I wasn't entirely sure that it would, but fortunately it does, as illustrated in the video below.
So I have made a step forwards in converting the Crawling Worm Kit into an actual robot - with a controller and (hopefully at some point) sensors as well. As mentioned above, I am planning to make a 3D printed framework for the Crawling Worm Robot to replace the wooden version and to customise it for the ATtiny85 controller and H bridge driver.
Dubbie
Top Comments