Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Motor over current protection handling in microcontroller

Status
Not open for further replies.

Ranbeer Singh

Full Member level 5
Joined
Jul 30, 2015
Messages
259
Helped
22
Reputation
44
Reaction score
22
Trophy points
1,298
Location
Faridabad India
Activity points
3,266
Hello

I was tring to make over current protection codes in microcontroller.

Code:
while(1){
          if(Current_ADC>2.0) PWM_On_Time = 0;
          else{ PWM_On_Time = ADC_Value/4.031;}
          }

When Current_ADC value reach more than 2.0 it will make PWM_On_Time = 0 and Current_ADC will be 0 also. In second loop Current_ADC will be less than 2.0 because at this time motor is in off mode. So it will go in else condition and will ON to motor again. Thus it will do like ON-OFF-ON-OFF-ON-OFF (motor will sound like ghid ghid ghid.....).
Motor will vibrate at this condition. how can i avoid to this error?

I am thinking a solution by reducing PWM_On_Time value one by one at list current more then 2.0A. But it will go again in else condition and motor will vibrate too.
 

Good work, man, you made a comparator. :thumbsup:
Such things newer being done on mcu. Only h/w logic allowed.
 

Thank you.....But it not matching with my rearguard condition. I was work on it yesterday and found that my motor was vibrating rapidly. I want to reduce vibrating will such a good work.
 

If you expecting for real help, you have to provide all the information - schematics, source codes, datasheets for components and e.t.c.
Otherwise discussion will be only the general. And useless.
 

You are right. A sequence of on-off-on-off is not a nice thing for a motor.

I do not know what you want to do, but I would have done if(Current_ADC>2.0) PWM_On_Time = 0.9*PWM_On_Time;

If current is high, supply less power but do not turn off immediately.
 

Hi,

C_mitra´s solution is much better.

To further improve this you could
* 0..1.8: 100% of expected PWM_ON_TIME
* 1.8 ...2.0: (100% down to 0% of expected value) Mathematically: (2 - Current_ADC) * PWM_ON_TIME / 0.2

from 0 to 1.8: nothing happens.
but from 1.8 to 2.0 it lowers PWM (= voltage) to theoretically 0V.

But you should carefully test this solution, because it is a regulation loop. It may tend to oscillations... depending on loop gain and phase margin (caused by loop delay)


Klaus
 

Considering that you are already measuring instantaneous current, why not think about implement some kind of PID control ? Although C_mitra suggestion is nicely easy to code and results could be satisfactory, it's based on a specific threshold value.
 
Thanks to all for advice

I tried every possible fundamental except PID. H-bridge chip limit is 3.5A. when current reach above to 3.5A chip internal logic stop output before my logic. When my loop come back to check ADC value he find the current is less to setpoint (2.0) or he found more current 1-2 time what will be fine to it.
Please see graph image and suggest to me any possibility.

https://obrazki.elektroda.pl/3125344500_1456548417.png
 

Hi,

This is close to what I described.

You see the lower chart current limit is not just reacting on the 2.0A limit, but it works in the range of 1.8A ... 2.0A.

In any case: the current influences the pwm value, the pwm value the voltage, the voltage the current...and this closes the loop.
Therefore you need known stable operation parameters.
* a known time constant of the analog current signal (maybe controlled by an additional LPF)
* a known and fixed ADC sample rate (i recommend it to synchronize it to the PWM frequency)
* maybe digital filtering
* overcurrent calculation and PWM calculation for every PWM value
* and a fixed PWM

All this helps to get a stable current limit regulation.

Klaus
 
Hi,

You want to say i should use algorithm like PID.
I never said this. But for sure a PID will give a stable solution..as long as you take care of stable loop parameters.

***
I gave you an example of a solution. It is a purely "P" = proportional solution.
It is just two lines of code:
* IF current >1.8
* {THEN ... the given formula}

***
You may use my solution or any other solution. There are a lot of others.
But with all you have to take care of loop stability to avoid oscillations.

Klaus
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top