Society of Robots - Robot Forum
Software => Software => Topic started by: fang-wei on June 03, 2007, 03:02:02 PM
-
Hi folks!!
I have a doubt that wanted to share with all of u :D
I have programmed two timers of the microcontroller (ATMEL 128) to obtain two pwm signals to modulate the power of a DC motor.
The thing is that if, in the main programm, if I just set the 2 pwm to a value (set_pwm1(50) , set_pwm2(100) for example) works, and the motor runs wonderfully at that velocity. But, if I want to have different velocities, for example after one minute running with velocity "A" I want it to change to the double the velocity (ste_pwm1(100), set_pwm(200) )
it just run with the same original velocity and doesn't seem to notice that I set other parameters to the timers!!!
The timers are well programmed, because when using the whole time the same velocity it works, but I just don't know why the motor does not change the velocity when I change the settings of the timer (the OCRn value)!!! It's weird!
Could it be that it can not make abrupt changes? :-\
By the way I am not using any interrupt...
mmm I hope I was clear enough... I didn't attach the file because it's just that: set_velocity, wait a minute, change velocity
if needed I could attach it of course.
Thank u for your time guys!
fang-wei
-
do you have an oscilloscope to measure the pwm?
-
Is this your own code?
I am currently using code from orangutan-lib for my PWM (on an AVR based MCU), it uses one timer for the PWM signal to both motors, interrupts are used as comparators. It compiles for the ATmega168, but should be easily portable to the ATmega128. I've used the code to change PWM on the fly, and it works. Maybe you have a coding problem, a motor wiring and/or a motor driver problem (if you have one).
- Rommel
-
Hi!
Thanks for your answers... it works now... it was just some odd port initialization that caused problems ...
Have a good day!!
fang-wei