Interupt or other alternative to an actuator controller using Arduino duemilanov

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.

Nobody has an idea for me?
I can't really believe it's that complicated what I want to do...

I'm a bit overwhelmed by all the requirements and will need some time to digest it.

Meanwhile here is a drawing of the shield with dimensions

www.robgray.com/temp/Arduino-PCB-dimensions.pdf

I have an Altium design I can send as well if you'd rather not design one from scratch.


Rob

Let's forget about how to do this for the moment and get clear what needs to be done.

As I interpret the above you need

Open and close buttons, momentary pushes to open/close
Open and close buttons, move towards open/close while pressed
Learn buttons, used to teach the 3/4 (open?) point
Current sensors, to detect obstruction
Pulse counters to read the actuator position outputs
Remote input (What is the "remote"? A wireless keychain dongle, switches inside a house?)

Are some of these switches (open/close) on the remote and some (learn) on the controller?


Rob

Graynomad, thanks for that. If you have the files for altium it would be even nicer. I haven't asked for them since I don't expect too many people to use it because of the price. i got it for free from my university.

1)Ok. I'm thinking of buying some relays from ebay with remote control. they hare 2 relays, so i can use one for open and one for close. the idea is that I don't know what configuration to use. here is one of them, in the description you can see what types of control they have. http://www.ebay.com/itm/2-CH-315M-RF-Remote-Wireless-Control-Controller-2-Relay-12V-Transmitter-Receiver-/130695130793?pt=LH_DefaultDomain_0&hash=item1e6e096ea9 (they might be, keep pushed to stay on, push and stay on push again to turn off, and push to stay on push another buton to turn off).
I want to push a button on the remote to open and one to close (not to keep it pressed).

2)then I want to push buttons (next to the arduino) with which to open/close the gates partially.

  1. current sensor: shunt resistor->opamp->adc simple, nice and very cheap

4)pulse counter for the position of the gate. from the datasheet (0.38mm/pulse; pulse/pause minimum 10ms; 798 pulses from fully closed to fully opened).

I had a shield component, so here's a dummy PCB with the individual components from that cut and pasted.

www.robgray.com/temp/Arduino-shield.PcbDoc

I have not used this for real yet so please apply a sanity test before committing your design.

It looks like you can jumper those remotes to act pretty much any way you like but not "push A to open and B to close". However I don't think that matters as you are using an Arduino to deal with the logic. I would set them to

Non-Latch type: Press the button, the relay on till you release it. Just like the button of Klaxon, if you press it, Klaxon on, and will turn off once you release it;

Then monitor the relays with the Arduino.

Current sensor, I prefer the hall effect chips but I get the point about an opamp being cheap. Just remember it will have to be in the GND return line.

The pulse counter is simple, run them to the external INT pins. Is the pulse output debounced?


Rob

yes the pulse it's debouced. it's a PNP signal. In case you don't know what it means, it a pulse for a PLC that will drive a transistor.

As for the remote, I can also configure them to stay ON until I push a different button. the latch function, form what I understand is:
push A, relay A is on until you push B;
and I would expect to work the same for B: push B, relay B is on until you push A.
the opamp I always used them on the return, with great results for higher voltages than 12V.

do you know what's the maximum output current of the 5V regulator inside the arduino? I'm not sure it has enough juice to drive 3-4 relays. 20mA each. or should I also look for a 7805

scorpio20:
I have no knowledge with the arduino programing.
...
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.
...
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?
...
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?

...

scorpio20:
Nobody has an idea for me?
I can't really believe it's that complicated what I want to do...

In 3 weeks you want to learn to program the Arduino, do interrupts, do sleep mode, do a CAD drawing, and get all this working?

Or do you want us to do it for you?

I'm happy to help you (as are others I'm sure) if you make a start, post your code, show your wiring, and ask for help with specific problems.

I've done some posts about sleep mode, and interrupts, however you show no sign of having found them, or indeed any posts by anybody.

I don't get your reply?
Did I asked you to do the code for me? Did I asked you to do the drawings for me?
I've only asked what sleepmode is? and if it's by default. If someone has the dimensions of the board, so I can make my own shield in Altium (don't have eagle).
and what would be the best solution to control it.
your post was irrelevant and could be considered a spam. I'm here to learn, if I knew what I asked, I wouldn't be here, but while I'm here I trying to help in the electrical field as much as I can.
Graynomad was nice enough to help and guide me, and by now I have an idea of what I need to do. but in order to be sure I'm still asking him a few things.
The fact that I haven't worked with arduino, doesn't mean I need you to do the programing for me. I have worked with other controllers but not for this, and I have worked once with an arduino but just for sine PWM.

Wouldn't it have been nicer if you would just ignore my topic, or if you bothered to come by, to explain to simple inexperienced person like me what sleepmode is or point me towards a better explanation.

, to explain to simple inexperienced person like me what sleepmode is or point me towards a better explanation.

At risk of being accused of spamming, you'll have to define "better".
"Better" is relative, but to what?

better than the one in the documentation from this site.

Section 10 of the datasheet has quite detailed information regarding the various sleep modes.

thanks, I've got the idea, I don't really need sleep more since I'm using an external power supply.

I can also configure them to stay ON until I push a different button. the latch function, form what I understand is:
push A, relay A is on until you push B;

I don't think the other modes help, you just need to detect a button press and let the Arduino take it from there.

As for the distance pulses, something like the following rough code

#define DPP 38; // work in 10ths of mm to keep in integers
#define TRAVEL_DIST (DPP * 500)

volatile int distance;


void ISR_pulse () {
   distance += DPP;
}

void setup () {
    attachInterrupt (1, ISR_pulse, RISING);  // assuming the pulse is active HIGH, not that it really matters in this case
}

void loop () {
   distance = 0;
   start_open ();
   while (distance < TRAVEL_DIST) {  // wait for actuator to travel TRAVEL_DIST
   // test stuff here
   }
   stop_open();
}

You need to test for a stop button and the excess current in the while loop as well.

maximum output current of the 5V regulator inside the arduino?

That will be limited by VIN value and the PCB design I think, not the chip itself. IIRC we normally recommend ~500mA but that sounds a little high so maybe not. I think 80mA plus say 20 for the Arduino itself will be OK.


Rob

scorpio20:
Wouldn't it have been nicer if you would just ignore my topic, or if you bothered to come by, to explain to simple inexperienced person like me what sleepmode is or point me towards a better explanation.

OK.

I'm scared that it might get into a loop and do nothing since the pin will remain low. What do you think?

That's a meaningless question. Do nothing? What pin? Do I think you are scared? Hard to say. Do you feel scared?


To save you the trouble:

Sleep mode: Gammon Forum : Electronics : Microprocessors : Power saving techniques for microprocessors

Interrupts: Gammon Forum : Electronics : Microprocessors : Interrupts

Handling multiple things at once: Gammon Forum : Electronics : Microprocessors : How to do multiple things at once ... like cook bacon and eggs

Enjoy.

first of all, thanks for the links, I've got the idea with sleep, and I don't think I need it.
my question was related to the interrupt pins, I wasn't sure how they work, and as I was supposing, if I keep the pin low a lot it will just loop in the interrupt loop.
as Graynomad sugested, I will use the interrupts to count the "position" of the actuators.

In the meanwhile, I have ordered from ebay all my components. I couldn't find any relays around so I had to order them, ended up ordering them with the driving circuit since I might receive them late and not have time build the circuits that I need without the footprints (I haven't yet found an ebay chinese seller who would put a datasheet).
If they will come in 2 weeks I will probably remove them from those boards and place them on my own shields. I'll have to wait and see.
After I finish receiving the components I will post here what I have so people can give me their feedback.

One more question: what is the working temperature and the storage temperature for the arduino duemilanove? Is it the same as the atmels?

Is it the same as the atmels?

No, it's the same as the worst (critical) component on the board. I don't know if that's ever been analysed or specified, if so I haven't seen it.


Rob