I've found a little bug, and the solution can be helpful to someone:
A have a TB6560 based board (4v3 - "the red one"). There were a lot of errors, missing steps, the motors sometimes worked sometimes not...I've tried everything. Finally the solution was, that I needed to invert the ENABLE signal:
case 'A': // All Motors on/off
if(val == '1') {digitalWrite(12, HIGH);} <----in here, change it to LOW
else {digitalWrite(12, LOW);} <---- in here, change it to HIGH
break;
The funny thing is, that without the signal inverting the motors sometimes worked. I don't know how...
The correct motor function needs the correct clock signal lenght:
PORTD = (PORTD & 0x0F) | (cmd & 0xf0); // Directions first!
PORTB = (PORTB & 0xF0) | (cmd & 0x0f); // and step
delayMicroseconds(25); // eventually wait a little bit <---- here change the value! According to the datasheet of TB6560 if you have 330pF on Cosc pin: the minimum clock widht must be higher than 30microsec
// and falling edge of step pulse
PORTB = (PORTB & 0xF0);
With these little modifications in the arduino code my motors are running perfectly (smooth, silent, without missing steps).
A have a TB6560 based board (4v3 - "the red one"). There were a lot of errors, missing steps, the motors sometimes worked sometimes not...I've tried everything. Finally the solution was, that I needed to invert the ENABLE signal:
case 'A': // All Motors on/off
if(val == '1') {digitalWrite(12, HIGH);} <----in here, change it to LOW
else {digitalWrite(12, LOW);} <---- in here, change it to HIGH
break;
The funny thing is, that without the signal inverting the motors sometimes worked. I don't know how...
The correct motor function needs the correct clock signal lenght:
PORTD = (PORTD & 0x0F) | (cmd & 0xf0); // Directions first!
PORTB = (PORTB & 0xF0) | (cmd & 0x0f); // and step
delayMicroseconds(25); // eventually wait a little bit <---- here change the value! According to the datasheet of TB6560 if you have 330pF on Cosc pin: the minimum clock widht must be higher than 30microsec
// and falling edge of step pulse
PORTB = (PORTB & 0xF0);
With these little modifications in the arduino code my motors are running perfectly (smooth, silent, without missing steps).