The motor that I am using at this point is:
STEPPER MOTOR
17HS24-2104S
2015.5.14
// I also attached a screen shot of the motor specifications as requested.
I was able to get the motor to run very smooth for a good amount of time with the code attached on the original post dated ( Posted by cterm - Jan 01, 2017, 12:07 am )
that file name was " Stepper_Motor_Code.txt"
my original plans were to upgrade the stepper if I had a working code but now that might not be possible.
PROBLEM: the major problem I am having is that the ball valve gets hotter then 125C and most servo or solenoid valves that I have found can not operate near those temperatures.
- My thoughts to solve this was to mount a motor a good distance below the valve and drive a chain gear. moving it 90 degrees one way or the other to open or close it. how ever I used a grinder and removed the 90 degree stops so I could use the DC motor with 90 degree stops (I kind of like that idea.)
NOTE: I also have a 24v p40-250 DC motor (AmpFlow Pancake Motors) that I am not using at this moment. I can also buy one as well.
I have a few limit switches as well.
- if anyone has any simple, quick and easy code for the DC motors along with any clues on how the switches should be connected, I would be very interested in that if it is a quick solution to my problem.
however I do have the motor and sensors already connected to a bench test arduino so if it is easier to get the code to work that would be good before I dismantle the current set up and switch gears (/motors)
the following code seems to be more accurate for the pressure transducer.
float s0 = analogRead(A0); // read the sensor voltage
int psi = ((s0-95)/204)*50; // converts RawData From INPUT pin to PSI.
if it can be done I think I am getting close.
I have been working on the following code and having some interesting results.
int Stepping = false; // hope that this sets the initial Stepping integer to false.
int DirPin = 8; // Sets Digital Pin 8 on Arduino as the StepperMotor "Direction".
int StepPin = 9; // Sets Digital Pin 9 on Arduino as the StepperMotor "Step" otherwise known as how
// far it moves in that direction.
void setup()
{
Serial.begin(9600); // Opens Serial Port at specific baud rate.
pinMode(DirPin, OUTPUT); // Sets DirPin as OUTPUT. For calculations that occur within the
// loop below.
pinMode(StepPin, OUTPUT); // Sets StepPin as OUTPUT. For calculations that occur within
// the loop below.
pinMode(A0, INPUT); // Sets PressureTransducer as an INPUT. For calculations that
//occur within the loop below.
}
void loop()
{
float s0 = analogRead(A0); // read the sensor voltage
int psi = ((s0-95)/204)*50; // converts RawData From INPUT pin to PSI.
delay (1500); // Delays the reading above.
int i; // Establishing "i" as a integer as for the below code.
int Stepping; // Establishes Stepping as a integer for the following code below.
if (analogRead(A0)>=108.00 && Stepping == false) // 1st "if" statement, having the stepper motor
// move if pressure increase past a certain point
// only if the variable "Stepping" is satisfied.
// also 108.00 is upper limit of 3PSI (for bench
// testing purposes)
{
digitalWrite(DirPin, LOW); // Set the direction.
Stepping = true; // Changes Stepping variable from 'false' to 'true'
delay(100); // I think there is a delay issue (possible??)
for (i = 0; i<400; i++) // Iterate for 400 microsteps. (this is a 90 turn for the stepper used)
digitalWrite(StepPin, LOW); // This LOW to HIGH change is what creates the
digitalWrite(StepPin, HIGH); // "Rising Edge" so the easydriver knows to when to step.
delayMicroseconds(400); // This delay time is close to top speed for this
// particular motor. Any faster the motor stalls.
// *** Those notes above were from the working code originally.
// this is a possible issue.
Serial.print(psi); // the following is me testing this on a serial port to see what is showing up.
Serial.print(" PSI ");
Serial.print(" = ");
Serial.print(s0);
Serial.print(" = ");
Serial.print("Valve is Open");
Serial.println (" ");
Serial.println(" ");
delay(analogRead(A0)<=94.00); // attempting to use a delay that is dependent on the signal from
// PressureTransducer
// also 94.00 is ~ 0PSI (for bench
// testing purposes) I hoped this would reset it all but the.
// stepping does NOT seem to be recording or is being overwritten
}
if (analogRead(A0) <= 80.00 && Stepping == true) // 2nd "if" statement, having the stepper motor
// move if pressure increase past a certain
// point only if the variable "Stepping"
// is satisfied. 80.00 ~ -3PSI
{
digitalWrite(DirPin, HIGH); // Set the direction.
Stepping = false;
delay(100);
for (i = 0; i<400; i++) // Iterate for 4000 microsteps
digitalWrite(StepPin, LOW); // This LOW to HIGH change is what creates the
digitalWrite(StepPin, HIGH); // "Rising Edge" so the easydriver knows to when to step.
delayMicroseconds(400); // This delay time is close to top speed for this
// particular motor. Any faster the motor stalls.
// *** Those notes above were from the working code originally.
// this is a possible issue.
Serial.print(psi); // the following is me testing this on a serial port to see what is showing up.
Serial.print(" PSI ");
Serial.print(" = ");
Serial.print(s0);
Serial.print(" = ");
Serial.print("Valve is Closed");
Serial.println (" ");
Serial.println(" ");
delay(analogRead(A0)>=94.00); // attempting to use a delay that is dependent on the signal from
// PressureTransducer
// also 94.00 is ~ 0PSI (for bench
// testing purposes) I hoped this would reset it all but the.
// stepping does NOT seem to be recording or is being overwritten
}
}
observed problems and thoughts:
-
one problem I am having is that the motor is jerking all over the place. I have a feeling this is an issue with the StepPin = 9 High and Low settings, delays/microdelays and possibly the DirPin.
-
The "int Stepping" = true/false is not holding or is being overwritten faster then expected.
-
the "if" statements might be off as well.
-
I think there is a issue with the initial motor start up position. as the motor seems to twitch all over the place when starting up.
after a few seconds of twitching from the motor during initial start up, the motor does not move that much or as often. above all the motor does not seem to be moving in the desired motion in what I had hoped to code for.
any help would be greatly appreciated.
once again if someone has any code, and diagrams for a dc motor and ball valve, that would be very helpful.
CT
