Control Parallax High Speed 360° servos with ESP32 boards. Works with interrupts and multitasking (FreeRTOS).
About this motor:
- 6V 2A power supply.
- ESP32 Dev board.
- Breadboard.
- Jumper wires.
- Parallax High Speed 360° servos
- Micro USB to USB 2.0
- Download the latest Arduino IDE then open it.
- Download the ESP32Servo360 library from Sketch > Include Library > Manage Libraries..., search for
ESP32Servo360
and install the latest release. - Go to File > Preferences, add
https://dl.espressif.com/dl/package_esp32_index.json
to Additional Boards Manager URLs, don't forget to separate the URLs with a comma. - In Board > Boards Manager, search and install the latest core esp32.
- Wire like the image above. Some pins may not work properly (GPIO0 for instance). Make sure to connect the ESP32 GND pin to the ground of the 6V power supply.
- Connect your esp32 to your computer and the motor to your 6V power supply.
- On Arduino IDE, find your board in Tools > Port. Mine, shows as /dev/cu.SLAB_USBtoUART.
- In Board > Boards Manager > ESP32 Arduino, select "DOIT ESP32 DEVKIT V1".
- Run one of the examples (File > Examples > ESP32Servo360). Check if the pins matches the code
servo.attach(4, 16)
.
Or
ESP32Servo360 servo([int offsetAngle]
, [int rpm]
, [int deceleration]
, [int minPulseWidth]
, [int maxPulseWidth]
, [int channel]
);
Set optionnal parameters directly at the creation of an instance.
offsetAngle
Default is 0 degrees.rpm
Default speed of the servo (Turns per Minute). Maximum is 140.deceleration
Ease-out. By default, deceleration starts at 70 degrees from target angle.minPulseWidth
PWM signal of the Hall Sensor at 0 degrees. Default is 32.maxPulseWidth
PWM signal of the Hall Sensor at ~360 degrees. Default is 1067.channel
ESP32 LEDC channel used to send the PWM signal to the motor. Automatic by default.
For better readable angle accuracy, manually set the PWM signal of the internal Hall Effect Sensor.
- Default
minPulseWidth
is 32. Signal at 0 degrees. - Default
maxPulseWidth
is 1067. Signal at ~360 degrees. - Get the values with the method
servo.calibrate();
.
Attach to the correct pins of your servo.
controlPin
is the white cable.feebackPin
is the yellow cable.
For better readable angle accuracy, automatically set the PWM signal of the internal Hall Effect Sensor.
The servo will turn and give you the result through Serial
.
Disconnect the servo from its pins.
To prevent any bouncing, especially due to high RPM.
You can start the deceleration to a higher angle from the target angle.
Default is set to 180 degrees.
If you decide to change the orientation of your motor, you can offset its zero position.
Change the maximum RPM (Rotation Per Minute) of your servo. Default is 70 RPM.
For easing rotations only, add more force when speed is minimal (at start & end of movement).
Default is 5.
Minimal force required for the servo to move. minimal force may barely move the servo, bigger force may do infinite bounces.
Default is 7.
Reset the number of turns.
Stop and hold the servo to its current angle. Will be harder to turn the motor by hand.
Disable this state by executing another rotation or calling servo.release();
.
Releases the servo from its hold state.
Rotate from current position.
Rotate by given angle with a ease-in-out-quad move.
Rotate to a specific position.
Rotate to a given angle with a ease-in-out-quad move.
Spin clockwise or anticlockwise at a the default RPM if the parameter unset.
Setting the parameter won't change the saved RPM of the servo. Instead use the method servo.setSpeed();
.
Value must be between -140 and 140.
Stop the rotation of the servo.
Wait for the motor to finish its rotation. Will hold the execution of the main loop().
true
if servo is attached to pins.
Returns bool.
true
if servo is still executing a rotation or holding an angle.
Returns bool.
Get the amount of rotation. Angle will go below 0 and above 360 degrees.
Returns a float.
Get the orientation between 0 to 360 degrees.
Returns a float.
Get number of turns. This will be reset after a reboot of the board.
Returns int.
Signal Spectacle, ECAL workshop with Pinaffo—Pluvinage, 2020
Author, maintainer: Sébastien Matos
ECAL 2020 Bachelor Media & Interaction design.