Using a motor with its "ESC" as a servomotor

Marc DANIEL

Well-Known Member
Licensed User
If you're used to working with servos with Arduino and B4R, you'll quickly understand how to use an electric motor with its ESC, as this interface behaves exactly like a servo, except that we'll be controlling the motor's speed rather than the servo's rotation angles. This is made possible by the flexibility of the rServo library!

There are, of course, several types of suitable motors and ESCs. We will choose the following model for our example.

Utilisation du moteur avec une ESC (1).jpg

The ESC includes:

- 2 wires for battery connection (Red + and Black (GND) -)

- 2 or 3 wires to power the motor (In our example, there are 2 wires, 1 red and 1 black. Reversing the connection to the motor will change the motor's direction of rotation). When there are 3 wires, they are often yellow.

- 1 microswitch

- 1 connecting cable with 3 wires (White: PWM signal, Red: 5 volts, Black: GND). This small cable will allow us to control our motor like a servo motor.
 

Attachments

  • ESCwithServo.zip
    848 bytes · Views: 12

Marc DANIEL

Well-Known Member
Licensed User
Controlling a motor controlled by an ESC like a servomotor:
'
#Region Project Attributes
    #AutoFlushLogs: True
    #CheckArrayBounds: True
    #StackBufferSize: 300
#End Region


Sub Process_Globals
    Public Serial1 As Serial
    Public Motor As Servo
End Sub

Private Sub AppStart
    Serial1.Initialize(115200)
    Motor.Attach2(9,1000,2000)
    Start
End Sub

Sub Start
    Motor.Write(1800)  'Engine speed: 80%
    Delay(5000)
    Motor.Write(2000)  'Engine speed: 100%
    Delay(5000)
    Motor.Write(1000)
End Sub
 
Last edited:
Top