I have always wanted to make a completely useless box or robot or something, but never actually got around to doing anything about it, so for the Project14 Cheer Us Up Competition I decided to have a go. I have been playing around with a low cost 4 WD robot that uses chain drive to transfer the power from the dc motor to the four wheels (Chain Drive Robot : The Original Kit | element14 | Dubbie Dubbie) and thinking about how I might use the chains on a mobile robot of my own. Then the Cheer Us Up Project14 competition was announced and I thought - "What would be more cheering that a chain driven mobile robot hanging from a clothes line that just moves forwards and backwards and doesn't do anything else. So I hacked about with the kit until I had a one wheel hanging mobile robot.
I could have gone with some timers and relays and stuff to control the DC motor direciton but decided 'who want's to do that' so stuffed in a Nano with a dual H bridge driver (I'm only using one channel). I had just purchased some more strip board and some turned pin headers and sockets (for the Nano) so decided to make a soldered in version rather than the protoboard approach I usually use. This could have been a mistake as despite this being a simple circuit I had endless problems with the assembly, due to mistakes (my eyesight is not what it was), poor soldering (I have been trying out some new leaded solder as Farnell will not sell it to me anymore - which could have caused some soldering problems) and just general weirdnesses - at one point I had a wire with a signal at one end but not at the other but the wire wasn't broken. I'm still not sure what caused this but I think it might have been the soldering.
Additionally, the 4WD robot kit does say at one point that the motor is suitable for solar power so it seemed to me that a robot hanging from a washing line that would move backwards and forwards forever! was useless and cheering - I could be mistaken about this. The motor only seems to need about 10 mA to run, a Nano is about 20 mA so I thought a smallish solar cell (120 x 38 mm 5V at a maximum output current 80 - 90 mA) would do the trick. It didn't. It wasn't a sunny day so I thought two of these solar cells would work. They didn't, so I tried four - still not working. I think the problem is that although the DC motor only required some 7-10 mA to run, the inrush current is much higher, causing the supply voltage to dip and the Nano to reset. I was almost at the point of changing back to batteries when I saw these solar cells (ALLPOWERS Solar Panel 2.5W 5V/500mAh Mini Encapsulated Solar Cell Epoxy DIY Battery Charger Kit Pack of 2: AmazonSmile: Sports & Outdoors) which purport to provide upto 500 mA at 5V. Maybe they do and maybe they don't, but in the not that sunny garden they do not provide the inrush current needed. Having got this far I did not want to give up so I thought of adding some capacitors to cope with the inrush current problem. The only capacitors I have are some 10 F Supercapacitors which have a maximum voltage of 2.7V so I put two in series. The circuit diagram is illustrated below:
Supercapacitors can be a bit tricky to use as they can take a fair bit of current to charge up. When I first added them nothing seemed to be working, the supply voltage wasn't increasing and nothing was turning on but then I noticed a gradual increase in the Supercapacitor voltage and realised that they were indeed charging - I was using the USB connection to the Nano to power the system and the laptop was limiting the current being use to charge them. Hooray success! Once I had charged up the capacitors from the USB link I could unplug the USB cable, take the system outside and it would then work successfully from the solar cell. See the video below.
Although I had produced a working system I still wondered if it might be possible to charge the Supercapacitors solely from the solar cell rather than pre-charging from the USB connection. So, I measured the current and voltage from the solar cell, as illustrated below.
The Supercapacitors take a fair bit of current from the USB connection, probably more than is good for the laptop electronics. But when just using the solar call, placed indoors up against a window on a cloudy day, it did successfully charge and enable the system to work - or probably work as I have not yet tried this outside. I think it will all depend on how sunny the day is.
The program used for the Nano is listed at the end. It does not do very much, just turn the DC motor on in one direction for a bit and then in the other direction for a bit, with a delay inbetween. I tried connecting the 5V supply to A5 on the Nano to see if I could get the program to wait until there was enough charge before starting, but this doesn't seem to work. I suspect this is because the ADC in the Nano uses the 5V rail as the reference voltage, which if it isn't at 5V isn't going to give accurate results. I couldn't use the serial monitor to look at these values as connecting the USB cable charges up the Supercapacitor anyway. However, time has run out so this is all I have. I like it.
Dubbie
PS The programme listing contains many commented out sections and functions that are not used as it is still a work in progress.
/* Dubbie Dubbie
* The Solar Do Nothing Mobile Robot
* Controls one DC motor to just move forwards and backwards
*
* 10th May'21
*
* Just for Fun
*/
#define leftforward 5
#define rightforward 2
#define leftbackward 3
#define rightbackward 4
#define motor1A 4
#define motor1B 5
#define motor2A 2
#define motor2B 3
#define go LOW
#define stop HIGH
#define text_delay 500
#define cm10 3300 // Should be the delay for 10 cm travel
#define batteryconn A5 // Using A5 to measure battery voltage
void setup(void)
{
pinMode(LED_BUILTIN, OUTPUT);
pinMode(motor2B, OUTPUT);
pinMode(motor2A, OUTPUT);
stopmotor(); // Make sure both motoros are stopped
delay(100);
} /* setup */
void loop(void)
{
char value;
int accel;
int solarcount;
int battvalue;
accel = 0;
value = 100;
battvalue = 0;
// Waiting for the Supercapcitors to charge
//delay(30000); // Delay after reset for getting assembled
battvalue = analogRead(batteryconn);
while (battvalue < 850)
{
digitalWrite(LED_BUILTIN, HIGH);
delay(100);
digitalWrite(LED_BUILTIN, LOW);
delay(battvalue);
battvalue = analogRead(batteryconn);
} /* while */
// Gives the soilar panel a few seconds to get going
for (solarcount = 0; solarcount < 6; solarcount++)
{
digitalWrite(LED_BUILTIN, HIGH);
delay(250);
digitalWrite(LED_BUILTIN, LOW);
delay(250);
} /* for */
delay(1000);
while (1)
{
digitalWrite(LED_BUILTIN, HIGH);
digitalWrite(motor2A, HIGH); // Set the motor direction
digitalWrite(motor2B, LOW);
// DCmotorpwm(60, 100, 2000, motor2A, motor2B); // Forwards
delay(3000);
digitalWrite(LED_BUILTIN, LOW);
digitalWrite(motor2A, LOW); // Set the motor direction
digitalWrite(motor2B, LOW);
delay(3000);
digitalWrite(LED_BUILTIN, HIGH);
digitalWrite(motor2A, LOW); // Set the motor direction
digitalWrite(motor2B, HIGH);
delay(1500);
// DCmotorpwm(60, 100, 2000, motor2B, motor2A); // Backwards
digitalWrite(LED_BUILTIN, LOW);
digitalWrite(motor2A, LOW); // Set the motor direction
digitalWrite(motor2B, LOW);
delay(1500);
// forward();
// stopmotor();
// delay(500);
// backward();
// delay(2000);
// 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 */
Top Comments