Can't Calibrate Motor Custom Hardware

Hi there, I have created my own hardware for my application and will provide it to the community once working correctly. It’s all based off v3.5 and copied exactly, I only have a single axis and have added a 24v boost converter and some optocouplers for some of the IO, just to suit my applications better. It’s based off azmatb schematics found here https://github.com/azmat-bilal/bldc_motor_controller_pcb and topic link Custom Odrive PCB

I have flashed the latest binaries and had no luck so I compiled my own binaries with debugging to try to get to the bottom of it. I have attached screenshots of no errors and then the errors I get. Note I can’t get the devel branch to work, it won’t even read the voltage or current sense at all. So I’m using the latest master branch for v3.5-48V ( I have tried 3.4 and 3.6 also with no luck )

I’m out of ideas and don’t know what to look for or try next, the errors don’t give enough details to try and track down where it’s going wrong. When I do the calibration the motor does nothing not a beep or slightest movement. I’m wondering if it’s the type of mosfets i’m using and the DRV8301 can’t drive them, would have thought I would have got a DRV error if that was the case. I don’t think it’s noise as everything looks good on the scope and smooth so far no motors running of course. The encoder is reading fine.

These are the mosfets i’m using https://datasheet.lcsc.com/szlcsc/1912111437_HUAYI-HY4306P_C358108.pdf

I now have the devel branch working and now responds what the DRV Fault is… doing the calibration I get this

(DRV8301_FaultType_FETLC_OC | DRV8301_FaultType_FETHC_OC | DRV8301_FaultType_FETLB_OC | DRV8301_FaultType_FETHB_OC | DRV8301_FaultType_FETLA_OC | DRV8301_FaultType_FETHA_OC | DRV8301_FaultType_OTW | DRV8301_FaultType_OTSD | DRV8301_FaultType_PVDD_UV | DRV8301_FaultType_GVDD_UV | DRV8301_FaultType_GVDD_OV)

I’m getting every possible error which seems odd, does this indicate an issue with the DRV Chip or the type of mosfets i’m using are causing all these errors.

I have now put another board together and identical issue, so I doubt I have 2x faulty DRV8301. I have been reading through the datasheet and I see there and some settings to set the mosfet OC over SPI I’m wondering if the DRV Is having issues with my mosfets and settings need to be adjusted. Does anyone know where to find this in the code or can the be adjusted via python odrive commands?

I have also noticed the Odrive code says I have all these DRV Faults but the actual SPI registers say FALSE as you can see in the attached picture. So could this just be a configuration issue or something incompatible?

I have found out the issue with the DVR faults and it’s a few capacitors which are quite critical I have now found out about after coming across this document. https://www.ti.com/lit/an/slva552/slva552.pdf?ts=1591088046139 Moved 2x capacitors with jumpers and no more DRV Errors.

I can now calibrate the motor fine with no error and everything reports back good and comes back true calibration etc encoder is working well and everything comes back ready to go. If i put it into velocity mode and set a velocity setpoint nothing happens and I get no errors. I get similar with position mode. When I put it into closed loop it will hold position slightly but if I turn it to much it will just stay there and not drive back. If I give it a position setpoint it will not do anything and does not report back any errors. I have tried both the Master and Devel branch and same results.

Does anyone know what could be causing this and what else to try from here?

UPDATE:

The issue I was having seemed to be an issue with the voltage divider and vbus reading wrong. I am using 10k and 510R ( tried with 470R but worse ) I could not find the exact values required on the schematics as they only show 24v version. I found the vbus reading was 1v upto 4v out as I increased the voltage. I have now changed the voltage divider ratio from 19 to 21 and now reading almost spot on ( around 100mv difference from multimeter ) I’m not sure how accurate this has to be. I ran through the calibration process and adjust PIDs and now I can use Position and Velocity Control. Now I’m running into cogging issues at low speeds. The BLDC motor is 4 pole pair so whether this is just the nature of having low pole pair motor. I will now start looking into anti cogging and report back with my findings

UPDATE:

Mucked around with anti-cogging but caused motor to get really hot and was taking over 10 minutes so had to cancel every time. I had issues once I ran the process I could no longer use velocity control etc I then reflashed stm and still same issue, in order to get rid of this problem I had to do full chip erase in ST-Link and then reflash firmware. I then had todo every calibration process again as even loading a saved configuration that had been running previously would not work. So some strange stuff going on there.

I decided I would just continue to muck around with the PIDs some more in Velocity mode since this is what I will end up using with 0-100% PWM Input and direction. The motor has no load on it and encoder is 1800ppr. I can get it quite stable with small vibrations at 0 ( can’t get rid of them at any setting ) in order to get running smooth at 1000 c/s my P = 0.00012 and I = 0.015 and If I bring the Velocity above 50000 c/s it becomes quite unstable and at 300000 c/s it cut’s out on unstable current sometimes. If I drop the I = 0.005 it’s very smooth right upto 500000 but barely rotates 1000 c/s it has large cogging. I can’t seem to find a sweet spot for the PIDs over such a large range.

Is there a way to have the PID values change once velocity is over a certain point or something along those lines. maybe there are some other settings i’m missing that could be adjusted?

UPDATE:

I changed the encoder bandwidth from 1000 to 2000 and that made a massive difference, I no longer get any vibrations with 0 velocity and I can run it from 100 c/s all the way up to 500,000 c/s without it going crazy and staying nice and smooth, great results. I can’t find much info on the encoder bandwidth and what it exactly does, but it does make a huge difference, so if anyone could explain that would be awesome.

Now I need to implement 0-100% PWM upto 10khz. I see in the RC PWM the maximum is 500hz because it is using an interrupt. I’m guessing I would need to access hardware timers/counters in order to implement this. I’m new to embedded programming and only done few small arduino stuff, so if someone could lead me in the right direction or maybe I’m best creating new post for this feature, I have seen it come up a few times, but nothing implemented yet. The reason for 10khz is the frequency the Kflop CNC controller outputs and they recommend not going below this.

3 Likes