Drive simple little servo-motor with HiFive1

I made a simple wiring like this arduino example.
I wonder if there example code to drive a servomotor with integrated PWM on E310 ?

I tryied to use the default arduino Servo library but it’s sound to be not implemented yet :

WARNING: library Servo claims to run on (avr, sam, samd, nrf52, stm32f4) architecture(s) and may be incompatible with your current board which runs on (riscv) architecture(s).
In file included from /tmp/arduino_modified_sketch_606983/Blink.ino:24:0:
/opt/arduino-1.8.5/libraries/Servo/src/Servo.h:73:2: error: #error “This library only supports boards with an AVR, SAM, SAMD, NRF52 or STM32F4 processor.”
#error “This library only supports boards with an AVR, SAM, SAMD, NRF52 or STM32F4 processor.”
exit status 1
Error compiling for board HiFive 1.

It’s not a surprise :wink: but I wonder if somebody has already tryied to drive Servomotor with HiFive1, to mutualize efforts ?

It doesn’t really answer your question, but my experience of RC servos is that you don’t actually need PWM with them. You just need to send them a pulse with length between about 500 us and 1500 us from time to time … and it really doesn’t matter much whether you do that at 200 Hz or at 20 Hz. A couple of digitalWrite() with a delayMicroseconds() between in your main loop should be fine. (and maybe a short delay() to prevent it being toooo fast)

1 Like

Thanks bruce, it simply works !


I see you’re using the same $1 servo I bought a dozen of from dealextreme once. They seem to work fine if you don’t need huge power.

In my local model shop the cheapest servos they had were $40!! And I think they were not better.

It was more expensive than $1 i think but provided with a robotic kit in fact :wink:

Seriously :slight_smile:

1 Like

HI bruce!

Is the same applicable for bldc motors? (1400kv used for quadcopters?)

It’s the same for normal RC plane “ESC” (Electronic Speed Control) units that control the motors. The ESC takes exactly the same input as a normal servo – you plug them in to a servo channel on the radio.

I haven’t done anything with quadcopters. I’d have thought they’d just have four ESC (or a big one with four inputs). But I don’t know. Maybe they do something different.

I did some googling. Seems like it’s basically the same. The only thing is they’re using pulse lengths a lot shorter than 1 mS to get faster response times. That makes sense when the control signal is coming from an on-board autopilot with IMU and PID and stuff, not from a bloke on the ground wiggling his thumbs.

Thanks bruce

This code works for the Arduino Zero I set up previously but I get the same error as Martoni when I plug in my HiFive 1. Do you have any insight in where I should put my delays to get it working?