Pages: [1] 2   Go Down
Author Topic: Need help adding proximity switch protection to hydraulic cylinder actuation  (Read 3216 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 21
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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 [code] [/code] tags added

Moderator edit: Title made more meaningful (Nick Gammon)
« Last Edit: April 27, 2012, 02:07:46 am by Nick Gammon » Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 636
Posts: 50276
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 21
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

West Des Moines, Iowa USA
Offline Offline
Sr. Member
****
Karma: 2
Posts: 428
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
« Last Edit: April 25, 2012, 08:31:31 am by Morris Dovey » Logged

There's always a better way!

0
Offline Offline
Newbie
*
Karma: 0
Posts: 21
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you Morris,

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

Regards
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 21
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Logged

italy
Offline Offline
Full Member
***
Karma: 3
Posts: 227
Muuuuu
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 309
Posts: 26495
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
please don't use title like "Real help asked!!!"
Perhaps s/he is a member of the Spanish monarchy.   smiley-grin
Logged

"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.

0
Offline Offline
Newbie
*
Karma: 0
Posts: 21
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry,

Still looking for help....
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 309
Posts: 26495
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

"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.

0
Offline Offline
Newbie
*
Karma: 0
Posts: 21
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 636
Posts: 50276
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 21
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

West Des Moines, Iowa USA
Offline Offline
Sr. Member
****
Karma: 2
Posts: 428
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#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();
}
« Last Edit: April 26, 2012, 10:27:38 am by Morris Dovey » Logged

There's always a better way!

0
Offline Offline
Newbie
*
Karma: 0
Posts: 21
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

•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.

« Last Edit: April 26, 2012, 01:19:02 pm by piet » Logged

Pages: [1] 2   Go Up
Jump to: