The main electronics |
Just a quick note - the green and blue wires you see that are going over and behind the plywood are not going anywhere really - it was just a way to get rid of the 'slack' I had, without cutting the wires to length. I always try to give myself slack when hooking up wires, run cables, etc.
Whenever I start a new electronics project, I break it down into different parts. The reason being is that I do not have a lot of experience in electronics, and therefore do not know much. So, I take the different components that I need to learn about, and proceed to learn about them one at a time.
From my point of view, there's 3 different aspects/components to the electronics for this project:
1. The Arduino parts
2. The motor parts
3. The 'clock' parts
So let's go in a little deeper...
1. The Arduino parts
I actually already knew about the Arduino parts from past projects, so there wasn't much to this part for me this time.
I'm not really going to go into detail about this as you probably already know about Arduino. However, if you are a beginner (like me) and want to know more about how to 'make your own' Arduino, you can check out my Instructable. Basically it shows you how to use your programmed ATMega328 chip on your own circuit. Instead of using up an entire, retail Arduino board ($25-$35) for your projects, you can just use a few cheap electronic components and build it in to your own project, like I did with this automatic cat feeder.
Here's a photo of an 'Arduino' on a breadboard from my Instructable that I just mentioned:
Standalone Arduino on a breadboard |
I do want to mention that during the learning/development/testing phase of a new project, I do use an actual, retail Arduino board. I have a couple of older Arduino Duemilanove boards that I always use for prototyping.
2. The motor parts
This ended up being an expensive part of the project. I've never 'driven' a motor from a microcontroller before, and had very little experience with motors in general. Having no idea what the specs needed to rotate the plastic paddle in the food dispenser, I purchased several different kinds and sizes of motors. I tried to keep it cheap, and mostly bought from RS Electronics. None of them ended up being sufficient enough though - they all spun pretty fast which was one problem, and they had very little torque which was the other problem.
What I needed was a motor that spun slow, and had good torque. As I mentioned in the main post for this project, I ended up buying a motor (on eBay) very similar to the one that this guy used. The specs for it:
Rated voltage: 12V
No-load speed: 5RPM
Product diameter: 37mm
Rated torque: 5kg/cm
Stall torque: 30kg/cm
Weight: 190g
Shaft diameter: 6mm
Product dimensions: 37mm (diameter) x 81mm (total length)
Here's a link to an eBay search that may come up with a motor with the same specs.
As I mentioned before, I have no experience with controlling a motor with a microcontroller, so this was all new to me. From what I found, there's a few options - you can buy an Arduino motor shield like this, this, or this. You can build what's called an H-bridge. You can drive it from your Arduino directly maybe (if you want to kill your Arduino). Or, you can go with one of these. It's fairly cheap, and pretty simple to use. It drives 1 or 2 motors (which I needed to run 2), so it worked out great for me.
If you want to use the same motor driver board that I did, check out the Bildr tutorial for it - it's what I used to learn how to hook it up, and run it.
One word of advice though - the last paragraph says that if you set the 2 direction pins HIGH or LOW, the motor will stop. This is not entirely true - you also have to enable standby with:
digitalWrite(STBY, LOW);
Ok, one more word of advice - I think that running a motor at full speed from a stopped position is not a good idea for the motor, so I 'ramp up' the speed in my code. There's a link to the Arduino code from my project's introduction page, but here's a little snippet:
//Don't spin motor full speed immediately - ramp it up!
for (i = 1; i < 256; i++) { // loop from 1 to 255
moveMotorLowLevel(whichMotor, i, 1); //motor A or B, speed from 1 to 255, spin left
Alarm.delay(10); // give a small delay between each speed change
}
Regarding dispensing the actual food, I just had to play with how many seconds to run the motor in order to get the desired of food dispensed out - there's no magic formula/equation as far as I know to get it precise the first time.
That about does it for the motor stuff, now on to our last 'component':
3. The 'clock' parts
What good would an automatic cat feeder if it didn't automatically feed the cats? There were 2 ways I could have (that I know of) approached this component:
1. Purchase some kind of automatic switching timer device like this one. There are tons of these on the Internet and brick-and-mortar places like Home Depot, Lowe's, WalMart, Target, etc. Going this route would have simplified the code/software side of things drastically.
2. Add a few components to the circuit to have a built-in clock/timer. This route makes writing the code more involved/complicated, but due to the existence of 'Time'-related libraries, I didn't need to write everything from scratch.
If you haven't picked it up already from reading my other posts, I'll just tell you now - I'm cheap. And, I wanted to learn about building my own clock and implementing 'timers' and the like. Sooo, I went the route of #2.
Turns out that it wasn't that difficult. I actually bought a couple DS1307 Real Time Clock breakout board kits a while back because I wanted to learn about making my own clock, and I knew this day would come where I 'needed' to build one into a project. If you looked at the link, you may have noticed that there are only 6 components including the battery/holder. So for this project, I just integrated those 6 components into my circuit and called it a day!
There was 1 major problem that I ran into doing this however. See Challenge #5 on my previous post, Automatic Cat Feeder - Challenges.
Well that brings this post to a conclusion. Hopefully this information will help someone out there. If you have a question, just leave a comment below.