Society of Robots - Robot Forum

Software => Software => Topic started by: ukesh on August 06, 2009, 09:54:19 AM

Title: Program Compilation Error
Post by: ukesh on August 06, 2009, 09:54:19 AM
I'm writing a program to create an pulsing effect by using the led in axon mcu. The following, is the code in the control.c file.

Code: [Select]
void control(void)
{
ledpulse();
}
void ledpulse(void)
{
int i;
PWM_Init_timer1_LED(8);
PWM_timer1_On_LED();
while(1)
{
for(i=110;i<255;i++)
{
PWM_timer1_Set_LED(i);
delay_ms(10);//control pulse speed
}
for(i=255;i>110;i--)
{
PWM_timer1_Set_LED(i);
delay_ms(10);//control pulse speed
}
}
}

I have not changed anything in the Axon.c file. I've changed the target name in the makefile. I get the following error.
Title: Re: Program Compilation Error
Post by: wil.hamilton on August 06, 2009, 01:50:42 PM
it looks like you didn't include a header file for the PWM functions, its saying that those aren't defined anywhere
Title: Re: Program Compilation Error
Post by: ukesh on August 07, 2009, 05:24:40 AM
it looks like you didn't include a header file for the PWM functions, its saying that those aren't defined anywhere
were can i find the header file for PWM functions? and where do i include the header file?
Title: Re: Program Compilation Error
Post by: wil.hamilton on August 07, 2009, 06:41:42 PM
i dont know what file the axon one is in, but to include it you would do something like
Code: [Select]
#include "pwm_file_name.h"

this should go at the top of your code
Title: Re: Program Compilation Error
Post by: ukesh on August 08, 2009, 06:21:32 AM
i dont know what file the axon one is in, but to include it you would do something like
Code: [Select]
#include "pwm_file_name.h"

this should go at the top of your code

oh okie man, thanks.

can any users of axon guide me on finding the header file for pwm functions??
Title: Re: Program Compilation Error
Post by: Admin on August 09, 2009, 07:03:00 PM
Its in timer640.c

http://www.societyofrobots.com/axon/axon_function_list.shtml#pwm
Title: Re: Program Compilation Error
Post by: ukesh on August 10, 2009, 05:04:35 AM
Its in timer640.c

http://www.societyofrobots.com/axon/axon_function_list.shtml#pwm
Do i need to add the header file timer640.h in the axon.c file ?
Title: Re: Program Compilation Error
Post by: Admin on August 10, 2009, 06:40:40 AM
Its in timer640.c

http://www.societyofrobots.com/axon/axon_function_list.shtml#pwm
Do i need to add the header file timer640.h in the axon.c file ?
It should already be there.

What code version are you using? This doesn't work on earlier code versions.
Title: Re: Program Compilation Error
Post by: ukesh on August 10, 2009, 06:44:40 AM
Its in timer640.c

http://www.societyofrobots.com/axon/axon_function_list.shtml#pwm
Do i need to add the header file timer640.h in the axon.c file ?
It should already be there.

What code version are you using? This doesn't work on earlier code versions.

no admin, i tried adding the header file timer640.h and still i get the same error. I'm using version 1.08.
Title: Re: Program Compilation Error
Post by: Admin on August 10, 2009, 06:49:26 AM
ok I'll look into it tonight
Title: Re: Program Compilation Error
Post by: Admin on August 10, 2009, 07:25:14 PM
ok so it appears it got broken when the PWM file was entirely rewritten . . .

Until I fix it, just add this code at the top of control.c, right after the variables are called, and it should work. It compiled fine for me, but I didn't test to see if it worked.

Code: [Select]

#ifndef PWM10
// mega128 PWM bits
#define PWM10 WGM10
#define PWM11 WGM11
#endif

//OC1B  pin B6 (attached to green LED)
void PWM_Init_timer1_LED(u08 bitRes)
{
// enable timer2 as 8,9,10bit PWM
if(bitRes == 9)
{ // 9bit mode
sbi(TCCR1A,PWM11);
cbi(TCCR1A,PWM10);
}
else if( bitRes == 10 )
{ // 10bit mode
sbi(TCCR1A,PWM11);
sbi(TCCR1A,PWM10);
}
else
{ // default 8bit mode
cbi(TCCR1A,PWM11);
sbi(TCCR1A,PWM10);
}
// clear output compare values
OCR1B = 0;
}

//on commands
void PWM_timer1_On_LED(void)
{
sbi(TCCR1A,COM1B1);
cbi(TCCR1A,COM1B0);
}


//off commands
void PWM_timer1_Off_LED(void)
{
cbi(TCCR1A,COM1B1);
cbi(TCCR1A,COM1B0);
}

void PWM_timer1_Set_LED(u16 pwmDuty)
{OCR1B = pwmDuty;}

Title: Re: Program Compilation Error
Post by: ukesh on August 11, 2009, 08:51:35 AM
thnx admin! It worked.  ;D
Can you work on this pwm error as soon as possible? If u can, it would be nice ;)
Title: Re: Program Compilation Error
Post by: Admin on August 11, 2009, 11:44:25 AM
thnx admin! It worked.  ;D
Can you work on this pwm error as soon as possible? If u can, it would be nice ;)

Well, since this quick hack fixes it, its now a low priority bug fix.

I'll make sure it works correctly with the next code version release.