Enter Your Electronics & Design Project for a chance to win a $200 shopping cart! Back to homepage | Project14 Home | |
Monthly Themes | ||
Monthly Theme Poll |
In the summer, having had the idea of detecting cats by using sand (Cat Detector Using Sand #1 : The Idea ) I have now progressed into an implementation. It proved to be much more difficult than I anticipated to create a mobile robot capable of levelling sand, which would also work outside. I have been wanting to make some sort of mobile robot capable of being outside for some time so this was a good opportunity to try out some ideas.
The first thing I needed was something to hold the sand. I could have used the base for the path as used in Part 1, but I finished putting the brick pavers down so that was no longer a possibility. I happened to have some spare bits of wood so I made a rectangular trough which seemed about the right size to fit across my side alley way. I choose a relatively shallow trough, mainly so that it would use less sand but this was not such a good idea, as sand overflowed the edges leading to wheel slip. Still, I had made the trough first, so I used it.
The Sand Levelling Mobile Robot
I then needed a mobile robot capable and suitable of levelling the sand and being left outside all day and night. I knew that I would need considerable power (Torque?) from the mobile robot in order to move the sand, so it was either big expensive motors or cheaper motors with a gearbox. I choose the gearbox approach as then the wheels would be moving much more slowly and this seemed a good idea. I chose a DC motor and gear box combination with wheel, running at 6 rpm. That seemed fast enough and probably powerful enough. I wanted it to go outside so I used a biggish lead acid battery, mostly because I happened to have one. This is quite heavy so again is another reason for needing more torque/power and would also help improve the grip. If sand gets onto the tyres then there will be less grip so a larger mass in this instances, helps with traction.
These major elements then lead to the rest of the components. I used a DC-DC convertor (LM2596 DC-DC) to convert from the 12-13V of the battery down to 5V for the Arduino and motors. Technically the motors are 6V but the Arduino was already wired up to use the 5V input and I could not be bothered to unsolder it and connect the power to the Vin pin. I wanted the possibility of being able to control the speed of the DC motors, even if they only rotate at 6 rpm, so I used a dual H bridge DC motor driver PCB (DRV8833). Then I just needed an Arduino Nano to produce the control signals for the dual H bridge driver and that completed the system. A system diagram is shown below. It isn't complicated but it provides the capability of controlling each DC motor independently, controlling the speed and direction of each DC motor, and with a bit of extra circuitry could implement sensors to detect when the two ends of the trough are detected. (Oops! Just noticed I left the 0V connection off the Nano. I'm sure you can add that in your mind.)
At this moment in time, the system does not contain any sensors which would be used to detect when the end of the trough was reached and reverse or stop movement, so technically, it is not actually a mobile robot, it is just a machine. But, it would be relatively simple to add some sensors, such as waterproof ultrasonic rangefinders, or similar. However, I do not have any suitable external sensors, plus I have run out of time.
The chassis which holds everything together is made from old bits of wood I just have lying around, plus a couple of castors. It is pure coincidence that the spacing of the castors matches the width of the trough. I'd liked to say I designed it that way - but I didn't. It is also pure coincidence that the two wheels of each castor fit almost exactly either side of the trough wooden side walls and therefore acts as steering guides. My original idea was to just put the mobile robot chassis onto the trough side walls and hope it stayed there as it moved forwards and backwards. I would then have the capability of adding some sensors to detect the trough wall edges, if needed to keep the mobile robot in place. As it turns out, that level of complexity was unneeded.
The sand levelling part is just a straight edge fitted under the mobile robot chassis to level the sand at a height of 2 cm. I had ideas for all sorts of complex mechanisms for fluffing up the sand, ploughing the sand and then smoothing it back down, all depending on which direction the chassis was moving. But, in the end, time ran out and I just screwed a piece of wood underneath and hoped it would work.
I have put all the electronics inside a small plastic container (an old AA battery storage box) and covered over most of the other connections to improve protection from the weather. The DC motors and gearboxes are mostly underneath the wooden chassis so are just about protected from direct rain. They will be affected by humidity, cold and splash back (if it rains) but they should be OK for short periods outside. If not, then I will have learnt something - not sure what - but something.
Software
The software is very simple and just outputs signals to turn the dual H bridge driver on and off in the correction direction for each DC motor. IThe program does include a function for controlling the speed, acceleration and deacceleration of the DC motors, but in the end it wasn't needed, but I have left it in.
/* Dubbie Dubbie
* The Cat Detector Using Sand Mobile Robot
*
* Nov'20
* Just for Fun
*/
#define leftforward 5
#define rightforward 2
#define leftbackward 3
#define rightbackward 4
#define motor1A 5
#define motor1B 4
#define motor2A 3
#define motor2B 2
#define go LOW
#define stop HIGH
#define text_delay 500
#define serial_delay 10
#define cm10 3300 // Should be the delay for 10 cm travel
void setup(void)
{
pinMode(leftforward, OUTPUT);
pinMode(rightforward, OUTPUT);
pinMode(leftbackward, OUTPUT);
pinMode(rightbackward, OUTPUT);
stopboth(); // Make sure both motoros are stopped
delay(100);
Serial.begin(9600);
} /* setup */
void loop(void)
{
char value;
int accel;
accel = 0;
value = 100;
Serial.println("Cat Sand Detector Robot DC Motors " );
Serial.println("Dubbie Dubbie : Just for Fun " );
Serial.println(" 12th Nov'20 ");
Serial.println();
delay(500);
//
//
//
// dist_value = 0;
// dist_value = range();
// Serial.print("Distance is ");
// Serial.println(dist_value) ;
//
forwardboth();
delay(cm10 * 5); // Forward along the sand
stopboth();
delay(3000);
backwardboth();
delay(cm10 * 5); // Backwards along the sand
stopboth();
while(1)
{
// Wait for a reset
} /* 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 forwardboth(void)
{
digitalWrite(motor1A, HIGH);
digitalWrite(motor1B, LOW);
digitalWrite(motor2A, HIGH);
digitalWrite(motor2B, LOW);
} /* forwardboth */
void backwardboth(void)
{
digitalWrite(motor1A, LOW);
digitalWrite(motor1B, HIGH);
digitalWrite(motor2A, LOW);
digitalWrite(motor2B, HIGH);
} /* backwardboth */
void stopboth(void)
{
digitalWrite(motor1A, LOW);
digitalWrite(motor1B, LOW);
digitalWrite(motor2A, LOW);
digitalWrite(motor2B, LOW);
} /* stopboth */
Thee are probably some bits that could be deleted and simplified, but it works so I have left it as it is, just in case I decide to improve it at some point in the future. It might happen, you never know.
Trial Run Inside
The whole system has been put together and the video below shows it's very first trial inside the house without any sand - or cats.
First Run Outside
Following the success of the trial inside the house, I packaged up the electronics and cable tied everything to the chassis and moved it outside to the trough filled (sort of) with sand.
As you can see, it mostly worked. There was an issue with sand spilling over the side of the trough as it was being levelled, which I hadn't considered, plus, once there was sand on the wheels and the trough sides, there was much more slippage. It was necessary to carefully clear away all that unwanted sand before each levelling sequence.
Improved Run Outside
Rather than try and redesign the trough and the robot chassis to be able to prevent sand spilling over the sides of the trough, I decided to just clear all the sand away from the edges of the trough instead. It doesn't make much difference to the detecting area and (mostly) prevents problems with sand piling up and spilling over the sides.
The next step was to add some (simulated) cat paw prints and see what happens. This is shown in the following video.
It does work, but does not completely smooth out the cat paw prints. I did think this might happen but I am always optimistic as it does seem reasonable that if a dent is made in the sand that the displaced sand must be raised up somewhere, so that when the mobile robot passes over it will all be smoothed out again. Sadly, it doesn't quite do that. It will need some sort of sand 'fluffing' up mechanism to move sufficient sand above the level of the plough under the mobile robot. However, time is running out for the Project14 competition and I have Tulips to plant so I didn't try anything else.
Will It Detect Any Cats?
I am going to leave the cat Sand Detector outside for the rest of this afternoon and all through the night to see if it will detect any actual cats and then, in the morning, see if it will smooth out the sand. It might rain and there will probably be a significant dew in the morning so that sand is likely to be pretty wet. Plus, the mobile robot will be left powered on during this time to see how well it fares. The current drain when not moving is approximately 21 mA so the battery should be OK as it is several Ahrs. Sadly, it is not a new battery but a discard from a fire alarm system that was no longer within specification. Hopefully it will still be working in the morning. Current drain when moving is approximately 180 mA but there is definitely a current spike when the motors first start.
External Operation
An additional reason for trying out this approach to detecting cats is that I want to gain experience of making mobile robots to go outside in the garden. Up until now, my mobile robots have all been indoors so I want to gain experience of how to cope with extremes of temperature and humidity, as well as rainfall, and you never know, possibly some sunshine.
Dubbie
Top Comments