Go Down

Topic: Need help adding proximity switch protection to hydraulic cylinder actuation (Read 3 times) previous topic - next topic

piet

Hello everybody,

Can somebody help me with the code below please?
It's a small program to control a hydrolic cilinder to operate it in and out.
1 Potmeter i use for the time/distance out,if the time/distance is reached it goes back in.
1 Potmeter for giving waitingtime to do the next cycle and so on.
I have done allot of reading forum's and projects to find out what i want.
Maybe its too difficult for a arduino starter like me......
The code below works but, what i want to do is put somekind of securety in with use of a proximity switch.
Like a reference too "see" when the cilinder is in.

Here the code
Regards everybody



Code: [Select]
int potPin1 = A0;      // select pin liftheight potmeter                              
int potPin2 = A1;      // select  pin wait potmeter                                
int potValue1 = 0;     // variable
int relaisPin = 12;    // select pin  relais 12                                  
// int proxpin =10;       // select pin for proximity sensor       NEW
// int startbutton = 9;    // select pin to startup                    NEW


void setup() {
 
 pinMode(relaisPin, OUTPUT);     // declare relaispin OUTPUT
 pinMode(potPin1,    INPUT);     // declare 1 potmeter INPUT
 pinMode(potPin2,    INPUT);     // declare 2 potmeter INPUT
//  pinMode(proxpin,    INPUT);     //declare proxpin input       NEW
//  pinmode(startbutton, INPUT);    //declare startbutton         NEW
}

void loop() {
 
 potValue1 = analogRead(potPin1);   //
 digitalWrite(relaisPin, HIGH);     //
 delay(potValue1+50);               //
 digitalWrite(relaisPin, LOW);      //
 potValue1 = analogRead(potPin2);   //
 delay(potValue1+150);              //  
}



Moderator edit: Real [font=Verdana][[/font]code] [font=Verdana][[/font]/code] tags added

Moderator edit: Title made more meaningful (Nick Gammon)

PaulS

Quote
1 Potmeter i use for the time/distance out,if the time/distance is reached it goes back in.

Is the potentiometer defining time or distance? Time and distance and not the same thing.

Quote
what i want to do is put somekind of securety in with use of a proximity switch.

And the problem is?

What is going to trigger the proximity switch? What is supposed to happen when that proximity switch is triggered?

For safety, these:
  delay(potValue1+50);               //
  delay(potValue1+150);              // 
have got to go. You won't be able to read the proximity switch while the doNothingButHandleInterruptsForAWhile() call is happening.

Look at the blink without delay example.

piet

Thank you for your replay,

It is the blink without delay example were i started with.
What i want with the prox switch is give a reference when the cilinder is in for the wait time potmeter to delay the next cycle.
I ám not sure if i must use a startbutton to startup the whole program.

regards

Morris Dovey

#3
Apr 25, 2012, 03:25 pm Last Edit: Apr 25, 2012, 03:31 pm by Morris Dovey Reason: 1
I suggest starting a simple sketch that uses the proximity switch to control an LED, then combining the proximity switch logic with what you have working.

A while ago I saw an Arduino sketch that uses Hall-effect sensors to control a pair of hydraulic rams in a compressed earth brick-making machine. The link I saved is http://opensourceecology.org/wiki/CEB_Press/Research_Development/Controller_Design and you should be able to navigate from there to the source code. It may be helpful to see how someone else did that job successfully.

Edit: I just found the code. See http://opensourceecology.org/w/images/3/3a/CEBControl.ino
There's always a better way!

piet

Thank you Morris,

I will studie again, if it's not clear to me you see me back here..

Regards

piet


Quote
1 Potmeter i use for the time/distance out,if the time/distance is reached it goes back in.

Is the potentiometer defining time or distance? Time and distance and not the same thing.

The potmeter is defining time.

Quote
what i want to do is put somekind of securety in with use of a proximity switch.

And the problem is?

What is going to trigger the proximity switch? What is supposed to happen when that proximity switch is triggered?

For safety, these:
  delay(potValue1+50);               //
  delay(potValue1+150);              // 
have got to go. You won't be able to read the proximity switch while the doNothingButHandleInterruptsForAWhile() call is happening.

Look at the blink without delay example.


cantore

please don't use title like "Real help asked!!!" or the forum will became less easy to consult

AWOL

Quote
please don't use title like "Real help asked!!!"
Perhaps s/he is a member of the Spanish monarchy.   :D
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

piet

Sorry,

Still looking for help....

AWOL

Quote
Still looking for help....

With what?

Quote
I ám not sure if i must use a startbutton to startup the whole program.

If you're not sure what your requirements are, we can't impose them on you.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

piet

What i want is simple for me to discribe but very difficult to program.

I will control 1 hydraulic cilinder to go out and in.
1 potmeter i would use to control the time for steering the cilinder out.
afther this function the cilinder goes back in.
From that point when the cilinder is in, i will use the second potmeter for the delay/waiting  time for the next cycle. And so on.

So far it works fine with the base program.

But i want to build in a i kind of securety with the proximity switch to know that the cilinder is in.
Afther that point de delay/wait potmeter has to do his work and start the cycle again.
And that's for me difficult to programm...

I hope that everybody understands what i want.

PaulS

Quote
And that's for me difficult to programm...

Which part of that is difficult to program? Reading a switch state couldn't be simpler:
Code: [Select]
int switchVal = digitalRead(switchPin);

Depending on how you have wired the switch, the value is switchVal could be HIGH or LOW when the switch is pressed, and the opposite when not pressed.

You haven't told us diddly about how the switch is wired.

Doing something with the switch state is simple, too. All that is needed is an if statement and some curly braces.

piet

The switchpin makes pin 10 high when it's pressed, or low when released.

Morris Dovey

#13
Apr 26, 2012, 05:24 pm Last Edit: Apr 26, 2012, 05:27 pm by Morris Dovey Reason: 1
You aren't providing enough information, so I'm going to make some assumptions about your design:
The hardware environment

  • relay-controlled electric hydraulic pump

  • relay-controlled hydraulic valve to control extend/retract

  • double-acting hydraulic cylinder

  • limit switches at both ends of cylinder travel


Given that context, the basic code structure can look like this:
Code: [Select]
#define InSw ?
#define OutSw ?    // Replace '?' with pin numbers
#define CylDir ?
#define CylPmp ?

#define RUN HIGH    // Pump motor relay
#define STOP LOW

#define EXTEND HIGH    // Valve relay control values
#define RETRACT LOW

void retract(void)
{  if (!digitalRead(InSw))
   {  digitalWrite(CylDir,RETRACT);
      digitalWrite(CylPmp,RUN);
      while (!digitalRead(InSw));
      digitalWrite(CylPmp,STOP);
   }
}

void extend(void)
{  if (!digitalRead(OutSw))
   {  digitalWrite(CylDir,EXTEND);
      digitalWrite(CylPmp,RUN);
      while (!digitalRead(OutSw));
      digitalWrite(CylPmp,STOP);
   }
}

void setup(void)
{  pinMode(InSw,INPUT);
   pinMode(OutSw,INPUT);

   pinMode(CylDir,OUTPUT);
   pinMode(CylPmp,OUTPUT);

   retract();
}

void loop(void)
{  extend();
   retract();
}
There's always a better way!

piet

#14
Apr 26, 2012, 06:20 pm Last Edit: Apr 26, 2012, 08:19 pm by piet Reason: 1
•relay-controlled electric hydraulic pump
•relay-controlled hydraulic valve to control extend/retract
•double-acting hydraulic cylinder
•limit switches at both ends of cylinder travel

First thanks for thinking with me!

The hydaulic pump pumps all the time.
So i don't need a relay to activate the pump this is regulated besides the arduino.
I only need the relay to activate the cilinder.
The cilinder goes automatical back in, because the cilinder is hanging vertical and lifts a weight that retracts the cilinder.
The reason that i need a proxswitch is to avoid dammage in the hydraulics.
The fuction of the proxswitch is to indicate that the cilinder is out/weight is down
from that point i will adjust the second potmeter for giving the time that the cilinder stays down just for some milliseconds.
the machine i will use for hammering steel sheetplates.

more questions replay please.


Go Up