2021-05-07, 06:53 AM
I have an old SPX tiller pilot drive, but no functional controller. I have an old 25A Rated H Bridge, that I tested with my own Arduino code with a Simple Fwd/Reverse button. I have an Adruino Uno I'm playing around with and an old Raspberry Pi 3B+
I'm trying to control this in Openplotter/Pypilot .
But looking at the Motor.ino sketch the logic of the H bridge mode seems a little different ( eg a single PWM and two enable lines?) .
THe controller I have requires 3 control wires. (apart from the motor/power supply wiring itself)
1) Motor Enable (EA) ( set to 5v) Any Digital out ( I use pin 6) from the Arduino set to high will enable the motor
2) PWM Input Channel A (PA) I set connect this from a PWM (Pin3) on the Arduino.
3) PWM Input Channel B (PB) I also connect this to an Arduino PWM (pin 5) output.
To make the motor run forwards :
digitalWrite(MotorEnablePIN,HIGH);
analogWrite(FwdPWMPin,255);
analogWrite(RevPWMPin,0);
To make it run backwards
digitalWrite(MotorEnablePIN,HIGH);
analogWrite(FwdPWMPin,0);
analogWrite(RevPWMPin,255);
IF you vary the 255, that will control the speed of the motor. Hooked it all up with two push buttons and it worked fine. eg I can move the ram forward and backwards by pushing the fwd/reverse buttons. THe motor is runs at full speed when I hold a button down.
I'll try to follow and rewire my setup to suit the pinout of the Motor.ino sketch which will mean modifying the pins I've used in my test set-up.
But it uses Pin9 only for the PWM if im correct. So wondering what code to modify to make the Motor.ino sketch work with my H bridge? And Which pins to wire up using this controller with the motor.ino sketch?
PS attached some info on how I connected it all together to test the Ram works from 12v which it does via two simple push buttons.
sketch info copied below as it wont allow me to add a .ino file?
*****************************************************************
int FwdPWMPin =3;
int RevPWMPin = 5;
int MotorEnable = 6;
int mspeed=255;
int FwdButtonIP= 12;
int RevButtonIP=13;
int buttonStateFwd = 0;
int buttonStateRev = 0;
//06/05/21 This Sketch makes the Linear A/p function
//THe Motor Enable set at 5v was the key step in making this H bridge work
// You use a PWM Digital IO via Analgue write to set the speed of the motor, which also serves as the input. One must be low=0 the other highish with 255 being max speed.
void setup() {
pinMode ( FwdPWMPin,OUTPUT);
pinMode ( RevPWMPin,OUTPUT);
pinMode( MotorEnable,OUTPUT);
pinMode( FwdButtonIP,INPUT);
pinMode( RevButtonIP,INPUT);
Serial.begin(9600);
}
void loop() {
buttonStateFwd= digitalRead(FwdButtonIP);
buttonStateRev= digitalRead(RevButtonIP);
if (buttonStateFwd== HIGH)
{
//Fwd first
//Serial.print("Forward Pressed");
//Serial.println();
buttonStateRev=0 ;//avoid both buttons being pressed
digitalWrite(MotorEnable,HIGH);
analogWrite(FwdPWMPin,255);
analogWrite(RevPWMPin,0);
}
else if(buttonStateRev==HIGH)
{
buttonStateFwd=0;
digitalWrite(MotorEnable,HIGH);
//then reverse
//Serial.print("Reverse Pressed");
//Serial.println();
analogWrite(FwdPWMPin,0);
analogWrite(RevPWMPin,255);
}
else
{
digitalWrite(MotorEnable,LOW);
analogWrite(FwdPWMPin,0);
analogWrite(RevPWMPin,0);
}
}
I'm trying to control this in Openplotter/Pypilot .
But looking at the Motor.ino sketch the logic of the H bridge mode seems a little different ( eg a single PWM and two enable lines?) .
THe controller I have requires 3 control wires. (apart from the motor/power supply wiring itself)
1) Motor Enable (EA) ( set to 5v) Any Digital out ( I use pin 6) from the Arduino set to high will enable the motor
2) PWM Input Channel A (PA) I set connect this from a PWM (Pin3) on the Arduino.
3) PWM Input Channel B (PB) I also connect this to an Arduino PWM (pin 5) output.
To make the motor run forwards :
digitalWrite(MotorEnablePIN,HIGH);
analogWrite(FwdPWMPin,255);
analogWrite(RevPWMPin,0);
To make it run backwards
digitalWrite(MotorEnablePIN,HIGH);
analogWrite(FwdPWMPin,0);
analogWrite(RevPWMPin,255);
IF you vary the 255, that will control the speed of the motor. Hooked it all up with two push buttons and it worked fine. eg I can move the ram forward and backwards by pushing the fwd/reverse buttons. THe motor is runs at full speed when I hold a button down.
I'll try to follow and rewire my setup to suit the pinout of the Motor.ino sketch which will mean modifying the pins I've used in my test set-up.
But it uses Pin9 only for the PWM if im correct. So wondering what code to modify to make the Motor.ino sketch work with my H bridge? And Which pins to wire up using this controller with the motor.ino sketch?
PS attached some info on how I connected it all together to test the Ram works from 12v which it does via two simple push buttons.
sketch info copied below as it wont allow me to add a .ino file?
*****************************************************************
int FwdPWMPin =3;
int RevPWMPin = 5;
int MotorEnable = 6;
int mspeed=255;
int FwdButtonIP= 12;
int RevButtonIP=13;
int buttonStateFwd = 0;
int buttonStateRev = 0;
//06/05/21 This Sketch makes the Linear A/p function
//THe Motor Enable set at 5v was the key step in making this H bridge work
// You use a PWM Digital IO via Analgue write to set the speed of the motor, which also serves as the input. One must be low=0 the other highish with 255 being max speed.
void setup() {
pinMode ( FwdPWMPin,OUTPUT);
pinMode ( RevPWMPin,OUTPUT);
pinMode( MotorEnable,OUTPUT);
pinMode( FwdButtonIP,INPUT);
pinMode( RevButtonIP,INPUT);
Serial.begin(9600);
}
void loop() {
buttonStateFwd= digitalRead(FwdButtonIP);
buttonStateRev= digitalRead(RevButtonIP);
if (buttonStateFwd== HIGH)
{
//Fwd first
//Serial.print("Forward Pressed");
//Serial.println();
buttonStateRev=0 ;//avoid both buttons being pressed
digitalWrite(MotorEnable,HIGH);
analogWrite(FwdPWMPin,255);
analogWrite(RevPWMPin,0);
}
else if(buttonStateRev==HIGH)
{
buttonStateFwd=0;
digitalWrite(MotorEnable,HIGH);
//then reverse
//Serial.print("Reverse Pressed");
//Serial.println();
analogWrite(FwdPWMPin,0);
analogWrite(RevPWMPin,255);
}
else
{
digitalWrite(MotorEnable,LOW);
analogWrite(FwdPWMPin,0);
analogWrite(RevPWMPin,0);
}
}