Hello,
I found this on combine forum:
Is this possible with the normal Arduino code and does anybody know how to connect the stepper driver to the Nano?
Hello,
I found this on combine forum:
Is this possible with the normal Arduino code and does anybody know how to connect the stepper driver to the Nano?
To control a stepper, you can use any of a variety of stepper libraries. They output two PWM signals. Direction and Step. Connect these pins to a stepper driver (like this, depending on amps required) which the stepper is connected to.
Libraries vary in features, some letting you tweak acceleration parameters and so forth:
https://www.arduino.cc/en/reference/stepper
https://www.airspayce.com/mikem/arduino/AccelStepper/
I used AccelStepper some time ago but never quite mastered it. I wanted to have a stepper motor quickly and smoothly come up to speed, turn 10 times, and then stop quickly. Never quite figured out how to get it to the speed I wanted. But it certainly did let me turn the motor precisely.
Keep in mind that when it comes to steering, you probably need a closed loop. Meaning that if the steering motor slips, or loses a step if it’s a stepper, you have to keep turning until you get to the desired angle. So a plain old motor is probably simpler, because you’ll have feedback from the WAS to control that anyway. Even if your stepper never slipped and was geared to the steering wheel, the nature of hydraulic steering valves is that they do internally slip some.
I’m pretty certain this is possible with accelstepper. It’s ages since I’ve played with it but have wondered myself about trying it for a motor system. WAS would close the circuit. I thought a stepper might be a bit more refined than a brushed motor.
Maybe just over complicating it. I guess the topcon steering wheel is some sort of large diameter stepper?
Thanks for the quick answers, it seems to be a bit complicated
The author of the post I quoted was using it steering the tractor but I was not able to contact him.
Maybe I schould start wit a normal brushed motor…
I have already implemented the stepper control into the PID.ino. At first attempt I tried to overwrite the timer control, but then I occasionaly found a PWM library. In order to keep the original Brian’s architecture, I utilized pwmDrive global variable to proportionally produce frequency output to stepper.
The library I used is stored here :
https://code.google.com/archive/p/arduino-pwm-frequency-library/downloads
DM556 driver jumper is set to 400 impulses per rotation.
“cFreqGain” is a constant, which is multiplied with pwmDrive to get the desired frequency (set by experiment).
MIN_PWM_STEP is constant, let it be 125 (actually its 50% duty)
#if (Motor_Valve_Driver_Board == 3) // Stepper motor NEMA + DM556 Driver board (no encoder between motor and driver)
void motorDrive(void)
{
const byte cFreqGain = 5 ;
pwmDisplay = pwmDrive;
//fast set the direction accordingly (this is pin DIR1_RL_ENABLE)
if (pwmDrive >= 0)
{
bitSet(PORTD, DIR1_RL_ENABLE); //set the correct direction
}
else
{
bitClear(PORTD, DIR1_RL_ENABLE);
pwmDrive = -1 * pwmDrive;
}
//write out the 0 to 255 value
if (pwmDrive == 0)
{
SetPinFrequencySafe(PWM2_RPWM, 1);
pwmWrite(PWM2_RPWM, 0); // turn off the stepper, no pulses
digitalWrite(ENA_STEPPER, HIGH); // disable stepper motor, it can be freely turned
}
else
{
SetPinFrequencySafe(PWM2_RPWM, pwmDrive * cFreqGain);
digitalWrite(ENA_STEPPER, LOW); // enable stepper
pwmWrite(PWM2_RPWM, MIN_PWM_STEP);
}
}
#endif
in AutosteerPCBv2.ino I added such code:
#define Motor_Valve_Driver_Board 3 // 1 = Steering Motor/valves + Cytron MD30C, MD13A Driver
// 2 = Steering Motor/valves + IBT 2
// 3 = NEMA Stepper
....
#define MIN_PWM_STEP 125 // for NEMA stepper
#define ENA_STEPPER 5 // has inverted behaviour - '1' disables stepper motor, '0' enables stepper or holds it position
....
in setup procudere added :
...
pinMode(ENA_STEPPER, OUTPUT);
...
#if (Motor_Valve_Driver_Board == 3) // Initialize stepper motor drive, NEMA23
//initialize all timers except for 0, to save time keeping functions
InitTimersSafe();
if (SetPinFrequencySafe(PWM2_RPWM, 1)) // 1Hz initialization for stepper
{
#if (Print_debug)
Serial.print("Freq set successfuly, Hz: ");
Serial.println(pwmDrive, DEC);
#endif
}
digitalWrite(ENA_STEPPER, HIGH); // disable stepper
#endif
Also you have to add PWM.h library to Arduino IDE.
Thank you, I will give it a try
did you manage to use the stepper? it would also interest me since I don’t have much space and a nema 23 is much shorter than the phidget.
No I havent managed it jet. I had too much work the
last weeks
I am thinking about using something like that
or Stepper driver with torque feedback
Waiting for delivery than i will try.
Can I use this? I got one for free, so it would be nice to be able to use it.
Or is it better with a dc motor (phidgets)
I’m soldering a pcbv2 now.
Hey Guys, i’m new in here and i also would like to steer with an nema17 stepper motor. I tried the code above, but it only gives errors. I think the code worked with an older Version of agopen GPS?
Maybe someone has a solution for the Autosteer_USB_4.3.10.ino ? Would be greatfuly