Society of Robots - Robot Forum
Electronics => Electronics => Topic started by: Hanoush on March 23, 2009, 04:43:28 AM
-
it appears that delay_ms() doesn't work when I use v1.05 but it works when I use version v1.01 but Now I need to use PWM which is on v1.05.
any ideas ?
void Motor(void);
void control(void)
{
Motor();
//axon_DAQ();//activate the DAQ software (data acquisition)
}
void Motor(void)
{
rprintf("Initializing timer4 for PWM\r\n");
//PWM_Init_timer2_H6(10);
PWM_Init_timer4_H3(10);
rprintf("Turning on both PWM channels\r\n");
//PWM_timer2_On_H6();
PWM_timer4_On_H3();
delay_ms(1000);
rprintf("Setting PWM to 1%% duty cycle Warming Motor up\r\n");
//PWM_timer2_Set_H6(0);
PWM_timer4_Set_H3(0);
delay_ms(6000);
rprintf("Setting PWM to 100%% duty cycle Warming Motor up\r\n");
//PWM_timer2_Set_H6(255);
PWM_timer4_Set_H3(1023);
delay_ms(6000);
rprintf("Setting PWM to 1%% duty cycle\r\n");
//PWM_timer2_Set_H6(1);
PWM_timer4_Set_H3(1);
delay_ms(5000);
rprintf("Setting PWM to 12.5%% duty cycle\r\n");
//PWM_timer2_Set_H6(127);
PWM_timer4_Set_H3(127);
delay_ms(5000);
rprintf("Setting PWM to 25%% duty cycle\r\n");
//PWM_timer2_Set_H6(254);
PWM_timer4_Set_H3(254);
delay_ms(5000);
rprintf("Setting PWM to 50%% duty cycle\r\n");
//PWM_timer2_Set_H6(254);
PWM_timer4_Set_H3(512);
delay_ms(5000);
rprintf("Setting PWM to 99%% duty cycle\r\n");
//PWM_timer2_Set_H6(254);
PWM_timer4_Set_H3(1023);
delay_ms(5000);
rprintf("Turning off PWM\r\n");
//PWM_timer2_Off_H6();
PWM_timer4_Off_H3();
delay_ms(1000);
}
-
What doesnt work? What happens?
???
-
it just stops running when it have to excute delay_ms().
and when I replaced delay_ms() with a for loop
for(i=0;i<1000;i++)
{
delay_cycles(1000);
}
it works fine for a while but for a sudden the Axon starts to print "warming up" a lot on the hyperterminal.
Please help because I am building a Quadcopter and I can't have unstable system on it.
-
i dont think axon will be a suitable processor for a quadcopter....u need a processor with atleast 50mhz speed to make any kinda UAV to hndle flight and all the gps data and all...
-
Well,I am thinking to use copilot that will help me to make the quadcopter stable when it isn't recieving any signal and that will save me alot of processing time if I will use gyroscopes and kalman filter or fuzzy logic control for it.
so,Axon will only control the motors,read ultrasonic sensors and take coordinates from the GPS.
Do you think that will work ?
-
Very possible, see here:
http://www.mikrokopter.de/ucwiki/en/MikroKopter (http://www.mikrokopter.de/ucwiki/en/MikroKopter)
They are using a 644 at 20mhz.
-
I am thinking to try out the Arduino Duemilanove and see if it is more stable than the Axon.It is based on ATMEGA 328 20MHZ. I already got one but never used it. anyone used it before ?
-
delay_ms() with all Axon code versions works perfectly fine for me . . . there is something else you aren't doing right . . .
-
I thought I do ,but Axon works perfectly when I use v1.01 but I want to use PWM with higher resolution and when I used the PWM code that you posted on the website, it ddin't work altough it worked once on my old Axon but I was using brushed motors but it is the same I think. Please tell me what could have gone wrong ?
-
Did you overwrite *all* files with the v1.05 version, including the make file?
When you say it didn't work, you mean you ran this code:
delay_ms(10000);
And it didn't actually delay?
Did you turn optimization on? (it only works when it is turned off)
-
Yes when I use it,Axon freezes or start to reset and print "Warming up".
Where do you turn optimization on and off ? I don't remember changing anything.
-
Run a much simpler program that doesn't involve motor(). And just rprintf before and after a delay. See what the output is.
rprintf()
delay_ms()
rprintf()
Also, are you sure your battery is fully charged?
-
I tried but didn't work also on v1.05 :@ and I was using a power supply. A friend of mine have an Axon,I will try to use his axon on my code and see what will happen.
-
and I was using a power supply.
What is this power supply rated at? Is it also powering your motors?
-
7.2V and let the Axon take its current and it work perfectly when I use v1.01 and for the motors I use 9.6V 1600mah battery.
and sometimes I switch and use the power supply for the motors because it worls better when i increase the current and The 9.6V battery for the Axon.
-
I know this thread is kinda old, but I thought I'd post after something similar happened to me. I don't know why version 1.01 works and 1.05 doesn't, but it looks like you are missing initializing the timer for delay_ms().
If you add a "timer0Init();" function call to the start of you app, the delay_ms should work.
-
thanks luke! I was having this problem also and didn't know I had to initialize timers!