User avatar
xSpamerx
Posts: 41
Joined: Mon Feb 25, 2013 11:23 pm

How to controll brushless motor using ESC and PWM signal

Wed Jun 26, 2013 12:47 pm

I have an ESC https://en.wikipedia.org/wiki/Electronic_speed_control and a brushless motor.
Motor is connected with ESC , ESC is connected to to accumulator.
Connector from ESC ( with 3 wires ( white , black, red) ) with white is connected to GPIO 4.
Tryed to use WiringPi to send signal

Code: Select all

gpio mode 0 pwm
pgio pwm 0 1023
but nothig happened

Tryed out https://github.com/richardghirst/PiBits ... rvoBlaster

Code: Select all

echo 0=200 > /dev/servoblaster
The same story.

When I connect ESC to the accumulator , ESC plays a sound, then I connect white wire to the raspberry pi GPIO 4 , ESC play's sound one more time. Then I try to change values from the terminal and ... just nothing happens. What I'm doing wrong?

User avatar
joan
Posts: 12745
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: How to controll brushless motor using ESC and PWM signal

Wed Jun 26, 2013 1:07 pm

Servoblaster should have worked. gpio4 is servoblaster #0.

User avatar
xSpamerx
Posts: 41
Joined: Mon Feb 25, 2013 11:23 pm

Re: How to controll brushless motor using ESC and PWM signal

Wed Jun 26, 2013 1:21 pm

When I connect white wire to the gpio 4 . ESC play's a sound then I try to change values
echo 0=150 > /dev/servoblaster
echo 0=200 > /dev/servoblaster


and just nothing.
When I disconnect white wire from gpio 4 , wait a little bit and connect it again it plays it's sound again. No matter I used
echo 0=200 > /dev/servoblaster or echo 0=0 > /dev/servoblaster before that.

User avatar
joan
Posts: 12745
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: How to controll brushless motor using ESC and PWM signal

Wed Jun 26, 2013 1:39 pm

I think that should have worked.

You could try my pigpio.

Code: Select all

wget abyz.co.uk/rpi/pigpio/pigpio.tar
tar xvf pigpio.tar
cd PIGPIO
cp libpigpio.a-hard libpigpio.a
make
make install
sudo pigpiod
pigs s 4 1000
pigs s 4 1500
pigs s 4 2000

http://www.youtube.com/watch?v=UVCH6R-CE3A
http://www.youtube.com/watch?v=EK2yHD46mAI

User avatar
xSpamerx
Posts: 41
Joined: Mon Feb 25, 2013 11:23 pm

Re: How to controll brushless motor using ESC and PWM signal

Wed Jun 26, 2013 3:00 pm

No, that also didn't helped =\ . Just nothing.

User avatar
joan
Posts: 12745
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: How to controll brushless motor using ESC and PWM signal

Wed Jun 26, 2013 3:07 pm

That's a pity.

I think some ESCs have safety features which prevent them operating until an initialisation sequence has completed. Have you got a link to the ESC documentation?

User avatar
xSpamerx
Posts: 41
Joined: Mon Feb 25, 2013 11:23 pm

Re: How to controll brushless motor using ESC and PWM signal

Wed Jun 26, 2013 3:18 pm

joan wrote:That's a pity.

I think some ESCs have safety features which prevent them operating until an initialisation sequence has completed. Have you got a link to the ESC documentation?
I found some useful information here http://electronics.stackexchange.com/qu ... th-arduino
But how to generate those 2ms and 1ms pulses..

I have RCTIMER SK 30 A ESC's
PDF Manual

User avatar
joan
Posts: 12745
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: How to controll brushless motor using ESC and PWM signal

Wed Jun 26, 2013 3:29 pm

With the ESC off try

pigs s 4 1000 # 1ms pulse on gpio4

switch ESC on and leave for 5 seconds then

pigs s 4 2000 # 2ms pulse on gpio4

User avatar
xSpamerx
Posts: 41
Joined: Mon Feb 25, 2013 11:23 pm

Re: How to controll brushless motor using ESC and PWM signal

Wed Jun 26, 2013 4:28 pm

joan wrote:With the ESC off try

pigs s 4 1000 # 1ms pulse on gpio4

switch ESC on and leave for 5 seconds then

pigs s 4 2000 # 2ms pulse on gpio4
Didn't help. May be I'll make a video soon and post it here..

User avatar
Hove
Posts: 1182
Joined: Sun Oct 21, 2012 6:55 pm
Location: Cotswolds, UK
Contact: Website

Re: How to controll brushless motor using ESC and PWM signal

Wed Jun 26, 2013 7:02 pm

I don't know how to do it via the command line, but with RPIO.PWM Python, you can assign a PWM channel to a GPIO pin. The PWM code defines a frequency you send the PWM messages at - most ESCs will accept somewhere between 100Hz and 450Hz.

That means every 0.01 to 0.002222.... seconds, you send a high pulse lasting between 1ms and 2 ms. Less than 1ms and the ESC will complain loudly and annoyingly. 1ms will shut it up, and between 1 and 2 milliseconds, the motor speed will increase to maximum supported by the ESC.

Code: Select all

	RPIO.PWM.setup(1)    # pulse sizes measures in 1us units
	RPIO.PWM.init_channel(RPIO_DMA_CHANNEL, 3000) # 3ms (333Hz subcycle) - pulses repeated at this frequency
	RPIO.PWM.add_channel_pulse(RPIO_DMA_CHANNEL, GPIO_PIN, 0, 1000) # set 1ms (=1000us) pulse
RPIO_DMA_CHANNEL is simple a choice of 1 of the 14 channels that can be used. GPIO_PIN is one of the BCM GPIO pin numbers.

For more info, checkout the RPIO PWM docs: http://pythonhosted.org/RPIO/pwm_py.html

I think the standard RPi.GPIO also supports PWM in an almost identical manner - my choice of RPIO is for other reasons.

You might also find some more info on my blog, but there's no PWM code there yet, until I have my drone flying, which, fingers crossed, will be any day now.

Hove
www.pistuffing.co.uk - Raspberry Pi and other stuffing!

User avatar
joan
Posts: 12745
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: How to controll brushless motor using ESC and PWM signal

Wed Jun 26, 2013 7:27 pm

Ummh. I assumed they were driven like hobby servos with a 50Hz update rate.

@xSpamerx

For a 400Hz update rate do

pigs pfs 4 400 # set 400Hz frequency on gpio4
pigs prs 4 2500 # dutycycle between 0 and 2500 micros

pigs p 4 1000 # 1ms pulse @ 400Hz

pigs p 4 2000 # 2ms pulse @ 400 Hz

User avatar
Hove
Posts: 1182
Joined: Sun Oct 21, 2012 6:55 pm
Location: Cotswolds, UK
Contact: Website

Re: How to controll brushless motor using ESC and PWM signal

Wed Jun 26, 2013 7:33 pm

joan wrote:Ummh. I assumed they were driven like hobby servos with a 50Hz update rate.

@xSpamerx

For a 400Hz update rate do

pigs pfs 4 400 # set 400Hz frequency on gpio4
pigs prs 4 2500 # dutycycle between 0 and 2500 micros

pigs p 4 1000 # 1ms pulse @ 400Hz

pigs p 4 2000 # 2ms pulse @ 400 Hz
You may well be right - I only have experience of quadcopter ESCs which seem to need faster than 100Hz subcycle - I can understand why a servo only needs 50Hz whereas as a quadcopter blade needs much finer control, and hence the higher carrier frequency
www.pistuffing.co.uk - Raspberry Pi and other stuffing!

User avatar
joan
Posts: 12745
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: How to controll brushless motor using ESC and PWM signal

Wed Jun 26, 2013 7:43 pm

A quick google does show update rates from 50Hz to 450Hz (and some claim more than 500Hz but that seems impossible if you want a 2ms pulse).

I'd have hoped the ESC documentation would give the preferred update rate or at least a working range.

firehopper
Posts: 7
Joined: Tue Feb 26, 2013 10:55 pm

Re: How to controll brushless motor using ESC and PWM signal

Wed Jun 26, 2013 9:46 pm

start at 50hz
all esc's should accept that.

set the pulse width to 1.0 ms
connect the esc to power with a motor attached, no prop
motor will make noise.
set pulse width to 1.3 ms

motor should spin slowly
if not then the esc may need to have its range set..

unplug esc
set pulse width to 2.0
connect esc, wait for noise.
set pulse width to 1.0
wait for noise.
set pulse width to 1.3
and motor should spin slowly
set pulse width to 1.0
motor should stop

you can also connect a standard servo and see if it moves when you issue those commands to see if you have things connected correctly

black connects to ground, white to signal. red do not connect

User avatar
xSpamerx
Posts: 41
Joined: Mon Feb 25, 2013 11:23 pm

Re: How to controll brushless motor using ESC and PWM signal

Wed Jun 26, 2013 10:30 pm

Oh big thanks! It worked! I didn't connect black wire (GND) to GND on the Rpi. It rotates and changes it's speed.
Just perfect.
Thanks a lot. I appriciate your help!

User avatar
joan
Posts: 12745
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: How to controll brushless motor using ESC and PWM signal

Thu Jun 27, 2013 7:13 am

xSpamerx wrote:Oh big thanks! It worked! I didn't connect black wire (GND) to GND on the Rpi. It rotates and changes it's speed.
Just perfect.
Thanks a lot. I appriciate your help!
Was the only problem ground not being connected?

User avatar
xSpamerx
Posts: 41
Joined: Mon Feb 25, 2013 11:23 pm

Re: How to controll brushless motor using ESC and PWM signal

Thu Jun 27, 2013 4:29 pm

joan wrote:
xSpamerx wrote:Oh big thanks! It worked! I didn't connect black wire (GND) to GND on the Rpi. It rotates and changes it's speed.
Just perfect.
Thanks a lot. I appriciate your help!
Was the only problem ground not being connected?
Yep, it was the only "problem".
It works when I send 2ms signal , than 1 ms. It calibrates and ready to work.
Also it could be run sending 1ms signal at start. Then it is also ready to work.
All works fine.

Return to “Русский”

Who is online

Users browsing this forum: No registered users and 1 guest