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
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 tags added
Moderator edit: Title made more meaningful (Nick Gammon)
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.
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.
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.
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 CEB Press/Research Development/Controller Design - Open Source Ecology 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.
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.
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.
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...
•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.