Stepping motor input for control

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);
}

how to change input for control stepping motor from POT to DC input 0-5Vdc?

your question does not mean anything... and see how to use the forum / use code tags to post code.

winner2523:
Below code how to change input for control stepping motor from POT to DC input 0-5Vdc? Thanks.

I don't understand what you want to do. The input to the ADC from a potentiometer is a voltage in the range 0-5vDC.

Where will your proposed 0-5v come from?

...R

I'm very sorry my message is not clearly, My English is not good :wink:

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

How do you want to control it?
control from arduino PWM (0-5vDC)

arduino PWM (0-5vDC) > arduino control step motor

winner2523:
for now if i input +5vdc to A0 stepping motor will turn right, input GND to A0 stepping motor will turn left

That is exactly what I would expect.

What do you want it to do that is different?

And you have not told us what will create the 0-5v DC. Without that important piece of information it will be difficult to help.

...R

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.

20091026113525_VID29_manual_EN-080606.pdf (373 KB)

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.

Yes. Thank you for you datasheet.

Robin2:
That is exactly what I would expect.

What do you want it to do that is different?

And you have not told us what will create the 0-5v DC. Without that important piece of information it will be difficult to help.

...R

I wants to map 0-5V into 0-315 degrees (or less) based on motor steps. Thanks.

winner2523:
I wants to map 0-5V into 0-315 degrees (or less) based on motor steps. Thanks.

The output from analogRead() will be a value between 0 and 1023.

You have not told us how many steps there are for 315 degress - but let's pretend there are 200 steps. Then you just need to map 0 to 1023 to 0 to 200

...R