Subversion Repositories svnkaklik

Compare Revisions

No changes between revisions

Ignore whitespace Rev 161 → Rev 162

/roboti/solarni/2006/jump/AX25.BAK
0,0 → 1,135
//#define PTT PIN_A2 // PTT control
//#define TXo PIN_C0 // To the transmitter modulator
#define PERIODAH delay_us(218) // Halfperiod H 222;78/1200 500;430/500
#define TAILH delay_us(74)
#define PERIODAL delay_us(408) // Halfperiod L 412;345/1200 1000;880/500
#define TAILL delay_us(341)
#byte STATUS = 3 // CPUs status register
 
byte SendData[16] = {'A'<<1, 'L'<<1, 'L'<<1, ' '<<1, ' '<<1, ' '<<1, 0x60,
'C'<<1, 'Z'<<1, '0'<<1, 'R'<<1, 'R'<<1, 'R'<<1, 0x61,
0x03, 0xF0};
 
boolean bit;
int fcslo, fcshi; // variabloes for calculating FCS (CRC)
int stuff; // stuff counter for extra 0
int flag_flag; // if it is sending flag (7E)
int fcs_flag; // if it is sending Frame Check Sequence
int i; // for for
 
void flipout() //flips the state of output pin a_1
{
stuff = 0; //since this is a 0, reset the stuff counter
if (bit)
{
bit=FALSE; //if the state of the pin was low, make it high.
}
else
{
bit=TRUE; //if the state of the pin was high make it low
}
}
 
void fcsbit(byte tbyte)
{
#asm
BCF STATUS,0
RRF fcshi,F // rotates the entire 16 bits
RRF fcslo,F // to the right
#endasm
if (((STATUS & 0x01)^(tbyte)) ==0x01)
{
fcshi = fcshi^0x84;
fcslo = fcslo^0x08;
}
}
 
void SendBit ()
{
if (bit)
{
output_low(TXo);
PERIODAH;
output_high(TXo);
PERIODAH;
output_low(TXo);
PERIODAH;
output_high(TXo);
TAILH;
}
else
{
output_low(TXo);
PERIODAL;
output_high(TXo);
TAILL;
};
}
 
void SendByte (byte inbyte)
{
int k, bt;
 
for (k=0;k<8;k++) //do the following for each of the 8 bits in the byte
{
bt = inbyte & 0x01; //strip off the rightmost bit of the byte to be sent (inbyte)
if ((fcs_flag == FALSE) & (flag_flag == FALSE)) fcsbit(bt); //do FCS calc, but only if this
//is not a flag or fcs byte
if (bt == 0)
{
flipout();
} // if this bit is a zero, flip the output state
else
{ //otherwise if it is a 1, do the following:
if (flag_flag == FALSE) stuff++; //increment the count of consequtive 1's
if ((flag_flag == FALSE) & (stuff == 5))
{ //stuff an extra 0, if 5 1's in a row
SendBit();
flipout(); //flip the output state to stuff a 0
}//end of if
}//end of else
// delay_us(850); //introduces a delay that creates 1200 baud
SendBit();
inbyte = inbyte>>1; //go to the next bit in the byte
}//end of for
}//end of SendByte
 
void SendPacket(char *data)
{
bit=FALSE;
 
fcslo=fcshi=0xFF; //The 2 FCS Bytes are initialized to FF
stuff = 0; //The variable stuff counts the number of 1's in a row. When it gets to 5
// it is time to stuff a 0.
 
// output_low(PTT); // Blinking LED
// delay_ms(1000);
// output_high(PTT);
 
flag_flag = TRUE; //The variable flag is true if you are transmitted flags (7E's) false otherwise.
fcs_flag = FALSE; //The variable fcsflag is true if you are transmitting FCS bytes, false otherwise.
 
for(i=0; i<10; i++) SendByte(0x7E); //Sends flag bytes. Adjust length for txdelay
//each flag takes approx 6.7 ms
flag_flag = FALSE; //done sending flags
 
for(i=0; i<16; i++) SendByte(SendData[i]); //send the packet bytes
 
for(i=0; 0 != *data; i++)
{
SendByte(*data); //send the packet bytes
data++;
};
 
fcs_flag = TRUE; //about to send the FCS bytes
fcslo =fcslo^0xff; //must XOR them with FF before sending
fcshi = fcshi^0xff;
SendByte(fcslo); //send the low byte of fcs
SendByte(fcshi); //send the high byte of fcs
fcs_flag = FALSE; //done sending FCS
flag_flag = TRUE; //about to send flags
SendByte(0x7e); // Send a flag to end packet
}
 
 
 
/roboti/solarni/2006/jump/AX25.c
0,0 → 1,139
//#define PTT PIN_A2 // PTT control
//#define TXo PIN_C0 // To the transmitter modulator
//#define PERIODAH delay_us(218) // Halfperiod H 222;78/1200 500;430/500
//#define TAILH delay_us(74)
//#define PERIODAL delay_us(408) // Halfperiod L 412;345/1200 1000;880/500
//#define TAILL delay_us(341)
#define PERIODAH delay_us(222) // Halfperiod H 222;78/1200 500;430/500
#define TAILH delay_us(78)
#define PERIODAL delay_us(412) // Halfperiod L 412;345/1200 1000;880/500
#define TAILL delay_us(345)
#byte STATUS = 3 // CPUs status register
 
byte SendData[16] = {'A'<<1, 'L'<<1, 'L'<<1, ' '<<1, ' '<<1, ' '<<1, 0x60,
'C'<<1, 'Z'<<1, '0'<<1, 'R'<<1, 'R'<<1, 'R'<<1, 0x61,
0x03, 0xF0};
 
boolean bit;
int fcslo, fcshi; // variabloes for calculating FCS (CRC)
int stuff; // stuff counter for extra 0
int flag_flag; // if it is sending flag (7E)
int fcs_flag; // if it is sending Frame Check Sequence
int i; // for for
 
void flipout() //flips the state of output pin a_1
{
stuff = 0; //since this is a 0, reset the stuff counter
if (bit)
{
bit=FALSE; //if the state of the pin was low, make it high.
}
else
{
bit=TRUE; //if the state of the pin was high make it low
}
}
 
void fcsbit(byte tbyte)
{
#asm
BCF STATUS,0
RRF fcshi,F // rotates the entire 16 bits
RRF fcslo,F // to the right
#endasm
if (((STATUS & 0x01)^(tbyte)) ==0x01)
{
fcshi = fcshi^0x84;
fcslo = fcslo^0x08;
}
}
 
void SendBit ()
{
if (bit)
{
output_low(TXo);
PERIODAH;
output_high(TXo);
PERIODAH;
output_low(TXo);
PERIODAH;
output_high(TXo);
TAILH;
}
else
{
output_low(TXo);
PERIODAL;
output_high(TXo);
TAILL;
};
}
 
void SendByte (byte inbyte)
{
int k, bt;
 
for (k=0;k<8;k++) //do the following for each of the 8 bits in the byte
{
bt = inbyte & 0x01; //strip off the rightmost bit of the byte to be sent (inbyte)
if ((fcs_flag == FALSE) & (flag_flag == FALSE)) fcsbit(bt); //do FCS calc, but only if this
//is not a flag or fcs byte
if (bt == 0)
{
flipout();
} // if this bit is a zero, flip the output state
else
{ //otherwise if it is a 1, do the following:
if (flag_flag == FALSE) stuff++; //increment the count of consequtive 1's
if ((flag_flag == FALSE) & (stuff == 5))
{ //stuff an extra 0, if 5 1's in a row
SendBit();
flipout(); //flip the output state to stuff a 0
}//end of if
}//end of else
// delay_us(850); //introduces a delay that creates 1200 baud
SendBit();
inbyte = inbyte>>1; //go to the next bit in the byte
}//end of for
}//end of SendByte
 
void SendPacket(char *data)
{
bit=FALSE;
 
fcslo=fcshi=0xFF; //The 2 FCS Bytes are initialized to FF
stuff = 0; //The variable stuff counts the number of 1's in a row. When it gets to 5
// it is time to stuff a 0.
 
// output_low(PTT); // Blinking LED
// delay_ms(1000);
// output_high(PTT);
 
flag_flag = TRUE; //The variable flag is true if you are transmitted flags (7E's) false otherwise.
fcs_flag = FALSE; //The variable fcsflag is true if you are transmitting FCS bytes, false otherwise.
 
for(i=0; i<10; i++) SendByte(0x7E); //Sends flag bytes. Adjust length for txdelay
//each flag takes approx 6.7 ms
flag_flag = FALSE; //done sending flags
 
for(i=0; i<16; i++) SendByte(SendData[i]); //send the packet bytes
 
for(i=0; 0 != *data; i++)
{
SendByte(*data); //send the packet bytes
data++;
};
 
fcs_flag = TRUE; //about to send the FCS bytes
fcslo =fcslo^0xff; //must XOR them with FF before sending
fcshi = fcshi^0xff;
SendByte(fcslo); //send the low byte of fcs
SendByte(fcshi); //send the high byte of fcs
fcs_flag = FALSE; //done sending FCS
flag_flag = TRUE; //about to send flags
SendByte(0x7e); // Send a flag to end packet
}
 
 
 
/roboti/solarni/2006/jump/AX25smpl.c
0,0 → 1,25
#include "D:\KAKL\PIC\AX25smpl\AX25smpl.h"
 
#define TXo PIN_C0 // To the transmitter modulator
#include "AX25.c" // Podprogram pro prenos telemetrie
char AXstring[40]; // Buffer pro prenos telemetrie
 
void main()
{
int n;
 
setup_adc_ports(RA0_RA1_RA3_ANALOG);
setup_adc(ADC_CLOCK_INTERNAL);
setup_spi(FALSE);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
 
n=0;
while(true)
{
sprintf(AXstring,"Counter: %U\0", n++); // Convert DATA to String.
SendPacket(&AXstring[0]);
delay_ms(1000);
}
}
/roboti/solarni/2006/jump/AX25smpl.h
0,0 → 1,5
#include <16F873.h>
#device adc=8
#use delay(clock=4000000)
#fuses NOWDT,XT, NOPUT, NOPROTECT, NOBROWNOUT, NOLVP, NOCPD, NOWRT, NODEBUG
 
/roboti/solarni/2006/jump/bak/menic_1.c
0,0 → 1,80
//#device ICD=TRUE
 
#include ".\menic.h"
 
//#use fast_io(B)
 
#define PIEZO PIN_A6
#define LED PIN_A7
#define MENIC PIN_B3
#define REFPWR PIN_B1
#define MOTOR PIN_B2
 
unsigned int32 n;
 
void pip()
{
int1 beep;
int i;
 
for(i=0; i<250; i++)
{
output_bit(PIEZO, beep);
beep=~beep;
output_bit(LED, beep);
delay_us(100);
};
output_high(PIEZO);
output_high(LED);
}
 
void main()
{
 
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF);
setup_spi(FALSE);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_256);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
 
setup_oscillator(OSC_4MHZ|OSC_INTRC);
 
// SET_TRIS_B( 0b11110011);
 
output_low(MENIC);
output_low(MOTOR);
output_low(REFPWR);
 
pip();
 
for(n=0;n<370000;n++)
// for(n=0;n<100000;n++)
{
// set_timer0(0);
// while ( get_timer0() < 250 )
{
output_high(MENIC);
delay_us(5);
output_low(MENIC);
delay_us(4);
// delay_us(90);
};
}
 
pip();
 
output_high(MOTOR);
delay_ms(3000);
output_low(MOTOR);
 
while(true)
{
output_high(LED);
delay_ms(300);
output_low(LED);
delay_ms(300);
}
}
/roboti/solarni/2006/jump/bak/menic_2_nefunguje_rozjezd.c
0,0 → 1,148
#include ".\menic.h"
 
#define RAZENI 100 // Po kolika ms se bude menit rychlost pro rozjizdeni
#define REFNOM 107 // Hodnota odpovidajici 1,2V pri nominalnim zatizeni
#define REFSTART 80 // Hodnota odpovidajici 1,2V pri nezatizenych clancich
 
#define PIEZO PIN_A6 // Jeden pol piezo reproduktoru
#define LED PIN_A7 // LED
#define MENIC PIN_B3 // Spinani tranzistoru menice
#define REFPWR PIN_B1 // Napajeni zdroje referencniho napeti
#define MOTOR PIN_B2 // Spinani tranzistoru motoru
 
#byte SSPBUF = 0x13 // Registry jednotky SSP
#byte SSPCON1 = 0x14
#byte SSPSTAT = 0x94
 
// Vzorky pro generovani PWM pomoci SSP
unsigned int8 const Pattern[8] = {0x02,0x06,0x0e,0x1e,0x3e,0x7e,0xfe,0xff};
unsigned int8 MotorPattern;
 
#INT_SSP
void IntSSP()
{
SSPBUF=MotorPattern; // znovu vysli stejnou hodnotu
}
 
void pip() // pipnuti a bliknuti
{
int1 beep;
int i;
 
for(i=0; i<250; i++)
{
output_bit(PIEZO, beep);
beep=~beep;
output_bit(LED, beep);
delay_us(100);
};
output_high(PIEZO);
output_high(LED);
}
 
void cvak() // pouze cvaknuti piezoelementem bez bliknuti
{
output_bit(PIEZO,~input(PIEZO));
}
 
void main()
{
int8 n;
int8 perioda;
 
setup_adc_ports(ADC_CLOCK_INTERNAL|sAN4|VSS_VDD);
setup_adc(ADC_CLOCK_INTERNAL);
setup_spi(FALSE);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_256);
setup_timer_1(T1_DISABLED);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
 
output_low(MENIC); // Vsechno zastav
output_low(MOTOR);
output_low(REFPWR);
output_high(LED);
output_high(PIEZO);
 
set_adc_channel(4); // Vyber AD kanal pro pomerne mereni napeti
set_pwm1_duty(0); // Spust PWM, ale zatim s trvalou 0 na vystupu
setup_ccp1(CCP_PWM); // PWM pro zatizeni clanku v seru
setup_timer_2(T2_DIV_BY_1,100,1); // perioda
 
setup_oscillator(OSC_4MHZ|OSC_INTRC); // rozjed PIC (zvysi se odber)
 
 
// jsme v depu?
set_pwm1_duty(2); // PWM pro zatizeni clanku pri malem osvetleni
n=0;
do
{
output_low(REFPWR);
delay_ms(100);
if (4==n++) {cvak(); n=0;};
output_high(REFPWR); // zapni napajeni napetove reference
delay_ms(1);
} while (read_adc()>REFSTART); // Odkryl starter clanky?
output_low(REFPWR);
 
pip(); // potvrzeni odstartovani
 
// regulace
perioda=100; // nastav optimalni periodu pri jedne 500W zarovce
for(n=0;n<=7;n++)
{
set_pwm1_duty(0);
setup_timer_2(T2_DIV_BY_1,perioda,1); // perioda
set_pwm1_duty(19); // delka sepnuti
delay_ms(100);
output_high(REFPWR); // zapni napajeni napetove reference
delay_ms(1);
if (read_adc()<REFNOM) perioda--; // zvyseni zatizeni menice
output_low(REFPWR); // konec mereni, odpoj napajeni reference
};
 
// nabíjíme
delay_ms(14000);
 
// rozjezd
SSPSTAT = 0;
SSPCON1 = 0x22; // SPI OSC/64
enable_interrupts(global);
 
for(n=0; n<=7; n++) // razeni osmi rychlostnich stupnu
{
disable_interrupts(INT_SSP); // zastav preruseni od SSP
MotorPattern=Pattern[n];
SSPBUF=MotorPattern; // data pro vyslani
enable_interrupts(INT_SSP); // az budou vyslana, prijde interrupt od SSP
delay_ms(RAZENI); // Pockej na dalsi razeni
};
SSPSTAT = 0;
SSPCON1 = 0; // SPI stop
disable_interrupts(INT_SSP); // zastav preruseni od SSP
 
// jedem co to da
output_high(MOTOR);
delay_ms(1000);
output_low(MOTOR);
set_pwm1_duty(0); // zastav menic
 
// vybiti kondenzatoru pro ucely mereni
pip();
delay_ms(2000);
pip();
output_high(MOTOR);
 
while(true)
{
output_high(LED);
output_low(PIEZO);
delay_ms(300);
output_low(LED);
output_high(PIEZO);
delay_ms(300);
}
// priprava na dalsi jizdu
delay_ms(5000);
reset_cpu();
}
/roboti/solarni/2006/jump/bak/menic_3.c
0,0 → 1,148
#include ".\menic.h"
 
#define RAZENI 50 // Po kolika ms se bude menit rychlost pro rozjizdeni
#define REFNOM 107 // Hodnota odpovidajici 1,2V pri nominalnim zatizeni
#define REFSTART 80 // Hodnota odpovidajici 1,2V pri nezatizenych clancich
 
#define PIEZO PIN_A6 // Jeden pol piezo reproduktoru
#define LED PIN_A7 // LED
#define MENIC PIN_B3 // Spinani tranzistoru menice
#define REFPWR PIN_B1 // Napajeni zdroje referencniho napeti
#define MOTOR PIN_B2 // Spinani tranzistoru motoru
 
#byte SSPBUF = 0x13 // Registry jednotky SSP
#byte SSPCON1 = 0x14
#byte SSPSTAT = 0x94
 
// Vzorky pro generovani PWM pomoci SSP
unsigned int8 const Pattern[8] = {0x02,0x06,0x0e,0x1e,0x3e,0x7e,0xfe,0xff};
unsigned int8 MotorPattern;
 
#INT_SSP
void IntSSP()
{
SSPBUF=MotorPattern; // znovu vysli stejnou hodnotu
}
 
void pip() // pipnuti a bliknuti
{
int1 beep;
int i;
 
for(i=0; i<250; i++)
{
output_bit(PIEZO, beep);
beep=~beep;
output_bit(LED, beep);
delay_us(100);
};
output_high(PIEZO);
output_high(LED);
}
 
void cvak() // pouze cvaknuti piezoelementem bez bliknuti
{
output_bit(PIEZO,~input(PIEZO));
}
 
void main()
{
int8 n;
int8 perioda;
 
setup_adc_ports(ADC_CLOCK_INTERNAL|sAN4|VSS_VDD);
setup_adc(ADC_CLOCK_INTERNAL);
setup_spi(FALSE);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_256);
setup_timer_1(T1_DISABLED);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
 
output_low(MENIC); // Vsechno zastav
output_low(MOTOR);
output_low(REFPWR);
output_high(LED);
output_high(PIEZO);
 
set_adc_channel(4); // Vyber AD kanal pro pomerne mereni napeti
set_pwm1_duty(0); // Spust PWM, ale zatim s trvalou 0 na vystupu
setup_ccp1(CCP_PWM); // PWM pro zatizeni clanku v seru
setup_timer_2(T2_DIV_BY_1,100,1); // perioda
 
setup_oscillator(OSC_4MHZ|OSC_INTRC); // rozjed PIC (zvysi se odber)
 
 
// jsme v depu?
set_pwm1_duty(2); // PWM pro zatizeni clanku pri malem osvetleni
n=0;
do
{
output_low(REFPWR);
delay_ms(100);
if (4==n++) {cvak(); n=0;};
output_high(REFPWR); // zapni napajeni napetove reference
delay_ms(1);
} while (read_adc()>REFSTART); // Odkryl starter clanky?
output_low(REFPWR);
 
pip(); // potvrzeni odstartovani
 
// regulace
perioda=100; // nastav optimalni periodu pri jedne 500W zarovce
for(n=0;n<=7;n++)
{
set_pwm1_duty(0);
setup_timer_2(T2_DIV_BY_1,perioda,1); // perioda
set_pwm1_duty(19); // delka sepnuti
delay_ms(100);
output_high(REFPWR); // zapni napajeni napetove reference
delay_ms(1);
if (read_adc()<REFNOM) perioda--; // zvyseni zatizeni menice
output_low(REFPWR); // konec mereni, odpoj napajeni reference
};
 
// nabíjíme
delay_ms(14000);
 
// rozjezd
SSPSTAT = 0;
SSPCON1 = 0x22; // SPI OSC/64
MotorPattern=0x02; // prvni data pro vyslani
SSPBUF=MotorPattern; // data pro vyslani
enable_interrupts(global);
enable_interrupts(INT_SSP); // az budou vyslana, prijde interrupt od SSP
 
for(n=0; n<=7; n++) // razeni osmi rychlostnich stupnu
{
MotorPattern=Pattern[n];
delay_ms(RAZENI); // Pockej na dalsi razeni
};
SSPSTAT = 0;
SSPCON1 = 0; // SPI stop
disable_interrupts(INT_SSP); // zastav preruseni od SSP
 
// jedem co to da
output_high(MOTOR);
delay_ms(1000);
output_low(MOTOR);
set_pwm1_duty(0); // zastav menic
 
// vybiti kondenzatoru pro ucely mereni
pip();
delay_ms(2000);
pip();
output_high(MOTOR);
 
while(true)
{
output_high(LED);
output_low(PIEZO);
delay_ms(300);
output_low(LED);
output_high(PIEZO);
delay_ms(300);
}
// priprava na dalsi jizdu
delay_ms(5000);
reset_cpu();
}
/roboti/solarni/2006/jump/bak/vssver.scc
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/roboti/solarni/2006/jump/menic.BAK
0,0 → 1,6
#include <16F88.h>
 
#device adc=8
#fuses NOWDT,INTRC_IO, NOPUT, MCLR, NOBROWNOUT, NOLVP, NOCPD, NOWRT, DEBUG, NOPROTECT, NOFCMEN, NOIESO, CCPB3
#use delay(clock=4000000)
 
/roboti/solarni/2006/jump/menic.HEX
0,0 → 1,91
:1000000000308A0071290000FF00030E8301A10067
:100010007F08A0000A08A8008A01A00E0408A20018
:100020007708A3007808A4007908A5007A08A6003C
:100030007B08A700831383128C308400801D222844
:100040008C193528220884002308F7002408F800BA
:100050002508F9002608FA002708FB0028088A006E
:10006000210E8300FF0E7F0E09008A114C280A1012
:100070008A100A118207023406340E341E343E34CC
:100080007E34FE34FF340A108A100A11820741348C
:1000900068346F346A340034680893008C118A1114
:1000A00022286D3084000008031963280130F8000D
:1000B000F701F70B5928F80B58283A30F700F70BDF
:1000C0005F28800B56280034831605178312051FFE
:1000D0006B2805136C2805178316051383128A11E4
:1000E000012A690884006D088000840A8001E90AF9
:1000F0008A110D2ABC01391C7F2839108028391437
:100100000034391CAB2883168612831286124530C0
:10011000F700F70B8928000000008316861283126F
:1001200086164530F700F70B932800000000831671
:100130008612831286124530F700F70B9D280000C7
:10014000000083168612831286161830F700F70B0C
:10015000A7280000BD2883168612831286128230DB
:10016000F700F70BB12883168612831286166C30BF
:10017000F700F70BB928000000000034EF016F080A
:10018000073C031C06296E080139F000BE0803195C
:10019000CB280030CC280130F100BD080319D2284B
:1001A0000030D32801307105003A0319E6287008A1
:1001B000F1000310BB0CBA0C030801397106013CB5
:1001C000031DE6288430BB060830BA06F008031D7C
:1001D000EB287A200129BD080319BC0ABD080319C0
:1001E000F3280030F4280130F1003C08053C0319E5
:1001F000FB280030FC2801307105031901298120FA
:100200007A2081200310EE0CEF0ABF280034391049
:10021000FF30BB00BA00BC010130BD00BE01BF0110
:100220003F08093C031C19297E30EE00BE20BF0A9E
:100230001029BD01BF013F080F3C031C28292930AC
:100240003F0784000008ED00EE00BE20BF0A1B2916
:10025000BF016C0884000008031937296C0884006A
:100260000008ED00EE00BE20EC0ABF0A292901308B
:10027000BE00FF30BA06BB063A08EE00BE203B08BF
:10028000EE00BE20BE010130BD007E30EE00BE207B
:100290008A11112AED016D08F93C031C68296C18BC
:1002A00053290513542905178316051301308312AA
:1002B000EC066C185D2985135E2985178316851356
:1002C0001F30F700F70B622900008312ED0A4B295B
:1002D000831605138312051783168513831285175A
:1002E000003484011F30830583161F129F121B08E0
:1002F00080399B0007309C0082308312A90098301F
:10030000AA00AB004030AC00AD00AE006030AF00E2
:100310008630B000B430B1006030B200A430B30019
:10032000B400B5006130B6000330B700F030B8005B
:10033000E90183161F129F121B088039D0389B00D9
:100340001F1383121F179F1783169F1383121F14E7
:10035000941283160611861406120030831294003C
:10036000831694000108C039073881008312900178
:10037000073083169C0005080230F700F70BBE29F2
:10038000000000001C0883120D1383169D018611C6
:1003900083128611831606118312061183168610A6
:1003A000831286108316851383128517831605130F
:1003B000831205172030F8001F08C73978049F0002
:1003C000950183168611831286110C309700003038
:1003D000F8000438920064308316920062308F0077
:1003E000023083129500EA0183168610831286106C
:1003F0006430ED0051206A08EA0A043C031D112A0A
:100400006428EA014030E900EC016C084320003820
:1004100003190E2AEC0AED007128052A4030EC0081
:10042000072983168610831286140130ED005120AF
:100430001F151F19192A1E08503C031CF429831686
:100440008610831286104A216430EB00EA016A08A4
:10045000073C031C4D2A95010030F8000438920037
:100460006B08831692001330831295006430ED0000
:10047000512083168610831286140130ED0051201E
:100480001F151F19412A1E086A3C0318EB03831627
:10049000861083128610EA0A272A3A30EC00FA30D6
:1004A000ED005120EC0B4F2A831694012230831269
:1004B00094000230E80068089300C0308B04831673
:1004C0008C158312EA016A08073C031C702A6A082B
:1004D0003720F800E8003C30ED005120EA0A632A9A
:1004E000831694018312940183168C1106118312D2
:1004F00006150430EC00FA30ED005120EC0B7B2A9D
:10050000831606118312061195014A210830EC006A
:10051000FA30ED005120EC0B882A4A21831606118F
:100520008312061583168513831285178316051308
:10053000831205130230EC009630ED005120EC0BD5
:100540009C2A831685138312851383160513831241
:1005500005170230EC009630ED005120EC0BAB2A71
:10056000922A1430EC00FA30ED005120EC0BB32A43
:060570008A01002863006F
:04400E003827FC3F14
:00000001FF
;PIC16F88
/roboti/solarni/2006/jump/menic.c
0,0 → 1,158
#include ".\menic.h"
 
 
#define TXo PIN_B5 // To the transmitter modulator
#include ".\AX25.c" // Podprogram pro prenos telemetrie
char AXstring[40]; // Buffer pro prenos telemetrie
 
#define RAZENI 60 // Po kolika ms se bude menit rychlost pro rozjizdeni
#define REFNOM 107 // Hodnota odpovidajici 1,2V pri nominalnim zatizeni
#define REFSTART 80 // Hodnota odpovidajici 1,2V pri nezatizenych clancich
 
#define PIEZO PIN_A6 // Jeden pol piezo reproduktoru
#define LED PIN_A7 // LED
#define MENIC PIN_B3 // Spinani tranzistoru menice
#define REFPWR PIN_B1 // Napajeni zdroje referencniho napeti
#define MOTOR PIN_B2 // Spinani tranzistoru motoru
 
#byte SSPBUF = 0x13 // Registry jednotky SSP
#byte SSPCON1 = 0x14
#byte SSPSTAT = 0x94
 
// Vzorky pro generovani PWM pomoci SSP
unsigned int8 const Pattern[8] = {0x02,0x06,0x0e,0x1e,0x3e,0x7e,0xfe,0xff};
unsigned int8 MotorPattern;
 
#INT_SSP
void IntSSP()
{
SSPBUF=MotorPattern; // znovu vysli stejnou hodnotu
}
 
void pip() // pipnuti a bliknuti
{
int1 beep;
int i;
 
for(i=0; i<250; i++)
{
output_bit(PIEZO, beep);
beep=~beep;
output_bit(LED, beep);
delay_us(100);
};
output_high(PIEZO);
output_high(LED);
}
 
void cvak() // pouze cvaknuti piezoelementem bez bliknuti
{
output_bit(PIEZO,~input(PIEZO));
}
 
void main()
{
int8 n;
int8 perioda;
 
setup_adc_ports(ADC_CLOCK_INTERNAL|sAN4|VSS_VDD);
setup_adc(ADC_CLOCK_INTERNAL);
setup_spi(FALSE);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_256);
setup_timer_1(T1_DISABLED);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
 
output_low(MENIC); // Vsechno zastav
output_low(MOTOR);
output_low(REFPWR);
output_high(LED);
output_high(PIEZO);
 
set_adc_channel(4); // Vyber AD kanal pro pomerne mereni napeti
set_pwm1_duty(0); // Spust PWM, ale zatim s trvalou 0 na vystupu
setup_ccp1(CCP_PWM); // PWM pro zatizeni clanku v seru
setup_timer_2(T2_DIV_BY_1,100,1); // perioda
 
setup_oscillator(OSC_4MHZ|OSC_INTRC); // rozjed PIC (zvysi se odber)
 
 
// jsme v depu?
set_pwm1_duty(2); // PWM pro zatizeni clanku pri malem osvetleni
n=0;
do
{
output_low(REFPWR);
delay_ms(100);
if (4==n++)
{
cvak(); n=0;
sprintf(AXstring,"Ahoj"); // Convert DATA to String.
SendPacket(&AXstring[0]);
};
output_high(REFPWR); // zapni napajeni napetove reference
delay_ms(1);
} while (read_adc()>REFSTART); // Odkryl starter clanky?
output_low(REFPWR);
 
pip(); // potvrzeni odstartovani
 
// regulace
perioda=100; // nastav optimalni periodu pri jedne 500W zarovce
for(n=0;n<=7;n++)
{
set_pwm1_duty(0);
setup_timer_2(T2_DIV_BY_1,perioda,1); // perioda
set_pwm1_duty(19); // delka sepnuti
delay_ms(100);
output_high(REFPWR); // zapni napajeni napetove reference
delay_ms(1);
if (read_adc()<REFNOM) perioda--; // zvyseni zatizeni menice
output_low(REFPWR); // konec mereni, odpoj napajeni reference
};
 
// nabíjíme
delay_ms(14500); // 14,5s
 
// rozjezd
SSPSTAT = 0;
SSPCON1 = 0x22; // SPI OSC/64
MotorPattern=0x02; // prvni data pro vyslani
SSPBUF=MotorPattern; // data pro vyslani
enable_interrupts(global);
enable_interrupts(INT_SSP); // az budou vyslana, prijde interrupt od SSP
 
for(n=0; n<=7; n++) // razeni osmi rychlostnich stupnu
{
MotorPattern=Pattern[n];
delay_ms(RAZENI); // Pockej na dalsi razeni
};
SSPSTAT = 0;
SSPCON1 = 0; // SPI stop
disable_interrupts(INT_SSP); // zastav preruseni od SSP
 
// jedem co to da
output_high(MOTOR);
delay_ms(1000);
output_low(MOTOR);
set_pwm1_duty(0); // zastav menic
 
// vybiti kondenzatoru pro ucely mereni
pip();
delay_ms(2000);
pip();
output_high(MOTOR);
 
while(true)
{
output_high(LED);
output_low(PIEZO);
delay_ms(300);
output_low(LED);
output_high(PIEZO);
delay_ms(300);
}
// priprava na dalsi jizdu
delay_ms(5000);
reset_cpu();
}
/roboti/solarni/2006/jump/menic.cof
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/roboti/solarni/2006/jump/menic.err
0,0 → 1,2
No Errors
0 Errors, 0 Warnings.
/roboti/solarni/2006/jump/menic.h
0,0 → 1,6
#include <16F88.h>
 
#device adc=8
#fuses NOWDT,INTRC_IO, NOPUT, MCLR, NOBROWNOUT, NOLVP, NOCPD, NOWRT, DEBUG, NOPROTECT, NOFCMEN, NOIESO, CCPB3
#use delay(clock=3800000)
 
/roboti/solarni/2006/jump/miho/A.BAT
0,0 → 1,4
call picpgr stop
call picpgr erase pic16f88
call picpgr program DART.hex hex pic16f88
call picpgr run
/roboti/solarni/2006/jump/miho/DART.BAK
0,0 → 1,426
// DART01A verze programu 1.00
// (c)miho 2005
 
#include "DART.h"
 
 
#define BEEP0 PIN_A6 // pipak, prvni vystup
#define BEEP1 PIN_A7 // pipak, druhy vystup
#define PWM PIN_B3 // PWM vystup pro menic
#define REFPOWER PIN_B1 // napajeni zdroje Vref
#define MOTOR PIN_B2 // zapinani motoru
#define SW0 PIN_B7 // konfiguracni prepinac 0
#define SW1 PIN_B6 // konfiguracni prepinac 1
 
 
void InitRS232()
// Inicializace HW RS232
{
SPBRG=xclock/9600/16-1; // ryclost 9600Bd
RCSTA=0b10000000; // enable USART
TXSTA=0b00100100; // BRGH=1, TX enable
}
 
 
void Putc(char c)
// Posilani znaku pres HW RS232
{
while(TRMT==0); // cekej na prazdny TX buffer
TXREG=c; // predej data
}
 
 
// Globalni promenna pro data posilana na SSP
// Nastavuje se funkci MotorPatternSet()
// Vyuziva se v prerusovaci rutine IntSSP()
unsigned int8 MotorPattern; // aktualni data pro SSP jednotku
 
 
void MotorPatternSet(unsigned int Gear)
// Na zaklade rychlosti nastavi MotorPattern pro SSP
// Rychlost 0 znamena stop, rychlost 8 je maximum
{
// Tabulka rychlost -> pattern pro SSP
unsigned int8 const ExpTab[8] = {0x02,0x06,0x0e,0x1e,0x3e,0x7e,0xfe,0xff};
 
// Vyber patternu
if (Gear==0) // stav 0 znamena stop
{
output_low(MOTOR); // klidovy stav
SSPSTAT = 0;
SSPCON1 = 0; // SPI stop
disable_interrupts(INT_SSP); // neni preruseni od SSP
}
else // rizeny vykon
{
if (Gear>7) // stav 8 a vice znamena plny vykon
{
Gear=8; // plny plyn
}
 
MotorPattern=ExpTab[--Gear]; // prevod z hodnoty plynu na data pro SSP
output_low(MOTOR); // klidovy stav
SSPSTAT = 0;
SSPCON1 = 0x22; // SPI OSC/64
 
SSPBUF=MotorPattern; // prvni data pro vyslani
enable_interrupts(INT_SSP); // az budou vyslana prijde interrupt od SSP
}
}
 
 
// Obsluha preruseni od SSP jednotky, posila data z promenne MotorRun do SSP.
#INT_SSP
void IntSSP()
{
SSPBUF=MotorPattern; // znova hdnota PWM patternu na SSP
}
 
 
void MotorSet(unsigned int Gear)
// Nastavi vykon motoru dle hodnoty Gear a zahaji posilani PWM dat pres SSP pod prerusenim
// od SSP jednotky
// 0 stop
// 1-7 pocet 1/8 vykonu
// >7 plny vykon
{
// Nastav PWM pattern
MotorPatternSet(Gear); // nastav PWM pattern pro SSP
 
// Povol preruseni
enable_interrupts(GLOBAL); // povol preruseni
}
 
 
void InitT0()
// Inicializace casovace T0 (cca 1000x za sekundu)
{
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_4); // T0 z internich hodin 1/4
enable_interrupts(INT_RTCC); // generuj preruseni od T0
enable_interrupts(GLOBAL); // povol preruseni
}
 
 
// Globalni promenna pro mereni casu
// Nastavuje se procedurou TimeSet()
// Testuje se funkci TimeIf()
// Modifikuje se pri preruseni od casovace IntTo()
unsigned int16 TimeTime;
 
 
void TimerSet(unsigned int16 Time)
// Nastavi casovac na zadany pocet ms
// Test uplynuti casu se dela pomoci TimerIf()
{
// Nastav hodnotu
disable_interrupts(INT_RTCC); // nesmi prijit preruseni
TimeTime=Time; // pri nastavovani hodnoty
enable_interrupts(INT_RTCC); // promenne (o delce vice nez 8 bitu)
}
 
 
int1 TimerIf()
// Vraci TRUE pokud casovac jiz dobehl
{
int1 Flag; // pomocna promenna
 
// Otestuj casovac
disable_interrupts(INT_RTCC); // nesmi prijit preruseni
Flag=(TimeTime==0); // behem testu promenne
enable_interrupts(INT_RTCC); // ted uz muze
 
// Navratova hodnota
return Flag; // TRUE znamena dobehl casovac
}
 
 
// Globalni promenne pro akceleraci
// Nastavuje se metodou MotorStart()
// Pouziva se v obsluze preruseni IntT0()
unsigned int8 MotorTime; // aktualni casovac pro rozjezd
unsigned int8 MotorDelay; // spozdeni mezi razenim
unsigned int8 MotorGear; // rychlostni stupen
 
 
void MotorStart(unsigned int8 Delay)
// Provede rizeny rozjezd motoru
{
disable_interrupts(INT_RTCC);
MotorGear=1;
MotorDelay=Delay;
MotorTime=MotorDelay;
enable_interrupts(INT_RTCC);
 
MotorPatternSet(1);
}
 
 
#INT_TIMER0
void IntT0()
// Preruseni od casovace cca 1000x za sekundu
{
// Odpocitavani casovace
if (TimeTime) TimeTime--;
 
// Obsluha akcelerace
if (MotorTime) MotorTime--; // dekrementuj casovac rozjezdu
if ((MotorGear>0) && (MotorGear<8) && (!MotorTime)) // dalsi rychlostni stupen
{
MotorTime=MotorDelay; // znovu nastav casovac
MotorGear++; // dalsi rychlost
MotorPatternSet(MotorGear); // nastav rychlost
}
}
 
 
// Cteni dat z AD prevodniku, zadava se cislo kanalu
int8 ReadAD(int8 Ch)
{
// Pokud merim Vref zapnu si jeho napajeni
if (Ch==4) output_high(REFPOWER);
 
// Inicializace a cislo kanalu
ADCON1=0x30; // Vref+-, bez deleni hodin, Left Justify
ADCON0=0x41+(Ch<<3); // on, Tosc/8, cislo kanalu
 
// Mereni
delay_us(50); // doba na prepnuti kanalu
ADCON0 |= 4; // start prevodu
delay_us(50); // doba na prevod
 
// Vypnu napajeni Vref (vzdycky)
output_low(REFPOWER);
 
// Navrat hodnoty
return ADRESH;
}
 
 
void main()
{
unsigned int8 Debug;
unsigned int8 i;
 
// Hodiny
OSCCON = 0x62; // 4 MHz interni RC oscilator
 
// Digitalni vystupy
output_low(PWM); // PWM vystup
output_low(MOTOR); // Proud do motoru
output_low(REFPOWER); // Napajeni Vref
port_b_pullups(TRUE); // Zbyvajici vyvody portu B
 
// Watch Dog
PSA=0; // preddelic prirazen casovaci
WDTCON=0x0E; // Watch Dog cca 130ms
/*
// Analogove vstupy
ANSEL = 0x1F; // AN0 az AN4
 
// nastaveni RS232
InitRS232(); // inicializace HW RS232 (nutno pockat cca 10ms)
 
// Pipnuti (a cekani)
for (i=1;i<30;i++) // pocet 1/2 period
{
int1 beep; // stavova promenna pro pipak
 
output_bit(BEEP0,beep);
beep=~beep;
output_bit(BEEP1,beep);
delay_us(1000);
}
 
// Rozhodnuti o rezimu cinnosti
Debug=0;
if (~input(SW0)) Debug|=1; // precti bit 0
if (~input(SW1)) Debug|=2; // precti bit 1
output_low(SW0); // nastav L aby se snizila spotreba
output_low(SW1); // na obou vstupech
 
// Zobrazeni rezimu
printf(Putc,"\fMode:%d",Debug);
*/
// Inicializace PWM
PR2 = 0x1F; // perioda PWM casovace
T2CON = 0x04; // povoleni casovace T2 bez preddelicu a postdelicu
CCP1CON = 0x0C; // PWM mode, lsb bity nulove
CCPR1L = 0; // na zacatku nulova data
output_low(PWM); // PWM vystup
 
//!!!KAKL
CCPR1L = 20; // pouziti vystupu
disable_interrupts(GLOBAL);
while(true);
 
// Inicializace casovace
InitT0(); // nastav casovac na cca 1ms
 
//!!!KAKL
Debug=3;
 
// Test menice PWM a rozjezdoveho PWM
if (Debug==1)
{
unsigned int8 Data1; // poteniometr P1 = PWM
unsigned int8 Data2; // poteniometr P2 = Rozjezd
 
while (1)
{
// watch dog
restart_wdt();
 
// mereni vstupu
Data1=ReadAD(0); // nacti parametr pro PWM
Data1>>=2; // redukuj rozsah na 0 az 63
Data2=ReadAD(1); // nacti parametr pro rozjezd
Data2>>=4; // redukuj rozsah na 0 az 15
 
// zobrazeni
printf(Putc,"\nPWM:%03u RUN:%03u",Data1,Data2);
delay_ms(20);
 
// nastaveni parametru PWM
CCPR1L = Data1;
 
// nastaveni parametru RUN
MotorSet(Data2);
}
}
 
// Testovani rozjezdu
// Zadava se cas mezi stupni razeni pro rozjezd v ms
if (Debug==2)
{
int8 Data;
int8 Start;
 
Start=0; // uvodni stav
while(1)
{
// Nacti a zobraz parametr
Data=ReadAD(1); // potenciometr P2 = rozjezd
printf(Putc,"\nRUN: %3ums ",Data); // zobraz
delay_ms(10); // prodleva pro terminal
 
// Uvodni pauza
if (Start==0) // spousti se 1x na zacatku
{
Start++; // dalsi stav je cekani
TimerSet(2000); // na dokonceni uvodni prodlevy
}
 
// Rozjezd
if ((Start==1) && TimerIf())
{
Start++;
printf(Putc,"R");
MotorStart(Data); // rozjezd s nastavenim prodlevy
 
TimerSet(2000); // nastav celkovy cas jizdy
}
 
// Zastaveni
if ((Start==2) && TimerIf())
{
Start++;
printf(Putc,"S");
MotorSet(0); // pokud dobehl casovac zastav motor
}
 
// watch dog
restart_wdt();
}
}
 
// Test nabijeciho algoritmu
if (Debug==3)
{
unsigned int8 PwmOut; // akcni hodnota pro PWM
unsigned int8 Req; // pozadovana hodnota z P1
unsigned int8 Vref; // merena hodnota vref
 
// Inicializace stavove promenne
PwmOut=0;
 
// Hlavni smycka
while (1)
{
// watch dog
restart_wdt();
 
// pozadovana hodnota (potenciometr P1)
Req=ReadAD(0);
Req=50+(ReadAD(0)>>1); // 50 az 177
 
// napeti na napajeni (vref)
Vref=ReadAD(4);
 
// ricici algoritmus
if ((Vref<Req) &&(PwmOut<30)) PwmOut++;
if ((Vref>=Req)&&(PwmOut> 0)) PwmOut--;
Vref+=10;
if ((Vref<(Req))&&(PwmOut<30)) PwmOut++; // urychleni nabehu
 
// nastaveni parametru PWM
if (PwmOut>24) PwmOut=24; // saturace
//!!!KAKL
PwmOut=20;
CCPR1L = PwmOut; // pouziti vystupu
disable_interrupts(GLOBAL);
while(true);
// zobrazeni
printf(Putc,"\nALG:%03u %03u %03u",Req,Vref,PwmOut);
delay_ms(10);
}
}
 
// Standardni beh
if (Debug==0)
{
unsigned int8 PwmOut; // akcni hodnota pro PWM
unsigned int8 Req; // pozadovana hodnota z P1
unsigned int8 Vref; // merena hodnota vref
int1 Run;
 
// Inicializace stavove promenne
PwmOut=0;
TimerSet(14000); // casovani startu
Run=1;
 
// Hlavni smycka
while (1)
{
// watch dog
restart_wdt();
 
// pozadovana hodnota (potenciometr P1)
Req=ReadAD(0);
Req=50+(ReadAD(0)>>1); // 50 az 177
 
// napeti na napajeni (vref)
Vref=ReadAD(4);
 
// ricici algoritmus
if ((Vref<Req) &&(PwmOut<30)) PwmOut++;
if ((Vref>=Req)&&(PwmOut> 0)) PwmOut--;
Vref+=10;
if ((Vref<(Req))&&(PwmOut<30)) PwmOut++; // urychleni nabehu
 
// nastaveni parametru PWM
if (PwmOut>24) PwmOut=24; // saturace
CCPR1L = PwmOut; // pouziti vystupu
 
// zobrazeni
printf(Putc,"\nALG:%03u %03u %03u",Req,Vref,PwmOut);
delay_ms(10);
 
// rozjezd
if (TimerIf()&&Run)
{
Run=0;
MotorStart(65);
}
}
}
}
/roboti/solarni/2006/jump/miho/DART.C
0,0 → 1,425
// DART01A verze programu 1.00
// (c)miho 2005
 
#include "DART.h"
 
 
#define BEEP0 PIN_A6 // pipak, prvni vystup
#define BEEP1 PIN_A7 // pipak, druhy vystup
#define PWM PIN_B3 // PWM vystup pro menic
#define REFPOWER PIN_B1 // napajeni zdroje Vref
#define MOTOR PIN_B2 // zapinani motoru
#define SW0 PIN_B7 // konfiguracni prepinac 0
#define SW1 PIN_B6 // konfiguracni prepinac 1
 
 
void InitRS232()
// Inicializace HW RS232
{
SPBRG=xclock/9600/16-1; // ryclost 9600Bd
RCSTA=0b10000000; // enable USART
TXSTA=0b00100100; // BRGH=1, TX enable
}
 
 
void Putc(char c)
// Posilani znaku pres HW RS232
{
while(TRMT==0); // cekej na prazdny TX buffer
TXREG=c; // predej data
}
 
 
// Globalni promenna pro data posilana na SSP
// Nastavuje se funkci MotorPatternSet()
// Vyuziva se v prerusovaci rutine IntSSP()
unsigned int8 MotorPattern; // aktualni data pro SSP jednotku
 
 
void MotorPatternSet(unsigned int Gear)
// Na zaklade rychlosti nastavi MotorPattern pro SSP
// Rychlost 0 znamena stop, rychlost 8 je maximum
{
// Tabulka rychlost -> pattern pro SSP
unsigned int8 const ExpTab[8] = {0x02,0x06,0x0e,0x1e,0x3e,0x7e,0xfe,0xff};
 
// Vyber patternu
if (Gear==0) // stav 0 znamena stop
{
output_low(MOTOR); // klidovy stav
SSPSTAT = 0;
SSPCON1 = 0; // SPI stop
disable_interrupts(INT_SSP); // neni preruseni od SSP
}
else // rizeny vykon
{
if (Gear>7) // stav 8 a vice znamena plny vykon
{
Gear=8; // plny plyn
}
 
MotorPattern=ExpTab[--Gear]; // prevod z hodnoty plynu na data pro SSP
output_low(MOTOR); // klidovy stav
SSPSTAT = 0;
SSPCON1 = 0x22; // SPI OSC/64
 
SSPBUF=MotorPattern; // prvni data pro vyslani
enable_interrupts(INT_SSP); // az budou vyslana prijde interrupt od SSP
}
}
 
 
// Obsluha preruseni od SSP jednotky, posila data z promenne MotorRun do SSP.
#INT_SSP
void IntSSP()
{
SSPBUF=MotorPattern; // znova hdnota PWM patternu na SSP
}
 
 
void MotorSet(unsigned int Gear)
// Nastavi vykon motoru dle hodnoty Gear a zahaji posilani PWM dat pres SSP pod prerusenim
// od SSP jednotky
// 0 stop
// 1-7 pocet 1/8 vykonu
// >7 plny vykon
{
// Nastav PWM pattern
MotorPatternSet(Gear); // nastav PWM pattern pro SSP
 
// Povol preruseni
enable_interrupts(GLOBAL); // povol preruseni
}
 
 
void InitT0()
// Inicializace casovace T0 (cca 1000x za sekundu)
{
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_4); // T0 z internich hodin 1/4
enable_interrupts(INT_RTCC); // generuj preruseni od T0
enable_interrupts(GLOBAL); // povol preruseni
}
 
 
// Globalni promenna pro mereni casu
// Nastavuje se procedurou TimeSet()
// Testuje se funkci TimeIf()
// Modifikuje se pri preruseni od casovace IntTo()
unsigned int16 TimeTime;
 
 
void TimerSet(unsigned int16 Time)
// Nastavi casovac na zadany pocet ms
// Test uplynuti casu se dela pomoci TimerIf()
{
// Nastav hodnotu
disable_interrupts(INT_RTCC); // nesmi prijit preruseni
TimeTime=Time; // pri nastavovani hodnoty
enable_interrupts(INT_RTCC); // promenne (o delce vice nez 8 bitu)
}
 
 
int1 TimerIf()
// Vraci TRUE pokud casovac jiz dobehl
{
int1 Flag; // pomocna promenna
 
// Otestuj casovac
disable_interrupts(INT_RTCC); // nesmi prijit preruseni
Flag=(TimeTime==0); // behem testu promenne
enable_interrupts(INT_RTCC); // ted uz muze
 
// Navratova hodnota
return Flag; // TRUE znamena dobehl casovac
}
 
 
// Globalni promenne pro akceleraci
// Nastavuje se metodou MotorStart()
// Pouziva se v obsluze preruseni IntT0()
unsigned int8 MotorTime; // aktualni casovac pro rozjezd
unsigned int8 MotorDelay; // spozdeni mezi razenim
unsigned int8 MotorGear; // rychlostni stupen
 
 
void MotorStart(unsigned int8 Delay)
// Provede rizeny rozjezd motoru
{
disable_interrupts(INT_RTCC);
MotorGear=1;
MotorDelay=Delay;
MotorTime=MotorDelay;
enable_interrupts(INT_RTCC);
 
MotorPatternSet(1);
}
 
 
#INT_TIMER0
void IntT0()
// Preruseni od casovace cca 1000x za sekundu
{
// Odpocitavani casovace
if (TimeTime) TimeTime--;
 
// Obsluha akcelerace
if (MotorTime) MotorTime--; // dekrementuj casovac rozjezdu
if ((MotorGear>0) && (MotorGear<8) && (!MotorTime)) // dalsi rychlostni stupen
{
MotorTime=MotorDelay; // znovu nastav casovac
MotorGear++; // dalsi rychlost
MotorPatternSet(MotorGear); // nastav rychlost
}
}
 
 
// Cteni dat z AD prevodniku, zadava se cislo kanalu
int8 ReadAD(int8 Ch)
{
// Pokud merim Vref zapnu si jeho napajeni
if (Ch==4) output_high(REFPOWER);
 
// Inicializace a cislo kanalu
ADCON1=0x30; // Vref+-, bez deleni hodin, Left Justify
ADCON0=0x41+(Ch<<3); // on, Tosc/8, cislo kanalu
 
// Mereni
delay_us(50); // doba na prepnuti kanalu
ADCON0 |= 4; // start prevodu
delay_us(50); // doba na prevod
 
// Vypnu napajeni Vref (vzdycky)
output_low(REFPOWER);
 
// Navrat hodnoty
return ADRESH;
}
 
 
void main()
{
unsigned int8 Debug;
unsigned int8 i;
 
// Hodiny
OSCCON = 0x62; // 4 MHz interni RC oscilator
/*
// Digitalni vystupy
output_low(PWM); // PWM vystup
output_low(MOTOR); // Proud do motoru
output_low(REFPOWER); // Napajeni Vref
port_b_pullups(TRUE); // Zbyvajici vyvody portu B
 
// Watch Dog
PSA=0; // preddelic prirazen casovaci
WDTCON=0x0E; // Watch Dog cca 130ms
// Analogove vstupy
ANSEL = 0x1F; // AN0 az AN4
 
// nastaveni RS232
InitRS232(); // inicializace HW RS232 (nutno pockat cca 10ms)
 
// Pipnuti (a cekani)
for (i=1;i<30;i++) // pocet 1/2 period
{
int1 beep; // stavova promenna pro pipak
 
output_bit(BEEP0,beep);
beep=~beep;
output_bit(BEEP1,beep);
delay_us(1000);
}
 
// Rozhodnuti o rezimu cinnosti
Debug=0;
if (~input(SW0)) Debug|=1; // precti bit 0
if (~input(SW1)) Debug|=2; // precti bit 1
output_low(SW0); // nastav L aby se snizila spotreba
output_low(SW1); // na obou vstupech
 
// Zobrazeni rezimu
printf(Putc,"\fMode:%d",Debug);
*/
// Inicializace PWM
PR2 = 0x1F; // perioda PWM casovace
T2CON = 0x04; // povoleni casovace T2 bez preddelicu a postdelicu
CCP1CON = 0x0C; // PWM mode, lsb bity nulove
CCPR1L = 0; // na zacatku nulova data
output_low(PWM); // PWM vystup
 
//!!!KAKL
CCPR1L = 20; // pouziti vystupu
disable_interrupts(GLOBAL);
while(true);
 
// Inicializace casovace
InitT0(); // nastav casovac na cca 1ms
 
//!!!KAKL
Debug=3;
 
// Test menice PWM a rozjezdoveho PWM
if (Debug==1)
{
unsigned int8 Data1; // poteniometr P1 = PWM
unsigned int8 Data2; // poteniometr P2 = Rozjezd
 
while (1)
{
// watch dog
restart_wdt();
 
// mereni vstupu
Data1=ReadAD(0); // nacti parametr pro PWM
Data1>>=2; // redukuj rozsah na 0 az 63
Data2=ReadAD(1); // nacti parametr pro rozjezd
Data2>>=4; // redukuj rozsah na 0 az 15
 
// zobrazeni
printf(Putc,"\nPWM:%03u RUN:%03u",Data1,Data2);
delay_ms(20);
 
// nastaveni parametru PWM
CCPR1L = Data1;
 
// nastaveni parametru RUN
MotorSet(Data2);
}
}
 
// Testovani rozjezdu
// Zadava se cas mezi stupni razeni pro rozjezd v ms
if (Debug==2)
{
int8 Data;
int8 Start;
 
Start=0; // uvodni stav
while(1)
{
// Nacti a zobraz parametr
Data=ReadAD(1); // potenciometr P2 = rozjezd
printf(Putc,"\nRUN: %3ums ",Data); // zobraz
delay_ms(10); // prodleva pro terminal
 
// Uvodni pauza
if (Start==0) // spousti se 1x na zacatku
{
Start++; // dalsi stav je cekani
TimerSet(2000); // na dokonceni uvodni prodlevy
}
 
// Rozjezd
if ((Start==1) && TimerIf())
{
Start++;
printf(Putc,"R");
MotorStart(Data); // rozjezd s nastavenim prodlevy
 
TimerSet(2000); // nastav celkovy cas jizdy
}
 
// Zastaveni
if ((Start==2) && TimerIf())
{
Start++;
printf(Putc,"S");
MotorSet(0); // pokud dobehl casovac zastav motor
}
 
// watch dog
restart_wdt();
}
}
 
// Test nabijeciho algoritmu
if (Debug==3)
{
unsigned int8 PwmOut; // akcni hodnota pro PWM
unsigned int8 Req; // pozadovana hodnota z P1
unsigned int8 Vref; // merena hodnota vref
 
// Inicializace stavove promenne
PwmOut=0;
 
// Hlavni smycka
while (1)
{
// watch dog
restart_wdt();
 
// pozadovana hodnota (potenciometr P1)
Req=ReadAD(0);
Req=50+(ReadAD(0)>>1); // 50 az 177
 
// napeti na napajeni (vref)
Vref=ReadAD(4);
 
// ricici algoritmus
if ((Vref<Req) &&(PwmOut<30)) PwmOut++;
if ((Vref>=Req)&&(PwmOut> 0)) PwmOut--;
Vref+=10;
if ((Vref<(Req))&&(PwmOut<30)) PwmOut++; // urychleni nabehu
 
// nastaveni parametru PWM
if (PwmOut>24) PwmOut=24; // saturace
//!!!KAKL
PwmOut=20;
CCPR1L = PwmOut; // pouziti vystupu
disable_interrupts(GLOBAL);
while(true);
// zobrazeni
printf(Putc,"\nALG:%03u %03u %03u",Req,Vref,PwmOut);
delay_ms(10);
}
}
 
// Standardni beh
if (Debug==0)
{
unsigned int8 PwmOut; // akcni hodnota pro PWM
unsigned int8 Req; // pozadovana hodnota z P1
unsigned int8 Vref; // merena hodnota vref
int1 Run;
 
// Inicializace stavove promenne
PwmOut=0;
TimerSet(14000); // casovani startu
Run=1;
 
// Hlavni smycka
while (1)
{
// watch dog
restart_wdt();
 
// pozadovana hodnota (potenciometr P1)
Req=ReadAD(0);
Req=50+(ReadAD(0)>>1); // 50 az 177
 
// napeti na napajeni (vref)
Vref=ReadAD(4);
 
// ricici algoritmus
if ((Vref<Req) &&(PwmOut<30)) PwmOut++;
if ((Vref>=Req)&&(PwmOut> 0)) PwmOut--;
Vref+=10;
if ((Vref<(Req))&&(PwmOut<30)) PwmOut++; // urychleni nabehu
 
// nastaveni parametru PWM
if (PwmOut>24) PwmOut=24; // saturace
CCPR1L = PwmOut; // pouziti vystupu
 
// zobrazeni
printf(Putc,"\nALG:%03u %03u %03u",Req,Vref,PwmOut);
delay_ms(10);
 
// rozjezd
if (TimerIf()&&Run)
{
Run=0;
MotorStart(65);
}
}
}
}
/roboti/solarni/2006/jump/miho/DART.HEX
0,0 → 1,108
:1000000000308A00C8290000FF00030E8301A10010
:100010007F08A0000A08A8008A01A00E0408A20018
:100020007708A3007808A4007908A5007A08A6003C
:100030007B08A700831383128C308400801D222844
:100040008C1939288B1E26280B193B28220884007E
:100050002308F7002408F8002508F9002608FA000C
:100060002708FB0028088A00210E8300FF0E7F0E60
:1000700009008A1189288A11B7280A108A100A11E2
:100080008207023406340E341E343E347E34FE348D
:10009000FF340A108A100A1182070A345034573488
:1000A0004D343A34253430343334753420345234BA
:1000B00055344E343A3425343034333475340034C6
:1000C0000A108A100A1182070A34523455344E3409
:1000D0003A3420342534333475346D347334203459
:1000E00000340A108A100A1182070A3441344C3451
:1000F00047343A342534303433347534203425349D
:10010000303433347534203425343034333475345A
:1001100000342A0893008C118A112628C408031D74
:100120009D288316061183120611831694018312EB
:10013000940183168C11B52883124408073C0318D8
:10014000A3280830C400C40344083D20F800AA00D6
:10015000831606118312061183169401223083122E
:1001600094002A08930083168C15831200342B0800
:100170002C040319BF282B080319AC03AB03AD08EB
:10018000031DAD03AF080319D2282F08073C031C39
:10019000D228AD08031DD2282E08AD00AF0A2F08C3
:1001A000C4008E200B118A11262883160108C0393D
:1001B0000138810083128B16C0308B048A11EF291D
:1001C0003D08043C031DE82883168610831286141C
:1001D000303083169F0083123D0DF700F70DF70DA9
:1001E000F830F7057708413E9F0064001030F700B3
:1001F000F70BF828000000001F1564001030F7000E
:10020000F70B002900000000831686108312861069
:100210001E08F800003483169818102983120B2941
:1002200083124108990000344208F8014102031882
:100230001C294108F7002829F7010830C300C10D27
:10024000F70D420877020318F700F80DC30B1F29BA
:1002500000344013C0123F08C1006430C2001421B2
:100260007708BF007808031D5329C01A5329C01905
:100270006129401B41294018412940194129C01BCF
:100280006129401C4D29C01B6129401B4D29401884
:10029000612940194D29C01B61292030401E303092
:1002A000C1000B216129C016C01F5D29780880009C
:1002B000F8002D30C1000B21C01330307807C10089
:1002C0000B21401B6C293F08C1000A30C2001421D9
:1002D0007708BF0040173229C01F71292D30C10097
:1002E0000B2130303F07C1000B2100343D3084002A
:1002F000000803198C290130F800BF30F7006400B2
:10030000F70B7F29F80B7D295830F700F70B86296A
:1003100000006400800B7B290034A9018B1BA91706
:100320008B133D08C4008E20A91B8B17C0308B0493
:1003300000348B123E08AC003D08AB008B16003435
:100340008B12AB08031DA729AC080319A92900309B
:10035000AA290130F8007818AF293D10B0293D14C2
:100360008B1600303D180130F80000348B1201303C
:10037000AF003D08AE002E08AD008B16A9018B1B07
:10038000A9178B130130C4008E20A91B8B170034D2
:1003900084011F30830583161F129F121B088039AA
:1003A0009B0007309C00050864001C0883120D1395
:1003B000623083168F001F30920004308312920047
:1003C0000C30970095018316861183128611143024
:1003D00095000B138B138B1BEA29ED29D5280330CD
:1003E000B000300B2C2A6400BD01E0207808B20078
:1003F000B20CB20C3F30B2050130BD00E0207808ED
:10040000B300B30E0F30B305BD013D084920BD0A4E
:10041000F700C1000B2105303D02031D052A3208FB
:10042000BF00C00129210930BE003E084920BE0A94
:10043000F700C1000B210E303E02031D152A3308C0
:10044000BF00C00129211430BD007621320895007B
:100450003308BD008D21F3293008023C031D7D2A9D
:10046000B5010130BD00E0207808B400BD013D08B1
:100470006020BD0AF700C1000B2106303D02031DBC
:10048000372A3408BF001030C00029216D30C10068
:100490000B217330C1000B212030C1000B210A3029
:1004A000BD007621B508031D5B2AB50A0730BE00E2
:1004B000D030BD009921350B6D2AA021F808031911
:1004C0006D2AB50A5230C1000B213408BD00B62197
:1004D0000730BE00D030BD0099213508023C031D15
:1004E0007B2AA021F80803197B2AB50A5330C100E2
:1004F0000B21BD018D216400312A3008033C031D0E
:10050000DB2AB6016400BD01E0207808B700BD0118
:10051000E0200310780C323EB7000430BD00E0202C
:100520007808B8003708380203189A2A36081D3CA4
:100530000318B60A37083802031CA12AB608031D9F
:10054000B6030A30B807370838020318AB2A360852
:100550001D3C0318B60A3608183C0318B12A183097
:10056000B6001430B600360895000B138B138B1BA6
:10057000B62AB92ABD013D087120BD0AF700C100A5
:100580000B2105303D02031DBB2A3708BF00C00107
:1005900029212030C1000B213808BF00C0012921CA
:1005A0002030C1000B213608BF00C00129210A30CC
:1005B000BD007621822AB008031D412BB9013630D7
:1005C000BE00B030BD0099213C146400BD01E020A4
:1005D0007808BA00BD01E0200310780C323EBA0062
:1005E0000430BD00E0207808BB003A083B02031845
:1005F000FD2A39081D3C0318B90A3A083B02031CBE
:10060000042BB908031DB9030A30BB073A083B02A3
:1006100003180E2B39081D3C0318B90A3908183C79
:100620000318142B1830B90039089500BD013D0896
:100630007120BD0AF700C1000B2105303D02031DEA
:10064000172B3A08BF00C00129212030C1000B211F
:100650003B08BF00C00129212030C1000B2139080F
:10066000BF00C00129210A30BD007621A021F80871
:100670000319402B3C1C402B3C104130BD00B621DF
:04068000E52A630004
:04400E00382FFF3F09
:00000001FF
;PIC16F88
/roboti/solarni/2006/jump/miho/DART.LST
0,0 → 1,1126
CCS PCM C Compiler, Version 3.221, 27853 21-VIII-05 18:18
 
Filename: C:\PIC\jump\miho\DART.LST
 
ROM used: 834 words (20%)
Largest free fragment is 2048
RAM used: 25 (14%) at main() level
42 (24%) worst case
Stack: 6 worst case (3 in main + 3 for interrupts)
 
*
0000: MOVLW 00
0001: MOVWF 0A
0002: GOTO 1C8
0003: NOP
0004: MOVWF 7F
0005: SWAPF 03,W
0006: CLRF 03
0007: MOVWF 21
0008: MOVF 7F,W
0009: MOVWF 20
000A: MOVF 0A,W
000B: MOVWF 28
000C: CLRF 0A
000D: SWAPF 20,F
000E: MOVF 04,W
000F: MOVWF 22
0010: MOVF 77,W
0011: MOVWF 23
0012: MOVF 78,W
0013: MOVWF 24
0014: MOVF 79,W
0015: MOVWF 25
0016: MOVF 7A,W
0017: MOVWF 26
0018: MOVF 7B,W
0019: MOVWF 27
001A: BCF 03.7
001B: BCF 03.5
001C: MOVLW 8C
001D: MOVWF 04
001E: BTFSS 00.3
001F: GOTO 022
0020: BTFSC 0C.3
0021: GOTO 039
0022: BTFSS 0B.5
0023: GOTO 026
0024: BTFSC 0B.2
0025: GOTO 03B
0026: MOVF 22,W
0027: MOVWF 04
0028: MOVF 23,W
0029: MOVWF 77
002A: MOVF 24,W
002B: MOVWF 78
002C: MOVF 25,W
002D: MOVWF 79
002E: MOVF 26,W
002F: MOVWF 7A
0030: MOVF 27,W
0031: MOVWF 7B
0032: MOVF 28,W
0033: MOVWF 0A
0034: SWAPF 21,W
0035: MOVWF 03
0036: SWAPF 7F,F
0037: SWAPF 7F,W
0038: RETFIE
0039: BCF 0A.3
003A: GOTO 089
003B: BCF 0A.3
003C: GOTO 0B7
.................... // DART01A verze programu 1.00
.................... // (c)miho 2005
....................
.................... #include "DART.h"
.................... // DART01A verze programu 1.00
.................... // (c)miho 2005
....................
.................... #include ".\lib\16F88.h" // standardni definice konstant
.................... //////// Header file for the PIC16F88
.................... #device PIC16F88
.................... #list
.................... #include ".\lib\16F88_Reg.h" // standardni definice vsech FSR
.................... #list
....................
....................
.................... #device adc=8 // AD prevodnik jen na 8 bitu
.................... #define xclock 4168000 // muj konkretni PIC je trochu rychlejsi
.................... #use delay(clock=xclock,restart_wdt)
0176: MOVLW 3D
0177: MOVWF 04
0178: MOVF 00,W
0179: BTFSC 03.2
017A: GOTO 18C
017B: MOVLW 01
017C: MOVWF 78
017D: MOVLW BF
017E: MOVWF 77
017F: CLRWDT
0180: DECFSZ 77,F
0181: GOTO 17F
0182: DECFSZ 78,F
0183: GOTO 17D
0184: MOVLW 58
0185: MOVWF 77
0186: DECFSZ 77,F
0187: GOTO 186
0188: NOP
0189: CLRWDT
018A: DECFSZ 00,F
018B: GOTO 17B
018C: RETLW 00
.................... #fuses INTRC_IO, NOWDT, NOPUT, NOPROTECT, NOBROWNOUT, MCLR, NOLVP, NOCPD, NODEBUG, CCPB3
....................
....................
....................
.................... #define BEEP0 PIN_A6 // pipak, prvni vystup
.................... #define BEEP1 PIN_A7 // pipak, druhy vystup
.................... #define PWM PIN_B3 // PWM vystup pro menic
.................... #define REFPOWER PIN_B1 // napajeni zdroje Vref
.................... #define MOTOR PIN_B2 // zapinani motoru
.................... #define SW0 PIN_B7 // konfiguracni prepinac 0
.................... #define SW1 PIN_B6 // konfiguracni prepinac 1
....................
....................
.................... void InitRS232()
.................... // Inicializace HW RS232
.................... {
.................... SPBRG=xclock/9600/16-1; // ryclost 9600Bd
.................... RCSTA=0b10000000; // enable USART
.................... TXSTA=0b00100100; // BRGH=1, TX enable
.................... }
....................
....................
.................... void Putc(char c)
.................... // Posilani znaku pres HW RS232
.................... {
.................... while(TRMT==0); // cekej na prazdny TX buffer
*
010B: BSF 03.5
010C: BTFSC 18.1
010D: GOTO 110
010E: BCF 03.5
010F: GOTO 10B
.................... TXREG=c; // predej data
0110: BCF 03.5
0111: MOVF 41,W
0112: MOVWF 19
.................... }
0113: RETLW 00
....................
....................
.................... // Globalni promenna pro data posilana na SSP
.................... // Nastavuje se funkci MotorPatternSet()
.................... // Vyuziva se v prerusovaci rutine IntSSP()
.................... unsigned int8 MotorPattern; // aktualni data pro SSP jednotku
....................
....................
.................... void MotorPatternSet(unsigned int Gear)
.................... // Na zaklade rychlosti nastavi MotorPattern pro SSP
.................... // Rychlost 0 znamena stop, rychlost 8 je maximum
.................... {
.................... // Tabulka rychlost -> pattern pro SSP
.................... unsigned int8 const ExpTab[8] = {0x02,0x06,0x0e,0x1e,0x3e,0x7e,0xfe,0xff};
....................
.................... // Vyber patternu
.................... if (Gear==0) // stav 0 znamena stop
*
008E: MOVF 44,F
008F: BTFSS 03.2
0090: GOTO 09D
.................... {
.................... output_low(MOTOR); // klidovy stav
0091: BSF 03.5
0092: BCF 06.2
0093: BCF 03.5
0094: BCF 06.2
.................... SSPSTAT = 0;
0095: BSF 03.5
0096: CLRF 14
.................... SSPCON1 = 0; // SPI stop
0097: BCF 03.5
0098: CLRF 14
.................... disable_interrupts(INT_SSP); // neni preruseni od SSP
0099: BSF 03.5
009A: BCF 0C.3
.................... }
.................... else // rizeny vykon
009B: GOTO 0B5
009C: BCF 03.5
.................... {
.................... if (Gear>7) // stav 8 a vice znamena plny vykon
009D: MOVF 44,W
009E: SUBLW 07
009F: BTFSC 03.0
00A0: GOTO 0A3
.................... {
.................... Gear=8; // plny plyn
00A1: MOVLW 08
00A2: MOVWF 44
.................... }
....................
.................... MotorPattern=ExpTab[--Gear]; // prevod z hodnoty plynu na data pro SSP
00A3: DECF 44,F
00A4: MOVF 44,W
00A5: CALL 03D
00A6: MOVWF 78
00A7: MOVWF 2A
.................... output_low(MOTOR); // klidovy stav
00A8: BSF 03.5
00A9: BCF 06.2
00AA: BCF 03.5
00AB: BCF 06.2
.................... SSPSTAT = 0;
00AC: BSF 03.5
00AD: CLRF 14
.................... SSPCON1 = 0x22; // SPI OSC/64
00AE: MOVLW 22
00AF: BCF 03.5
00B0: MOVWF 14
....................
.................... SSPBUF=MotorPattern; // prvni data pro vyslani
00B1: MOVF 2A,W
00B2: MOVWF 13
.................... enable_interrupts(INT_SSP); // az budou vyslana prijde interrupt od SSP
00B3: BSF 03.5
00B4: BSF 0C.3
.................... }
.................... }
00B5: BCF 03.5
00B6: RETLW 00
....................
....................
.................... // Obsluha preruseni od SSP jednotky, posila data z promenne MotorRun do SSP.
.................... #INT_SSP
.................... void IntSSP()
.................... {
.................... SSPBUF=MotorPattern; // znova hdnota PWM patternu na SSP
*
0089: MOVF 2A,W
008A: MOVWF 13
.................... }
....................
....................
008B: BCF 0C.3
008C: BCF 0A.3
008D: GOTO 026
.................... void MotorSet(unsigned int Gear)
*
018D: CLRF 29
018E: BTFSC 0B.7
018F: BSF 29.7
0190: BCF 0B.7
.................... // Nastavi vykon motoru dle hodnoty Gear a zahaji posilani PWM dat pres SSP pod prerusenim
.................... // od SSP jednotky
.................... // 0 stop
.................... // 1-7 pocet 1/8 vykonu
.................... // >7 plny vykon
.................... {
.................... // Nastav PWM pattern
.................... MotorPatternSet(Gear); // nastav PWM pattern pro SSP
0191: MOVF 3D,W
0192: MOVWF 44
0193: CALL 08E
0194: BTFSC 29.7
0195: BSF 0B.7
....................
.................... // Povol preruseni
.................... enable_interrupts(GLOBAL); // povol preruseni
0196: MOVLW C0
0197: IORWF 0B,F
.................... }
0198: RETLW 00
....................
....................
.................... void InitT0()
.................... // Inicializace casovace T0 (cca 1000x za sekundu)
.................... {
.................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_4); // T0 z internich hodin 1/4
*
00D5: BSF 03.5
00D6: MOVF 01,W
00D7: ANDLW C0
00D8: IORLW 01
00D9: MOVWF 01
.................... enable_interrupts(INT_RTCC); // generuj preruseni od T0
00DA: BCF 03.5
00DB: BSF 0B.5
.................... enable_interrupts(GLOBAL); // povol preruseni
00DC: MOVLW C0
00DD: IORWF 0B,F
.................... }
00DE: BCF 0A.3
00DF: GOTO 1EF (RETURN)
....................
....................
.................... // Globalni promenna pro mereni casu
.................... // Nastavuje se procedurou TimeSet()
.................... // Testuje se funkci TimeIf()
.................... // Modifikuje se pri preruseni od casovace IntTo()
.................... unsigned int16 TimeTime;
....................
....................
.................... void TimerSet(unsigned int16 Time)
.................... // Nastavi casovac na zadany pocet ms
.................... // Test uplynuti casu se dela pomoci TimerIf()
.................... {
.................... // Nastav hodnotu
.................... disable_interrupts(INT_RTCC); // nesmi prijit preruseni
*
0199: BCF 0B.5
.................... TimeTime=Time; // pri nastavovani hodnoty
019A: MOVF 3E,W
019B: MOVWF 2C
019C: MOVF 3D,W
019D: MOVWF 2B
.................... enable_interrupts(INT_RTCC); // promenne (o delce vice nez 8 bitu)
019E: BSF 0B.5
.................... }
019F: RETLW 00
....................
....................
.................... int1 TimerIf()
.................... // Vraci TRUE pokud casovac jiz dobehl
.................... {
.................... int1 Flag; // pomocna promenna
....................
.................... // Otestuj casovac
.................... disable_interrupts(INT_RTCC); // nesmi prijit preruseni
01A0: BCF 0B.5
.................... Flag=(TimeTime==0); // behem testu promenne
01A1: MOVF 2B,F
01A2: BTFSS 03.2
01A3: GOTO 1A7
01A4: MOVF 2C,F
01A5: BTFSC 03.2
01A6: GOTO 1A9
01A7: MOVLW 00
01A8: GOTO 1AA
01A9: MOVLW 01
01AA: MOVWF 78
01AB: BTFSC 78.0
01AC: GOTO 1AF
01AD: BCF 3D.0
01AE: GOTO 1B0
01AF: BSF 3D.0
.................... enable_interrupts(INT_RTCC); // ted uz muze
01B0: BSF 0B.5
....................
.................... // Navratova hodnota
.................... return Flag; // TRUE znamena dobehl casovac
01B1: MOVLW 00
01B2: BTFSC 3D.0
01B3: MOVLW 01
01B4: MOVWF 78
.................... }
01B5: RETLW 00
....................
....................
.................... // Globalni promenne pro akceleraci
.................... // Nastavuje se metodou MotorStart()
.................... // Pouziva se v obsluze preruseni IntT0()
.................... unsigned int8 MotorTime; // aktualni casovac pro rozjezd
.................... unsigned int8 MotorDelay; // spozdeni mezi razenim
.................... unsigned int8 MotorGear; // rychlostni stupen
....................
....................
.................... void MotorStart(unsigned int8 Delay)
.................... // Provede rizeny rozjezd motoru
.................... {
.................... disable_interrupts(INT_RTCC);
01B6: BCF 0B.5
.................... MotorGear=1;
01B7: MOVLW 01
01B8: MOVWF 2F
.................... MotorDelay=Delay;
01B9: MOVF 3D,W
01BA: MOVWF 2E
.................... MotorTime=MotorDelay;
01BB: MOVF 2E,W
01BC: MOVWF 2D
.................... enable_interrupts(INT_RTCC);
01BD: BSF 0B.5
01BE: CLRF 29
01BF: BTFSC 0B.7
01C0: BSF 29.7
01C1: BCF 0B.7
....................
.................... MotorPatternSet(1);
01C2: MOVLW 01
01C3: MOVWF 44
01C4: CALL 08E
01C5: BTFSC 29.7
01C6: BSF 0B.7
.................... }
01C7: RETLW 00
....................
....................
.................... #INT_TIMER0
.................... void IntT0()
.................... // Preruseni od casovace cca 1000x za sekundu
.................... {
.................... // Odpocitavani casovace
.................... if (TimeTime) TimeTime--;
*
00B7: MOVF 2B,W
00B8: IORWF 2C,W
00B9: BTFSC 03.2
00BA: GOTO 0BF
00BB: MOVF 2B,W
00BC: BTFSC 03.2
00BD: DECF 2C,F
00BE: DECF 2B,F
....................
.................... // Obsluha akcelerace
.................... if (MotorTime) MotorTime--; // dekrementuj casovac rozjezdu
00BF: MOVF 2D,F
00C0: BTFSS 03.2
00C1: DECF 2D,F
.................... if ((MotorGear>0) && (MotorGear<8) && (!MotorTime)) // dalsi rychlostni stupen
00C2: MOVF 2F,F
00C3: BTFSC 03.2
00C4: GOTO 0D2
00C5: MOVF 2F,W
00C6: SUBLW 07
00C7: BTFSS 03.0
00C8: GOTO 0D2
00C9: MOVF 2D,F
00CA: BTFSS 03.2
00CB: GOTO 0D2
.................... {
.................... MotorTime=MotorDelay; // znovu nastav casovac
00CC: MOVF 2E,W
00CD: MOVWF 2D
.................... MotorGear++; // dalsi rychlost
00CE: INCF 2F,F
.................... MotorPatternSet(MotorGear); // nastav rychlost
00CF: MOVF 2F,W
00D0: MOVWF 44
00D1: CALL 08E
.................... }
.................... }
....................
....................
.................... // Cteni dat z AD prevodniku, zadava se cislo kanalu
00D2: BCF 0B.2
00D3: BCF 0A.3
00D4: GOTO 026
.................... int8 ReadAD(int8 Ch)
.................... {
.................... // Pokud merim Vref zapnu si jeho napajeni
.................... if (Ch==4) output_high(REFPOWER);
*
00E0: MOVF 3D,W
00E1: SUBLW 04
00E2: BTFSS 03.2
00E3: GOTO 0E8
00E4: BSF 03.5
00E5: BCF 06.1
00E6: BCF 03.5
00E7: BSF 06.1
....................
.................... // Inicializace a cislo kanalu
.................... ADCON1=0x30; // Vref+-, bez deleni hodin, Left Justify
00E8: MOVLW 30
00E9: BSF 03.5
00EA: MOVWF 1F
.................... ADCON0=0x41+(Ch<<3); // on, Tosc/8, cislo kanalu
00EB: BCF 03.5
00EC: RLF 3D,W
00ED: MOVWF 77
00EE: RLF 77,F
00EF: RLF 77,F
00F0: MOVLW F8
00F1: ANDWF 77,F
00F2: MOVF 77,W
00F3: ADDLW 41
00F4: MOVWF 1F
....................
.................... // Mereni
.................... delay_us(50); // doba na prepnuti kanalu
00F5: CLRWDT
00F6: MOVLW 10
00F7: MOVWF 77
00F8: DECFSZ 77,F
00F9: GOTO 0F8
00FA: NOP
00FB: NOP
.................... ADCON0 |= 4; // start prevodu
00FC: BSF 1F.2
.................... delay_us(50); // doba na prevod
00FD: CLRWDT
00FE: MOVLW 10
00FF: MOVWF 77
0100: DECFSZ 77,F
0101: GOTO 100
0102: NOP
0103: NOP
....................
.................... // Vypnu napajeni Vref (vzdycky)
.................... output_low(REFPOWER);
0104: BSF 03.5
0105: BCF 06.1
0106: BCF 03.5
0107: BCF 06.1
....................
.................... // Navrat hodnoty
.................... return ADRESH;
0108: MOVF 1E,W
0109: MOVWF 78
.................... }
010A: RETLW 00
....................
....................
.................... void main()
.................... {
*
01C8: CLRF 04
01C9: MOVLW 1F
01CA: ANDWF 03,F
01CB: BSF 03.5
01CC: BCF 1F.4
01CD: BCF 1F.5
01CE: MOVF 1B,W
01CF: ANDLW 80
01D0: MOVWF 1B
01D1: MOVLW 07
01D2: MOVWF 1C
01D3: MOVF 05,W
01D4: CLRWDT
01D5: MOVF 1C,W
01D6: BCF 03.5
01D7: BCF 0D.6
.................... unsigned int8 Debug;
.................... unsigned int8 i;
....................
.................... // Hodiny
.................... OSCCON = 0x62; // 4 MHz interni RC oscilator
01D8: MOVLW 62
01D9: BSF 03.5
01DA: MOVWF 0F
.................... /*
.................... // Digitalni vystupy
.................... output_low(PWM); // PWM vystup
.................... output_low(MOTOR); // Proud do motoru
.................... output_low(REFPOWER); // Napajeni Vref
.................... port_b_pullups(TRUE); // Zbyvajici vyvody portu B
....................
.................... // Watch Dog
.................... PSA=0; // preddelic prirazen casovaci
.................... WDTCON=0x0E; // Watch Dog cca 130ms
.................... // Analogove vstupy
.................... ANSEL = 0x1F; // AN0 az AN4
....................
.................... // nastaveni RS232
.................... InitRS232(); // inicializace HW RS232 (nutno pockat cca 10ms)
....................
.................... // Pipnuti (a cekani)
.................... for (i=1;i<30;i++) // pocet 1/2 period
.................... {
.................... int1 beep; // stavova promenna pro pipak
....................
.................... output_bit(BEEP0,beep);
.................... beep=~beep;
.................... output_bit(BEEP1,beep);
.................... delay_us(1000);
.................... }
....................
.................... // Rozhodnuti o rezimu cinnosti
.................... Debug=0;
.................... if (~input(SW0)) Debug|=1; // precti bit 0
.................... if (~input(SW1)) Debug|=2; // precti bit 1
.................... output_low(SW0); // nastav L aby se snizila spotreba
.................... output_low(SW1); // na obou vstupech
....................
.................... // Zobrazeni rezimu
.................... printf(Putc,"\fMode:%d",Debug);
.................... */
.................... // Inicializace PWM
.................... PR2 = 0x1F; // perioda PWM casovace
01DB: MOVLW 1F
01DC: MOVWF 12
.................... T2CON = 0x04; // povoleni casovace T2 bez preddelicu a postdelicu
01DD: MOVLW 04
01DE: BCF 03.5
01DF: MOVWF 12
.................... CCP1CON = 0x0C; // PWM mode, lsb bity nulove
01E0: MOVLW 0C
01E1: MOVWF 17
.................... CCPR1L = 0; // na zacatku nulova data
01E2: CLRF 15
.................... output_low(PWM); // PWM vystup
01E3: BSF 03.5
01E4: BCF 06.3
01E5: BCF 03.5
01E6: BCF 06.3
....................
.................... //!!!KAKL
.................... CCPR1L = 20; // pouziti vystupu
01E7: MOVLW 14
01E8: MOVWF 15
.................... disable_interrupts(GLOBAL);
01E9: BCF 0B.6
01EA: BCF 0B.7
01EB: BTFSC 0B.7
01EC: GOTO 1EA
.................... while(true);
01ED: GOTO 1ED
....................
.................... // Inicializace casovace
.................... InitT0(); // nastav casovac na cca 1ms
01EE: GOTO 0D5
....................
.................... //!!!KAKL
.................... Debug=3;
01EF: MOVLW 03
01F0: MOVWF 30
....................
.................... // Test menice PWM a rozjezdoveho PWM
.................... if (Debug==1)
01F1: DECFSZ 30,W
01F2: GOTO 22C
.................... {
.................... unsigned int8 Data1; // poteniometr P1 = PWM
.................... unsigned int8 Data2; // poteniometr P2 = Rozjezd
....................
.................... while (1)
.................... {
.................... // watch dog
.................... restart_wdt();
01F3: CLRWDT
....................
.................... // mereni vstupu
.................... Data1=ReadAD(0); // nacti parametr pro PWM
01F4: CLRF 3D
01F5: CALL 0E0
01F6: MOVF 78,W
01F7: MOVWF 32
.................... Data1>>=2; // redukuj rozsah na 0 az 63
01F8: RRF 32,F
01F9: RRF 32,F
01FA: MOVLW 3F
01FB: ANDWF 32,F
.................... Data2=ReadAD(1); // nacti parametr pro rozjezd
01FC: MOVLW 01
01FD: MOVWF 3D
01FE: CALL 0E0
01FF: MOVF 78,W
0200: MOVWF 33
.................... Data2>>=4; // redukuj rozsah na 0 az 15
0201: SWAPF 33,F
0202: MOVLW 0F
0203: ANDWF 33,F
....................
.................... // zobrazeni
.................... printf(Putc,"\nPWM:%03u RUN:%03u",Data1,Data2);
0204: CLRF 3D
0205: MOVF 3D,W
0206: CALL 049
0207: INCF 3D,F
0208: MOVWF 77
0209: MOVWF 41
020A: CALL 10B
020B: MOVLW 05
020C: SUBWF 3D,W
020D: BTFSS 03.2
020E: GOTO 205
020F: MOVF 32,W
0210: MOVWF 3F
0211: CLRF 40
0212: CALL 129
0213: MOVLW 09
0214: MOVWF 3E
0215: MOVF 3E,W
0216: CALL 049
0217: INCF 3E,F
0218: MOVWF 77
0219: MOVWF 41
021A: CALL 10B
021B: MOVLW 0E
021C: SUBWF 3E,W
021D: BTFSS 03.2
021E: GOTO 215
021F: MOVF 33,W
0220: MOVWF 3F
0221: CLRF 40
0222: CALL 129
.................... delay_ms(20);
0223: MOVLW 14
0224: MOVWF 3D
0225: CALL 176
....................
.................... // nastaveni parametru PWM
.................... CCPR1L = Data1;
0226: MOVF 32,W
0227: MOVWF 15
....................
.................... // nastaveni parametru RUN
.................... MotorSet(Data2);
0228: MOVF 33,W
0229: MOVWF 3D
022A: CALL 18D
.................... }
022B: GOTO 1F3
.................... }
....................
.................... // Testovani rozjezdu
.................... // Zadava se cas mezi stupni razeni pro rozjezd v ms
.................... if (Debug==2)
022C: MOVF 30,W
022D: SUBLW 02
022E: BTFSS 03.2
022F: GOTO 27D
.................... {
.................... int8 Data;
.................... int8 Start;
....................
.................... Start=0; // uvodni stav
0230: CLRF 35
.................... while(1)
.................... {
.................... // Nacti a zobraz parametr
.................... Data=ReadAD(1); // potenciometr P2 = rozjezd
0231: MOVLW 01
0232: MOVWF 3D
0233: CALL 0E0
0234: MOVF 78,W
0235: MOVWF 34
.................... printf(Putc,"\nRUN: %3ums ",Data); // zobraz
0236: CLRF 3D
0237: MOVF 3D,W
0238: CALL 060
0239: INCF 3D,F
023A: MOVWF 77
023B: MOVWF 41
023C: CALL 10B
023D: MOVLW 06
023E: SUBWF 3D,W
023F: BTFSS 03.2
0240: GOTO 237
0241: MOVF 34,W
0242: MOVWF 3F
0243: MOVLW 10
0244: MOVWF 40
0245: CALL 129
0246: MOVLW 6D
0247: MOVWF 41
0248: CALL 10B
0249: MOVLW 73
024A: MOVWF 41
024B: CALL 10B
024C: MOVLW 20
024D: MOVWF 41
024E: CALL 10B
.................... delay_ms(10); // prodleva pro terminal
024F: MOVLW 0A
0250: MOVWF 3D
0251: CALL 176
....................
.................... // Uvodni pauza
.................... if (Start==0) // spousti se 1x na zacatku
0252: MOVF 35,F
0253: BTFSS 03.2
0254: GOTO 25B
.................... {
.................... Start++; // dalsi stav je cekani
0255: INCF 35,F
.................... TimerSet(2000); // na dokonceni uvodni prodlevy
0256: MOVLW 07
0257: MOVWF 3E
0258: MOVLW D0
0259: MOVWF 3D
025A: CALL 199
.................... }
....................
.................... // Rozjezd
.................... if ((Start==1) && TimerIf())
025B: DECFSZ 35,W
025C: GOTO 26D
025D: CALL 1A0
025E: MOVF 78,F
025F: BTFSC 03.2
0260: GOTO 26D
.................... {
.................... Start++;
0261: INCF 35,F
.................... printf(Putc,"R");
0262: MOVLW 52
0263: MOVWF 41
0264: CALL 10B
.................... MotorStart(Data); // rozjezd s nastavenim prodlevy
0265: MOVF 34,W
0266: MOVWF 3D
0267: CALL 1B6
....................
.................... TimerSet(2000); // nastav celkovy cas jizdy
0268: MOVLW 07
0269: MOVWF 3E
026A: MOVLW D0
026B: MOVWF 3D
026C: CALL 199
.................... }
....................
.................... // Zastaveni
.................... if ((Start==2) && TimerIf())
026D: MOVF 35,W
026E: SUBLW 02
026F: BTFSS 03.2
0270: GOTO 27B
0271: CALL 1A0
0272: MOVF 78,F
0273: BTFSC 03.2
0274: GOTO 27B
.................... {
.................... Start++;
0275: INCF 35,F
.................... printf(Putc,"S");
0276: MOVLW 53
0277: MOVWF 41
0278: CALL 10B
.................... MotorSet(0); // pokud dobehl casovac zastav motor
0279: CLRF 3D
027A: CALL 18D
.................... }
....................
.................... // watch dog
.................... restart_wdt();
027B: CLRWDT
.................... }
027C: GOTO 231
.................... }
....................
.................... // Test nabijeciho algoritmu
.................... if (Debug==3)
027D: MOVF 30,W
027E: SUBLW 03
027F: BTFSS 03.2
0280: GOTO 2DB
.................... {
.................... unsigned int8 PwmOut; // akcni hodnota pro PWM
.................... unsigned int8 Req; // pozadovana hodnota z P1
.................... unsigned int8 Vref; // merena hodnota vref
....................
.................... // Inicializace stavove promenne
.................... PwmOut=0;
0281: CLRF 36
....................
.................... // Hlavni smycka
.................... while (1)
.................... {
.................... // watch dog
.................... restart_wdt();
0282: CLRWDT
....................
.................... // pozadovana hodnota (potenciometr P1)
.................... Req=ReadAD(0);
0283: CLRF 3D
0284: CALL 0E0
0285: MOVF 78,W
0286: MOVWF 37
.................... Req=50+(ReadAD(0)>>1); // 50 az 177
0287: CLRF 3D
0288: CALL 0E0
0289: BCF 03.0
028A: RRF 78,W
028B: ADDLW 32
028C: MOVWF 37
....................
.................... // napeti na napajeni (vref)
.................... Vref=ReadAD(4);
028D: MOVLW 04
028E: MOVWF 3D
028F: CALL 0E0
0290: MOVF 78,W
0291: MOVWF 38
....................
.................... // ricici algoritmus
.................... if ((Vref<Req) &&(PwmOut<30)) PwmOut++;
0292: MOVF 37,W
0293: SUBWF 38,W
0294: BTFSC 03.0
0295: GOTO 29A
0296: MOVF 36,W
0297: SUBLW 1D
0298: BTFSC 03.0
0299: INCF 36,F
.................... if ((Vref>=Req)&&(PwmOut> 0)) PwmOut--;
029A: MOVF 37,W
029B: SUBWF 38,W
029C: BTFSS 03.0
029D: GOTO 2A1
029E: MOVF 36,F
029F: BTFSS 03.2
02A0: DECF 36,F
.................... Vref+=10;
02A1: MOVLW 0A
02A2: ADDWF 38,F
.................... if ((Vref<(Req))&&(PwmOut<30)) PwmOut++; // urychleni nabehu
02A3: MOVF 37,W
02A4: SUBWF 38,W
02A5: BTFSC 03.0
02A6: GOTO 2AB
02A7: MOVF 36,W
02A8: SUBLW 1D
02A9: BTFSC 03.0
02AA: INCF 36,F
....................
.................... // nastaveni parametru PWM
.................... if (PwmOut>24) PwmOut=24; // saturace
02AB: MOVF 36,W
02AC: SUBLW 18
02AD: BTFSC 03.0
02AE: GOTO 2B1
02AF: MOVLW 18
02B0: MOVWF 36
.................... //!!!KAKL
.................... PwmOut=20;
02B1: MOVLW 14
02B2: MOVWF 36
.................... CCPR1L = PwmOut; // pouziti vystupu
02B3: MOVF 36,W
02B4: MOVWF 15
.................... disable_interrupts(GLOBAL);
02B5: BCF 0B.6
02B6: BCF 0B.7
02B7: BTFSC 0B.7
02B8: GOTO 2B6
.................... while(true);
02B9: GOTO 2B9
.................... // zobrazeni
.................... printf(Putc,"\nALG:%03u %03u %03u",Req,Vref,PwmOut);
02BA: CLRF 3D
02BB: MOVF 3D,W
02BC: CALL 071
02BD: INCF 3D,F
02BE: MOVWF 77
02BF: MOVWF 41
02C0: CALL 10B
02C1: MOVLW 05
02C2: SUBWF 3D,W
02C3: BTFSS 03.2
02C4: GOTO 2BB
02C5: MOVF 37,W
02C6: MOVWF 3F
02C7: CLRF 40
02C8: CALL 129
02C9: MOVLW 20
02CA: MOVWF 41
02CB: CALL 10B
02CC: MOVF 38,W
02CD: MOVWF 3F
02CE: CLRF 40
02CF: CALL 129
02D0: MOVLW 20
02D1: MOVWF 41
02D2: CALL 10B
02D3: MOVF 36,W
02D4: MOVWF 3F
02D5: CLRF 40
02D6: CALL 129
.................... delay_ms(10);
02D7: MOVLW 0A
02D8: MOVWF 3D
02D9: CALL 176
.................... }
02DA: GOTO 282
.................... }
....................
.................... // Standardni beh
.................... if (Debug==0)
02DB: MOVF 30,F
02DC: BTFSS 03.2
02DD: GOTO 341
.................... {
.................... unsigned int8 PwmOut; // akcni hodnota pro PWM
.................... unsigned int8 Req; // pozadovana hodnota z P1
.................... unsigned int8 Vref; // merena hodnota vref
.................... int1 Run;
....................
.................... // Inicializace stavove promenne
.................... PwmOut=0;
02DE: CLRF 39
.................... TimerSet(14000); // casovani startu
02DF: MOVLW 36
02E0: MOVWF 3E
02E1: MOVLW B0
02E2: MOVWF 3D
02E3: CALL 199
.................... Run=1;
02E4: BSF 3C.0
....................
.................... // Hlavni smycka
.................... while (1)
.................... {
.................... // watch dog
.................... restart_wdt();
02E5: CLRWDT
....................
.................... // pozadovana hodnota (potenciometr P1)
.................... Req=ReadAD(0);
02E6: CLRF 3D
02E7: CALL 0E0
02E8: MOVF 78,W
02E9: MOVWF 3A
.................... Req=50+(ReadAD(0)>>1); // 50 az 177
02EA: CLRF 3D
02EB: CALL 0E0
02EC: BCF 03.0
02ED: RRF 78,W
02EE: ADDLW 32
02EF: MOVWF 3A
....................
.................... // napeti na napajeni (vref)
.................... Vref=ReadAD(4);
02F0: MOVLW 04
02F1: MOVWF 3D
02F2: CALL 0E0
02F3: MOVF 78,W
02F4: MOVWF 3B
....................
.................... // ricici algoritmus
.................... if ((Vref<Req) &&(PwmOut<30)) PwmOut++;
02F5: MOVF 3A,W
02F6: SUBWF 3B,W
02F7: BTFSC 03.0
02F8: GOTO 2FD
02F9: MOVF 39,W
02FA: SUBLW 1D
02FB: BTFSC 03.0
02FC: INCF 39,F
.................... if ((Vref>=Req)&&(PwmOut> 0)) PwmOut--;
02FD: MOVF 3A,W
02FE: SUBWF 3B,W
02FF: BTFSS 03.0
0300: GOTO 304
0301: MOVF 39,F
0302: BTFSS 03.2
0303: DECF 39,F
.................... Vref+=10;
0304: MOVLW 0A
0305: ADDWF 3B,F
.................... if ((Vref<(Req))&&(PwmOut<30)) PwmOut++; // urychleni nabehu
0306: MOVF 3A,W
0307: SUBWF 3B,W
0308: BTFSC 03.0
0309: GOTO 30E
030A: MOVF 39,W
030B: SUBLW 1D
030C: BTFSC 03.0
030D: INCF 39,F
....................
.................... // nastaveni parametru PWM
.................... if (PwmOut>24) PwmOut=24; // saturace
030E: MOVF 39,W
030F: SUBLW 18
0310: BTFSC 03.0
0311: GOTO 314
0312: MOVLW 18
0313: MOVWF 39
.................... CCPR1L = PwmOut; // pouziti vystupu
0314: MOVF 39,W
0315: MOVWF 15
....................
.................... // zobrazeni
.................... printf(Putc,"\nALG:%03u %03u %03u",Req,Vref,PwmOut);
0316: CLRF 3D
0317: MOVF 3D,W
0318: CALL 071
0319: INCF 3D,F
031A: MOVWF 77
031B: MOVWF 41
031C: CALL 10B
031D: MOVLW 05
031E: SUBWF 3D,W
031F: BTFSS 03.2
0320: GOTO 317
0321: MOVF 3A,W
0322: MOVWF 3F
0323: CLRF 40
0324: CALL 129
0325: MOVLW 20
0326: MOVWF 41
0327: CALL 10B
0328: MOVF 3B,W
0329: MOVWF 3F
032A: CLRF 40
032B: CALL 129
032C: MOVLW 20
032D: MOVWF 41
032E: CALL 10B
032F: MOVF 39,W
0330: MOVWF 3F
0331: CLRF 40
0332: CALL 129
.................... delay_ms(10);
0333: MOVLW 0A
0334: MOVWF 3D
0335: CALL 176
....................
.................... // rozjezd
.................... if (TimerIf()&&Run)
0336: CALL 1A0
0337: MOVF 78,F
0338: BTFSC 03.2
0339: GOTO 340
033A: BTFSS 3C.0
033B: GOTO 340
.................... {
.................... Run=0;
033C: BCF 3C.0
.................... MotorStart(65);
033D: MOVLW 41
033E: MOVWF 3D
033F: CALL 1B6
.................... }
.................... }
0340: GOTO 2E5
.................... }
.................... }
....................
0341: SLEEP
 
Configuration Fuses:
Word 1: 2F38 NOWDT NOPUT MCLR NOBROWNOUT NOLVP NOCPD NOWRT NODEBUG CCPB3 NOPROTECT INTRC_IO
Word 2: 3FFF FCMEN IESO
/roboti/solarni/2006/jump/miho/DART.PJT
0,0 → 1,38
[PROJECT]
Target=DART.HEX
Development_Mode=
Processor=0x688F
ToolSuite=CCS
 
[Directories]
Include=C:\Program Files\PICC\devices\
Library=
LinkerScript=
 
[Target Data]
FileList=DART.C;
BuildTool=C-COMPILER
OptionString=+FM
AdditionalOptionString=
BuildRequired=1
 
[DART.C]
Type=4
Path=
FileList=
BuildTool=
OptionString=
AdditionalOptionString=
 
[mru-list]
1=DART.C
 
[Windows]
0=0000 DART.C 0 0 796 451 3 0
 
[Opened Files]
1=C:\PIC\jump\miho\DART.C
2=C:\PIC\jump\miho\DART.h
3=C:\PIC\jump\miho\lib\16F88.h
4=C:\PIC\jump\miho\lib\16F88_Reg.h
5=
/roboti/solarni/2006/jump/miho/DART.SYM
0,0 → 1,376
000 INDF
001 TMR0
003.0 C
003 STATUS
003.1 DC
003.2 Z
003.3 PD
003.4 TO
003.5 RP0
003.6 RP1
003.7 IRP
005 PORTA
006 PORTB
00A PCLATH
00B INTCON
00B.0 RBIF
00B.1 INT0IF
00B.2 TMR0IF
00B.3 RBIE
00B.4 INT0IE
00B.5 TMR0IE
00B.6 PEIE
00B.7 GIE
00C PIR1
00C.0 TMR1IF
00C.1 TMR2IF
00C.2 CCP1IF
00C.3 SSPIF
00C.4 TXIF
00C.5 RCIF
00C.6 ADIF
00D PIR2
00D.4 EEIF
00D.6 CMIF
00D.7 OSFIF
00E TMR1L
00F TMR1H
010 T1CON
010.0 TMR1ON
010.1 TMR1CS
010.2 T1SYNC
010.3 T1OSCEN
010.4 T1CKPS0
010.5 T1CKPS1
010.6 T1RUN
011 TMR2
012 T2CON
012.0 T2CKPS0
012.1 T2CKPS1
012.2 TMR2ON
012.3 TOUTPS0
012.4 TOUTPS1
012.5 TOUTPS2
012.6 TOUTPS3
013 SSPBUF
014.0 SSPM0
014 SSPCON1
014.1 SSPM1
014.2 SSPM2
014.3 SSPM3
014.4 CKP
014.5 SSPEN
014.6 SSPOV
014.7 WCOL
015 CCP_1_LOW
015 CCPR1L
015-016 CCP_1
016 CCP_1_HIGH
016 CCPR1H
017.0 CCP1M0
017 CCP1CON
017.1 CCP1M1
017.2 CCP1M2
017.3 CCP1M3
017.4 CCP1Y
017.5 CCP1X
018 RCSTA
018.0 RX9D
018.1 OERR
018.2 FERR
018.3 ADDEN
018.4 CREN
018.5 SREN
018.6 RX9
018.7 SPEN
019 TXREG
01A RCREG
01E ADRESH
01F ADCON0
01F.0 ADON
01F.2 GO
01F.3 CHS0
01F.4 CHS1
01F.5 CHS2
01F.6 ADCS0
01F.7 ADCS1
020 @INTERRUPT_AREA
021 @INTERRUPT_AREA
022 @INTERRUPT_AREA
023 @INTERRUPT_AREA
024 @INTERRUPT_AREA
025 @INTERRUPT_AREA
026 @INTERRUPT_AREA
027 @INTERRUPT_AREA
028 @INTERRUPT_AREA
029 @INTERRUPT_AREA
02A MotorPattern
02B-02C TimeTime
02D MotorTime
02E MotorDelay
02F MotorGear
030 main.Debug
031 main.i
032 Data1
033 Data2
034 Data
035 Start
036 PwmOut
037 Req
038 Vref
039 PwmOut
03A Req
03B Vref
03C.0 Run
03D-03E TimerSet.Time
03D ReadAD.Ch
03D MotorSet.Gear
03D.0 TimerIf.Flag
03D MotorStart.Delay
03D @delay_ms1.P1
03D main.@SCRATCH
03E main.@SCRATCH
03F @PRINTF_U_494.P1
040 @PRINTF_U_494.P1
041 @DIV88.P1
041 putchar.C
042 @DIV88.P1
042 putchar.@SCRATCH
043 @DIV88.@SCRATCH
044 MotorPatternSet.Gear
077 @SCRATCH
078 @SCRATCH
078 _RETURN_
079 @SCRATCH
07A @SCRATCH
07B @SCRATCH
080 INDF_1
081.0 PS0
081 OPTION
081.1 PS1
081.2 PS2
081.3 PSA
081.4 T0SE
081.5 T0CS
081.6 INTEDG
081.7 RBPU
082 PCL
083.0 C_1
083 STATUS_1
083.1 DC_1
083.2 Z_1
083.3 PD_1
083.4 TO_1
083.5 RP0_1
083.6 RP1_1
083.7 IRP_1
084 FSR
085 TRISA
086 TRISB
08A PCLATH_1
08B INTCON_1
08B.0 RBIF_1
08B.1 INT0IF_1
08B.2 TMR0IF_1
08B.3 RBIE_1
08B.4 INT0IE_1
08B.5 TMR0IE_1
08B.6 PEIE_1
08B.7 GIE_1
08C.0 TMR1IE
08C PIE1
08C.1 TMR2IE
08C.2 CCP1IE
08C.3 SSPIE
08C.4 TXIE
08C.5 RCIE
08C.6 ADIE
08D PIE2
08D.4 EEIE
08D.6 CMIE
08D.7 OSFIE
08E PCON
08E.0 BOR
08E.1 POR
08F OSCCON
08F.0 SCS0
08F.1 SCS1
08F.2 IOFS
08F.3 OSTS
08F.4 IRCF0
08F.5 IRCF1
08F.6 IRCF2
090 OSCTUNE
090.0 TUN0
090.1 TUN1
090.2 TUN2
090.3 TUN3
090.4 TUN4
090.5 TUN5
092 PR2
093 SSPADD
094.0 BF
094 SSPSTAT
094.1 UA
094.2 RW
094.3 S
094.4 P
094.5 DA
094.6 CKE
094.7 SMP
098 TXSTA
098.0 TX9D
098.1 TRMT
098.2 BRGH
098.4 SYNC
098.5 TXEN
098.6 TX9
098.7 CSRC
099 SPBRG
09B.0 ANS0
09B ANSEL
09B.1 ANS1
09B.2 ANS2
09B.3 ANS3
09B.4 ANS4
09B.5 ANS5
09B.6 ANS6
09C CMCON
09C.0 CM0
09C.1 CM1
09C.2 CM2
09C.3 CIS
09C.4 C1INV
09C.5 C2INV
09C.6 C1OUT
09C.7 C2OUT
09D CVRCON
09D.0 CVR0
09D.1 CVR1
09D.2 CVR2
09D.3 CVR3
09D.5 CVRR
09D.6 CVROE
09D.7 CVREN
09E ADRESL
09F ADCON1
09F.4 VCFG0
09F.5 VCFG1
09F.6 ADCS2
09F.7 ADFM
100 INDF_2
101 TMR0_2
102 PCL_2
103.0 C_2
103 STATUS_2
103.1 DC_2
103.2 Z_2
103.3 PD_2
103.4 TO_2
103.5 RP0_2
103.6 RP1_2
103.7 IRP_2
104 FSR_2
105 WDTCON
105.0 SWDTEN
105.1 WDTPS0
105.2 WDTPS1
105.3 WDTPS2
105.4 WDTPS3
106 PORTB_2
10A PCLATH_2
10B.0 RBIF_2
10B INTCON_2
10B.1 INT0IF_2
10B.2 TMR0IF_2
10B.3 RBIE_2
10B.4 INT0IE_2
10B.5 TMR0IE_2
10B.6 PEIE_2
10B.7 GIE_2
10C EEDATA
10D EEADR
10E EEDATH
10F EEADRH
180 INDF_3
181.0 PS0_3
181 OPTION_3
181.1 PS1_3
181.2 PS2_3
181.3 PSA_3
181.4 T0SE_3
181.5 T0CS_3
181.6 INTEDG_3
181.7 RBPU_3
182 PCL_3
183.0 C_3
183 STATUS_3
183.1 DC_3
183.2 Z_3
183.3 PD_3
183.4 TO_3
183.5 RP0_3
183.6 RP1_3
183.7 IRP_3
184 FSR_3
186 TRISB_3
18A PLATH_3
18B.0 RBIF_3
18B INTCON_3
18B.1 INT0IF_3
18B.2 TMR0IF_3
18B.3 RBIE_3
18B.4 INT0IE_3
18B.5 TMR0IE_3
18B.6 PEIE_3
18B.7 GIE_3
18C.0 RD
18C EECON1
18C.1 WR
18C.2 WREN
18C.3 WRERR
18C.4 FREE
18C.7 EEPGD
18D EECON2
 
0176 @delay_ms1
010B putchar
003D @const312
008E MotorPatternSet
0089 IntSSP
018D MotorSet
00D5 InitT0
0199 TimerSet
01A0 TimerIf
01B6 MotorStart
00B7 IntT0
00E0 ReadAD
01C8 main
0049 @const10122
0114 @DIV88
0129 @PRINTF_U_494
0060 @const10152
0071 @const10203
01C8 @cinit
 
Project Files:
C:\PIC\jump\miho\DART.C
C:\PIC\jump\miho\DART.h
C:\PIC\jump\miho\lib\16F88.h
C:\PIC\jump\miho\lib\16F88_Reg.h
 
Compiler Settings:
Processor: PIC16F88
Pointer Size: 8
ADC Range: 0-255
Opt Level: 9
Short,Int,Long: 1,8,16
 
Output Files:
Errors: C:\PIC\jump\miho\DART.err
INHX8: C:\PIC\jump\miho\DART.HEX
Symbols: C:\PIC\jump\miho\DART.SYM
List: C:\PIC\jump\miho\DART.LST
Debug/COFF: C:\PIC\jump\miho\DART.cof
Call Tree: C:\PIC\jump\miho\DART.tre
Statistics: C:\PIC\jump\miho\DART.sta
/roboti/solarni/2006/jump/miho/DART.cof
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/roboti/solarni/2006/jump/miho/DART.err
0,0 → 1,0
No Errors
/roboti/solarni/2006/jump/miho/DART.h
0,0 → 1,10
// DART01A verze programu 1.00
// (c)miho 2005
 
#include ".\lib\16F88.h" // standardni definice konstant
#include ".\lib\16F88_Reg.h" // standardni definice vsech FSR
 
#device adc=8 // AD prevodnik jen na 8 bitu
#define xclock 4168000 // muj konkretni PIC je trochu rychlejsi
#use delay(clock=xclock,restart_wdt)
#fuses INTRC_IO, NOWDT, NOPUT, NOPROTECT, NOBROWNOUT, MCLR, NOLVP, NOCPD, NODEBUG, CCPB3
/roboti/solarni/2006/jump/miho/DART.sta
0,0 → 1,47
 
ROM used: 834 (20%)
834 (20%) including unused fragments
 
1 Average locations per line
5 Average locations per statement
 
RAM used: 25 (14%) at main() level
42 (24%) worst case
 
Lines Stmts % Files
----- ----- --- -----
426 160 100 C:\PIC\jump\miho\DART.C
11 0 0 C:\PIC\jump\miho\DART.h
216 0 0 C:\PIC\jump\miho\lib\16F88.h
315 0 0 C:\PIC\jump\miho\lib\16F88_Reg.h
----- -----
1936 320 Total
 
Page ROM % RAM Functions:
---- --- --- --- ----------
0 23 3 1 @delay_ms1
0 9 1 2 putchar
0 12 1 0 @const312
0 41 5 1 MotorPatternSet
0 5 1 0 IntSSP
0 12 1 1 MotorSet
0 11 1 0 InitT0
0 7 1 2 TimerSet
0 22 3 1 TimerIf
0 18 2 1 MotorStart
0 30 4 0 IntT0
0 43 5 1 ReadAD
0 378 45 4 main
0 23 3 0 @const10122
0 21 3 3 @DIV88
0 77 9 2 @PRINTF_U_494
0 17 2 0 @const10152
0 24 3 0 @const10203
 
Segment Used Free
--------- ---- ----
00000-00003 4 0
00004-0003C 57 0
0003D-007FF 773 1214
00800-00FFF 0 2048
 
/roboti/solarni/2006/jump/miho/DART.tre
0,0 → 1,130
ÀÄDART
ÃÄmain 0/378 Ram=4
³ ÃÄ??0??
³ ÃÄInitT0 0/11 Ram=0
³ ÃÄReadAD 0/43 Ram=1
³ ÃÄReadAD 0/43 Ram=1
³ ÃÄ@const10122 0/23 Ram=0
³ ÃÄputchar 0/9 Ram=2
³ ÃÄ@PRINTF_U_494 0/77 Ram=2
³ ³ ÃÄ@DIV88 0/21 Ram=3
³ ³ ÃÄputchar 0/9 Ram=2
³ ³ ÃÄputchar 0/9 Ram=2
³ ³ ÃÄputchar 0/9 Ram=2
³ ³ ÃÄ@DIV88 0/21 Ram=3
³ ³ ÃÄputchar 0/9 Ram=2
³ ³ ÀÄputchar 0/9 Ram=2
³ ÃÄ@const10122 0/23 Ram=0
³ ÃÄputchar 0/9 Ram=2
³ ÃÄ@PRINTF_U_494 0/77 Ram=2
³ ³ ÃÄ@DIV88 0/21 Ram=3
³ ³ ÃÄputchar 0/9 Ram=2
³ ³ ÃÄputchar 0/9 Ram=2
³ ³ ÃÄputchar 0/9 Ram=2
³ ³ ÃÄ@DIV88 0/21 Ram=3
³ ³ ÃÄputchar 0/9 Ram=2
³ ³ ÀÄputchar 0/9 Ram=2
³ ÃÄ@delay_ms1 0/23 Ram=1
³ ÃÄMotorSet 0/12 Ram=1
³ ³ ÀÄMotorPatternSet 0/41 Ram=1
³ ³ ÀÄ@const312 0/12 Ram=0
³ ÃÄReadAD 0/43 Ram=1
³ ÃÄ@const10152 0/17 Ram=0
³ ÃÄputchar 0/9 Ram=2
³ ÃÄ@PRINTF_U_494 0/77 Ram=2
³ ³ ÃÄ@DIV88 0/21 Ram=3
³ ³ ÃÄputchar 0/9 Ram=2
³ ³ ÃÄputchar 0/9 Ram=2
³ ³ ÃÄputchar 0/9 Ram=2
³ ³ ÃÄ@DIV88 0/21 Ram=3
³ ³ ÃÄputchar 0/9 Ram=2
³ ³ ÀÄputchar 0/9 Ram=2
³ ÃÄputchar 0/9 Ram=2
³ ÃÄputchar 0/9 Ram=2
³ ÃÄputchar 0/9 Ram=2
³ ÃÄ@delay_ms1 0/23 Ram=1
³ ÃÄTimerSet 0/7 Ram=2
³ ÃÄTimerIf 0/22 Ram=1
³ ÃÄputchar 0/9 Ram=2
³ ÃÄMotorStart 0/18 Ram=1
³ ³ ÀÄMotorPatternSet 0/41 Ram=1
³ ³ ÀÄ@const312 0/12 Ram=0
³ ÃÄTimerSet 0/7 Ram=2
³ ÃÄTimerIf 0/22 Ram=1
³ ÃÄputchar 0/9 Ram=2
³ ÃÄMotorSet 0/12 Ram=1
³ ³ ÀÄMotorPatternSet 0/41 Ram=1
³ ³ ÀÄ@const312 0/12 Ram=0
³ ÃÄReadAD 0/43 Ram=1
³ ÃÄReadAD 0/43 Ram=1
³ ÃÄReadAD 0/43 Ram=1
³ ÃÄ@const10203 0/24 Ram=0
³ ÃÄputchar 0/9 Ram=2
³ ÃÄ@PRINTF_U_494 0/77 Ram=2
³ ³ ÃÄ@DIV88 0/21 Ram=3
³ ³ ÃÄputchar 0/9 Ram=2
³ ³ ÃÄputchar 0/9 Ram=2
³ ³ ÃÄputchar 0/9 Ram=2
³ ³ ÃÄ@DIV88 0/21 Ram=3
³ ³ ÃÄputchar 0/9 Ram=2
³ ³ ÀÄputchar 0/9 Ram=2
³ ÃÄputchar 0/9 Ram=2
³ ÃÄ@PRINTF_U_494 0/77 Ram=2
³ ³ ÃÄ@DIV88 0/21 Ram=3
³ ³ ÃÄputchar 0/9 Ram=2
³ ³ ÃÄputchar 0/9 Ram=2
³ ³ ÃÄputchar 0/9 Ram=2
³ ³ ÃÄ@DIV88 0/21 Ram=3
³ ³ ÃÄputchar 0/9 Ram=2
³ ³ ÀÄputchar 0/9 Ram=2
³ ÃÄputchar 0/9 Ram=2
³ ÃÄ@PRINTF_U_494 0/77 Ram=2
³ ³ ÃÄ@DIV88 0/21 Ram=3
³ ³ ÃÄputchar 0/9 Ram=2
³ ³ ÃÄputchar 0/9 Ram=2
³ ³ ÃÄputchar 0/9 Ram=2
³ ³ ÃÄ@DIV88 0/21 Ram=3
³ ³ ÃÄputchar 0/9 Ram=2
³ ³ ÀÄputchar 0/9 Ram=2
³ ÃÄ@delay_ms1 0/23 Ram=1
³ ÃÄTimerSet 0/7 Ram=2
³ ÃÄReadAD 0/43 Ram=1
³ ÃÄReadAD 0/43 Ram=1
³ ÃÄReadAD 0/43 Ram=1
³ ÃÄ@const10203 0/24 Ram=0
³ ÃÄputchar 0/9 Ram=2
³ ÃÄ@PRINTF_U_494 0/77 Ram=2
³ ³ ÃÄ@DIV88 0/21 Ram=3
³ ³ ÃÄputchar 0/9 Ram=2
³ ³ ÃÄputchar 0/9 Ram=2
³ ³ ÃÄputchar 0/9 Ram=2
³ ³ ÃÄ@DIV88 0/21 Ram=3
³ ³ ÃÄputchar 0/9 Ram=2
³ ³ ÀÄputchar 0/9 Ram=2
³ ÃÄputchar 0/9 Ram=2
³ ÃÄ@PRINTF_U_494 0/77 Ram=2
³ ³ ÃÄ@DIV88 0/21 Ram=3
³ ³ ÃÄputchar 0/9 Ram=2
³ ³ ÃÄputchar 0/9 Ram=2
³ ³ ÃÄputchar 0/9 Ram=2
³ ³ ÃÄ@DIV88 0/21 Ram=3
³ ³ ÃÄputchar 0/9 Ram=2
³ ³ ÀÄputchar 0/9 Ram=2
³ ÃÄputchar 0/9 Ram=2
³ ÃÄ@PRINTF_U_494 0/77 Ram=2
³ ³ ÃÄ@DIV88 0/21 Ram=3
³ ³ ÃÄputchar 0/9 Ram=2
³ ³ ÃÄputchar 0/9 Ram=2
³ ³ ÃÄputchar 0/9 Ram=2
³ ³ ÃÄ@DIV88 0/21 Ram=3
³ ³ ÃÄputchar 0/9 Ram=2
³ ³ ÀÄputchar 0/9 Ram=2
³ ÃÄ@delay_ms1 0/23 Ram=1
³ ÃÄTimerIf 0/22 Ram=1
³ ÀÄMotorStart 0/18 Ram=1
³ ÀÄMotorPatternSet 0/41 Ram=1
³ ÀÄ@const312 0/12 Ram=0
ÃÄIntSSP 0/5 Ram=0
ÀÄIntT0 0/30 Ram=0
ÀÄMotorPatternSet 0/41 Ram=1
ÀÄ@const312 0/12 Ram=0
/roboti/solarni/2006/jump/miho/LIB/16f88.h
0,0 → 1,216
//////// Header file for the PIC16F88
#device PIC16F88
#nolist
//////// Program memory: 4096x14 Data RAM: 368 Stack: 8
//////// I/O: 16 Analog Pins: 7
//////// Data EEPROM: 256
//////// C Scratch area: 77 ID Location: 2000
// Fuses:
// Oscilator: LP - oscilator LP
// XT - oscilator XT
// HS - oscilator HS
// EC_IO - externi vstup, RA6/CLKO je IO port
// INTRC - RC oscilator, RA6/CLKO je CLKO, RA7/CLKI je IO port port,
// INTRC_IO - RC oscilator, RA6 i RA7 je IO port
// RC - ext RC, RA6/CLKO je CLKO
// RC_IO - ext RC, RA6 je IO port
// Watch: NOWDT - neni watchog
// WDT - je watchdog
// PUT: NOPUT - neni power up timer
// PUT - je power up timer
// MCLR: MCLR - RA5/MCLR je MCLR
// NOMCLR - RA5/MCLR je IO port
// BOR: BROWNOUT - BOR povolen
// NOBROWNOUT - BOR zakazan
// LVP: LVP - RB3/PGM je PGM
// NOLVP - RB3/PGM je IO port
// CPD: CPD - je ochrana EEPROM
// NOCPD - neni ochrana EEPROM
// WRT WRT - zakaz zapisu do pameti programu
// NOWRT - povolen zapis do pameti programu
// DEBUG: DEBUG - RB6 a RB7 jsou ICD port
// NODEBUG - RB6 a RB7 jsou IO port
// CCPMX: CCPB0 - CCP/PWM na RB0
// CCPB3 - CCP/PWM na RB3
// CP: PROTECT - pamet programu je chranena
// NOPROTECT - pamet programu neni chranena
//
 
////////////////////////////////////////////////////////////////// I/O
// Discrete I/O Functions: SET_TRIS_x(), OUTPUT_x(), INPUT_x(),
// PORT_B_PULLUPS(), INPUT(),
// OUTPUT_LOW(), OUTPUT_HIGH(),
// OUTPUT_FLOAT(), OUTPUT_BIT()
// Constants used to identify pins in the above are:
 
 
 
#define PIN_A0 40
#define PIN_A1 41
#define PIN_A2 42
#define PIN_A3 43
#define PIN_A4 44
#define PIN_A5 45
#define PIN_A6 46
#define PIN_A7 47
 
#define PIN_B0 48
#define PIN_B1 49
#define PIN_B2 50
#define PIN_B3 51
#define PIN_B4 52
#define PIN_B5 53
#define PIN_B6 54
#define PIN_B7 55
 
////////////////////////////////////////////////////////////////// Useful defines
#define FALSE 0
#define TRUE 1
 
#define BYTE int
#define BOOLEAN short int
 
#define getc getch
#define fgetc getch
#define getchar getch
#define putc putchar
#define fputc putchar
#define fgets gets
#define fputs puts
 
////////////////////////////////////////////////////////////////// Control
// Control Functions: RESET_CPU(), SLEEP(), RESTART_CAUSE()
// Constants returned from RESTART_CAUSE() are:
#define WDT_FROM_SLEEP 0
#define WDT_TIMEOUT 8
#define MCLR_FROM_SLEEP 16
#define NORMAL_POWER_UP 24
 
 
////////////////////////////////////////////////////////////////// Timer 0
// Timer 0 (AKA RTCC)Functions: SETUP_COUNTERS() or SETUP_TIMER0(),
// SET_TIMER0() or SET_RTCC(),
// GET_TIMER0() or GET_RTCC()
// Constants used for SETUP_TIMER0() are:
#define RTCC_INTERNAL 0
#define RTCC_EXT_L_TO_H 32
#define RTCC_EXT_H_TO_L 48
 
#define RTCC_DIV_1 8
#define RTCC_DIV_2 0
#define RTCC_DIV_4 1
#define RTCC_DIV_8 2
#define RTCC_DIV_16 3
#define RTCC_DIV_32 4
#define RTCC_DIV_64 5
#define RTCC_DIV_128 6
#define RTCC_DIV_256 7
 
 
#define RTCC_8_BIT 0
 
// Constants used for SETUP_COUNTERS() are the above
// constants for the 1st param and the following for
// the 2nd param:
 
////////////////////////////////////////////////////////////////// WDT
// Watch Dog Timer Functions: SETUP_WDT() or SETUP_COUNTERS() (see above)
// RESTART_WDT()
//
#define WDT_18MS 8
#define WDT_36MS 9
#define WDT_72MS 10
#define WDT_144MS 11
#define WDT_288MS 12
#define WDT_576MS 13
#define WDT_1152MS 14
#define WDT_2304MS 15
 
////////////////////////////////////////////////////////////////// Timer 1
// Timer 1 Functions: SETUP_TIMER_1, GET_TIMER1, SET_TIMER1
// Constants used for SETUP_TIMER_1() are:
// (or (via |) together constants from each group)
#define T1_DISABLED 0
#define T1_INTERNAL 0x85
#define T1_EXTERNAL 0x87
#define T1_EXTERNAL_SYNC 0x83
 
#define T1_CLK_OUT 8
 
#define T1_DIV_BY_1 0
#define T1_DIV_BY_2 0x10
#define T1_DIV_BY_4 0x20
#define T1_DIV_BY_8 0x30
 
////////////////////////////////////////////////////////////////// Timer 2
// Timer 2 Functions: SETUP_TIMER_2, GET_TIMER2, SET_TIMER2
// Constants used for SETUP_TIMER_2() are:
#define T2_DISABLED 0
#define T2_DIV_BY_1 4
#define T2_DIV_BY_4 5
#define T2_DIV_BY_16 6
 
////////////////////////////////////////////////////////////////// CCP
// CCP Functions: SETUP_CCPx, SET_PWMx_DUTY
// CCP Variables: CCP_x, CCP_x_LOW, CCP_x_HIGH
// Constants used for SETUP_CCPx() are:
#define CCP_OFF 0
#define CCP_CAPTURE_FE 4
#define CCP_CAPTURE_RE 5
#define CCP_CAPTURE_DIV_4 6
#define CCP_CAPTURE_DIV_16 7
#define CCP_COMPARE_SET_ON_MATCH 8
#define CCP_COMPARE_CLR_ON_MATCH 9
#define CCP_COMPARE_INT 0xA
#define CCP_COMPARE_RESET_TIMER 0xB
#define CCP_PWM 0xC
#define CCP_PWM_PLUS_1 0x1c
#define CCP_PWM_PLUS_2 0x2c
#define CCP_PWM_PLUS_3 0x3c
long CCP_1;
#byte CCP_1 = 0x15
#byte CCP_1_LOW= 0x15
#byte CCP_1_HIGH= 0x16
////////////////////////////////////////////////////////////////// COMP
// Comparator Variables: C1OUT, C2OUT
// Constants used in setup_comparators() are:
#define A0_A3_A1_A2 4
#define A0_A2_A1_A2 3
#define NC_NC_A1_A2 5
#define NC_NC_NC_NC 7
#define A0_VR_A1_VR 2
#define A3_VR_A2_VR 10
#define A0_A2_A1_A2_OUT_ON_A3_A4 6
#define A3_A2_A1_A2 9
 
//#bit C1OUT = 0x1f.6
//#bit C2OUT = 0x1f.7
 
////////////////////////////////////////////////////////////////// VREF
// Constants used in setup_vref() are:
#define VREF_LOW 0xa0
#define VREF_HIGH 0x80
#define VREF_A2 0x40
 
////////////////////////////////////////////////////////////////// INT
// Interrupt Functions: ENABLE_INTERRUPTS(), DISABLE_INTERRUPTS(),
// EXT_INT_EDGE()
//
// Constants used in EXT_INT_EDGE() are:
#define L_TO_H 0x40
#define H_TO_L 0
// Constants used in ENABLE/DISABLE_INTERRUPTS() are:
#define GLOBAL 0x0BC0
#define INT_RTCC 0x0B20
#define INT_RB 0x0B08
#define INT_EXT 0x0B10
#define INT_TBE 0x8C10
#define INT_RDA 0x8C20
#define INT_TIMER1 0x8C01
#define INT_TIMER2 0x8C02
#define INT_CCP1 0x8C04
#define INT_SSP 0x8C08
#define INT_COMP 0x8D40
#define INT_EEPROM 0x8D10
#define INT_TIMER0 0x0B20
#list
/roboti/solarni/2006/jump/miho/LIB/16f88_reg.h
0,0 → 1,314
#nolist
//
// Komplete definition of all Special Feature Registers for CCS C compiler
//
// PIC16F87
// PIC16F88
//
// (c)miho 2005
//
// History:
//
// 1.00 First Version, not verified yet
 
 
// SFR Registers in Memory Bank 0
//
#byte INDF = 0x00
#byte TMR0 = 0x01
#byte PCL = 0x02
#byte STATUS = 0x03
#bit IRP = STATUS.7
#bit RP1 = STATUS.6
#bit RP0 = STATUS.5
#bit TO = STATUS.4
#bit PD = STATUS.3
#bit Z = STATUS.2
#bit DC = STATUS.1
#bit C = STATUS.0
#byte FSR = 0x04
#byte PORTA = 0x05
#byte PORTB = 0x06
#byte PCLATH = 0x0A
#byte INTCON = 0x0B
#bit GIE = INTCON.7
#bit PEIE = INTCON.6
#bit TMR0IE = INTCON.5
#bit INT0IE = INTCON.4
#bit RBIE = INTCON.3
#bit TMR0IF = INTCON.2
#bit INT0IF = INTCON.1
#bit RBIF = INTCON.0
#byte PIR1 = 0x0C
#bit ADIF = PIR1.6
#bit RCIF = PIR1.5
#bit TXIF = PIR1.4
#bit SSPIF = PIR1.3
#bit CCP1IF = PIR1.2
#bit TMR2IF = PIR1.1
#bit TMR1IF = PIR1.0
#byte PIR2 = 0x0D
#bit OSFIF = PIR2.7
#bit CMIF = PIR2.6
#bit EEIF = PIR2.4
#byte TMR1L = 0x0E
#byte TMR1H = 0x0F
#byte T1CON = 0x10
#bit T1RUN = T1CON.6
#bit T1CKPS1 = T1CON.5
#bit T1CKPS0 = T1CON.4
#bit T1OSCEN = T1CON.3
#bit T1SYNC = T1CON.2
#bit TMR1CS = T1CON.1
#bit TMR1ON = T1CON.0
#byte TMR2 = 0x11
#byte T2CON = 0x12
#bit TOUTPS3 = T2CON.6
#bit TOUTPS2 = T2CON.5
#bit TOUTPS1 = T2CON.4
#bit TOUTPS0 = T2CON.3
#bit TMR2ON = T2CON.2
#bit T2CKPS1 = T2CON.1
#bit T2CKPS0 = T2CON.0
#byte SSPBUF = 0x13
#byte SSPCON1 = 0x14
#bit WCOL = SSPCON1.7
#bit SSPOV = SSPCON1.6
#bit SSPEN = SSPCON1.5
#bit CKP = SSPCON1.4
#bit SSPM3 = SSPCON1.3
#bit SSPM2 = SSPCON1.2
#bit SSPM1 = SSPCON1.1
#bit SSPM0 = SSPCON1.0
#byte CCPR1L = 0x15
#byte CCPR1H = 0x16
#byte CCP1CON = 0x17
#bit CCP1X = CCP1CON.5
#bit CCP1Y = CCP1CON.4
#bit CCP1M3 = CCP1CON.3
#bit CCP1M2 = CCP1CON.2
#bit CCP1M1 = CCP1CON.1
#bit CCP1M0 = CCP1CON.0
#byte RCSTA = 0x18
#bit SPEN = RCSTA.7
#bit RX9 = RCSTA.6
#bit SREN = RCSTA.5
#bit CREN = RCSTA.4
#bit ADDEN = RCSTA.3
#bit FERR = RCSTA.2
#bit OERR = RCSTA.1
#bit RX9D = RCSTA.0
#byte TXREG = 0x19
#byte RCREG = 0x1A
#byte ADRESH = 0x1E // F88 only
#byte ADCON0 = 0x1F // F88 only
#bit ADCS1 = ADCON0.7
#bit ADCS0 = ADCON0.6
#bit CHS2 = ADCON0.5
#bit CHS1 = ADCON0.4
#bit CHS0 = ADCON0.3
#bit GO = ADCON0.2
#bit ADON = ADCON0.0
 
 
// SFR Registers in Memory Bank 1
//
#byte INDF_1 = 0x80 // miror
#byte OPTION = 0x81
#bit RBPU = OPTION.7
#bit INTEDG = OPTION.6
#bit T0CS = OPTION.5
#bit T0SE = OPTION.4
#bit PSA = OPTION.3
#bit PS2 = OPTION.2
#bit PS1 = OPTION.1
#bit PS0 = OPTION.0
#byte PCL = 0x82
#byte STATUS_1 = 0x83 // mirror
#bit IRP_1 = STATUS_1.7
#bit RP1_1 = STATUS_1.6
#bit RP0_1 = STATUS_1.5
#bit TO_1 = STATUS_1.4
#bit PD_1 = STATUS_1.3
#bit Z_1 = STATUS_1.2
#bit DC_1 = STATUS_1.1
#bit C_1 = STATUS_1.0
#byte FSR = 0x84
#byte TRISA = 0x85
#byte TRISB = 0x86
#byte PCLATH_1 = 0x8A // mirror
#byte INTCON_1 = 0x8B // mirror
#bit GIE_1 = INTCON_1.7
#bit PEIE_1 = INTCON_1.6
#bit TMR0IE_1 = INTCON_1.5
#bit INT0IE_1 = INTCON_1.4
#bit RBIE_1 = INTCON_1.3
#bit TMR0IF_1 = INTCON_1.2
#bit INT0IF_1 = INTCON_1.1
#bit RBIF_1 = INTCON_1.0
#byte PIE1 = 0x8C
#bit ADIE = PIE1.6
#bit RCIE = PIE1.5
#bit TXIE = PIE1.4
#bit SSPIE = PIE1.3
#bit CCP1IE = PIE1.2
#bit TMR2IE = PIE1.1
#bit TMR1IE = PIE1.0
#byte PIE2 = 0x8D
#bit OSFIE = PIE2.7
#bit CMIE = PIE2.6
#bit EEIE = PIE2.4
#byte PCON = 0x8E
#bit POR = PCON.1
#bit BOR = PCON.0
#byte OSCCON = 0x8F
#bit IRCF2 = OSCCON.6
#bit IRCF1 = OSCCON.5
#bit IRCF0 = OSCCON.4
#bit OSTS = OSCCON.3
#bit IOFS = OSCCON.2
#bit SCS1 = OSCCON.1
#bit SCS0 = OSCCON.0
#byte OSCTUNE = 0x90
#bit TUN5 = OSCTUNE.5
#bit TUN4 = OSCTUNE.4
#bit TUN3 = OSCTUNE.3
#bit TUN2 = OSCTUNE.2
#bit TUN1 = OSCTUNE.1
#bit TUN0 = OSCTUNE.0
#byte PR2 = 0x92
#byte SSPADD = 0x93
#byte SSPSTAT = 0x94
#bit SMP = SSPSTAT.7
#bit CKE = SSPSTAT.6
#bit DA = SSPSTAT.5
#bit P = SSPSTAT.4
#bit S = SSPSTAT.3
#bit RW = SSPSTAT.2
#bit UA = SSPSTAT.1
#bit BF = SSPSTAT.0
#byte TXSTA = 0x98
#bit CSRC = TXSTA.7
#bit TX9 = TXSTA.6
#bit TXEN = TXSTA.5
#bit SYNC = TXSTA.4
#bit BRGH = TXSTA.2
#bit TRMT = TXSTA.1
#bit TX9D = TXSTA.0
#byte SPBRG = 0x99
#byte ANSEL = 0x9B // F88 only
#bit ANS6 = ANSEL.6
#bit ANS5 = ANSEL.5
#bit ANS4 = ANSEL.4
#bit ANS3 = ANSEL.3
#bit ANS2 = ANSEL.2
#bit ANS1 = ANSEL.1
#bit ANS0 = ANSEL.0
#byte CMCON = 0x9C
#bit C2OUT = CMCON.7
#bit C1OUT = CMCON.6
#bit C2INV = CMCON.5
#bit C1INV = CMCON.4
#bit CIS = CMCON.3
#bit CM2 = CMCON.2
#bit CM1 = CMCON.1
#bit CM0 = CMCON.0
#byte CVRCON = 0x9D
#bit CVREN = CVRCON.7
#bit CVROE = CVRCON.6
#bit CVRR = CVRCON.5
#bit CVR3 = CVRCON.3
#bit CVR2 = CVRCON.2
#bit CVR1 = CVRCON.1
#bit CVR0 = CVRCON.0
#byte ADRESL = 0x9E // F88 only
#byte ADCON1 = 0x9F // F88 only
#bit ADFM = ADCON1.7
#bit ADCS2 = ADCON1.6
#bit VCFG1 = ADCON1.5
#bit VCFG0 = ADCON1.4
 
 
// SFR Registers in Memory Bank 2
//
#byte INDF_2 = 0x100 // mirror
#byte TMR0_2 = 0x101 // mirror
#byte PCL_2 = 0x102 // mirror
#byte STATUS_2 = 0x103 // mirror
#bit IRP_2 = STATUS_2.7
#bit RP1_2 = STATUS_2.6
#bit RP0_2 = STATUS_2.5
#bit TO_2 = STATUS_2.4
#bit PD_2 = STATUS_2.3
#bit Z_2 = STATUS_2.2
#bit DC_2 = STATUS_2.1
#bit C_2 = STATUS_2.0
#byte FSR_2 = 0x104 // mirror
#byte WDTCON = 0x105
#bit WDTPS3 = WDTCON.4
#bit WDTPS2 = WDTCON.3
#bit WDTPS1 = WDTCON.2
#bit WDTPS0 = WDTCON.1
#bit SWDTEN = WDTCON.0
#byte PORTB_2 = 0x106 // mirror
#byte PCLATH_2 = 0x10A // mirror
#byte INTCON_2 = 0x10B // mirror
#bit GIE_2 = INTCON_2.7
#bit PEIE_2 = INTCON_2.6
#bit TMR0IE_2 = INTCON_2.5
#bit INT0IE_2 = INTCON_2.4
#bit RBIE_2 = INTCON_2.3
#bit TMR0IF_2 = INTCON_2.2
#bit INT0IF_2 = INTCON_2.1
#bit RBIF_2 = INTCON_2.0
#byte EEDATA = 0x10C
#byte EEADR = 0x10D
#byte EEDATH = 0x10E
#byte EEADRH = 0x10F
 
 
// SFR Registers in Memory Bank 3
//
#byte INDF_3 = 0x180 // mirror
#byte OPTION_3 = 0x181 // mirror
#bit RBPU_3 = OPTION_3.7
#bit INTEDG_3 = OPTION_3.6
#bit T0CS_3 = OPTION_3.5
#bit T0SE_3 = OPTION_3.4
#bit PSA_3 = OPTION_3.3
#bit PS2_3 = OPTION_3.2
#bit PS1_3 = OPTION_3.1
#bit PS0_3 = OPTION_3.0
#byte PCL_3 = 0x182 // mirror
#byte STATUS_3 = 0x183 // mirror
#bit IRP_3 = STATUS_3.7
#bit RP1_3 = STATUS_3.6
#bit RP0_3 = STATUS_3.5
#bit TO_3 = STATUS_3.4
#bit PD_3 = STATUS_3.3
#bit Z_3 = STATUS_3.2
#bit DC_3 = STATUS_3.1
#bit C_3 = STATUS_3.0
#byte FSR_3 = 0x184 // mirror
#byte TRISB_3 = 0x186 // mirror
#byte PLATH_3 = 0x18A // mirror
#byte INTCON_3 = 0x18B // mirror
#bit GIE_3 = INTCON_3.7
#bit PEIE_3 = INTCON_3.6
#bit TMR0IE_3 = INTCON_3.5
#bit INT0IE_3 = INTCON_3.4
#bit RBIE_3 = INTCON_3.3
#bit TMR0IF_3 = INTCON_3.2
#bit INT0IF_3 = INTCON_3.1
#bit RBIF_3 = INTCON_3.0
#byte EECON1 = 0x18C
#bit EEPGD = EECON1.7
#bit FREE = EECON1.4
#bit WRERR = EECON1.3
#bit WREN = EECON1.2
#bit WR = EECON1.1
#bit RD = EECON1.0
#byte EECON2 = 0x18D
 
 
#list
/roboti/solarni/2006/jump/miho/LIB/vssver.scc
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/roboti/solarni/2006/jump/miho/vssver.scc
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/roboti/solarni/2006/jumpk/menic.BAK
0,0 → 1,7
#include <16F88.h>
 
#device adc=8
#fuses WDT,INTRC_IO, NOPUT, MCLR, NOBROWNOUT, NOLVP, NOCPD, NOWRT, \
NODEBUG, NOPROTECT, NOFCMEN, NOIESO, CCPB3
#use delay(clock=4000000, RESTART_WDT)
 
/roboti/solarni/2006/jumpk/menic.HEX
0,0 → 1,44
:1000000000308A005F280000FF00030E8301A1007A
:100010007F08A0000A08A8008A01A00E0408A20018
:100020007708A3007808A4007908A5007A08A6003C
:100030007B08A700831383128C308400801D222844
:100040008C193528220884002308F7002408F800BA
:100050002508F9002608FA002708FB0028088A006E
:10006000210E8300FF0E7F0E09008A1143280A101B
:100070008A100A118207023406340E341E343E34CC
:100080007E34FE34FF34290893008C118A11222813
:100090002F308400000803195E280130F800BF30BB
:1000A000F7006400F70B5128F80B4F284A30F7008F
:1000B000F70B582800006400800B4D2800348401A1
:1000C0001F308305603083168F001F129F121B089C
:1000D00080399B0007309C000108C03981000E3038
:1000E000F700073083128101813084000008F03965
:1000F0000738800064000008F739F719F0397704F1
:10010000800083161F129F121B088039D2389B0073
:100110001F1383121F179F1783169F1383121F1419
:10012000941283160611861406120030831294006E
:100130008316940083129001073083169C000508F3
:1001400064000230F700F70BA328000000001C0831
:1001500083120D1383169D01861183128611831657
:100160000611831206118316861083128610203022
:10017000F8001F08C73978049F009501831686117F
:10018000831286110C3097000030F800043892007A
:1001900064308316920062308F0002308312950023
:1001A00083168610831286106430AF0048208316B1
:1001B0008610831286141430AF0048201F151F19B3
:1001C000DF281E08783C031CD02883168610831273
:1001D00086100830F8001F08C73978049F006400B3
:1001E0002030F700F70BF228000000001F151F1940
:1001F000F7281E08F7000310F70C7708283EAC001C
:1002000095010030F800043892002C088316920003
:100210001430831295003230AE00FA30AF0048201F
:10022000AE0B0D2983169401223083129400023004
:10023000A90029089300C0308B0483168C15831203
:10024000AA012A08073C031C2E292A083720F80097
:10025000A9003730AF004820AA0A2129831694014B
:100260008312940183168C110611831206150A302D
:10027000AE008230AF004820AE0B3929831606113C
:080280008312061142296300FC
:04400E003C2FFC3F08
:00000001FF
;PIC16F88
/roboti/solarni/2006/jumpk/menic.c
0,0 → 1,114
//----------------------------
// Sagitta - 9. 9. 2005
//----------------------------
 
#include ".\menic.h"
 
#define RAZENI 55 // Po kolika ms se bude menit rychlost pri rozjizdeni
#define REFSTART 120 // Hodnota komparatoru odpovidajici 1,7V pri
// nezatizenych solarnich clancich
#define DUTY1 2 // Delka sepnuti PWM v us pro sero
#define DUTY2 20 // Delka sepnuti PWM v us pro jednu zarovku 500W
 
// Tabulka napeti vuci referencni LED (cca 1,7V)
// hodnota prevodniku / napeti na clancich
// 250 1,6V
// 200 2,1V
// 150 2,8V
// 145 2,9V
// 120 3,6V
// 110 4,0V
 
#define MENIC PIN_B3 // Spinani tranzistoru menice
#define REFPWR PIN_B1 // Napajeni zdroje referencniho napeti
#define MOTOR PIN_B2 // Spinani tranzistoru motoru
 
#byte SSPBUF = 0x13 // Registry jednotky SSP
#byte SSPCON1 = 0x14
#byte SSPSTAT = 0x94
 
// Vzorky pro generovani PWM pomoci SSP
unsigned int8 const Pattern[8] = {0x02,0x06,0x0e,0x1e,0x3e,0x7e,0xfe,0xff};
unsigned int8 MotorPattern;
 
#INT_SSP
void IntSSP() // Vyvola se po odeslani znaku pres SSP
{
SSPBUF=MotorPattern; // znovu vysli stejnou hodnotu
}
 
void main()
{
int8 n;
int8 cekej;
int8 perioda;
int8 rozjezd;
 
// Inicializace casovacu a prevodniku
setup_timer_0(RTCC_INTERNAL);setup_wdt(WDT_1152MS);
setup_adc_ports(ADC_CLOCK_INTERNAL|sAN1|sAN4|VSS_VDD);
setup_adc(ADC_CLOCK_INTERNAL);
setup_spi(FALSE);
setup_timer_1(T1_DISABLED);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
 
output_low(MENIC); // Vsechno zastav
output_low(MOTOR);
output_low(REFPWR);
 
set_adc_channel(4); // Vyber AD kanal pro pomerne mereni napeti
set_pwm1_duty(0); // Spust PWM, ale zatim s trvalou 0 na vystupu
setup_ccp1(CCP_PWM); // PWM pro zatizeni clanku v seru
setup_timer_2(T2_DIV_BY_1,100,1); // perioda PWM
 
setup_oscillator(OSC_4MHZ|OSC_INTRC); // rozjed PIC (zvysi se odber)
 
// jsme v depu?
set_pwm1_duty(DUTY1); // delka sepnuti
do
{
output_low(REFPWR);
delay_ms(100);
output_high(REFPWR); // zapni napajeni napetove reference (LED)
delay_ms(20);
} while (read_adc()>REFSTART); // Odkryl starter clanky?
output_low(REFPWR);
 
// Precti trimr
set_adc_channel(1); // Zjisteni nastaveni trimru PWM
delay_us(100); // Pockej na prepnuti kanalu A/D prevodniku
perioda=(read_adc()>>1)+40; // rozsah: 40 az 167
set_pwm1_duty(0); // Zastav PWM, aby slo zmenit periodu
setup_timer_2(T2_DIV_BY_1,perioda,1); // Zapis nastavenou periodu
 
// nabíjíme
set_pwm1_duty(DUTY2); // delka sepnuti PWM
delay_ms(12500);
 
// rozjezd
SSPSTAT = 0; // inicializace SPI jednotky
SSPCON1 = 0x22; // SPI OSC/64
MotorPattern=Pattern[0];
SSPBUF=MotorPattern; // 1. data pro vyslani
enable_interrupts(global);
enable_interrupts(INT_SSP); // az budou vyslana, prijde preruseni
 
for(n=0; n<=7; n++) // razeni osmi rychlostnich stupnu
{
MotorPattern=Pattern[n];
delay_ms(RAZENI); // Pockej na dalsi razeni
};
SSPSTAT = 0;
SSPCON1 = 0; // SPI stop
disable_interrupts(INT_SSP); // zastav preruseni od SSP
 
// jedem co to da
output_high(MOTOR);
delay_ms(1300); // dyl jak 1,3s bysme nemeli jet :)
output_low(MOTOR); // zastav motor
// Menic je stale zapnut a zatezuje clanky
 
while(TRUE); // Cekej, dokud se neztrati svetlo,
// nebo prijde WatchDog
}
/roboti/solarni/2006/jumpk/menic.h
0,0 → 1,9
#include <16F88.h>
 
#device adc=8
 
#fuses WDT,INTRC_IO, NOPUT, MCLR, NOBROWNOUT, NOLVP, NOCPD, NOWRT, \
NODEBUG, NOPROTECT, NOFCMEN, NOIESO, CCPB3
 
#use delay(clock=4000000, RESTART_WDT)