Hi Everybody,
I'm trying to make a project with an duemilanove and some actuators.
I haven't bought everything I need some help with understanding the programing.
I have already a duemilanove which I received as a present and I have no knowledge with the arduino programing. I have some basic knowledge with other programing languages, but that's not the main problem.
I'll try to explain what I'm trying to do and then at the end I'll put all my questions.
I want to control 2 actuators with the duemilanove. they are used to open and close gates. I already have the actuators and I'm not planing to buy new ones.
Basically I will have 2 relays with a remote to control the actuators. One for closing and one for opening.
The actuators can open 300mm but I need them to open only 200mm. I have a encoder attached to them, which gives me a relative positioning, 1 impulse for each 3mm. (or something like that).
the actuators have internal micro switches for end stop, and automatic brakes, so that should not be a problem.
Also, in order to open or close them I have 2 wires which need to be connected to 12 V (1 for open and one for close). As the 12V pins I will use another wire from the actuators (the "Ready" pin) which give 12V only when the actuators can operate safely (duty-cycle ok, power ok, everything is ok).
I also want to have 2 push buttons (reset buttons) with which to control the relative positioning (to open the actuators only 3/4, etc.).
Basically I want to push a button on the remote to close one of the relays and open the gate, and another one close the second relay and close the gate. and to use 2 separate small buttons with which to close and open the gates only for as long as I'm pressing the buttons.
I will also use a shunt resistance to measure the current drawn by the actuator in order to be sure that nothing will get squeezed by the actuators (they are pretty powerful, with 1kN push/pull), and if the current value changes from a predefined value, to stop. For the position I will use a counter to know where exactly the actuator is.
The actuators should work asynchronous, since one of them needs to be closed before the other.
I hope my explanations are clear enough. I don't need help with interfacing the electronics since I have a decent electronics background. I need help with the programing since I have only 3 weeks to do it (in 1 month I will have a 3 weeks vacation) and I need to order all the components as soon as possible from Ebay.
Initially I wanted to connected the 2 actuators from the remote to the 2 interrupt pins of the arduino. For as long as "open" pin is low, and the counter of the position is still in the values, and the current value is still under the threshold, to open. when one of the above rules isn't ok to stop and in case of the current value, to move back 10-15 mm and wait until the pin is high and low again. the same as above for the "close" pin.
At the same time, to have 2 push buttons so I can open and close them manually as I like, respecting only the "position condition" (I want this because sometimes the wind might be to strong and make sufficient pressure on the gate so that the arduino might think something is in the way and it won't close, but at the same time to be able to open it only a little bit if it rains).
So I was thinking of using a latch remote relays (stay on until commanded again) and some reset buttons for the push ones.
in speudo-code it should be like:
if interrupt 0 low & poscount<x & current<y;
pin w high (actuator open);
else
if current > y pin W low pin z High (actuator close) for 1 second;
else pin W low;
and for interrupt 1 almost the same.
is that ok? how should I define the interrupt? (falling or low)
I'm scared that it might get into a loop and do nothing since the pin will remain low. What do you think?
What is the sleep mode of the arduino? Is it automatic or can I leave him always on? If I make him stay always on I could use other pins instead of the interrupts? I wanted to use the interrupts so I can be sure that in case something like a kid is in the way I can cancel the current action (open/close) so the gates won't even touch him. I'm thinking about using also some sensors on the poles, but I can't find any on ebay (maybe I'm not searching right).
The electronics for the circuit except for the remote relays I already have around and I can build a nice PCB with all of them. Also, can someone help me with a shield CAD drawings. I need them so I can get the measurements since I'm working with Altium (don't know eagle).
What else should I consider?
Thank you for reading everything and for the answers.
P.S. I don't want to buy other actuators or a gate opener. Where I live they are pretty expensive and the actuators are from an old project, they cost a lot and can work in extreme conditions. Plus they have huge push/pull force, which is ideal for me, for future projects.