Hi! I'm working on my first Arduino project where I'm attempting to rotate 4 display panels 180* simultaneously with a momentary push button and then 180* in the reverse direction with a second button using Nema 23 stepper motors and TB6600 Drivers.
I would also like to add a simple RF reciever to do the same thing remotely but first thing first.
My first attempt was spent using ac motors, limit switches and magnets. It worked well unloaded but as weight was added to the panels a slew of problems arouse not relevant to this forum. Here's a simple sketch of what I'm trying to achieve:
On to the Arduino.
I started with 1 stepper, driver and Uno and wired them per DFRobot's Diagram and ran the sample code provided by DFRobot:
int PUL=7; //define Pulse pin
int DIR=6; //define Direction pin
int ENA=5; //define Enable Pin
void setup() {
pinMode (PUL, OUTPUT);
pinMode (DIR, OUTPUT);
pinMode (ENA, OUTPUT);
}
void loop() {
for (int i=0; i<6400; i++) //Forward 5000 steps
{
digitalWrite(DIR,LOW);
digitalWrite(ENA,HIGH);
digitalWrite(PUL,HIGH);
delayMicroseconds(50);
digitalWrite(PUL,LOW);
delayMicroseconds(50);
}
for (int i=0; i<6400; i++) //Backward 5000 steps
{
digitalWrite(DIR,HIGH);
digitalWrite(ENA,HIGH);
digitalWrite(PUL,HIGH);
delayMicroseconds(50);
digitalWrite(PUL,LOW);
delayMicroseconds(50);
}
}
This is where the first problem arose. The motor ran, but only in one direction continually for roughly 30-45seconds before the TB6600 shut down and signaled the Alarm LED. It never reversed direction and ran the other way so I couldnt figure out if i was executing the correct amount of steps with this code. I also cant figure out if the shutdown is due to thermal or current protection, wiring, coding etc. The driver isn't alarmingly hot to the touch.
Determined to get a motor to step 180* I started fooling around with the AccelStepper library. My wiring remains the same and it looks like the AccelStepper library is just using step and direction so my enable - signal is not doing anything.
Running this simple script instead, I was able to rotate the motor exactly 180* but ONLY when microstepping was set to 1 on the TB6600. Here is the new script:
#include<AccelStepper.h>
AccelStepper stepper(1, 7, 6);
int target = 9331/2;
void setup()
{
stepper.setMaxSpeed(2000);
stepper.setAcceleration(3500);
stepper.move(target);
}
void loop()
{
//while (stepper.distanceToGo()!=0)
{
stepper.run();
}
}
Keep in mind the Nema 23 stepper that I'm using has a 46.656 planetary reducer so at 200 steps per rotation it takes 9,331.2 theoretical steps to rotate the output shaft 360*. Again, this will only work with microstepping at 1.
With microstepping set to 4,8,16 or 32 on the driver and the initial target values corrected in the code the stepper will not reach its target. It even behaves as strangely as it will sometimes rotate less after increasing the target value. For example with a target value of 20,000 it might turn 360* but with a target value of 200,000 it will turn 90*. And then of course the problem of the driver shutting down after a few minutes of experimenting.
To summarize my first point of attack is figuring out why the drivers are shutting down. Once this is solved I would like to move forward to the programming and adding in the buttons/RF/Homing of the steppers as the planetary reducers don't seem to allow movement from external forces. Therefore manual homing is out of the question.
Any and all help is greatly appreciated. I'm new at this. The only programming experience i have is introductory Matlab stuff and a few led tutorials so Im way outside of my comfort zone. Its been a short journey just getting the motors to turn after starting with a l298 h bridge and then a gecko g540 from a cnc project to now.
Here are some stepper motor,driver and PS specs:
TB6600 Driver
Feature:
PWM chopper type bipolar stepper motor driver IC
- 9V-42V DC power supply
- H bridge bipolar constant phase flow drive
- the maximum 4.0A of the eight kinds of output current
- the largest 32 subdivision of the 6 models are optional
- input signal high speed photoelectric isolation
- common-anodestandard single pulse interface
- offline to maintain the function
- semi closed enclosure can be adapted to a more stringent environment
- to provide energy-saving semi-automatic current lock function
- built-in temperature protection and over current protection.
Can control 2 phase stepper motor forward and reverse rotation, With 1-2, W1 -2 , 2W1 -2, 4W1 -2 phase excitation mode.
Only the clock pulse signal can be driven two-phase bipolar stepper motor to achieve low vibration, high efficiency work.
IC parameter:
single chip bipolar sine microstep stepper motor driver
the new BiCD 0.13 nm process
up to 42V
resistance (a +) = 0.4
?the forward and reverse rotation control
5 subdivision mode options (1/1, 1/2, 1/4, 1/8, 1/16,1/32)
output current: IOUT = 4.0A (peak, in 100ms)
rated output: IOUT = 3.5 A
package: HZIP25 - 1.00F
input port internal pull-down resistor: 100 K
alarm output pin current:Ialert = 1mA
monitoring output pin (MO): Imo= 1mA
with reset and enable pin
with standby function
Break through the traditional, single power supply
built in overheating protection (TSD) circuit
Undervoltage protection, built-in (UVLO) circuit
built-in overcurrent detection (ISD), circuit
Package Included:
1 x Motor Driver
1 x Box
Power Supply is a 40v 10A 400w unit