Hello arduino community I am currently busy on this filler machine project and would like your assistance on what products I can buy to make this plan work.
In brief I'd like to push a button to initiate a sequence on a 12V DC motor to power on and rotate 90* / 1/4 turn then stop, this will cause a bunch of valves to open via chain & sprockets.
I need it to then count "x" seconds and then rotate the opposite direction 90* (to close the valves ) - end of sequence for Button A
If possible i'd like to have a second Button B doing the same thing but with different on/off times (to fill a lower quantity of fluid)
I'll attach my amazon shopping basket and a sketch to hopefully give a better insight on what I am trying to achieve here. Any questions please ask!
Hi thanks for your interest Paul_KD7HB !
The motor should only cycle ON when either button A or B is pressed. The microswitches are there only to prevent over turning of the shaft to protect the valves, they can only rotate back and forth within 90 degrees.
Hi thanks for your reply jremington,
I have added a geared stepping motor to my basket to trial it. Thank you for your suggestion
I just need a way to make the dc motor run the "open valve" sequence,
e.g. Press button A, motor rotates 90* and then stops when "fully open" position is reached, then after "x" seconds rotate opposite direction 90* (back to fully closed position automatically).
Any ideas of the components i'd need to achieve this ?
so far i have on my list:
12V Geared stepping motor
12V Battery
Speed controller (potentiometer)
Button A
Button B
micro switches @ 0* & 90* positions of shaft (prevent over turns)
Any arduino kit I could include to make this work?
Potentially yes, the only problem with that is the microswitch will just cut off the power to the motor and I actually need it to run a sequence, e.g reach fully open position, wait for "x" seconds, then reverse polarity back to fully closed position.
You could add a second set of microswitches that are activated just before the safety switches are hit. You can hookup the switches to let arduino turn of the motor. Then wait and turn back again
The already suggested option for a stepper motor will be more accurate.
I ordered an arduino super starter kit, i believe it has a stepper driver included cant wait until my order arrives i added a dozen microswitches and lots of other goodies in hope to make this project work, lets see i will i update on the progress when they arrive Thanks for your replies and suggestions i really appreciate them!
Found a code to make motor shaft do 1/4 turn (open), stop 5 seconds and then turn back (close).
Problem i had was my 12v DC motor was overshooting positions after a few cycles, which is a big NO GO for my project it will damage the motor or valve components when system is fully setup.
I purchased a similar motor which has a built in Encoder to try resolve the problem:
Tested the same code (Sketch 1) with the motor plugged in using ONLY + & - wires, the overshooting still occurs but not as noticeable as it starts randomly after a good 10-20 ish cycles.
Followed a video tutorial on how to wire the Encoder wires from the dc motor to arduino, in hope to implement ZERO overshoot, it allowed me to make the motor do sinusoidal wave pattern using the encoder / PID however, I don't understand this code enough to modify it to my needs.
So I transferred some of the good bits from (sketch 2) into (sketch 1), now my code recognises the encoder wires/pin allocation.
Q1. Can some one help me edit/add a piece of code into Sketch 1 below, currently encoder not really being used to control anything to prevent overshoot
//Motor A connections
int in1=7; //Pin 7 designated to motor controllers In1 port
int in2=6; //Pin 8 designated to motor controllers In2 port
int enA=5; //Pin 5 designated to motor controllers ENA port
int SPEED = 210; //Initialize motor speed
#define ENCA 2 //Yellow wire feedback signal from motor encoder to pin2
#define ENCB 3 //Green wire feedback signal from encoder pin3
void setup() {
// Set all Motor A connection pins to output mode:
pinMode(enA,OUTPUT); //Tells arduino that ENA pin is set to give the output
pinMode(in1,OUTPUT); //Tells arduino that in1 pin is set to give the output
pinMode(in2,OUTPUT);//Tells arduino that in2 pin is set to give the output
// Set encoder feedback signal pins to input mode:
Serial.begin(9600);
pinMode(ENCA,INPUT);
pinMode(ENCB,INPUT);
//Turn off motor A
digitalWrite(in1,LOW);
digitalWrite(in2,LOW);
}
void loop() {
int a = digitalRead(ENCA); //Encoder
int b = digitalRead(ENCB); //Encoder
Serial.print(a*5); //Encoder
Serial.print(""); //Encoder
Serial.print(b*5); //Encoder
Serial.println(); //Encoder
directionControl(); //Direction of rotation based of High/Low
delay(3000);
//speedControl();
//delay(1000);
}
void directionControl()
{
//Set motor to maximum speed
analogWrite(enA,190);
//Press button A to Turn on the motor (OPEN VALVE) (rotate ACW)
digitalWrite(in1,HIGH);
digitalWrite(in2,LOW);
delay(1800);
//Turn off the motor (WAITING FOR 140ML TO FILL)
digitalWrite(in1,LOW);
digitalWrite(in2,LOW);
delay(4000);
//Change the motor direction (CLOSE VALVE) (rotate CW)
digitalWrite(in1,LOW);
digitalWrite(in2,HIGH);
delay(1800);
//Turn off the motor (CLOSED FOR HIGH DURATION - not to repeat cycle *UNTILL Button A IS PRESSED AGAIN)
digitalWrite(in1,LOW);
digitalWrite(in2,LOW);
delay(99999999999999999999);
}
//Controlling the speed of the Motor A
//void speedControl()
//{
//Turn on motors
// digitalWrite(in1,LOW);
//digitalWrite(in2,HIGH);
//Accelerate from zero to maximum speed
//for (int i=0;i<256;i++)
//{
// analogWrite(enA,i);
// delay(20);
//}
//Decelerate from maximum speed to 0
//for(int i=22;i>=0;i--)
// {
// analogWrite(enA,i);
// delay(20);
//}
//Turn off motor A
//digitalWrite(in1,LOW);
//digitalWrite(in2,LOW);
//delay(5000);
//}
Q2. Need advice on wiring/coding Button A to start the whole cycle A instead of having to use the reset button on my arduino chip.
I want to add Button B into the code aswel (same sequence as A, but with shorter open position delay)
Please see below video: sketch 1 and then sketch 2 in action.
You are not going to need an Arduino coder because, you have fundamental design problem. A DC motor cannot be stopped at some defined position without a BRAKE on the motor shaft to actually stop the motor. Redesign using appropriately sized stepper motors and stepper controllers and power supply.
Not correct! You need a controller for the selected stepper motor. The stepper selection will be based on the torque required to move your device.
Your project may also require a microswitch to indicate the starting position for your stepper motor. Then you can count steps as you rotate the motor to do your job. Might be worthwhile to look at some sample stepper motor programs.
(I've uploaded pictures here showing description, if there's any thing else you think I will need or change to make this plan work please let me know I'll add them to my basket)
Hopefully by the time my goodies arrive, some one here could help me out with the wiring + coding side of it - As mentioned previously I need the motor shaft to rotate 1/4 turn, stop and wait for 4 seconds, then rotate back to starting position (cycle finishd), need this cycle to repeat whenever Button A is pressed.
I agree with you, I thought I could use x2 micro switches, 1 at start and 1 at end position in order to indicate back to the controller that the desired position is reached. In theory this made sense but in practice might be abit tricky for me to setup as im only a beginner to all of this.