Weird current pattern

Hi

I realize that I reported on a burried topic.

I use a know good hardware from a Onewheel gyro, before modify it , it was ok , motor was smooth and quiet (no noise).

after struggling with simplefoc , with my simple brain, I successfully got a spinning wheel… good.

but , what a noise! god!

let’s have look on one phase current …

you got it? yes … it isn’t a sinusoid… that’s weird

the setup is complete, I mean, with current sensor (low side). And the shunt is … Drain to Source , so almost 10mR.

at the begining I believed that ADC was triggered without blanking after commutation, but even if I remove current sensor from software… it is the same result.

… my question is…. is there a way to generate waveforms “bareback” … just to see…

thx

It’s an oddly clean waveform for something not right. The only thing I can think to check is that you have the motor pole pairs set right (half the total number of rotor magnets).

Open loop mode generates voltage waveforms. It can be helpful to run that and plot out the measured current waveforms to see how closely they match. I got different waveforms at each speed when I did it. Not sure what to make of that. Gooser: a 4-in-1 Lepton derivative - #94 by dekutree64

thx for your time,

waveform is clean because it is current clamp for a brand compagny (Tektronix) and a good scope.

I’ll try open loop mode (if I found how to settle it) tomorrow .

according pole pair, it should be could because the monotor return PP-check OK!

I ll probably open it to have a confirmation.

bye

The reason for the non sinusoidal current waveform could also be because the motor is wound with trapezoidal Back EMF, while usually FOC works with sinusoidal Back EMF. To check, measure the voltage of the motor while spinning it by hand or with another motor / drill.

Another reason could be dead time from the half bridge causing PWM duty cycle distortion, or because the current PIDs are not tuned correctly.

When I measure the current from my motors I also get some not very sinusoidal looking current waveforms (although a different shape than you are getting), but the motor still spins fine. I’ve taken some screenshots with my motor (Robomaster M3508) with my driver running custom firmware so you can compare. Pink signal is the current, yellow and green are encoder signals.

Unfortunately I don’t have any good ideas on how to improve the waveform shape.

To check, measure the voltage of the motor while spinning it by hand or with another motor / drill.

the curves bellow are for : a phase acts for a reference for the two scope channel.

as you can see, spinned by hand at around 1 to 1.5 revolution bby second, voltage generated are close to a sinus .

after that I used a small RC filter 10K 100nF to remove HF signal and extract Voltage from a phase…

and of course it isn’t voltage that see a phase because probr was referenced to gnd on the driver’s board…

.. but,… wow.. it isn’t a sinus even if I make an effort…

what’s wrong?

I must add that I also used BLDCDriver6PWM standalone with

driver.setPwm(x,y,z);

to check voltage of each output, and it works well (I used the scope computation RMS voltage for square waveform)

I also checked the wiring by analysis : it is a star wired, each winding is R=0.25 ohm and L= 6mH.

by using the example in library folder, I was able to find KV for this motor => 1 or something close.

the Onewheel device embeded battery is 60V … (quite high!)

The filtered voltage waveform looks a little nasty. It isn’t always going to be a sine wave, because of SVPWM. So you would expect to see one of these waveforms if you are using SVPWM instead of Sine PWM:

From your provided waveform it appears you are using SinePWM, it’s just distorted.

I have noticed in your screenshot of your filtered waveform that the phase voltage seems to rise compared to a perfect sine wave when the current is positive, and fall when the current is negative. I think this points towards a high wiring resistance, or a too long dead time.

Could you measure the supply rails on the input of the driver board while the motor is running, as well as the output voltage without the filter, showing a single PWM cycle? This way we can check for any unusual voltage drops, and check whether the distortion is caused by the dead time.

Another theory is that the position sensor is not very accurate, so the inaccuracies cause the FOC computations to be off, resulting in weird current shapes.

Hey @iso14000,

I love onewheels, I’ve used to have one for a couple of years, but it got stolen :smiley:

Can you tell us a bit more about your setup?
What is the driver you’re using, I suppose it’s not the original onewheel driver?

Where are you measuring this current, it looks more like the power supply current than the phase current… :face_with_monocle:
Of is it the current measured across the low-side shunt (plus some filtering) ?

If you’re really motivated you could take one of your 10mOhm resistors and put it in series with one of the phases of the motor and measure the current directly on it.

Hi Andrew , Hi Antun , all
thx for you interest, regardfullness, and work…

@Antun… funny, I studied microelectronics at IXL lab … 30y ago… almost neighbour

OK, then, this topic is spin off from this one => Is it possible to use inverted low input with simple foc? - #26 by iso14000

I played a few month ago with the almost “out of the box” software from M. Feru (and others) for hoverboard… it was fun and wanted to dive a little more on this fascinating project…

I’m an electronics, and of course bad in C and worst in C++.

The actual hardware is 99% genuine from a onewheel (buyed on a famous french peer to peer plateform for a ridiculous price)
I’m sure the hardware is working, because before tinkering with it, the device was working OK, quietly .. do for me it is a good starting point.

After struggling with some code , I ‘ve got a wheel spinning , noisy.. good

What is the driver you’re using, I suppose it’s not the original onewheel driver?

on the contrary… it is the genuine one!

Where are you measuring this current, it looks more like the power supply current than the phase current… :face_with_monocle:

the current is measured with a current clamp (green), on the same branch that provides voltage (yellow).

Of is it the current measured across the low-side shunt (plus some filtering) ?

there is no shunt on this board, current is measured across Mosfet Drain to source voltage and added to an offset , and finally a small gain is applied.

The only shunt available was a 3.5 mR , but the latter make a sum of all three branchs current, I guess it is used as an emergency stop in case of catastrophic failure. Actually this shunt is deactivated becasue library doesn’t handle it (afaik) .

f you’re really motivated you could take one of your 10mOhm resistors and put it in series with one of the phases of the motor and measure the current directly on it.

my probe do that nicely :slight_smile:

I have noticed in your screenshot of your filtered waveform that the phase voltage seems to rise compared to a perfect sine wave when the current is positive, and fall when the current is negative. I think this points towards a high wiring resistance, or a too long dead time.

wiring is the genuine one, far from perfection of course, but it is very short, I have to remove my hand from the mouse to not be injured by the wheel when it starts spinning.

Could you measure the supply rails on the input of the driver board while the motor is running, as well as the output voltage without the filter, showing a single PWM cycle? This way we can check for any unusual voltage drops, and check whether the distortion is caused by the dead time.

I will , so with sweep time about 10xf0 (here f0 is around 20Khz)

Another theory is that the position sensor is not very accurate, so the inaccuracies cause the FOC computations to be off, resulting in weird current shapes.

as I said, hardware is 99% genuine, (emergency shunt deactivated)

thx for your advices

OK great!

Haha mine was stolen in Bordeaux. So you might it might be the same one :smiley:

I’m wondering what is the actual hardware of the onewheel is a stm32 chip or something more exotic?
What PWM drivers/mosfets do they use?

If I remeber correctly the onewheel motor was controlled using the 6 step commutation (when I was riding on low-speeds I remember the jumps from one step to another). So depending on it’s winding the current waveform could be pretty non-sinusoidal :smiley:
And if the mosfets are dimensioned for the six-step modulation they might have long rize times and that could even more impact the overall performance.

You might try running a trapezoidal commutation with simplefoc instead the sinusoidal.

motor.foc_modulation = FOCModulationType::Trapezoid_120;

Additionally you could play a bit with the dead-time, I imagine you’re using hte 6pwm modualtion.

dirver.dead_zone = 0.02;  // by default it's 2% of the duty cycle (1 = 100%)

And the PWM frequency

driver.pwm_frequency = 25000; // by default it's 25kHz for stm32

so to give a answer :

herebelow in yellow, a phase filtered output , in blue the power rail for driver (drain for H side mosfets) and in green current in the phase.

and with a different timesweep , blue trace is now the half bridge middle point (phase voltage without filter )

@Antun_Skuric : the board is well dipected on the link above : “true” STM32F103C8T6 , no gate driver but a discrete transistor based (I can share the reverse if required) driver.

Mosfets are P75NF75 from ST (cocorico!) , an old reference (almost 20Y) but for these times it ‘ve got a good figure of merit.

If I recompile with trapezoidal option… the system is turning wild, it doesn’t even align!..

I do use the 6PWM engine, yes

OK sorry, did not look into the other thread.

You’re using the closed loop right?
If you’re using the hall-sensors, you’re effectively limited to the 6-step anyway.
No need to try the trapezoidal modulation.

Could you try the open-loop and show the currents. The open-loop should create near perfectly sinousoidal voltage and we will see what is the current profile.

yes and… no.

I explain, I’m clumsy, and because I have a small habit in power electronics, I don’t want to connect a battery to my setup. So I use a PSU with a limited amount of power (where a battery can deliver a huge energy in a small time leading to … component explosion).

So.. because my motor has KV~1 , and a very small resistance (above caracteristics are R=0.25omh, star wiring) I have to set driver.voltage_limit = 5 . otherwise , my PSU will limit the current, then the power, then setup behavior is catastrophic.

nevertheless, I did the test you asked me sir.. because I’m a total newbee and full of respect for your team (cirage de pompes :-)> )

the voltage RMS requested is so low… that PWM resolution isn’t enough deep to have a sine .. I think.

green phase current, yellow phase voltage filtered, blue not connected.

the driver supply was 30V.

Looks like there’s a lot of jumps in the waveform which isn’t due to PWM resolution, because that would show up as discrete levels and not huge sudden jumps. Maybe try probing output of MCU to MOSFET driver input, to see whether signal is distorted coming out of MCU or only on the motor phases, and whether the driver is the cause of the signal distortion. Do one measurement with the filter, and another zoomed in on one PWM cycle without filter.

I must be crazy…

BLDCMotor motor = BLDCMotor(polePairs,0.25,1.00,NOT_SET);
BLDCDriver6PWM driver = BLDCDriver6PWM(PA8, PB13, PA9, PB14, PA10, PB15, NOT_SET);

driver.pwm_frequency = 15000;
  // power supply voltage [V]
  driver.voltage_power_supply = 20;
  // Max DC voltage allowed - default voltage_power_supply
  driver.voltage_limit = 5; <= very low phase resistance... remember!
  // dead_zone [0,1] - default 0.02f - 2%
  driver.dead_zone = 0.01f;

/ set motion control loop to be used
  motor.torque_controller = TorqueControlType::voltage;

   motor.controller = MotionControlType::velocity;
  motor.foc_modulation=FOCModulationType::SinePWM;

 motor.target = 5; //

at the begining, motor was only humming, then I spin it by hand, and yes… it spins

but I can stop it , and by hand on the reverse way, it spins at the opposite target!!!

same thing if I change “velocity” to “torque”…

my global feeling about all that is ..

if I stay in voltage and not in dc_current or foc_current , things are quiet good.. not perfect , but good.

so I ding a little further into current sensing,

here bellow is the Phase voltage and its current measurment output , ready to be converted by ADC.

yellow : phase voltage

blue : voltage , itself a conversion from current across low side mosfet Rdson.

my question is…. where it is sampled? because , of course the sampling time must be slightly delayed according high to low mosfet switching, AND an extra time for blanking…

my concern is , if current is sampled a little too close from transition…

the above voltage for current to voltage amplifier is around 1.5V, meaning, if my expectation are good , the low side mosfet is actually switching almost 10A…

if sampling is done, before the plateau, too close from swithing.. the voltage is 2V, leading to a revert current up to 40A!!

herebelow a small simulation for the actual current to voltage circuitry , sampled by STM32.

plot is transfert function

when low side Mosfet is off and, worst case, hidh side mosfet on , the opamp voltage is pushed to positive supply rail (or highest possible by opamp technology) . embeded opamp isn’t the best one so far, it is stuck to ~2V (see above real plots)

I have a feeling that your LTSpice schematic is wrong, because that circuit isn’t using the opamp in a sensible way, and the simulation results show a gain of less than 1 which is very unusual (typical gain would be in 10 to 100 range)

HI , an eagleye right? :saluting_face:

of course, my mistake, R3 wasn’t correctly connected.

it is better now and look like a almost standard non inverter amp.

gain is quite low, opamp is about 3.2, and lowered by the offset circuitry, by simulation ~2.7

so 1A step is converteded to 2.7x0.01 => 27mV

back on the lab to chase the bug…

ok then…

I removed any form of current sense in configuration . My goal is to have a check on voltage pattern , I also remove automatic sensor alignement procedure (I know it is CW)

following my settings

 TorqueControlType::voltage; //voltage  dc_current foc_current 
 MotionControlType::velocity; //torque velocity angle velocity_openloop angle_openloop  
FOCModulationType::SinePWM; // SinePWM  SpaceVectorPWM Trapezoid_120 Trapezoid_150 

modulation is far from sinusoidal :

rich in harmonics, that’s why motor is so noisy…

do you have a clue?

Hi @iso14000,

could this be an issue with the rise time of the driver which might be long?
It could also be an issue with our dead-time injected into the low-side PWM. By default it’s 2% of the duty cycle, if I’m not mistaking. You could try reducing it to 1% or less.

driver.dead_zone = 0.01; // 1%