Page 3 of 5

Re: TB65603A Single Axis Stepper Motor Driver Board (HCMODU0

Posted: Wed Apr 29, 2015 10:04 am
by jatin13978
i am using arduino uno. and switch is connected to pin 7 of arduino and switch center off to GND

Re: TB65603A Single Axis Stepper Motor Driver Board (HCMODU0

Posted: Wed Apr 29, 2015 11:18 am
by andrew
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);
}

Re: TB65603A Single Axis Stepper Motor Driver Board (HCMODU0

Posted: Mon Aug 03, 2015 5:00 pm
by Rom327
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.

Re: TB65603A Single Axis Stepper Motor Driver Board (HCMODU0

Posted: Tue Aug 04, 2015 12:41 pm
by andrew
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.

Re: TB65603A Single Axis Stepper Motor Driver Board (HCMODU0

Posted: Tue Aug 04, 2015 2:11 pm
by Rom327
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);

Re: TB65603A Single Axis Stepper Motor Driver Board (HCMODU0

Posted: Tue Aug 04, 2015 3:53 pm
by andrew
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);

Re: TB65603A Single Axis Stepper Motor Driver Board (HCMODU0

Posted: Tue Aug 04, 2015 5:16 pm
by Rom327
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...

Re: TB65603A Single Axis Stepper Motor Driver Board (HCMODU0

Posted: Tue Aug 04, 2015 5:45 pm
by Rom327
removed unnecessary

Re: TB65603A Single Axis Stepper Motor Driver Board (HCMODU0

Posted: Tue Aug 04, 2015 5:56 pm
by Rom327
removed unnecessary

Re: TB65603A Single Axis Stepper Motor Driver Board (HCMODU0

Posted: Wed Aug 05, 2015 9:51 am
by Rom327
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.