Ali,
I am certainly not the expert, but I recently set up my AXON board to control two servos.
It takes 1 (ONE) timer channel to get my two PWM signals out to servos. Some of the timers can do 3 PWM signals I beleive and some can only do one on these boards. Read more in the
So, with code like this:
PWM_Init_timer3_E3(10);
PWM_Init_timer3_E4(10);
delay_ms(50);
PWM_timer3_On_E3();
PWM_timer3_On_E4();
delay_ms(50);
PWM_timer3_Set_E3(SERVO_CENTER);
PWM_timer3_Set_E4(SERVO_CENTER);
delay_ms(50);
I have set up two different PINS to have separate PWM signals through one timer and one interrupt. I have also centered the servos with a default value.
Then, this code:
void go_forward(void)
{
PWM_timer3_Set_E3(SERVO_CENTER-SERVO_FULL_SPEED);
PWM_timer3_Set_E4(SERVO_CENTER+SERVO_FULL_SPEED);
}
Is what I use for a set-and-forget forward motion. I have a similar one for stop and backward.
This is basically what you need to do but you'll need to use 2 timers I believe with the four independent signals spread across them.
This is a comment section from timer640.c
/*
ATmega640: Four 8-bit PWM Channels, Six/Twelve PWM
Channels with Programmable Resolution from 2 to 16 Bits
PWM pins on Axon:
OC0A B7 (not connected)
OC0B G5 (attached to button)
OC1A B5 (not connected)
OC1B B6 (attached to green LED)
OC1C B7 (not connected)
OC2A B4 (not connected)
OC2B H6
OC3A E3
OC3B E4
OC3C E5
OC4A H3
OC4B H4
OC4C H5
OC5A L3 (not connected)
OC5B L4 (not connected)
OC5C L5 (not connected)
explanations:
http://www.societyofrobots.com/robotforum/index.php?topic=1827.0http://www.societyofrobots.com/robotforum/index.php?topic=5590.0If you use this, then you cannot use the associated timers for other things.
H6 uses timer2
E3-5 uses timer3
H3-5 uses timer4
Unfortunately, the 3 pins that use timer5 are not connected on the Axon board, so they are
not available for PWM. The upside is that timer5 is available for other use without interference.
*/
Hopefully this helps.
Doug