Getting back to my running BLDC, I looked at the timing of the hi and low drivers, it is amazing that thing is spinning around the way the signals are out of alignment, so I would like to get the timing in order so that it may run top efficient.
This is the hand made timing diagram of the hi and low of the three half bridges:
I notice that the B-hi and B-low are both 1.5ms in duration, whereas A and C are both 1.1ms, so why the h... is that? Is that a misalignment of one hall sensor?
Otherwise ABC-low signals are all over the place, I can't see any pattern in it that would give a hint to what the problem might be.
The controller is implemented with a PIC 16F1933 and the code is adapted from AN857 Brushless DC Motor Control Made Easy (yeah right ...'easy'... however the free running Timer0 is a masterpiece, but annoying - I would prefer to do it with interrupts, but I need to get the timing right first)
Come to think of it, maybe this is more suitable for the microcontroller department? It doesn't seem to be a peripheral hardware issue as the timing signals are written to the port all at the same time (one byte)? So where can I request this thread to be moved to the microcontroller department?
To verify the problem you should include the halll signals into your diagram. With the exact timing relation to the power bridge control signals.
I assume the brige signals are symmetric with 120° phase shift.
But maybe the hall signals are distorted by the power signals. This may lead to wrong readings at the microcontroller input and thus it may lead to wrong microcontroller output signals.
But maybe the hall signals are distorted by the power signals. This may lead to wrong readings at the microcontroller input and thus it may lead to wrong microcontroller output signals.
Klaus
That´s how it should be, but your scope picture shows smething different.
The timing is awful. Cheap motor? If you can´t adjust the hall signals, then you can´t expect higher quality signal output from microcontroller unless you put a lot of effort in the software.
All the signals should be 50% duty cycle. And 120° phase shifted.
******
righteous:
I would need a logic analyzer for that, but here's a scope shot of the hall signals at the input pins of the MCU
No, you don´t need a logic analyzer to add some signals to your hand drawn diagram.
For timing alignment you just need to refer to the timing of one signal that already is in your diagram.
A two channel scope is sufficient. For sure a 4 channel one is better.
The timing is awful. Cheap motor? If you can´t adjust the hall signals, then you can´t expect higher quality signal output from microcontroller unless you put a lot of effort in the software.
All the signals should be 50% duty cycle. And 120° phase shifted.
No, quality-ish motor without sensors. So I had to glue 3 hall sensors in place, but when the epoxy had set, I noticed one sensor was 1-2% misaligned, but that shouldn't cause such a big difference.
I have attached the code at the bottom.
How many green lines is 120° in your annotated scope shot?
You see there are 6 from falling_yellow_edge to next falling_yellow_edge.
360° / 6 = 60°
two green lines = 120°
falling_yellow_edge --> 2 green lines later (120°) --> falling_cyan_edge --> 2 green lines later (120°) --> falling_magenta_edge --> 2 green lines later (120°) --> falling_yellow_edge ...
OK, here it is, please note that hi-side FET's are ACTIVE LOW:
ch1: A-hall ch2: B-hall ch3: C-hall ch4: A-hi FET (see hand drawn timing diagram)
ch1: A-hall ch2: B-hall ch3: C-hall ch4: B-hi FET (see hand drawn timing diagram)
ch1: A-hall ch2: B-hall ch3: C-hall ch4: C-hi FET (see hand drawn timing diagram)
all your pictures show:
* fast reaction from hall_falling_edge to bridge_rising_edge.
* but relatively long from hall_rising_edge to bridge_falling_edge.
(this may be intended, I don´t know)
But really weird is that the duty cycle of bridge_Ch:B is different from the others.
I don´t think it´s because of the hall signals, I rather think there is a software problem.
The port (half-bridge FET's) is only written to once (Line 110 in the source file) in each loop (Line 97 in the source file) , therefore logic dictates that there should be no difference in X-hi and X-lo as they are outputted at the same time, but yet there is....!
The only reason I can see that could cause this is; when the sensor reading changes, the FET's period (be it on or off) is extended or cut short with the next sensor reading (Line 124-125 in the source file) e.g. B-low in phase 6 4 5 and 3, C-hi in phase 6 4 and 5, or B-hi in phase 4 and 5.
EDIT: This guy could be on to something: "The look-up table is registered with the PWM edge to avoid transitions from happening in the middle of a PWM cycle" see Controlling a brushless motor (BLDC): Software
Ref. Table 2 Page 4 in "AN857 Brushless DC Motor Control Made Easy"
Well, I don't know either, so I rewrote the code with interrupts and it runs better, but still not as good as it could be. So far I managed to get the ON period of B-hi to be active in phase 5 but not phase 4....
I finally made it work, there were two minor problems. The first being that my hall sensors were glued in a bit off sync, so I redid those. Then there were some software bugs, which are now debugged.
I feel grateful for the help I have received in this forum so I will make the BLDC Controller code freely available here for any edaboard users
;------------------------------------------------------------------------------
; April 08 2018 BLDC Controller by righteous @ edaboard.com
;
; Based on Microchip's "AN857 Brushless DC Motor Control Made Easy"
;
; * Simplified, modernised and fully MPLAB relocatable
; * Interrupt based
; * Works with any PIC with following requirements
; - 3 digital input pins with IOC (Interrupt On Change) for Hall sensors
; - 6 digital ouput pins for 3 half-bridge drivers
;------------------------------------------------------------------------------