evilheart
Member level 3
hi guys
i have done a code for software PWM generator , that uses mainly timer1 for timing ,
but instead of generating just one PWM wave , it generates arbitrary number of waves on any pin , each has its own duty cycle , but all of them have the same frequency.
the code was running accurately on proteus , but when i tested the atmega8 on the oscilloscope , the timing wasn't accurate at all!!!!
the duty cycles had good values that are very near to the actual value ,
the problem was the timing itself , the code should give a PWM wave of period 20 ms , but the atmega8 doesn't give that period!!!
it may give a period of 24 , 28 , or even 29 ms , so each time i restart it i get a different period , and all of them are far away from the right value !!!
i am intending to use this code in controlling servo-motors , as servo motors are controlled just by changing the duty cycles from 5 % to 10 %. i think the timing should be very accurate to get accurate results.
also i am intending to use the same atmega8 in UART communication , if the whole chip Timing is missed up , then i may have problems also with the UART !!!!
any one knows what can be the source of this problem ??? crystal ?? the chip ?? maybe the atmega8 is not reliable enough ???
i have done a code for software PWM generator , that uses mainly timer1 for timing ,
but instead of generating just one PWM wave , it generates arbitrary number of waves on any pin , each has its own duty cycle , but all of them have the same frequency.
the code was running accurately on proteus , but when i tested the atmega8 on the oscilloscope , the timing wasn't accurate at all!!!!
the duty cycles had good values that are very near to the actual value ,
the problem was the timing itself , the code should give a PWM wave of period 20 ms , but the atmega8 doesn't give that period!!!
it may give a period of 24 , 28 , or even 29 ms , so each time i restart it i get a different period , and all of them are far away from the right value !!!
i am intending to use this code in controlling servo-motors , as servo motors are controlled just by changing the duty cycles from 5 % to 10 %. i think the timing should be very accurate to get accurate results.
also i am intending to use the same atmega8 in UART communication , if the whole chip Timing is missed up , then i may have problems also with the UART !!!!
any one knows what can be the source of this problem ??? crystal ?? the chip ?? maybe the atmega8 is not reliable enough ???