Two questions about BLDC motor control

Status
Not open for further replies.

toneboy1

New member
Messages
7
Reaction score
0
Hi,

I am new here.

I have purchased the common Bora 1800W motor:

https://www.aliexpress.com/item/New...ctric-Motor-Electric-Scooter/32653016751.html

I have seen other people discuss this motor on the forums.

However, I am building my own controller using a raspberry pi and 3 H-Bridges.

I have seen people discuss this controller here:
http://www.diygokarts.com/vb/showthread.php?t=37537
http://www.diygokarts.com/vb/showthread.php?t=37176

I have four questions;

Q1: The sensors have 5 pins in the plug, can someone please tell me what voltage is between the red and black pins? (I assume these are for three Hall sensors?)

Q2: Can someone tell me if the hall sensors are 60degrees or 120degrees off-set?

Q3: Regarding the three binary bits coming from the Hall sensor, the switch combination that these bits relate to, is this for the current/present switch positions/states (i.e. the current magnetic arrangement). Or the next switch positions/states to be triggered?

This is a general BLDC commutation question, because I have no prior experience.

Q4: I have seen people express doubt on here that the Boma motors aren't really as powerful as the name plate suggests (i.e. not really capable of 1800W). Can anyone give an indication of approximately what power they are actually capable of outputting?


Thanks in advance!
 

itsid

Moderator
Staff member
Messages
11,563
Reaction score
248
Location
Ruhrpott [Germany]
H-Bridges and a raspberry pi?
I mean sure, you can make a almost everything from almost anything,
but that is quite a *cough* idea I must say.

First: the Pi needs an operating system loaded to make use of most of it's ports..
with that all real time operation is essentially void.
(so at worse the motor could get stuck in 100% power full speed and no signal you send could change that once the OS decides to break and get stuck in a loop)

a simple microcontroller (arduino esque) makes wayyyyy more sense for what little code you need.
I mean, you certainly won't need audio/video out on a motor controller, and storage isn'te catly necessary either is it?
So yeah... sure you can controll 'whatever' with a full size Laptop if you're so inclined.. BUT WHY??

Anywhoo.. H Bridges.. as usefull as jeff Bridges here
Full power, no control but timing.

Again .. nothing you should consider a good idea..

you want smooth transitions between pole-pairs..
and you want to go slow at times (say downhill for example)
at least you want that option.

binary bit output? not from the hall effect sensors I know..
those are all analog and send a 0-5V signal (ideally.. in reality closer to 0.7-4.2V)
the closer whatever sensed magnetic field is, the less chopped the incomming voltage
(more often than not 5V ) will be.
a common ground to reduce false readings against the controller...
and with three sensors you have five pins.

three sensors are 120° spaced of course.

Power.. IDK could be that Bomas are labeleld with their peak power (usually means less than 10s bursts or the motor will burn out)
could also be electrical Powerdraw (VA) instead of mechanical Poweroutput

IDK, but Kevin has a few of those and they all perform rather well (with a proper controller that is)
I'd say expect ~80% of their claims to be available at max and you're on the safe side.

If it's the full 100%.. you simply have a slightly quicker vehicle (which isn't bad, is it?)

'sid
 

toneboy1

New member
Messages
7
Reaction score
0
Thanks heaps for the reply Sid.

I am using an arduino for the analogue to digital conversion from throttle to pi. So if worse comes to worse I'll just use the Arudino. However, my reasons for using the pi are for learning/practice purposes. A larger multi-year project of building a single phase Universal Power Quality Filter, which can inject reactive power, remove real power harmonics and perform power factor correction.

So this project is a good segue/foray into the required practicals (although the power filter will require coding Space Vectors etc.).

SIDE NOTE:
All these potential pit-falls such as the OS breaking and getting stuck in a loop (which I would never have considered) will be good for me to learn.

I have only done some basic testing on the pi (sending an array of bits to a pin) and measuring with a multimeter, and I think I can use more than enough DI/O pins for the PWM etc.

I'm pretty happy with my untested control code for the H-bridges, but time will tell. I'll let you know in due course.

MAIN CONTENT OF REPLY:

I can power the sensors with 3.3V or 5V. If they work off 3.3V that would be excellent.
Okay, well if they're analogue I expect there is an ON/OFF voltage threshold for 1 or 0. I'll have to check what this is on the pi.

I did expect they would be 120 degrees, from what I've read this is preferred arrangement because 111 or 000 can be returned and you know there is a fault. However, so many things I've seen online, including people installing the sensors are a 60 degree arrangement.

It doesn't matter which order the three hall sensors are in, does it?

With regards to my 'Q3' I have made an illustration to hopefully better illustrate my question, please see the attached picture.

Another question I have just thought, does anyone know the maximum PWM these sort of motors can handle? I assume it's related to the LR constant of the lamina.
My H-bridges can go up to 200k hz, so I guess I'll start there and work backwards.

Thanks,
Rob


P.S. the code will be running on boot, without any monitor screen, and it will be wired such that if there was any freakish OS break 'loop' situation, a contact switch will be able to break the connection.
 

Attachments

  • goKartReply.PNG
    goKartReply.PNG
    94.7 KB · Views: 5

itsid

Moderator
Staff member
Messages
11,563
Reaction score
248
Location
Ruhrpott [Germany]
Well, I think you missed my reply to that rather than me misunderstanding the question.

HE sensor are unlikely to give you a digital signal,
and even if they do it wouldn't be a single bit, instead it'd be a series of bits per pin.

And while you could run an A/D converter to toggle between 0 and 1 at the halfway voltage between the possible pin values (again reasonable is 0.7V - 4.2V per pin)
that would'nt do justice to the motors rotational behaviours much..
it'd be a square wave signal instead of a nice sinusoidial one...

And as I tried to explain, the high value indicates the magnetic field is close
And there are several possible readings with that.
the errected coil (the usual HE signal you want)
the overall field strength of your permanent magnets
(that's where the 0.7V are coming from mostly... the nice thing is, you can see degradation of the magnets from motor overheating by reading the base voltage and comparing that to month/year old values)
And then there's the Back EMF getting registered in the sensors as well.

Sooo enough signals (far enough apart to matter) for a straight binary signal to make nearly no sense.
(that's why they're most likely NOT binary divices ;))

You can pick up the Back EMF from the coils (and skip the sensors entirely)
to get read as rotational position (what sensorless controllers do)
OR you can pick the signal and use that to determine what rotational position the motor is in.
strongest signal is the errect coil.. or should be let's say ;)
weakest are the base values for the PM field.
and the Back EMF is inbetween and varaible depending on rotational speed.

What you need is a time table to determine ho..
put the sensors to a oscilloscope and turn over the motor shaft by hand.. you'll see what to do from there :D

Again.. I still think the Raspberry Pi is waaaaay overkill for such.
especially if the arduino (providing all and more than you need) is a slave device anyways.

What I'd do instead (if you insist of adding the raspi..)
Is building the controller purely on arduino platform,
add a monitor and BT device to the Pi,
and use it as a 'monitor and logging device' for the motor controller.
you can collect all data from the motor/sensors/arduino and use the Pi
to monitor and log all values .. that way you can maybe see flaws in controlcode
that are otherwise undetected, heck with a programming environment a small display and a BT keyboard you could even reprogramm that arduino if you want :D

You could add a secondary control loop from the Pi (a GPS signal, throttle pos)
to add fancy features (say an invisible fence to stop the kart/bike from leaving a predefined area [at least self powered])
You could use a LIDAR or other obstacle detection to cause the Pi to trigger a brake signal on the arduino.
hundreds of things that make sense in terms of fun and education.
But the actual controller should be as realtime as possible, and more importantly..
as SIMPLE as possible (the least amount of code)

And ..
Ahhh by H Bridge you meant MosFets in HBridge configuration..
GOOD!!

200kHz isn't needed really, don't forget you have a mechanical D/A converter on the other end (since that's what motors are in a way)
I'd say maybe 1kHz could give you a fine enough resolution already
with the benefit of a much more reliable signal.
if you need finer graduation you can step up.. of course, but I doubt you'll need anything like 200kHz.
coils are toggled at ~100Hz at full speed right?
A factor of ten allows for a 10% resolution per coil
and you could interpolate that to cut the value in half even
(parity check toggle 50 & 60 % power and you get a 55% overall signal)

at slower paces, the available 'timely room' grows and you get even finer resolution.

'sid
 

toneboy1

New member
Messages
7
Reaction score
0
Hi Sid,

Thanks again.

I think I did understand you correctly; you clearly have a world of experience with Hall Effect sensors, more than me. So I don't want this to sound like I'm telling grandma how to suck eggs, but everything I've seen regarding the three Hall sensor pins is that they are binary 1 or 0.

Nothing is perfectly digital and from what I've read, the pi GIPIOs INPUTS are < 1.19V for LOW and between 1.34V to 3.3V for HIGH. (Or falling or rising edge). So I don't really see a problem using the hall analogue output as a digital input. Similarly, I don't see an issue with it being a square wave profile rather than a sinusoid, because as far as I know, the windings are not sinusoidally distributed in the stator, so the back EMF will be trapazoidal anyway.

Note: turning it with my hand, I feel 18 pole changes per rotation, so I presume there are 9 pole pairs. Which I guess means 9 electrical cycles per mechanical rotation. Which, I don't think has any bearing on the controller code.

That is really interesting about comparing the base Hall voltage, to diagnose degradation of magnets.

I did read a little bit about sensorless control, but I think this will be much harder for me to programme.

I will put my oscilloscope on the hall sensors tomorrow and turn it by hand to see what happens. I may well end up using just an arduino initially, or even in the end. However, this project is also about my learning about how to use a pi to build a power quality analyser etc. So I will be using the pi at some point, as the controller. As a practice for my other, much larger project which does require data collection and computation.

Forgive me if you did answer Q3, but I didn't get it. But regarding the attachment picture of the time table in my last reply. I'm still not sure if the high/low patter of H1, H2 & H3 are telling the motor what the Mosfets ARE or what they SHOULD BE.

Because I have written a switch statement in c such that when they correspond to the decimal equivalent number between 1 to 6, it sets the H-Bridge mosfets accordingly.

Also, it doesn't matter which order these three H.E. sensors are in, does it?

Thanks again!

Rob
 

itsid

Moderator
Staff member
Messages
11,563
Reaction score
248
Location
Ruhrpott [Germany]
Again, I don't have the motor spec sheet, so I can't tell for sure..
And you WILL have a problem if that is a 5V signal and the pi is expecting 3.3 max
since that might already fry your IO port.
1.3 to 3.3 as hi might also not fit your bill either
with a 0.7 base and a 3.5 range the midpoint would be at 2.45V not 1.3
so reading will be off (by roundabout 30° in both directions... 60° of error in a 120° segment... *cough* 50/50 chance right?)

9pole pairs.. three per set .. sounds reasonable .. but no, it doesn't make any difference in controlling the motor.. you have three terminals to power
and there are only two possible ways to do so (ABC -A-B-C or ACB -A-C-B) and that only affects direction of rotation. internal propagation is (one two or three coils per set) is hardwire and can't be influenced by the controller anyways.
It might make a difference in the physical sensor positions however (again not important for the controller)

Okay, I'll try to word it differently:
The sensor are just that SENSORS, they do not predict,
they tell you what's the current state.
If the hallsensors are color coded to the input terminals or not IDK..
and if they are IDK if their offset.
Of course their order matters..
110 is not 101, (else that'd be 1bit with parity check and error correction)

So, the sensor closest to the errect coil gives the strongest signal
(and that's the point.. if two were pulled high, which one is it?? that's why you want voltages not bits; sinusoidial not square waves ;))

so you need to turn the rotor a bit to toggle the "false" bits (should be 110, 010, 011) previous and upcoming trigger points toggle at the transition point... closest sensor will remain high.

And that's where another one of my remarks comes in:
WHY BOTHER?!
leave those Hall effect sensors alone for now!
decide for one (say ABC) and in case it runs the wrong way around just swap to connecting leads to reverse the rotation
(you don't even need the back emf for bench testing... after one cycle of buzzing the motor wills tart to turn even w/o knowing it's current position.. surely good enough for bench testing.

log the hall effect sensors simultaneously and you know for sure at which engaged coil wich sensor state appears. (and further you know which came before and what will follow to determine direction of rotation)
And in the next code update you have the sensors sorted out.

'sid
 

toneboy1

New member
Messages
7
Reaction score
0
Hi Sid,

I may well have to work something out to go between the hall sensors and the microcontroller. Maybe using op-amps and voltage divider.

I have spoken to the seller and they have said that the hall sensors are powered by between 48v to 54VDC! This is a lot higher than the 5 v I was expecting. Does this sound reasonable to you?

I put my oscilloscope on the hall sensors using a 5V supply today, and spun the motor with my battery drill. But I didn't see anything resembling a square wave.

Note: I know that the sensors cannot predict anything. But I was thinking that the table may have been meaning that the sensors were indicating the state of the rotor AND the states of the mosfets which caused it to get there, however, I think that this is such a remote possibility that I'll not worry about it until I cross that bridge in due course. (i.e. the switch states on the table are prescriptive, rather than descriptive).


Thanks
 

Functional Artist

Well-known member
Messages
5,646
Reaction score
3,281
Location
Toledo, Ohio
Not sure if it well help,

I've done some testing on the "speed controller" (not the motor) that came with my 60VDC Boma motor.

Controller Off
All plugs showed 0 VDC, except the on/off plug (labeled "electric lock")
...& the charge port plug (they both showed pack voltage)

Controller On
With the controller switched on, the Battery Indicator plug showed pack voltage (of course) but, also
...the Indicator Light plug
...the Brake Light (lever) plug
…& the Brake Light plug, all showed pack voltage (~64.5VDC)

To my surprise, when I tested the other control circuits, the Reverse plug (labeled Astern) showed 4.6VDC & the 3-speed plug showed 5VDC/0 VDC/ 5VDC (about the same as the throttle)

I even did an amp draw test on the "Electric Lock" circuit, just to see what was flowing thru it.
At first nothing was showing on the meter (must be below .2A) so, I changed the setting to 200mA & then, got a reading of 14.5mA

* According to my notes, the Hall plug showed:
Red = 4.6VDc
Black = 0VDC
& the rest all showed 5VDC :cheers2:
 

itsid

Moderator
Staff member
Messages
11,563
Reaction score
248
Location
Ruhrpott [Germany]
...
I have spoken to the seller and they have said that the hall sensors are powered by between 48v to 54VDC! This is a lot higher than the 5 v I was expecting. Does this sound reasonable to you?
...

no, that sounds like the seller was having a brain fart..

Contact uumotor.com and ask the same question..
I found a power datasheet for the 48V 1600W there
(looks great.. peak output is indeed above 1600W and at that peak efficiency is above 80%... that's good )
I'll attach it below for futur reference ..

Unfortunately there's no hall data present (since it doesn't matter for the power curves)

I'd say pop it open and read the label of the sensor to find the sensor datasheet..
but that's a bit too much hassle for something as trivial as a HE sensor.

Go with what Kevin said!
(put in 5V and ground.. and read the resulting voltage of the remaining three)

'sid
 

Attachments

  • BM481500curvingdata.pdf
    281.3 KB · Views: 4
Last edited:

toneboy1

New member
Messages
7
Reaction score
0
Hi,
Just a quick one.

Yeah, when I asked the seller how many poles the motor had, they said it had 'three'. Not sure if that is a language issue or they don't know the difference between phase and pole. But God knows where they got that voltage range from.

I could not get the motor open, and I didn't want to take a hammer to the shaft to do so. So I left it.

So I swapped the 5V linear regulator out for a buck converter, and just used a multimeter and rotated the motor by hand.

The sensors seemed to work for a buck output voltage of 3.3V. However, curiously the voltage from the Hall sensor was about 4V! Higher than the input.

I was thinking, couldn't I just use 3.3V from the buck converter, and put a 3.3V zener diode across the output to clip it when it get's over 3.3V? (Thus protecting the micro-controller.)


I'll look at uumotor when I get a chance.

Cheers,
Rob
 

itsid

Moderator
Staff member
Messages
11,563
Reaction score
248
Location
Ruhrpott [Germany]
database error..
sales@ would be their email address and uumotor their skype ID (google cache ;))

but taken from their controller pdf (24-60V 2kW)
hall sensor wires, red:+5V, black: GND, yellow, blue and green hall sensor wires.
Usually, the motor hall sensor wires should be connected to them with each color
accordingly

and it not showing a square wave on the scope means to me it's same old same old 0-5V reply.
(well plus base minus loss.. 07-4.2 or so)

you can still ask, but I'm afraid I know the answer already.

'sid
 

toneboy1

New member
Messages
7
Reaction score
0
HI,

so sales@uumotor.com?

Sorry, to clarify: Using the buck converter to supply 5V also seemed to work on the multimeter similar to the 3.3V. However, I didn't try using the buck on the oscilloscope, it may have been a square wave.

One important thing I realised was that I was quite possibly using the linear regulator incorrectly. I forgot to connect the two capacitors across the input and output of the regulator. So maybe it would have had the Halls work on the multimeter too.

I won't get a chance to do any more on this until after Christmas.

Cheers
 
Status
Not open for further replies.
Top