Society of Robots - Robot Forum
Software => Software => Topic started by: saliraza on April 05, 2009, 05:28:53 PM
-
Hi Everyone,
I am very tired and frustrated after trying many things for simply getting 4 PWM controlled outputs from my Axon. I would really appreciate anyone's help in this regard.
I have been working with microcontrollers, PICS, ATMEGA's, 8051 etc etc ..... I love Axon, but here is my problem:
I just need to get 4 PWM individual outputs from my Axon. The code I am using is provided below;
PWM_Init_timer2_H6(8);//9 doesn't work
delay_ms(100);
PWM_Init_timer3_E3(8);
delay_ms(100);
PWM_Init_timer3_E4(8);
delay_ms(100);
PWM_Init_timer3_E5(8);
delay_ms(100);
PWM_timer2_On_H6();
PWM_timer3_On_E3();
PWM_timer3_On_E4();
PWM_timer3_On_E5();
delay_ms(1000);
PWM_timer2_Set_H6(127);
PWM_timer3_Set_E3(127);
PWM_timer3_Set_E4(127);
PWM_timer3_Set_E5(127);
delay_ms(5000);
PWM_timer2_Set_H6(254);
PWM_timer3_Set_E3(254);
PWM_timer3_Set_E4(254);
PWM_timer3_Set_E5(254);
delay_ms(5000);
PWM_timer2_Set_H6(127);
PWM_timer3_Set_E3(127);
PWM_timer3_Set_E4(127);
PWM_timer3_Set_E5(127);
delay_ms(5000);
PWM_timer2_Set_H6(191);
PWM_timer3_Set_E3(191);
PWM_timer3_Set_E4(191);
PWM_timer3_Set_E5(191);
delay_ms(9000);
PWM_timer2_Off_H6();
PWM_timer3_Off_E3();
PWM_timer3_Off_E4();
PWM_timer3_Off_E5();
delay_ms(1000);
THE PROBLEM:
Only H6 is doing what its suppose to ..... E3,E4, and E5 are simply dead not doing anything....... Why why why???? :?( Please Help ..... Admin ????
Please do not recommend me the Tutorial, or the basic links available on the SoR, I have already tried several of these and NO RESULTS ..... I just wanted to know why the code above is not working and what is wrong with it.
Regards,
Ali
-
PWM on the E port only works with the latest code version. I am guessing you are using the old code version?
-
Thanks for the reply Admin,
I am able to use other PWM ports and to get them working I had to change the timer prescale settings in timer640.h as such:
#define TIMER0PRESCALE TIMER_CLK_DIV1024 ///< timer 0 prescaler default//original was TIMER_CLK_DIV8
#define TIMER1PRESCALE TIMER_CLK_DIV64 ///< timer 1 prescaler default
#define TIMER2PRESCALE TIMERRTC_CLK_DIV64 ///< timer 2 prescaler default
#define TIMER3PRESCALE TIMERRTC_CLK_DIV8 ///< timer 3 prescaler default
#define TIMER4PRESCALE TIMERRTC_CLK_DIV8 ///< timer 4 prescaler default
#define TIMER5PRESCALE TIMER_CLK_DIV64 ///< timer 4 prescaler default
if you notice i changed the timer 3 and 4 prescale to use TIMERRTC_CLK_DIV8 instead of original values such as used with timer5 .... now all the PWM channes work fine E3,E4,E5,H3,H4,H5, and H6.
I am now working to do proper scaling of the Accelerometers and Gyro measurement. I am posting a new topic please help me there.
Regards,
Ali