Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

12V BLDC & Raspberry Pi

Status
Not open for further replies.

Iawia

Member
Hi Guys,

I have some concerns regarding the Raspberry Pi 3 & a BLDC. Its a continuous rotation 12V BLDC (https://www.surplussales.com/Motors/pdf/mot-000-0222.pdf).

I have a nameless/label-less ESC in my assortment of electronics. It is setup like any old ESC with 2 wires for the battery, 3 wires for the BLDC, and a red/white/blk 3 wire bundle. Since I don't have much info on the ESC, is it absurd to think it can run the 12V BLDC on it? Is there any danger to my Rasp Pi if I try this?

From what it seems, the raspberry pi should be safe since it is merely providing the PWM signal to the white wire, blk wire to ground (PWM between 10-20% duty cycle for MIN/MAX RPM @50 Hz). Red wire I will leave alone.

I'm not 100% sure what I am doing, I'm just watching videos incessantly to learn. Looking for some guidance. Thank you all!
 
That sounds OK.

I'd just check the voltage from the black/ground wire to the white and red wires, with the 12V supply connected to the ESC but no connection to the Pi.

As long as there is no more than 5V on them, it should be safe to connect.

The red wire could be a low current 5V out to power an RC receiver, or it could be a logic supply to the ESC?

If it does not run with the black & white connected and appropriate signal present, see if the red wire has voltage? If not, try connecting that to 5V as well?
 
Hi RJ

Ok just to follow this up. I did not need to connect the 5v rail. Everything worked ok as far as I can tell by using only the white and black wires from the ESC. That being said, I still have some questions about the Raspberry Pi3. When i use the pins with the 'pwm' label (Pins 12, 32), they do NOT work or turn the motor. I was able to send pwm using pins 9 ground using pin 11 (see code snip)

Why does the motor not run on these pins that are explicitly for PWM, and a pin that is not designated as PWM will run it? (I also changed to the nearest ground pin when changing the PWM pin, it didn't help). and of course changed the code GPIO.setup(X, GPIO.OUT) where X is a new pin value.

Is it normal for the BLDC motor speed to be super constrained between 4.5% and 8.0%? I thought it was between 10-20% duty cycle or is this dependent on motor mfg?

I was just curious if you knew what was happening. Thanks! -t

1667545460321.png


my python code is super basic and as the following:

import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BOARD)
GPIO.setup(11, GPIO.OUT)

p.start(0)
while(1)
p.ChangeDutyCycle(4.5)
print("Trying 4.5% Duty")
time.sleep(3)

p.ChangeDutyCycle(4.6)
print("Trying 4.6% Duty")
time.sleep(3)

GPIO.cleanup()
 
I don't see any setup for the repetition rate or actual pulse length etc? I'm guessing that code is using some form of software PWM.
(I only use C or assembler, I've never particularly liked Python).


RC servos and ESCs do not use simple % duty PWM, as you would for power control etc.

They need an accurately timed pulse, usually between 1 to 2 mS for 0 to 100% position or power. 1.5mS is middle for a servo or 50% power for an ESC.
That should repeat at something like 50Hz, or a 20mS frame rate for a sequence of servos.

Some newer devices use 0.5mS to 2.5mS range, but still with 1.5mS as mid position or 50%
 
I don't know if this is any help, a C demo program I posted a while ago that can drive up to eight servos (or ESCs) running purely as a background task on a PIC. Once initialised all you need to do in your main program is update the pulse times in the servo_times[] array.

If the Pi has an output compare type interrupt you could use a similar principle.

Otherwise, turn the output on and use a delay_us() type function to determine the pulse length, then turn the output off and do something else for around 20mS.

 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top