TB65603A Single Axis Stepper Motor Driver Board (HCMODU0022)

Stepper and DC type motor drivers
jatin13978
Posts: 4
Joined: Tue Apr 28, 2015 4:24 am

Re: TB65603A Single Axis Stepper Motor Driver Board (HCMODU0

Post by jatin13978 » Wed Apr 29, 2015 10:04 am

i am using arduino uno. and switch is connected to pin 7 of arduino and switch center off to GND

andrew
Site Admin
Posts: 1374
Joined: Sun Aug 05, 2012 4:15 pm

Re: TB65603A Single Axis Stepper Motor Driver Board (HCMODU0

Post by andrew » Wed Apr 29, 2015 11:18 am

I've added a few lines to output the state of the switch to the serial port. Try the sketch below and open up the serial monitor (Tools->Serial Monitor). Set the baud rate to 9600. When you flick the switch the output in the serial monitor change between 'Switch high' and 'Switch low'. If it does then the problem has something to do with the connections to your stepper motor driver.

Code: Select all

int sensorPin = A3;
int sensorValue = 0;
int DirectionSwitch = 7; //Connect switch to this pin and GND
int DirectionOutput = 8; //Connect this pin to the direction pin on your stepper controller.
boolean SwitchState;

void setup() { 
  Serial.begin(9600);
  pinMode(DirectionOutput, OUTPUT); //direction pin
  pinMode(DirectionSwitch, INPUT_PULLUP); 
  pinMode(9, OUTPUT); //step pin
  //digitalWrite(8, LOW);
  digitalWrite(9, LOW);
}

void loop() {
  sensorValue = analogRead(sensorPin);
  sensorValue = map(sensorValue,0,1023,3600,1);
  SwitchState = digitalRead(DirectionSwitch);


  if(SwitchState)
  {
    Serial.println("Switch high");
  }else
  {
    Serial.println("Switch low");
  }
  digitalWrite(DirectionOutput, SwitchState);

  digitalWrite(9, HIGH);
  delayMicroseconds(sensorValue); 
  digitalWrite(9, LOW); 
  delayMicroseconds(sensorValue);
}
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

Rom327
Posts: 8
Joined: Mon Aug 03, 2015 1:08 pm

Re: TB65603A Single Axis Stepper Motor Driver Board (HCMODU0

Post by Rom327 » Mon Aug 03, 2015 5:00 pm

Hello! Help to understand with the program. I have a MEGA 2560, the rest is all like the pictures in the original. Library downloaded. Launched, the motor rotates in both directions, the speed changes depending on the position of the rotor resistor. Everything seems right, but when rotated in one direction the frequency Step-Clk" 993 Hz, and in another 763 Hz. How to increase this frequency? TB 6560 allows up to 15000 Hz. Thanks in advance.
P.S. Sorry for my English, I write through the translator.

andrew
Site Admin
Posts: 1374
Joined: Sun Aug 05, 2012 4:15 pm

Re: TB65603A Single Axis Stepper Motor Driver Board (HCMODU0

Post by andrew » Tue Aug 04, 2015 12:41 pm

If you're using the HCMotor library, this wasn't written for or tested on a Mega so I quite surprised it actually works.

You can edit the library to get a bit more speed out of it. Open up the HCMotor.cpp file and find the following line of code:

Code: Select all

HCMotor::_MotorTimer2Init(T2_CLK_DIV_32, 49);
You should be able to get more speed out of it by either reducing the number 49 and / or changing the T2_CLK_DIV_32 argument to T2_CLK_DIV_8

You can change either one or both arguments but there is a limit to how much you can speed it up before the library will stop working.
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

Rom327
Posts: 8
Joined: Mon Aug 03, 2015 1:08 pm

Re: TB65603A Single Axis Stepper Motor Driver Board (HCMODU0

Post by Rom327 » Tue Aug 04, 2015 2:11 pm

Thank you!
Changed some code and it worked, although it is not clear... Now the frequency of about 5 kHz to either side.
How to register in the program 2 motors and 2 resistor?

HCMotor.Direction(0, REVERSE);
Speed = map(Pot, POT_REV_MIN, POT_REV_MAX, 2, 10);

/* 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, 10, 1);

andrew
Site Admin
Posts: 1374
Joined: Sun Aug 05, 2012 4:15 pm

Re: TB65603A Single Axis Stepper Motor Driver Board (HCMODU0

Post by andrew » Tue Aug 04, 2015 3:53 pm

I would suggest looking at each line of the example sketch to see if you can understand how it works. In the exampel sketch you will notice this line which adds a motor:

Code: Select all

HCMotor.attach(0, STEPPER, CLK_PIN, DIR_PIN);
For two motors just add an additional line so it looks like this:

Code: Select all

HCMotor.attach(0, STEPPER, CLK_PIN, DIR_PIN);
HCMotor.attach(1, STEPPER, CLK_PIN, DIR_PIN);
Remember to change CLK and DIR parameters to match the pins your motors are connected to. Notice that the first parameter is 0 for the first line and 1 for the second. This is the reference to the motors. 0 is the reference to the first motor, and 1 is a reference to the second motor. All the other motor commands use a reference in the same way so for example to set the direction for the first motor (0) you would use:

Code: Select all

HCMotor.Direction(0, REVERSE);
And to set the direction for the second motor (1) you would use:

Code: Select all

HCMotor.Direction(1, REVERSE);
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

Rom327
Posts: 8
Joined: Mon Aug 03, 2015 1:08 pm

Re: TB65603A Single Axis Stepper Motor Driver Board (HCMODU0

Post by Rom327 » Tue Aug 04, 2015 5:16 pm

Thank you!
Could you please write the whole code snippet.
I only started to learn Arduino, and absolutely no knowledge of the programming language, not to mention English...

Rom327
Posts: 8
Joined: Mon Aug 03, 2015 1:08 pm

Re: TB65603A Single Axis Stepper Motor Driver Board (HCMODU0

Post by Rom327 » Tue Aug 04, 2015 5:45 pm

removed unnecessary
Last edited by Rom327 on Wed Aug 05, 2015 10:10 am, edited 1 time in total.

Rom327
Posts: 8
Joined: Mon Aug 03, 2015 1:08 pm

Re: TB65603A Single Axis Stepper Motor Driver Board (HCMODU0

Post by Rom327 » Tue Aug 04, 2015 5:56 pm

removed unnecessary
Last edited by Rom327 on Wed Aug 05, 2015 10:10 am, edited 1 time in total.

Rom327
Posts: 8
Joined: Mon Aug 03, 2015 1:08 pm

Re: TB65603A Single Axis Stepper Motor Driver Board (HCMODU0

Post by Rom327 » Wed Aug 05, 2015 9:51 am

Hello! Again need help... Wrote a sketch on 3 motors and 3 of the potentiometer. Built the circuit and found the following: the motors operate in parallel from any of the potentiometer. How to assign one potentiometer - one motor? Thank you! The sketch in the archive.
You do not have the required permissions to view the files attached to this post.

Post Reply

Return to “Motor drivers”