Manuel Stepper Speed and Control with TB6560 driver

I got my lathe up and running and can speed it up slow ti down with a pot and change dirictions with a switch. With the pot I can bring it to a stop and hold position and this is good as we are using this on a cnc hot wire foam cutter. This lets us index for dirrerent cuts. We plan in the future to run this off of Mach 4 cnc programing we will up date on the progress.

//writen by Sammy at sammyeggerman@gmail.com

//simple stepper connection
//using a SainSmart single axis 3.5amp T6560 stepper driver, 2 switches and1 50K potenometer
// power supply +12 volts to S1 +24v on driver and Vin on ARDUINO
// power supply - or Gound to G on driver and GRN on ARDUINO
// driver B+ B- A+ A- to motor
// driver STEP to 13 on ARDUINO
// driver DIR to S2 to 12 on ARDUINO
// driver EN to 10 on ARDUINO
// driver +5 volts to 5 volts on ARDUINO
// ARDUINO A0 to center pin R1 50K Pot
// 50K Pot 1 outer leg to 5 volts the other to GRN
// SET DIP Switches on driver as per specs for your motor
// you can change response to pot by changing the number behind the sensorvalue in the void loop

int enablePin = 10; //enaple pin
int sensorPin = A0; //input from potentiometer
int stp = 13;  //connect pin 13 to step
int dir = 12;  // connect pin 12 to dir
int sensorValue = 0; // to be scored from pot reading


void setup() 
{ pinMode (10, OUTPUT); 
  digitalWrite(10, HIGH);              
  pinMode(stp, OUTPUT);
  digitalWrite(stp, LOW);
  pinMode(dir, OUTPUT);       
}


void loop() 
{
  sensorValue = analogRead(sensorPin);
  for(int i = 0; i < (sensorValue * 0.0309); i++)
  {
    delay(0.5);
  }
    digitalWrite(stp, HIGH);  
    delay(0.5);               
    digitalWrite(stp, LOW);                
}

Is this is the same project as in your other Thread ?

Don't split the discussion. Ask the moderator to merge this with the earlier Thread.

...R

actully not, the other thread was using a small stepper and a pololu A4988 driver rated at 1 amp max, and this is using a larger stepper motor at 2.5 amps and a SainSmart single axis 3.5 amp driver #TB6650.

Both projects are working they do the same but are not interchangible because of the size of the motor and amp draw, and both sketches achive the same control of the motors, but with differances in the aproches because of the different drivers.

You can run the small motor on the SainSmart driver, but do not put the larger motor on the Pololu as it will only last about 10 seconds and then poof.

I belive these are 2 different projects, but if you think they are close enouph go ahead and merge them.

Sammy

segg3060:
I belive these are 2 different projects,

That’s fine.

As far as the Arduino is concerned there is probably no difference between the A4988 and the TB6560. AFAIK they both take step and direction signals.

…R

Here is an improved sketch with better conttol

//This sketch is borrowed from NYC CNC with modifications
//SainSmart single axis 3.5amp #T6560 stepper driver, 2 switches and a 10K potenometer
//  12 volt powersuppy to S1 to +24 volts in on driver to the barrel jack on the ARDUINO
// powersupply ground to driver and Arduino
// Driver  B+ B- A+ A- to motor
// Driver STEP to pin 9 on ARDUINO
// Driver DIR to S2 to pin8 on ARDUINO
// Driver EN to 10 on ARDUINO
// Driver +5 volts to 5 volts on ARDUINO
// ARDUINO A3 to center pin R1 10K Pot
// 10K Pot 1 outer leg to 5 volts the other to GRN
// SET DIP Switches on driver as per specs for your motor
// you can change response to pot by changing the number behind the sensorvalue in the void loop
// You can part and  index your motor in any position and hold it there by flipping a switch 


int sensorPin = A3;
int sensorValue = 0;

void setup() {
 pinMode (8, OUTPUT);
 pinMode (9, OUTPUT); // Step Pin
 digitalWrite (8,LOW);
 digitalWrite (9, LOW);
// digitalWrite (A3 = 0); 
 }

void loop() {
 sensorValue = analogRead (sensorPin);
 sensorValue = map (sensorValue, 0, 2023, 5100, 1);
 digitalWrite (9, HIGH);
 delayMicroseconds (3.5);
 digitalWrite (9, LOW);
 delayMicroseconds (sensorValue); 

}

segg3060: Here is an improved sketch with better conttol

Good to hear you have a solution.

...R

I just wish there was a one stop shop where a person could pick up these soluitions without looking all over the place, what I mean is a good text book that does not spend 3/4 of the time showing things of little value, and when they get around to motors not just skimming over the top.
Sammy

segg3060: I just wish there was a one stop shop where a person could pick up these soluitions without looking all over the place,

I tried to make a small contribution with stepper motor basics.

If you want to suggest some additional material that I might add to it I will certainly consider what you say, but I am not making any commitment to include any more stuff. I would appreciate it if you would make your suggestions here where I can easily relate them to your project.

...R

I read your stepper motor basics and it was good. What I found unhelpfull was all the referaince books I found on line and here at the University of Arizona where I work as they skimmed over every thing and tryed to cover too much so they did not cover any thing well, and left confusion in thier wake. I actually found YouTube to be helpfull, but it is easy to get side tracted there also. Maybe I am just an old grumpy guy who like to have apaper book in his hand to look things up in . Also Grumpy Mike was hepfull also

Thanks for your help Sammy

The best book on motors I know is Hughes & Drury "Electric Motors and Drives", >400 pages covering every type of motor and drive circuit.

segg3060: We plan in the future to run this off of Mach 4 cnc programing we will up date on the progress.

You might like to have a look at LinuxCNC as an alternative to Mach4. It is free and more configurable.

Russell.