Autosteer - Brushless Motor

just tried the esc arduino library , just a version of servo.h .

Apologies for the beginner question :grimacing: but where in the .ino would I add this in?
Iā€™m hoping to use a Roboteq controller to drive a actuator for steering in a robot lawnmower but this is my first time using an Arduino so Iā€™m a bit in the dark,

Cheers

This is an advanced subject. If this is your first Arduino project then I suggest you start with a simpler project first. Most likely my code wonā€™t work directly for you and will need modifying.

Made also some first desktop tests yesterday. Configuration in VESC tool is quite a bit tricky when using it the first time.

I succeded the motor calibration and am now at the ā€œinputā€ setting. there are many parameters and ways to control the vesc.

The Wizard asks to use the control, full speed one way and full speed the other way.
How can I do that in AOG ? drive on a line with simulator and move the WAS full one side and then full the other side ?

image

in the steering settings using the Drive mode, with the arrows steer to the left and then to the right, checking that the PWM reaches maximum (254) from both sides

Worked well !

I was able to make it turn both ways. Not really noisy, low spped was ok, the motor was jumping before calibration but ran smoothly after calibration.

But burned my power supply ;-)ā€¦ Max PWM to high and when moving the WAS to calibrate the other direction it was far too reactive.
It was a computer power supply and I think I sent back power to ā€œreload the batteryā€ ā€¦

VESC tool is realy tricky and not really adapted for what we do, so many parameters are dedicated to electric scooters.

Have you try to follow an AB line?

No, I made what you said, drive mode, steer switch activated. I had to move the WAS both ways to test both directions.
Impulses per degree were too low, pwm max too high and high reactivity in the ESC.

Ok! how did you set the control mode in the vesc tool? current, duty or something else?

to not recharge the power supply set the parameter ā€œbattery current max regenā€ to 0 or really low

Current.
I should limit the max rpm but didnā€™t find where for the moment.
What I appreciate is that the motor can rotate freely because it has no gear reduction. It is possible to let it all the time engaged on the driving wheel.

Coupled with a torque detection to disengage it automatically it fits to what I expect from the system.

I think that the 6374 is too big for what we do. Maybe a smaller motor with a smaller driving gear (or roller) would be enough.

Regarding price, esc + motor is about 100ā‚¬ for that size. Nearly the same price as phidget + cytron.

1 Like

I have not been able to get a ā€œlinearā€ response by control it in current, or it does not move, or it starts like a rocket and then oscillates around the target angle

Where are you now ? You are using another parameter then ? Of forgot that idea ?

I tried in duty cycle but the engine remains braked even with the autosteer off, letā€™s say Iā€™m at a standstill, with the doubt that my 5065 engine is too small.

I finally got it to work 80% correct at the office. I m quite confident it will be also working in field.
Duty cycle, I tried many adjustment in VEST TOOLS and came to something acceptable.

It reverses correctly, is proportionnal to PWM comming from PCB V2. I connected the ESC to PWM 1 and GND which is normally dedicated to cytron.

I modified the INO as proposed by m_elias and it works well. On the video bellow, Iā€™m moving the WAS and motor follows as required.

Next steps => test on the tractor.

5 Likes

Be careful because in duty cycle when you deactivate the autosteer or the PWM is 0 the motor is braked, and you lose one of the greatest advantages of the brushless: being able to always leave the motor engaged

Your are right, I found that disconnecting the signal cable between PCB (PWM1) and ESC releases the rotation. Maybe add a relay in between which is open when it should be rotating freely, when steering should be disengaged ?

Or maybe we could use a software trick putting the arduino output to low instead of the mid pwm ?

i used this code: in autosteer.ino:
comment:

//#define PWM1_LPWM  3  //PD3

add:

#include <Servo.h>
Servo ESC;

in Autosteer PID:

void motorDrive(void) 
{
// Used with Cytron MD30C Driver
// Steering Motor
// Dir + PWM Signal
if (aogSettings.CytronDriver)
{     
  pwmDisplay = pwmDrive;

 if (pwmDrive == 0)
 ESC.detach();
 else
  
  {
    ESC.attach(3,1000,2000);
    pwmDrive=map(pwmDrive, -255, 255, 0, 180);
    ESC.write(pwmDrive);
   }
  }
else

{
  // Used with IBT 2  Driver for Steering Motor
  // Dir1 connected to BOTH enables
  // PWM Left + PWM Right Signal     
  pwmDisplay = pwmDrive; 

  if (pwmDrive > 0)
  {
    analogWrite(PWM2_RPWM, 0);//Turn off before other one on
    //analogWrite(PWM1_LPWM, pwmDrive);
  }      
  else
  {
    pwmDrive = -1 * pwmDrive;  
    //analogWrite(PWM1_LPWM, 0);//Turn off before other one on
    analogWrite(PWM2_RPWM, pwmDrive);
  }
 }
}

maybe you need to recalibrate your vesc input.

1 Like

It works, I added the condition in the code. If the PWM signal should be 0, do not add 1500 sothat it stays at 0. In this case, it rotates freely.

if (pwmServo != 0) pwmServo += 1500;                    
myServo.writeMicroseconds(pwmServo);

Good.:+1:
It would be the best if it were possible to set the vesc that, when a certain load/stall is reached, sends a signal to release the autosteer, but I have not found any option to do this, someone would be able to modify the firmware

What if one of these engines were to be used. They are used for the camera gimbal so they should be accurate. I plan to order one for a trial, the choice is not easy.

1 Like