Below code how to change input for control stepping motor from POT to DC input 0-5Vdc? Thanks.
/*------------------------------------------------------
Gauge_Pot01
Arduining.com 10 July 2011
Direct driving of Miniature Stepper Motor used as an indicator
drive for dashboard instrumentation.
Hardware:
-Arduino UNO.
-Potentiometer.
-Stepper Motor VID29-05P (Can be directly driven by MCU):
-Low current consumption: <20mA
-Rotation Angle:Max 315°
-0.5°/full step
-Coil resistance: 280 +/- 20Ω
-----------------------------------------------------*/
#include <Stepper.h>
#define STEPS 720 // steps per revolution (limited to 315°)
#define COIL1 8
#define COIL2 9
#define COIL3 10
#define COIL4 11
#define PotIn 0
// create an instance of the stepper class:
Stepper stepper(STEPS, COIL1, COIL2, COIL3, COIL4);
void setup(){
stepper.setSpeed(30); // set the motor speed to 30 RPM (360 PPS aprox.).
stepper.step(630); //Reset Position(630 steps counter-clockwise).
// Serial.begin(9600); //for debuging.
}
int pos=0; //Position in steps(0-630)= (0°-315°)
void loop(){
int val = analogRead(PotIn); //get the potentiometer value (range 0-1023)
val= map(val,0,1023,0,630); // map pot range in the stepper range.
if(abs(val - pos)> 2){ //if diference is greater than 2 steps.
if((val - pos)> 0){
stepper.step(-1); // move one step to the left.
pos++;
}
if((val - pos)< 0){
stepper.step(1); // move one step to the right.
pos--;
}
}
// Serial.println(pos); //for debuging...
// Serial.println(val);
// delay(100);
}
I'm very sorry my message is not clearly, My English is not good
This code stepping motor control by potentiometer (V+ // A0 // GND) I want to replace potentiometer and use power supply 0-5vdc to control stepping motor.
for now if i input +5vdc to A0 stepping motor will turn right, input GND to A0 stepping motor will turn left
How do you want to control it?
If you put the pot all the way one direction you get 0 and you get 5V the other way. If you don’t want a pot, just put a button with a current limiting resistance
Please edit your first post and add code tags. Respect basic forum rules...
The stepper that OP is referencing is a VID29, used in instrumentation. It has 0-315 degree full scale deflection. My assumption is that the OP wants to map 0-5V into 0-315 degrees (or less) based on motor steps. For those interested, I've attached a datasheet.
P.S. the code is a direct copy from the site referenced, so this is not really a programming question, it's a request for a re-write. I'll leave it up to those of you who do these types of favours.
DKWatson:
The stepper that OP is referencing is a VID29, used in instrumentation. It has 0-315 degree full scale deflection. My assumption is that the OP wants to map 0-5V into 0-315 degrees (or less) based on motor steps. For those interested, I've attached a datasheet.