I would like to create a timer either with two outputs (to send a pulse about 12 hours apart from each other) with a microcontroller or by using some other method. Basically I want to trigger a 12v motor to run for about a second and then in 12 hours run in the opposite direction for about a second. I was thinking of reversing the polarity to the motor simply by swapping the terminals on each relay in each circuit before the motor.
From reading around it seems like all different types of Arduinos are available which do slightly different things(?) so my question is which type of Arduino would be simplest to do this? I know very little about microprocessors, am and keen to start learning how to program them. I’d just like to know where to start, so any advice I could get would be greatly appreciated.
redbeard:
Basically I want to trigger a 12v motor to run for about a second and then in 12 hours run in the opposite direction for about a second. I was thinking of reversing the polarity to the motor simply by swapping the terminals on each relay in each circuit before the motor.
A Trinket is probably the simplest Arduino you could use for this task. As for reversing the polarity ... were you going to do this manually or did you want it to happen automagically ? You can do the latter using a H bridge driver. It will have to be chosen to match the voltage and current requirements of the motor. You'll also need some sort of power supply (presumably ~12V).
As for the relays, I was just going to use a couple of automotive ones (the motor is a windscreen wiper motor from a car, which has the advantage of returning to the same position when turned off) and attach the polarities on the motor side of the circuit differently for each one. I think these relays need minimal voltage to be triggered, but I understand (partially!) that I will need some sort of catch diode at the microprocessor end to stop any current returning to the microprocessor?
And yes, the whole thing will be run on 12v, charged by a solar panel to a battery.
It might be possible to construct a timer to do what you want w/o using a microcontroller … perhaps using a CD4060 as it’s heart. It’ll be more wiring than using a Trinket but some people don’t care to learn the programming needed.
It’s to open a door to my chicken coop so will need to be changeable as daylight hours change throughout the year. It also needs only to run the motor for one second or so, to bring up or down the door.
Ah. A fellow chicken nut who doesn’t have AC power to his coop.
A small microcontroller is the easiest way to do this if you don’t have A/C power (otherwise I’d suggest a cheap off the shelf timer). You can hardcode the time when the unit is put into service. The main problem with that is going to be adjusting the time as it inevitably drifts over the year.
I would not bother building a UI for something like this. I’d either program in the current time, or set the time with a PC over a serial port.
You can get any number of shields to drive the relays for motor control. I also have a couple boards that just got here for a product I’m building to drive motors and relays from an Arduino.
It’s such a common topic on backyardchickens.com that I actually started a project to do this and I went looking for it just now, but I must have deleted it. My “girls” (and the one guy) stay in their run since I’ve had too many losses from predators even in the day (suspect a neighbor’s dog, but can’t prove it) so I keep them off pasture now. That’s why I abandoned the project. This summer I’m building a chicken tractor so I can put them back out on pasture but not have to worry about letting them in or out.
Fun project, let’s know how it goes. What kind of solar cells are you using? I have LEDs in my coop so I can check up on things at night, but they are powered from a motorcycle battery.
Thanks for this, still in the design stage so not sure about the solar panels yet, everything here is on solar so I may just hook it into the 12v circuit. Please forgive my ignorance but do I need a shield to drive the motor? Or is shield a word for something with which I am not familiar?
If I use a Trinket to trigger the normally-open relay (with a catch diode inline to stop any reverse flow when it turns off), which runs the motor for as long as it takes to open the door (say, one second), and have the same setup coming out of a different port in the Trinket and with the power to the motor on the second relay setup with the reverse polarity, which will be triggered when the door needs to be closed, I think that is all I need?
Correct. Motor reversing and on/off can be done with two SPDT (single pole double throw) relays. A “shield” is just the Arduino term for an add-on board that provides another function. There are power driver shields that will drive relays and motors.
another question or two, how can I work out what size relay to get?
I have tested the motor and it draws about 1.2 amps so it runs on 14.4 watts, but the starting draw may be much higher than this. I’m not sure either how to test the starting voltage or how much bigger the relay should be than the running voltage.
Also, I imagine this will impact on the size of catch diode (although they will be on the other side of the relay and the output from the Trinket will only be 5v)? I am in the dark as to how to work that out either.
The relay should be rated for the maximum current it will see. Otherwise you risk pitting and/or welding the contacts together. It’s certainly possible to get by with a lower rated relay if it’s not a critical application, but I wouldn’t recommend it.
As far as sizing the diode, I’ve seen people spend a lot of time doing the math to estimate the maximum current when the load turns off. In the end, it always involves a lot of assumptions and you end up no better off than an educated guess. A 1N4001 or similar diode should handle the relay coil just fine.