Page 1 of 1
Problem with PWM disable
Posted: Thu May 18, 2017 9:42 am
by Zyxcel314
Have to create for a exam a program to allow to a robot to follow a lines. For this program, I used 4 PWM which works by pair for the four wheels. Only, while I try to simulate the program, I have an "impossible" configuration where I have 3 PWM activated. Also, I can't disactivated PWM blocks when I activated two.
Thanks for your help, here is the program and the: ATMEGA328P.
Re: Problem with PWM disable
Posted: Thu May 18, 2017 9:58 am
by Benj
Hello,
Your program doesn't contain any delays and so it looks like the program will loop around at high speed enabling and disabling the PWM. Probably so fast that you think the disable is not working.
Please see this page on finite state machines, they might help you to craft a working program without resorting to using delays.
https://www.flowcode.co.uk/wikiv7/index. ... ateMachine
Re: Problem with PWM disable
Posted: Thu May 18, 2017 10:37 am
by Zyxcel314
Thank you for your response but I try to put delays at different places ( 5ms ) but the problem stay the same. For example, when the program starts PWM 1 and 3 are activated but when I switch on the left captor ( the left switch on the
2D pannel ) the Pwm 2 and 3 are activated but the third PWM doesn't want to be disabled altough everything in the end of the program is made to disable it.
Re: Problem with PWM disable
Posted: Thu May 18, 2017 12:06 pm
by Benj
Hello,
With 5ms delays you will still be struggling to actually see the channel being disabled, I know I can't see things that last only 5ms.
Maybe try slowing things down while you develop the code and replace 5ms with say 5s. The disable is certainly known to work so this hopefully shouldn't be a problem.
Are you using just the simulation or are you also using hardware to test your program?
Re: Problem with PWM disable
Posted: Fri May 19, 2017 11:06 am
by Zyxcel314
Yes, I want put the program into the arduino card of a kind of little car