I am making a washing machine by controlling motor speed using H-Bridge . The signals to H-Bridge's MOSFETs are controlled by a micro controller PICAXE 14M2.
The Motor is coupled with a generator and a bucket that takes the load. Default duty cycle is 25% . At 50% motor stops and greater than 50% the rotation of motor changes.
Now, what I want to do is , When load is added to the bucket the motor should maintain its speed and in order to maintain the speed I want to control the duty cycle.
So, if load increases, resistance to motor increases, which means bucket should slow down, making generator to produce less voltage .
Now, I need to increase the duty cycle, so motor increases the speed to catch up with the default value.
Unfortunately, I am unable to perform the close loop function . Can anyone please help me out ....
PS. I am using two 12V DC motors. One acting as motor to rotate the bucket (which is also coupled with other motor) and other motor is acting as generator to get the feedback
Thanks.
I am using the following code:
setfreq M32 ' 100 kHz Frequency
main:
if pinB.5 = 1 then goto Closeloop
goto main
***************************************************************************
Closeloop:
symbol duty = b2
let duty = 79
gosub closeloop1
closeloop1:
for b11 = 1 to 100
hpwm 1,0,0,79,duty
readadc C.4, b22 ` Read generated voltage from pin C.4
IF b22 > 204 then gosub stepdown 'if Generated voltage > 4 V , stepdown the duty cycle
IF b22 < 153 then gosub stepup 'if V< 3 V, stepup the duty cycle
stepup: ` Increase the duty (So speed is increased) if gernerated voltage is less than 3V
duty = duty - 5
goto closeloop1
stepdown: ` Decrease the duty (So speed is reduced) if gernerated voltage is more than 4V
duty = duty + 5
goto closeloop1
next b11