Control Stepper with Potentiometer, not moving. Update, got some movement!

Hi,

Trying to control a stepper motor with a potentiometer.

I followed the instructions for This Project and after trying many many times to get the motor to run, I have had no success. Checked everything, the code compiles. Nothing.

Using an Original Arduino Uno board.

This is the Motor I’m using. 3.4V 1.7A 1.8 deg. bipolar motor.

This is the Driver Board I’m using, (SW1 is on for 1.6 A current, all others are off).

This is the code I’m using, it uses the HCMotor Library :

#include <HCMotor.h>


/* Include the library */
/*#include "HCMotor.h"
 */
/* Pins used to drive the motors */
#define DIR_PIN 8 //Connect to drive modules 'direction' input.
#define CLK_PIN 9 //Connect to drive modules 'step' or 'CLK' input.
 
/* Set the analogue pin the potentiometer will be connected to. */
#define POT_PIN A0
 
/* Set a dead area at the centre of the pot where it crosses from forward to reverse */
#define DEADZONE 20 
 
/* The analogue pin will return values between 0 and 1024 so divide this up between 
forward and reverse */
#define POT_REV_MIN 0
#define POT_REV_MAX (512 - DEADZONE)
#define POT_FWD_MIN (512 + DEADZONE)
#define POT_FWD_MAX 1024
 
 
/* Create an instance of the library */
HCMotor HCMotor;
 
 
 
void setup() 
{
  //Serial.begin(9600);
  /* Initialise the library */
  HCMotor.Init();
 
  /* Attach motor 0 to digital pins 8 & 9. The first parameter specifies the 
motor number, the second is the motor type, and the third and forth are the 
digital pins that will control the motor */
  HCMotor.attach(0, STEPPER, CLK_PIN, DIR_PIN);
 
  /* Set the number of steps to continuous so the the motor is always turning whilst 
 not int he dead zone*/
  HCMotor.Steps(0,CONTINUOUS);
}
 
 
void loop() 
{
  int Speed, Pot;
 
  /* Read the analogue pin to determine the position of the pot. */
  Pot = analogRead(POT_PIN);
 
  /* Is the pot in the reverse position ? */
  if (Pot >= POT_REV_MIN && Pot <= POT_REV_MAX)
  {
    HCMotor.Direction(0, REVERSE);
    Speed = map(Pot, POT_REV_MIN, POT_REV_MAX, 10, 1024);
 
    /* Is the pot in the forward position ? */
  }else if (Pot >= POT_FWD_MIN && Pot <= POT_FWD_MAX)
  
  {
    HCMotor.Direction(0, FORWARD);
    Speed = map(Pot, POT_FWD_MIN, POT_FWD_MAX, 1024, 10);
 
    /* Is the pot in the dead zone ? */
  }else
  
  {
    Speed = 0;
  }
 
  /* Set the duty cycle of the clock signal in 100uS increments */
  HCMotor.DutyCycle(0, Speed);
 
}

Now, When I first tried, The SW1 on the TB6560 Driver was at Off, then I read some more and put it at On to drive a 1.6A motor. When it was at Off, I would get a soft humm when cranking the voltage up a bit, (around 12 V).

Then, I put the SW1 at On on the TB6560, and as soon as I get past 5V, the fault light on my power supply starts to flicker, it did this once, didn’t try it twice…

Here’s a Drawing of the setup:

What am I doing wrong?

Thanks for helping!

Forget about the arduino, all it is doing is sending a direction signal, and steps to the driver. I know that a number of these type of drivers do not have the correct diagram for the switches, so check all over the web to see if others have had that issue with that driver. Make sure you have correctly identified the A and B coils of the stepper motor. Use a meter set to ohms, the resistance will be very low for each coil. Do not worry about the orientation A+, A- just make sure you have one coil connected to A+, A- and the other to B+,B-. I expect you will most likely need about 15V to drive the motor adequately. Remove the arduino connections. Make up say 3 AA cells in series, or use a usb charger at 5 volts ,say,. Connect the -ve to cw- and clk- and +ve to cw+, then have a wire from +ve and tap the clk+ a few times. You should hear the motor 'click one step for each pulse. (stick a bit of tape (a flag) on the shaft to see movement. You said you'd adjusted sw1, but for a 1.6A motor, the other switches should be off. The diagram is rather confusing, having a s1 too. I can see no other setting for all switches off, so I expect you did not have 1.6A set. (assuming the diagram is correct) Try setting it to some other current values, in case the diagram is incorrect. If that works, then write a simple sketch to step it forward (or backwards) just fire a string of pulses to the clk +. fwiw, these type of stepper motors are quite happy running very hot, generally too hot to touch, but I doubt if you'll be going that far. Let us know how you get on.

Thank for answering,

About the switches for setting the current to 1.6A, There are 3 on/off switches, as you can see on this chart and diagram. So the current is ok. For the coils, I used this page's information, and double checked by measuring the resistance, and it is fine. Otherwise, is the procedure you are suggesting a test to see if the motor is working? I'm trying to have a potentiometer controlled stepper, guess I'll need the analog function of the arduino for that.

Ok, so I re-rewired everything and set the driver board to 1.9A, the motor is spinning (that feels good!).

I had read the color diagram of the motor leads wrong... (novice stuff...)

But still, the motor is turning smoothly when the pot is all the way to the left, and not so smoothly when turned a bit to the right, and if I put it all the way to the right, I get a loud kinda grindy noise.... Also, when the pot is centered, the ampmeter of my power supply cranks up to around 4.5A.

I can play around with the motor for about 15 seconds, then it stops working, I turn the power off, wait a little, turn it on again, I'm good for another 15 seconds.

Should I set it to a higher Amp setting? Would I risk damaging something?

Try this Simple Stepper Code. It does not need any driver.

If the motor stops after a period of time it suggests that the driver is overheating and shutting down. And I admit that seems strange if the current setting is well within the limits of the driver. Maybe the driver is faulty.

Be VERY CAREFUL never to disconnect the wires between the motor and the stepper driver while the driver is powered up. The driver will be instantly destroyed.

...R Stepper Motor Basics

Piedro: Thank for answering,

About the switches for setting the current to 1.6A, There are 3 on/off switches, as you can see on this chart and diagram. So the current is ok. For the coils, I used this page's information, and double checked by measuring the resistance, and it is fine. Otherwise, is the procedure you are suggesting a test to see if the motor is working? I'm trying to have a potentiometer controlled stepper, guess I'll need the analog function of the arduino for that.

on the chart you have shown, and which I referred to in my first reply, there are 4 switches that control the motor current. I had already pointed that out to you.. My suggestion was that you start from square one and methodically get the fundamental problem solved, before fiddling with the arduino side of things. I'm glad you discoverd that you had messed up the coil connections. The article you have based your experiment specifically mentions to ignore the colour of the motor wiring. Also, the chart can be wrong (but initially you have to assume it is correct) It's called a stepper motor for a reason, you need to take small steps to get it working. :)