N
nirmal_rockin
Guest
Hi ...
Es esmu steidzami ..Man šī programma somewher no tīkla, un es esmu edited to mana pozīcija sekotājs, kuru es esmu ēka .... bet programma parāda dažas kļūdas (mikrovadības tiek izmantota ATMEGA16), un es esmu pilnīgi apjucis header files "delay.h" un "mega16.h" i mēģināja izmantojot header failus paredzēts avr_libc .. bet tas liecina vairākas kļūdas ....var kāds man palīdzēt atrisināt šo problēmu ...
Kā es varu izveidot errorless programma ....
pls help me .....i dono daudz par mikrokontrolleri ....
thank you ...Quote:/************************************************* ****
Projekts: Line Sekotājam
Chip type: ATMEGA16
Program type: Application
Clock frequency: 7.372800 MHz
Memory modelis: Small
External SRAM lielums: 0
Dati skursteni izmērs: 256
************************************************** *** /
/ / # define debug 1
# include <mega16.h>
# include <delay.h>
# ifdef debug
# include <stdio.h>
# endif
# define FWD 0xAA
# define REV 0x55
# define R 0x22
# define L 0x88
# define CW 0x99
# define CCW 0x66
# define STOP 0x00
# define B 0xFF
# define RSPEED OCR1AL
# define LSPEED OCR1BL
# define SPEED0 255
# define SPEED1 0
# define SPEED2 0
# define SPEED3 0
# define MAX 3
# define HMAX 1
anulēts pārvietot (unsigned char dir, neparakstītu palija kavēšanās, unsigned char jauda);
unsigned char i, rdev, ldev, ip, kavējuma, dir, Power, dirl, vēsture [max], hcount = 0, rotpow;
# ifdef debug
unsigned char rep = 0, prev = 0;
# endif
anulēts main (anulēts)
(
/ / Input / Output Ports inicializācijas
/ / Port inicializācijas
/ / Func7 = In Func6 = In Func5 = In Func4 = In Func3 = In Func2 = In Func1 = In Func0 = In
/ / State7 = T State6 = T State5 = T State4 = T State3 = T State2 = T State1 = T State0 = T
PORTA = 0x00;
DDRA = 0x00;
/ / Port B inicializācijas
/ / Func7 = In Func6 = In Func5 = In Func4 = In Func3 = In Func2 = In Func1 = In Func0 = In
/ / State7 = T State6 = T State5 = T State4 = T State3 = T State2 = T State1 = T State0 = T
PORTB = 0x00;
DDRB = 0x00;
/ / Port C inicializācijas
/ / Func7 = In Func6 = In Func5 = In Func4 = In Func3 = In Func2 = In Func1 = In Func0 = In
/ / State7 = T State6 = T State5 = T State4 = T State3 = T State2 = T State1 = T State0 = T
PORTC = 0x00;
DDRC = 0xFF;
/ / Port D inicializācijas
/ / Func7 = In Func6 = In Func5 = Out Func4 = Out Func3 = In Func2 = In Func1 = In Func0 = In
/ / State7 = T State6 = T State5 = 0 State4 = 0 State3 = T State2 = T State1 = T State0 = T
PORTD = 0x00;
DDRD = 0x30;
/ / Timer / Counter 0 inicializācijas
/ / Clock avots: System Clock
/ / Clock vērtība: Timer 0 Apturēts
/ / Mode: Normal top = FFh
/ / OC0 jauda: Atvienots
TCCR0 = 0x00;
TCNT0 = 0x00;
OCR0 = 0x00;
/ / Timer / Counter 1 inicializācijas
/ / Clock avots: System Clock
/ / Clock vērtība: 921,600 kHz
/ / Mode: Fast PWM top = 00FFh
/ / OC1A output: Non-Inv.
/ / OC1B output: Non-Inv.
/ / Noise Canceler: Off
/ / Input Capture par Falling Edge
TCCR1A = 0xA1;
TCCR1B = 0x0A;
TCNT1H = 0x00;
TCNT1L = 0x00;
ICR1H = 0x00;
ICR1L = 0x00;
OCR1AH = 0x00;
OCR1AL = 0xFF;
OCR1BH = 0x00;
OCR1BL = 0xFF;
/ / Timer / Counter 2 inicializācijas
/ / Clock avots: System Clock
/ / Clock vērtība: Timer 2 Apturēts
/ / Mode: Normal top = FFh
/ / OC2 jauda: Atvienots
APSR = 0x00;
TCCR2 = 0x00;
TCNT2 = 0x00;
OCR2 = 0x00;
/ / Ārējie Interrupt (s) inicializācijas
/ / INT0: Off
/ / INT1: Off
/ / INT2: Off
MCUCR = 0x00;
MCUCSR = 0x00;
# ifdef debug
/ / USART inicializācijas
/ / Communication Parametri: 8 Datus, 1 Stop, Nr paritāte
/ / USART Saņēmējs: On
/ / USART Transmitter: On
/ / USART Mode: Asynchronous
/ / USART Baud rate: 57.600
UCSRA = 0x00;
UCSRB = 0x18;
UCSRC = 0x86;
UBRRH = 0x00;
UBRRL = 0x07;
# endif
/ / Taimeris (s) / Counter (s) Interrupt (s) inicializācijas
TIMSK = 0x00;
/ / Analog Comparator inicializācijas
/ / Analog Comparator: Off
/ / Analog Comparator Input ieguvi, taimeri / skaitītāju 1: Off
ACSR = 0x80;
SFIOR = 0x00;
while (1) (
# ifdef debug
if (rep <255)
rep ;
if (iepriekšējais! = Pina) (
prev = Pina;
printf ( "% u \ r", rep);
for (i = 0; i <8; i )
printf ( "% u \ t" (iepriekšējais>> i) un 0x01);
rep = 0;
)
# endif
if (Pina! = 255) (
rotpow = 255;
ldev = rdev = 0;
if (PINA.3 == 0)
rdev = 1;
if (PINA.2 == 0)
rdev = 2;
if (PINA.1 == 0)
rdev = 3;
if (PINA.0 == 0)
rdev = 4;
if (PINA.4 == 0)
ldev = 1;
if (PINA.5 == 0)
ldev = 2;
if (PINA.6 == 0)
ldev = 3;
if (PINA.7 == 0)
ldev = 4;
if (rdev> ldev)
pārvietot (R, 0.195 12 * rdev);
if (rdev <ldev)
pārvietot (L, 0.195 12 * ldev);
if (rdev == ldev)
pārvietot (FWD, 0.200);
)
else (
for (i = 0, dirl = 0; i <max; i ) (
if (vēsture == L)
(dirl
)
if (rotpow <160) (rotpow = 160
if (rotpow <255) (rotpow
if (dirl> HMAX)
(pārvietot (CW, 0, rotpow)
citādi
(pārvietot (CCW, 0, rotpow)
)
);
)
anulēts pārvietot (unsigned char dir, neparakstītu palija kavēšanās, unsigned char power) (
PORTC = dir;
if (dir == l | | dir == R) (
hcount = (hcount 1)% max;
vēsture [hcount] = dir;
)
LSPEED = RSPEED = 255; / / power;
/ / delay_ms (kavēšanās);
)
Es esmu steidzami ..Man šī programma somewher no tīkla, un es esmu edited to mana pozīcija sekotājs, kuru es esmu ēka .... bet programma parāda dažas kļūdas (mikrovadības tiek izmantota ATMEGA16), un es esmu pilnīgi apjucis header files "delay.h" un "mega16.h" i mēģināja izmantojot header failus paredzēts avr_libc .. bet tas liecina vairākas kļūdas ....var kāds man palīdzēt atrisināt šo problēmu ...
Kā es varu izveidot errorless programma ....
pls help me .....i dono daudz par mikrokontrolleri ....
thank you ...Quote:/************************************************* ****
Projekts: Line Sekotājam
Chip type: ATMEGA16
Program type: Application
Clock frequency: 7.372800 MHz
Memory modelis: Small
External SRAM lielums: 0
Dati skursteni izmērs: 256
************************************************** *** /
/ / # define debug 1
# include <mega16.h>
# include <delay.h>
# ifdef debug
# include <stdio.h>
# endif
# define FWD 0xAA
# define REV 0x55
# define R 0x22
# define L 0x88
# define CW 0x99
# define CCW 0x66
# define STOP 0x00
# define B 0xFF
# define RSPEED OCR1AL
# define LSPEED OCR1BL
# define SPEED0 255
# define SPEED1 0
# define SPEED2 0
# define SPEED3 0
# define MAX 3
# define HMAX 1
anulēts pārvietot (unsigned char dir, neparakstītu palija kavēšanās, unsigned char jauda);
unsigned char i, rdev, ldev, ip, kavējuma, dir, Power, dirl, vēsture [max], hcount = 0, rotpow;
# ifdef debug
unsigned char rep = 0, prev = 0;
# endif
anulēts main (anulēts)
(
/ / Input / Output Ports inicializācijas
/ / Port inicializācijas
/ / Func7 = In Func6 = In Func5 = In Func4 = In Func3 = In Func2 = In Func1 = In Func0 = In
/ / State7 = T State6 = T State5 = T State4 = T State3 = T State2 = T State1 = T State0 = T
PORTA = 0x00;
DDRA = 0x00;
/ / Port B inicializācijas
/ / Func7 = In Func6 = In Func5 = In Func4 = In Func3 = In Func2 = In Func1 = In Func0 = In
/ / State7 = T State6 = T State5 = T State4 = T State3 = T State2 = T State1 = T State0 = T
PORTB = 0x00;
DDRB = 0x00;
/ / Port C inicializācijas
/ / Func7 = In Func6 = In Func5 = In Func4 = In Func3 = In Func2 = In Func1 = In Func0 = In
/ / State7 = T State6 = T State5 = T State4 = T State3 = T State2 = T State1 = T State0 = T
PORTC = 0x00;
DDRC = 0xFF;
/ / Port D inicializācijas
/ / Func7 = In Func6 = In Func5 = Out Func4 = Out Func3 = In Func2 = In Func1 = In Func0 = In
/ / State7 = T State6 = T State5 = 0 State4 = 0 State3 = T State2 = T State1 = T State0 = T
PORTD = 0x00;
DDRD = 0x30;
/ / Timer / Counter 0 inicializācijas
/ / Clock avots: System Clock
/ / Clock vērtība: Timer 0 Apturēts
/ / Mode: Normal top = FFh
/ / OC0 jauda: Atvienots
TCCR0 = 0x00;
TCNT0 = 0x00;
OCR0 = 0x00;
/ / Timer / Counter 1 inicializācijas
/ / Clock avots: System Clock
/ / Clock vērtība: 921,600 kHz
/ / Mode: Fast PWM top = 00FFh
/ / OC1A output: Non-Inv.
/ / OC1B output: Non-Inv.
/ / Noise Canceler: Off
/ / Input Capture par Falling Edge
TCCR1A = 0xA1;
TCCR1B = 0x0A;
TCNT1H = 0x00;
TCNT1L = 0x00;
ICR1H = 0x00;
ICR1L = 0x00;
OCR1AH = 0x00;
OCR1AL = 0xFF;
OCR1BH = 0x00;
OCR1BL = 0xFF;
/ / Timer / Counter 2 inicializācijas
/ / Clock avots: System Clock
/ / Clock vērtība: Timer 2 Apturēts
/ / Mode: Normal top = FFh
/ / OC2 jauda: Atvienots
APSR = 0x00;
TCCR2 = 0x00;
TCNT2 = 0x00;
OCR2 = 0x00;
/ / Ārējie Interrupt (s) inicializācijas
/ / INT0: Off
/ / INT1: Off
/ / INT2: Off
MCUCR = 0x00;
MCUCSR = 0x00;
# ifdef debug
/ / USART inicializācijas
/ / Communication Parametri: 8 Datus, 1 Stop, Nr paritāte
/ / USART Saņēmējs: On
/ / USART Transmitter: On
/ / USART Mode: Asynchronous
/ / USART Baud rate: 57.600
UCSRA = 0x00;
UCSRB = 0x18;
UCSRC = 0x86;
UBRRH = 0x00;
UBRRL = 0x07;
# endif
/ / Taimeris (s) / Counter (s) Interrupt (s) inicializācijas
TIMSK = 0x00;
/ / Analog Comparator inicializācijas
/ / Analog Comparator: Off
/ / Analog Comparator Input ieguvi, taimeri / skaitītāju 1: Off
ACSR = 0x80;
SFIOR = 0x00;
while (1) (
# ifdef debug
if (rep <255)
rep ;
if (iepriekšējais! = Pina) (
prev = Pina;
printf ( "% u \ r", rep);
for (i = 0; i <8; i )
printf ( "% u \ t" (iepriekšējais>> i) un 0x01);
rep = 0;
)
# endif
if (Pina! = 255) (
rotpow = 255;
ldev = rdev = 0;
if (PINA.3 == 0)
rdev = 1;
if (PINA.2 == 0)
rdev = 2;
if (PINA.1 == 0)
rdev = 3;
if (PINA.0 == 0)
rdev = 4;
if (PINA.4 == 0)
ldev = 1;
if (PINA.5 == 0)
ldev = 2;
if (PINA.6 == 0)
ldev = 3;
if (PINA.7 == 0)
ldev = 4;
if (rdev> ldev)
pārvietot (R, 0.195 12 * rdev);
if (rdev <ldev)
pārvietot (L, 0.195 12 * ldev);
if (rdev == ldev)
pārvietot (FWD, 0.200);
)
else (
for (i = 0, dirl = 0; i <max; i ) (
if (vēsture == L)
(dirl
)
if (rotpow <160) (rotpow = 160
if (rotpow <255) (rotpow
if (dirl> HMAX)
(pārvietot (CW, 0, rotpow)
citādi
(pārvietot (CCW, 0, rotpow)
)
);
)
anulēts pārvietot (unsigned char dir, neparakstītu palija kavēšanās, unsigned char power) (
PORTC = dir;
if (dir == l | | dir == R) (
hcount = (hcount 1)% max;
vēsture [hcount] = dir;
)
LSPEED = RSPEED = 255; / / power;
/ / delay_ms (kavēšanās);
)