Subversion Repositories svnkaklik

Compare Revisions

No changes between revisions

Ignore whitespace Rev 174 → Rev 178

/roboti/solarni/2006/scamnum/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/scamnum/menic.BAK
0,0 → 1,156
// *************************************
// * Scamnum Specularis ** 20. 9. 2006 *
// *************************************
 
#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 REFSTART 95 // Hodnota odpovidajici 1,2V pri nezatizenych clancich
#define DUTY1 2 // Delka sepnuti PWM v us pro sero
#define DUTY2 19 // Delka sepnuti PWM v us pro jednu zarovku 500W
 
// Tabulka hodnot prevodniku pro ruzna napajeci napeti
// 80 3,99V
// 90 3,54V
// 100 3,20V
// 105 3,04V
// 107 2,99V
// 110 2,91v
// 200 1,61V
 
#define PIEZO PIN_A6 // Jeden pol piezo reproduktoru
#define LED PIN_A7 // LED / druhy pol piezo reproduktoru
#define MENIC PIN_B3 // Spinani tranzistoru menice
#define REFPWR PIN_B1 // Napajeni zdroje referencniho napeti
#define MOTOR PIN_B2 // Spinani tranzistoru motoru
#define SW1 PIN_B6 // DIPswitch 1
#define SW2 PIN_B7 // DIPswitch 2
#define NAPETI 4 // Cislo kanalu DA prevodniku pro mereni napeti
#define PWM 0 // Cislo kanalu DA prevodniku pro nastaveni PWM
#define ROZJEZD 1 // Cislo kanalu DA prevodniku pro nastaveni rozjezdu
 
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;
int8 razeni;
int8 uclanku;
int8 ble;
 
setup_timer_0(RTCC_INTERNAL);setup_wdt(WDT_1152MS);
setup_timer_1(T1_DISABLED);
setup_adc_ports(ADC_CLOCK_INTERNAL|sAN0|sAN1|sAN4|VSS_VDD);
setup_adc(ADC_CLOCK_INTERNAL);
setup_spi(FALSE);
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(NAPETI); // Vyber AD kanal pro pomerne mereni napeti
set_pwm1_duty(0); // Spust PWM, ale zatim s trvalou 0 na vystupu
setup_ccp1(CCP_PWM);
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(DUTY1); // PWM pro zatizeni clanku pri malem osvetleni
n=0;
do
{
output_low(REFPWR); // Vypni napajeni napetove reference, aby se setrilo
delay_ms(100);
if (4==n++) {cvak(); n=0;}; // Kazdy 4. pruchod cvakni
output_high(REFPWR); // Zapni napajeni napetove reference
delay_ms(1); // Pockej na ustaleni napeti
} while (read_adc()>REFSTART); // Odkryl starter clanky?
output_low(REFPWR); // Vypni napajeni napetove reference, aby se setrilo
 
// port_b_pullups(TRUE); // Zapni pullupy, aby slo cist DIPswitch
// do
// {
// Precti trimry
set_adc_channel(PWM); // Zjisteni nastaveni PWM
delay_us(100); // Pockej na prepnuti kanalu A/D prevodniku
perioda=(read_adc()>>2)+40; // rozsah: 40 az 103
 
set_adc_channel(ROZJEZD); // Zjisteni nastaveni rozjezdu
delay_us(100); // Pockej na prepnuti kanalu A/D prevodniku
razeni=read_adc()>>4; // rozsah: 0 az 15
 
// Rozjeti menice
set_pwm1_duty(0); // Zastav PWM, aby slo nastavit jinou frekvenci
setup_timer_2(T2_DIV_BY_1,perioda,1); // perioda
set_pwm1_duty(DUTY2); // PWM pro zatizeni clanku pri jedne 500W zarovce
 
pip(); // potvrzeni odstartovani / servisni mod
delay_ms(500);
 
// } while (input(SW1)); // Je zapnut servisni mod? SW1(OFF)=ANO
// port_b_pullups(FALSE); // Vypni pullupy, aby se setrilo energii
 
// zmereni napeti na clancich
output_high(REFPWR); // Prepni AD na mereni napeti clanku
set_adc_channel(NAPETI); // Prepni Zmer napeti clanku
delay_us(50); // Pockej na prepnuti kanalu A/D prevodniku
uclanku=read_adc();
output_low(REFPWR); // odpoj odpor pro mereni napeti
 
// posli telemetrii
sprintf(AXstring,"p=%u r=%u u=%u", perioda, razeni, uclanku); // Convert DATA to String.
SendPacket(&AXstring[0]);
 
delay_ms(14000); // Pockame do 14.5s
 
// rozjezd
for( ble=1;ble<255;ble++)
{
for(n=0;n<=razeni;n++)
{
output_high(MOTOR);
delay_us(ble);
delay_us(ble);
output_low(MOTOR);
delay_us(255-ble);
delay_us(255-ble);
}
}
 
// jedem co to da
output_high(MOTOR);
 
delay_ms(1300); // Nemeli bysme jet dele nez 1,3s :-)
output_low(MOTOR); // Zastav motor
// Menic je stale zapnut a zatezuje clanky
 
while(TRUE); // Cekej, dokud se neztrati svetlo.
}
/roboti/solarni/2006/scamnum/menic.HEX
0,0 → 1,100
:1000000000308A0089290000663084000008031946
:1000100019280130F800BF30F7006400F70B0D28F5
:10002000F80B0B284230F700F70B14286400800B04
:1000300009280034831605178312051F212805138C
:10004000222805178316051383128A11292AE6012F
:100050006608F93C031C4728651830280513312829
:1000600005178316051301308312E50665183A2833
:1000700085133B2885178316851364001F30F7000E
:10008000F70B4028000000008312E60A2828831698
:1000900005138312051783168513831285178A119A
:1000A000762A5F08840067088000840A8001DF0ADE
:1000B00000346808F8016702031861286708F70030
:1000C0006D28F7010830E900E70DF70D68087702A1
:1000D0000318F700F80DE90B642800347808650868
:1000E000E7006430E80059207708E50078083030F0
:1000F000031D8128E61C8828E6198828661A203006
:100100008428E61166126614F8077808E700512083
:100110006508E7000A30E80059207708E50078080C
:100120003030031D9928E6199D28661C9D28661A03
:100130002030F8077808E70051203030E5076508DF
:10014000E70051200034B301301CA8283010A92842
:1001500030140034301CD62883168612831286127F
:1001600064004730F700F70BB328000083168612AF
:100170008312861664004730F700F70BBD28000095
:10018000831686128312861264004730F700F70B3D
:10019000C728000083168612831286166400183062
:1001A000F700F70BD12800000000E928831686121B
:1001B0008312861264008530F700F70BDD28831662
:1001C00086128312861664006F30F700F70BE6285C
:1001D00000000034E8016808073C031C3229670866
:1001E0000139E900B5080319F7280030F828013073
:1001F000EA00B4080319FE280030FF2801306A0520
:10020000003A031912296908EA000310B20CB10C74
:10021000030801396A06013C031D12298430B20625
:100220000830B106E908031D1729A3202D29B408B9
:100230000319B30AB40803191F290030202901301B
:10024000EA003308053C031927290030282901302A
:100250006A0503192D29AA20A320AA200310E70C60
:10026000E80AEB2800343010FF30B200B100B301CF
:100270000130B400B501B6013608093C031C45291C
:100280007E30E700EA20B60A3C29B401B601360800
:100290000F3C031C54292030360784000008E60078
:1002A000E700EA20B60A4729B6016508840000087D
:1002B00003196329650884000008E600E700EA20C6
:1002C000E50AB60A55290130B500FF30B106B2067D
:1002D0003108E700EA203208E700EA20B5010130E2
:1002E000B4007E30E700EA208A11C22A1230E6020A
:1002F000031C882966308400FC3080050310800CC4
:10030000800C00080319882986296400800B852940
:10031000003484011F30830583161F129F121B08AF
:1003200080399B0007309C0082308312A0009830F7
:10033000A100A2004030A300A400A5006030A600E8
:100340008630A700B430A8006030A900A430AA000D
:10035000AB00AC006130AD000330AE00F030AF0058
:10036000DF0183160108C03981000E30F700073025
:1003700083128101813084000008F0390738800041
:1003800064000008F739F719F0397704800090010C
:1003900083161F129F121B088039D3389B001F132E
:1003A00083121F179F1783169F1383121F14941213
:1003B00083160611861406120030831294008316E9
:1003C000940007309C00050864000230F700F70B2A
:1003D000E72900001C0883120D1383169D01861166
:1003E0008312861183160611831206118316861056
:1003F00083128610831685138312851783160513BF
:10040000831205172030F8001F08C73978049F00B1
:10041000950183168611831286110C3097000030E7
:10042000F8000438920064308316920062308F0026
:10043000023083129500E001831686108312861025
:100440006430E60004206008E00A043C031D2A2A08
:100450001A28E00183168610831286140130E60004
:1004600004201F151F19322A1E085F3C031C1C2A7A
:1004700083168610831286100030F8001F08C739D3
:1004800078049F0064001F30F700F70B452A000036
:1004900000001F151F194A2A1E08F700F70CF70C59
:1004A0003F30F7057708283EE1000830F8001F08C4
:1004B000C73978049F0064001F30F700F70B5E2AED
:1004C000000000001F151F19632A1E081E0EE200FF
:1004D0000F30E20595010030F80004389200610801
:1004E0008316920013308312950027280230E5000E
:1004F000FA30E6000420E50B782A83168610831272
:1005000086142030F8001F08C73978049F00640063
:100510000F30F700F70B8A2A00001F151F198E2ACB
:100520001E08E30083168610831286103730DF0022
:100530007030E70051203D30E70051206108E500B0
:100540001B30E6006E202030E70051207230E700BB
:1005500051203D30E70051206208E5001B30E600E5
:100560006E202030E70051207530E70051203D30EB
:10057000E70051206308E5001B30E6006E203730AD
:10058000E50033293830E500FA30E6000420E50BB9
:10059000C42A0130E400640FCE2AEF2AE00160088B
:1005A0006202031CED2A83160611831206156408E5
:1005B000E60076216408E600762183160611831290
:1005C00006116408FF3CE500E60076216408FF3C64
:1005D000E500E6007621E00ACF2AE40ACB2A83165A
:1005E0000611831206150A30E5008230E600042069
:1005F000E50BF52A83160611831206118A010028DD
:02060000630095
:04400E003827FC3F14
:00000001FF
;PIC16F88
/roboti/solarni/2006/scamnum/menic.LST
0,0 → 1,1025
CCS PCM C Compiler, Version 3.245, 27853 20-IX-06 03:03
 
Filename: D:\KAKL\roboti\solarni\2006\scamnum\menic.lst
 
ROM used: 769 words (19%)
Largest free fragment is 2048
RAM used: 76 (43%) at main() level
82 (47%) worst case
Stack: 3 locations
 
*
0000: MOVLW 00
0001: MOVWF 0A
0002: GOTO 189
0003: NOP
.................... // *************************************
.................... // * Scamnum Specularis ** 20. 9. 2006 *
.................... // *************************************
....................
.................... #include ".\menic.h"
.................... #include <16F88.h>
.................... //////// Standard Header file for the PIC16F88 device ////////////////
.................... #device PIC16F88
.................... #list
....................
....................
.................... #device adc=8
....................
.................... #fuses NOWDT,INTRC_IO, NOPUT, MCLR, NOBROWNOUT, NOLVP, NOCPD, \
.................... NOWRT, DEBUG, NOPROTECT, NOFCMEN, NOIESO, CCPB3
....................
.................... #use delay(clock=3900000,RESTART_WDT)
*
0004: MOVLW 66
0005: MOVWF 04
0006: MOVF 00,W
0007: BTFSC 03.2
0008: GOTO 019
0009: MOVLW 01
000A: MOVWF 78
000B: MOVLW BF
000C: MOVWF 77
000D: CLRWDT
000E: DECFSZ 77,F
000F: GOTO 00D
0010: DECFSZ 78,F
0011: GOTO 00B
0012: MOVLW 42
0013: MOVWF 77
0014: DECFSZ 77,F
0015: GOTO 014
0016: CLRWDT
0017: DECFSZ 00,F
0018: GOTO 009
0019: RETLW 00
*
0176: MOVLW 12
0177: SUBWF 66,F
0178: BTFSS 03.0
0179: GOTO 188
017A: MOVLW 66
017B: MOVWF 04
017C: MOVLW FC
017D: ANDWF 00,F
017E: BCF 03.0
017F: RRF 00,F
0180: RRF 00,F
0181: MOVF 00,W
0182: BTFSC 03.2
0183: GOTO 188
0184: GOTO 186
0185: CLRWDT
0186: DECFSZ 00,F
0187: GOTO 185
0188: RETLW 00
....................
....................
....................
.................... #define TXo PIN_B5 // To the transmitter modulator
.................... #include ".\AX25.c" // Podprogram pro prenos telemetrie
.................... //#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};
*
0194: MOVLW 82
0195: BCF 03.5
0196: MOVWF 20
0197: MOVLW 98
0198: MOVWF 21
0199: MOVWF 22
019A: MOVLW 40
019B: MOVWF 23
019C: MOVWF 24
019D: MOVWF 25
019E: MOVLW 60
019F: MOVWF 26
01A0: MOVLW 86
01A1: MOVWF 27
01A2: MOVLW B4
01A3: MOVWF 28
01A4: MOVLW 60
01A5: MOVWF 29
01A6: MOVLW A4
01A7: MOVWF 2A
01A8: MOVWF 2B
01A9: MOVWF 2C
01AA: MOVLW 61
01AB: MOVWF 2D
01AC: MOVLW 03
01AD: MOVWF 2E
01AE: MOVLW F0
01AF: MOVWF 2F
....................
.................... 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
*
00A3: CLRF 33
.................... if (bit)
00A4: BTFSS 30.0
00A5: GOTO 0A8
.................... {
.................... bit=FALSE; //if the state of the pin was low, make it high.
00A6: BCF 30.0
.................... }
.................... else
00A7: GOTO 0A9
.................... {
.................... bit=TRUE; //if the state of the pin was high make it low
00A8: BSF 30.0
.................... }
.................... }
00A9: RETLW 00
....................
.................... void fcsbit(byte tbyte)
.................... {
.................... #asm
.................... BCF STATUS,0
*
0105: BCF 03.0
.................... RRF fcshi,F // rotates the entire 16 bits
0106: RRF 32,F
.................... RRF fcslo,F // to the right
0107: RRF 31,F
.................... #endasm
.................... if (((STATUS & 0x01)^(tbyte)) ==0x01)
0108: MOVF 03,W
0109: ANDLW 01
010A: XORWF 6A,W
010B: SUBLW 01
010C: BTFSS 03.2
010D: GOTO 112
.................... {
.................... fcshi = fcshi^0x84;
010E: MOVLW 84
010F: XORWF 32,F
.................... fcslo = fcslo^0x08;
0110: MOVLW 08
0111: XORWF 31,F
.................... }
.................... }
....................
.................... void SendBit ()
.................... {
.................... if (bit)
*
00AA: BTFSS 30.0
00AB: GOTO 0D6
.................... {
.................... output_low(TXo);
00AC: BSF 03.5
00AD: BCF 06.5
00AE: BCF 03.5
00AF: BCF 06.5
.................... PERIODAH;
00B0: CLRWDT
00B1: MOVLW 47
00B2: MOVWF 77
00B3: DECFSZ 77,F
00B4: GOTO 0B3
00B5: NOP
.................... output_high(TXo);
00B6: BSF 03.5
00B7: BCF 06.5
00B8: BCF 03.5
00B9: BSF 06.5
.................... PERIODAH;
00BA: CLRWDT
00BB: MOVLW 47
00BC: MOVWF 77
00BD: DECFSZ 77,F
00BE: GOTO 0BD
00BF: NOP
.................... output_low(TXo);
00C0: BSF 03.5
00C1: BCF 06.5
00C2: BCF 03.5
00C3: BCF 06.5
.................... PERIODAH;
00C4: CLRWDT
00C5: MOVLW 47
00C6: MOVWF 77
00C7: DECFSZ 77,F
00C8: GOTO 0C7
00C9: NOP
.................... output_high(TXo);
00CA: BSF 03.5
00CB: BCF 06.5
00CC: BCF 03.5
00CD: BSF 06.5
.................... TAILH;
00CE: CLRWDT
00CF: MOVLW 18
00D0: MOVWF 77
00D1: DECFSZ 77,F
00D2: GOTO 0D1
00D3: NOP
00D4: NOP
.................... }
.................... else
00D5: GOTO 0E9
.................... {
.................... output_low(TXo);
00D6: BSF 03.5
00D7: BCF 06.5
00D8: BCF 03.5
00D9: BCF 06.5
.................... PERIODAL;
00DA: CLRWDT
00DB: MOVLW 85
00DC: MOVWF 77
00DD: DECFSZ 77,F
00DE: GOTO 0DD
.................... output_high(TXo);
00DF: BSF 03.5
00E0: BCF 06.5
00E1: BCF 03.5
00E2: BSF 06.5
.................... TAILL;
00E3: CLRWDT
00E4: MOVLW 6F
00E5: MOVWF 77
00E6: DECFSZ 77,F
00E7: GOTO 0E6
00E8: NOP
.................... };
.................... }
00E9: RETLW 00
....................
.................... 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
00EA: CLRF 68
00EB: MOVF 68,W
00EC: SUBLW 07
00ED: BTFSS 03.0
00EE: GOTO 132
.................... {
.................... bt = inbyte & 0x01; //strip off the rightmost bit of the byte to be sent (inbyte)
00EF: MOVF 67,W
00F0: ANDLW 01
00F1: MOVWF 69
.................... if ((fcs_flag == FALSE) & (flag_flag == FALSE)) fcsbit(bt); //do FCS calc, but only if this
00F2: MOVF 35,F
00F3: BTFSC 03.2
00F4: GOTO 0F7
00F5: MOVLW 00
00F6: GOTO 0F8
00F7: MOVLW 01
00F8: MOVWF 6A
00F9: MOVF 34,F
00FA: BTFSC 03.2
00FB: GOTO 0FE
00FC: MOVLW 00
00FD: GOTO 0FF
00FE: MOVLW 01
00FF: ANDWF 6A,W
0100: XORLW 00
0101: BTFSC 03.2
0102: GOTO 112
0103: MOVF 69,W
0104: MOVWF 6A
.................... //is not a flag or fcs byte
.................... if (bt == 0)
*
0112: MOVF 69,F
0113: BTFSS 03.2
0114: GOTO 117
.................... {
.................... flipout();
0115: CALL 0A3
.................... } // if this bit is a zero, flip the output state
.................... else
0116: GOTO 12D
.................... { //otherwise if it is a 1, do the following:
.................... if (flag_flag == FALSE) stuff++; //increment the count of consequtive 1's
0117: MOVF 34,F
0118: BTFSC 03.2
0119: INCF 33,F
.................... if ((flag_flag == FALSE) & (stuff == 5))
011A: MOVF 34,F
011B: BTFSC 03.2
011C: GOTO 11F
011D: MOVLW 00
011E: GOTO 120
011F: MOVLW 01
0120: MOVWF 6A
0121: MOVF 33,W
0122: SUBLW 05
0123: BTFSC 03.2
0124: GOTO 127
0125: MOVLW 00
0126: GOTO 128
0127: MOVLW 01
0128: ANDWF 6A,W
0129: BTFSC 03.2
012A: GOTO 12D
.................... { //stuff an extra 0, if 5 1's in a row
.................... SendBit();
012B: CALL 0AA
.................... flipout(); //flip the output state to stuff a 0
012C: CALL 0A3
.................... }//end of if
.................... }//end of else
.................... // delay_us(850); //introduces a delay that creates 1200 baud
.................... SendBit();
012D: CALL 0AA
.................... inbyte = inbyte>>1; //go to the next bit in the byte
012E: BCF 03.0
012F: RRF 67,F
.................... }//end of for
0130: INCF 68,F
0131: GOTO 0EB
.................... }//end of SendByte
0132: RETLW 00
....................
.................... void SendPacket(char *data)
.................... {
.................... bit=FALSE;
0133: BCF 30.0
....................
.................... fcslo=fcshi=0xFF; //The 2 FCS Bytes are initialized to FF
0134: MOVLW FF
0135: MOVWF 32
0136: MOVWF 31
.................... stuff = 0; //The variable stuff counts the number of 1's in a row. When it gets to 5
0137: CLRF 33
.................... // 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.
0138: MOVLW 01
0139: MOVWF 34
.................... fcs_flag = FALSE; //The variable fcsflag is true if you are transmitting FCS bytes, false otherwise.
013A: CLRF 35
....................
.................... for(i=0; i<10; i++) SendByte(0x7E); //Sends flag bytes. Adjust length for txdelay
013B: CLRF 36
013C: MOVF 36,W
013D: SUBLW 09
013E: BTFSS 03.0
013F: GOTO 145
0140: MOVLW 7E
0141: MOVWF 67
0142: CALL 0EA
0143: INCF 36,F
0144: GOTO 13C
.................... //each flag takes approx 6.7 ms
.................... flag_flag = FALSE; //done sending flags
0145: CLRF 34
....................
.................... for(i=0; i<16; i++) SendByte(SendData[i]); //send the packet bytes
0146: CLRF 36
0147: MOVF 36,W
0148: SUBLW 0F
0149: BTFSS 03.0
014A: GOTO 154
014B: MOVLW 20
014C: ADDWF 36,W
014D: MOVWF 04
014E: MOVF 00,W
014F: MOVWF 66
0150: MOVWF 67
0151: CALL 0EA
0152: INCF 36,F
0153: GOTO 147
....................
.................... for(i=0; 0 != *data; i++)
0154: CLRF 36
0155: MOVF 65,W
0156: MOVWF 04
0157: MOVF 00,W
0158: BTFSC 03.2
0159: GOTO 163
.................... {
.................... SendByte(*data); //send the packet bytes
015A: MOVF 65,W
015B: MOVWF 04
015C: MOVF 00,W
015D: MOVWF 66
015E: MOVWF 67
015F: CALL 0EA
.................... data++;
0160: INCF 65,F
.................... };
0161: INCF 36,F
0162: GOTO 155
....................
.................... fcs_flag = TRUE; //about to send the FCS bytes
0163: MOVLW 01
0164: MOVWF 35
.................... fcslo =fcslo^0xff; //must XOR them with FF before sending
0165: MOVLW FF
0166: XORWF 31,F
.................... fcshi = fcshi^0xff;
0167: XORWF 32,F
.................... SendByte(fcslo); //send the low byte of fcs
0168: MOVF 31,W
0169: MOVWF 67
016A: CALL 0EA
.................... SendByte(fcshi); //send the high byte of fcs
016B: MOVF 32,W
016C: MOVWF 67
016D: CALL 0EA
.................... fcs_flag = FALSE; //done sending FCS
016E: CLRF 35
.................... flag_flag = TRUE; //about to send flags
016F: MOVLW 01
0170: MOVWF 34
.................... SendByte(0x7e); // Send a flag to end packet
0171: MOVLW 7E
0172: MOVWF 67
0173: CALL 0EA
.................... }
0174: BCF 0A.3
0175: GOTO 2C2 (RETURN)
....................
....................
....................
....................
.................... char AXstring[40]; // Buffer pro prenos telemetrie
....................
.................... #define REFSTART 95 // Hodnota odpovidajici 1,2V pri nezatizenych clancich
.................... #define DUTY1 2 // Delka sepnuti PWM v us pro sero
.................... #define DUTY2 19 // Delka sepnuti PWM v us pro jednu zarovku 500W
....................
.................... // Tabulka hodnot prevodniku pro ruzna napajeci napeti
.................... // 80 3,99V
.................... // 90 3,54V
.................... // 100 3,20V
.................... // 105 3,04V
.................... // 107 2,99V
.................... // 110 2,91v
.................... // 200 1,61V
....................
.................... #define PIEZO PIN_A6 // Jeden pol piezo reproduktoru
.................... #define LED PIN_A7 // LED / druhy pol piezo reproduktoru
.................... #define MENIC PIN_B3 // Spinani tranzistoru menice
.................... #define REFPWR PIN_B1 // Napajeni zdroje referencniho napeti
.................... #define MOTOR PIN_B2 // Spinani tranzistoru motoru
.................... #define SW1 PIN_B6 // DIPswitch 1
.................... #define SW2 PIN_B7 // DIPswitch 2
.................... #define NAPETI 4 // Cislo kanalu DA prevodniku pro mereni napeti
.................... #define PWM 0 // Cislo kanalu DA prevodniku pro nastaveni PWM
.................... #define ROZJEZD 1 // Cislo kanalu DA prevodniku pro nastaveni rozjezdu
....................
.................... void pip() // pipnuti a bliknuti
.................... {
.................... int1 beep;
.................... int i;
....................
.................... for(i=0; i<250; i++)
*
0027: CLRF 66
0028: MOVF 66,W
0029: SUBLW F9
002A: BTFSS 03.0
002B: GOTO 047
.................... {
.................... output_bit(PIEZO, beep);
002C: BTFSC 65.0
002D: GOTO 030
002E: BCF 05.6
002F: GOTO 031
0030: BSF 05.6
0031: BSF 03.5
0032: BCF 05.6
.................... beep=~beep;
0033: MOVLW 01
0034: BCF 03.5
0035: XORWF 65,F
.................... output_bit(LED, beep);
0036: BTFSC 65.0
0037: GOTO 03A
0038: BCF 05.7
0039: GOTO 03B
003A: BSF 05.7
003B: BSF 03.5
003C: BCF 05.7
.................... delay_us(100);
003D: CLRWDT
003E: MOVLW 1F
003F: MOVWF 77
0040: DECFSZ 77,F
0041: GOTO 040
0042: NOP
0043: NOP
.................... };
0044: BCF 03.5
0045: INCF 66,F
0046: GOTO 028
.................... output_high(PIEZO);
0047: BSF 03.5
0048: BCF 05.6
0049: BCF 03.5
004A: BSF 05.6
.................... output_high(LED);
004B: BSF 03.5
004C: BCF 05.7
004D: BCF 03.5
004E: BSF 05.7
.................... }
004F: BCF 0A.3
0050: GOTO 276 (RETURN)
....................
.................... void cvak() // pouze cvaknuti piezoelementem bez bliknuti
.................... {
.................... output_bit(PIEZO,~input(PIEZO));
*
001A: BSF 03.5
001B: BSF 05.6
001C: BCF 03.5
001D: BTFSS 05.6
001E: GOTO 021
001F: BCF 05.6
0020: GOTO 022
0021: BSF 05.6
0022: BSF 03.5
0023: BCF 05.6
.................... }
0024: BCF 03.5
0025: BCF 0A.3
0026: GOTO 229 (RETURN)
....................
.................... void main()
.................... {
*
0189: CLRF 04
018A: MOVLW 1F
018B: ANDWF 03,F
018C: BSF 03.5
018D: BCF 1F.4
018E: BCF 1F.5
018F: MOVF 1B,W
0190: ANDLW 80
0191: MOVWF 1B
0192: MOVLW 07
0193: MOVWF 1C
.................... int8 n;
.................... int8 perioda;
.................... int8 razeni;
.................... int8 uclanku;
.................... int8 ble;
....................
.................... setup_timer_0(RTCC_INTERNAL);setup_wdt(WDT_1152MS);
*
01B1: BSF 03.5
01B2: MOVF 01,W
01B3: ANDLW C0
01B4: MOVWF 01
01B5: MOVLW 0E
01B6: MOVWF 77
01B7: MOVLW 07
01B8: BCF 03.5
01B9: CLRF 01
01BA: MOVLW 81
01BB: MOVWF 04
01BC: MOVF 00,W
01BD: ANDLW F0
01BE: IORLW 07
01BF: MOVWF 00
01C0: CLRWDT
01C1: MOVF 00,W
01C2: ANDLW F7
01C3: BTFSC 77.3
01C4: ANDLW F0
01C5: IORWF 77,W
01C6: MOVWF 00
.................... setup_timer_1(T1_DISABLED);
01C7: CLRF 10
.................... setup_adc_ports(ADC_CLOCK_INTERNAL|sAN0|sAN1|sAN4|VSS_VDD);
01C8: BSF 03.5
01C9: BCF 1F.4
01CA: BCF 1F.5
01CB: MOVF 1B,W
01CC: ANDLW 80
01CD: IORLW D3
01CE: MOVWF 1B
.................... setup_adc(ADC_CLOCK_INTERNAL);
01CF: BCF 1F.6
01D0: BCF 03.5
01D1: BSF 1F.6
01D2: BSF 1F.7
01D3: BSF 03.5
01D4: BCF 1F.7
01D5: BCF 03.5
01D6: BSF 1F.0
.................... setup_spi(FALSE);
01D7: BCF 14.5
01D8: BSF 03.5
01D9: BCF 06.2
01DA: BSF 06.1
01DB: BCF 06.4
01DC: MOVLW 00
01DD: BCF 03.5
01DE: MOVWF 14
01DF: BSF 03.5
01E0: MOVWF 14
.................... setup_comparator(NC_NC_NC_NC);
01E1: MOVLW 07
01E2: MOVWF 1C
01E3: MOVF 05,W
01E4: CLRWDT
01E5: MOVLW 02
01E6: MOVWF 77
01E7: DECFSZ 77,F
01E8: GOTO 1E7
01E9: NOP
01EA: MOVF 1C,W
01EB: BCF 03.5
01EC: BCF 0D.6
.................... setup_vref(FALSE);
01ED: BSF 03.5
01EE: CLRF 1D
....................
.................... output_low(MENIC); // Vsechno zastav
01EF: BCF 06.3
01F0: BCF 03.5
01F1: BCF 06.3
.................... output_low(MOTOR);
01F2: BSF 03.5
01F3: BCF 06.2
01F4: BCF 03.5
01F5: BCF 06.2
.................... output_low(REFPWR);
01F6: BSF 03.5
01F7: BCF 06.1
01F8: BCF 03.5
01F9: BCF 06.1
.................... output_high(LED);
01FA: BSF 03.5
01FB: BCF 05.7
01FC: BCF 03.5
01FD: BSF 05.7
.................... output_high(PIEZO);
01FE: BSF 03.5
01FF: BCF 05.6
0200: BCF 03.5
0201: BSF 05.6
....................
.................... set_adc_channel(NAPETI); // Vyber AD kanal pro pomerne mereni napeti
0202: MOVLW 20
0203: MOVWF 78
0204: MOVF 1F,W
0205: ANDLW C7
0206: IORWF 78,W
0207: MOVWF 1F
.................... set_pwm1_duty(0); // Spust PWM, ale zatim s trvalou 0 na vystupu
0208: CLRF 15
.................... setup_ccp1(CCP_PWM);
0209: BSF 03.5
020A: BCF 06.3
020B: BCF 03.5
020C: BCF 06.3
020D: MOVLW 0C
020E: MOVWF 17
.................... setup_timer_2(T2_DIV_BY_1,100,1); // perioda
020F: MOVLW 00
0210: MOVWF 78
0211: IORLW 04
0212: MOVWF 12
0213: MOVLW 64
0214: BSF 03.5
0215: MOVWF 12
....................
.................... setup_oscillator(OSC_4MHZ|OSC_INTRC); // rozjed PIC (zvysi se odber)
0216: MOVLW 62
0217: MOVWF 0F
....................
.................... // jsme v depu?
.................... set_pwm1_duty(DUTY1); // PWM pro zatizeni clanku pri malem osvetleni
0218: MOVLW 02
0219: BCF 03.5
021A: MOVWF 15
.................... n=0;
021B: CLRF 60
.................... do
.................... {
.................... output_low(REFPWR); // Vypni napajeni napetove reference, aby se setrilo
021C: BSF 03.5
021D: BCF 06.1
021E: BCF 03.5
021F: BCF 06.1
.................... delay_ms(100);
0220: MOVLW 64
0221: MOVWF 66
0222: CALL 004
.................... if (4==n++) {cvak(); n=0;}; // Kazdy 4. pruchod cvakni
0223: MOVF 60,W
0224: INCF 60,F
0225: SUBLW 04
0226: BTFSS 03.2
0227: GOTO 22A
0228: GOTO 01A
0229: CLRF 60
.................... output_high(REFPWR); // Zapni napajeni napetove reference
022A: BSF 03.5
022B: BCF 06.1
022C: BCF 03.5
022D: BSF 06.1
.................... delay_ms(1); // Pockej na ustaleni napeti
022E: MOVLW 01
022F: MOVWF 66
0230: CALL 004
.................... } while (read_adc()>REFSTART); // Odkryl starter clanky?
0231: BSF 1F.2
0232: BTFSC 1F.2
0233: GOTO 232
0234: MOVF 1E,W
0235: SUBLW 5F
0236: BTFSS 03.0
0237: GOTO 21C
.................... output_low(REFPWR); // Vypni napajeni napetove reference, aby se setrilo
0238: BSF 03.5
0239: BCF 06.1
023A: BCF 03.5
023B: BCF 06.1
....................
.................... // port_b_pullups(TRUE); // Zapni pullupy, aby slo cist DIPswitch
.................... // do
.................... // {
.................... // Precti trimry
.................... set_adc_channel(PWM); // Zjisteni nastaveni PWM
023C: MOVLW 00
023D: MOVWF 78
023E: MOVF 1F,W
023F: ANDLW C7
0240: IORWF 78,W
0241: MOVWF 1F
.................... delay_us(100); // Pockej na prepnuti kanalu A/D prevodniku
0242: CLRWDT
0243: MOVLW 1F
0244: MOVWF 77
0245: DECFSZ 77,F
0246: GOTO 245
0247: NOP
0248: NOP
.................... perioda=(read_adc()>>2)+40; // rozsah: 40 az 103
0249: BSF 1F.2
024A: BTFSC 1F.2
024B: GOTO 24A
024C: MOVF 1E,W
024D: MOVWF 77
024E: RRF 77,F
024F: RRF 77,F
0250: MOVLW 3F
0251: ANDWF 77,F
0252: MOVF 77,W
0253: ADDLW 28
0254: MOVWF 61
....................
.................... set_adc_channel(ROZJEZD); // Zjisteni nastaveni rozjezdu
0255: MOVLW 08
0256: MOVWF 78
0257: MOVF 1F,W
0258: ANDLW C7
0259: IORWF 78,W
025A: MOVWF 1F
.................... delay_us(100); // Pockej na prepnuti kanalu A/D prevodniku
025B: CLRWDT
025C: MOVLW 1F
025D: MOVWF 77
025E: DECFSZ 77,F
025F: GOTO 25E
0260: NOP
0261: NOP
.................... razeni=read_adc()>>4; // rozsah: 0 az 15
0262: BSF 1F.2
0263: BTFSC 1F.2
0264: GOTO 263
0265: MOVF 1E,W
0266: SWAPF 1E,W
0267: MOVWF 62
0268: MOVLW 0F
0269: ANDWF 62,F
....................
.................... // Rozjeti menice
.................... set_pwm1_duty(0); // Zastav PWM, aby slo nastavit jinou frekvenci
026A: CLRF 15
.................... setup_timer_2(T2_DIV_BY_1,perioda,1); // perioda
026B: MOVLW 00
026C: MOVWF 78
026D: IORLW 04
026E: MOVWF 12
026F: MOVF 61,W
0270: BSF 03.5
0271: MOVWF 12
.................... set_pwm1_duty(DUTY2); // PWM pro zatizeni clanku pri jedne 500W zarovce
0272: MOVLW 13
0273: BCF 03.5
0274: MOVWF 15
....................
.................... pip(); // potvrzeni odstartovani / servisni mod
0275: GOTO 027
.................... delay_ms(500);
0276: MOVLW 02
0277: MOVWF 65
0278: MOVLW FA
0279: MOVWF 66
027A: CALL 004
027B: DECFSZ 65,F
027C: GOTO 278
....................
.................... // } while (input(SW1)); // Je zapnut servisni mod? SW1(OFF)=ANO
.................... // port_b_pullups(FALSE); // Vypni pullupy, aby se setrilo energii
....................
.................... // zmereni napeti na clancich
.................... output_high(REFPWR); // Prepni AD na mereni napeti clanku
027D: BSF 03.5
027E: BCF 06.1
027F: BCF 03.5
0280: BSF 06.1
.................... set_adc_channel(NAPETI); // Prepni Zmer napeti clanku
0281: MOVLW 20
0282: MOVWF 78
0283: MOVF 1F,W
0284: ANDLW C7
0285: IORWF 78,W
0286: MOVWF 1F
.................... delay_us(50); // Pockej na prepnuti kanalu A/D prevodniku
0287: CLRWDT
0288: MOVLW 0F
0289: MOVWF 77
028A: DECFSZ 77,F
028B: GOTO 28A
028C: NOP
.................... uclanku=read_adc();
028D: BSF 1F.2
028E: BTFSC 1F.2
028F: GOTO 28E
0290: MOVF 1E,W
0291: MOVWF 63
.................... output_low(REFPWR); // odpoj odpor pro mereni napeti
0292: BSF 03.5
0293: BCF 06.1
0294: BCF 03.5
0295: BCF 06.1
....................
.................... // posli telemetrii
.................... sprintf(AXstring,"p=%u r=%u u=%u", perioda, razeni, uclanku); // Convert DATA to String.
*
01B0: CLRF 5F
*
0296: MOVLW 37
0297: MOVWF 5F
0298: MOVLW 70
0299: MOVWF 67
029A: CALL 051
029B: MOVLW 3D
029C: MOVWF 67
029D: CALL 051
029E: MOVF 61,W
029F: MOVWF 65
02A0: MOVLW 1B
02A1: MOVWF 66
02A2: CALL 06E
02A3: MOVLW 20
02A4: MOVWF 67
02A5: CALL 051
02A6: MOVLW 72
02A7: MOVWF 67
02A8: CALL 051
02A9: MOVLW 3D
02AA: MOVWF 67
02AB: CALL 051
02AC: MOVF 62,W
02AD: MOVWF 65
02AE: MOVLW 1B
02AF: MOVWF 66
02B0: CALL 06E
02B1: MOVLW 20
02B2: MOVWF 67
02B3: CALL 051
02B4: MOVLW 75
02B5: MOVWF 67
02B6: CALL 051
02B7: MOVLW 3D
02B8: MOVWF 67
02B9: CALL 051
02BA: MOVF 63,W
02BB: MOVWF 65
02BC: MOVLW 1B
02BD: MOVWF 66
02BE: CALL 06E
.................... SendPacket(&AXstring[0]);
02BF: MOVLW 37
02C0: MOVWF 65
02C1: GOTO 133
....................
.................... delay_ms(14000); // Pockame do 14.5s
02C2: MOVLW 38
02C3: MOVWF 65
02C4: MOVLW FA
02C5: MOVWF 66
02C6: CALL 004
02C7: DECFSZ 65,F
02C8: GOTO 2C4
....................
.................... // rozjezd
.................... for( ble=1;ble<255;ble++)
02C9: MOVLW 01
02CA: MOVWF 64
02CB: INCFSZ 64,W
02CC: GOTO 2CE
02CD: GOTO 2EF
.................... {
.................... for(n=0;n<=razeni;n++)
02CE: CLRF 60
02CF: MOVF 60,W
02D0: SUBWF 62,W
02D1: BTFSS 03.0
02D2: GOTO 2ED
.................... {
.................... output_high(MOTOR);
02D3: BSF 03.5
02D4: BCF 06.2
02D5: BCF 03.5
02D6: BSF 06.2
.................... delay_us(ble);
02D7: MOVF 64,W
02D8: MOVWF 66
02D9: CALL 176
.................... delay_us(ble);
02DA: MOVF 64,W
02DB: MOVWF 66
02DC: CALL 176
.................... output_low(MOTOR);
02DD: BSF 03.5
02DE: BCF 06.2
02DF: BCF 03.5
02E0: BCF 06.2
.................... delay_us(255-ble);
02E1: MOVF 64,W
02E2: SUBLW FF
02E3: MOVWF 65
02E4: MOVWF 66
02E5: CALL 176
.................... delay_us(255-ble);
02E6: MOVF 64,W
02E7: SUBLW FF
02E8: MOVWF 65
02E9: MOVWF 66
02EA: CALL 176
.................... }
02EB: INCF 60,F
02EC: GOTO 2CF
.................... }
02ED: INCF 64,F
02EE: GOTO 2CB
....................
.................... // jedem co to da
.................... output_high(MOTOR);
02EF: BSF 03.5
02F0: BCF 06.2
02F1: BCF 03.5
02F2: BSF 06.2
....................
.................... delay_ms(1300); // Nemeli bysme jet dele nez 1,3s :-)
02F3: MOVLW 0A
02F4: MOVWF 65
02F5: MOVLW 82
02F6: MOVWF 66
02F7: CALL 004
02F8: DECFSZ 65,F
02F9: GOTO 2F5
.................... output_low(MOTOR); // Zastav motor
02FA: BSF 03.5
02FB: BCF 06.2
02FC: BCF 03.5
02FD: BCF 06.2
.................... // Menic je stale zapnut a zatezuje clanky
....................
.................... reset_cpu();
02FE: CLRF 0A
02FF: GOTO 000
.................... }
0300: SLEEP
 
Configuration Fuses:
Word 1: 2738 NOWDT NOPUT MCLR NOBROWNOUT NOLVP NOCPD NOWRT DEBUG CCPB3 NOPROTECT INTRC_IO
Word 2: 3FFC NOFCMEN NOIESO
/roboti/solarni/2006/scamnum/menic.PJT
0,0 → 1,56
[PROJECT]
Target=menic.HEX
Development_Mode=
Processor=0x688F
ToolSuite=CCS
 
[Directories]
Include=C:\Program Files\PICC\devices\
Library=
LinkerScript=
 
[Target Data]
FileList=D:\KAKL\roboti\solarni\2006\scamnum\menic.c
BuildTool=C-COMPILER
OptionString=+FM
AdditionalOptionString=
BuildRequired=1
 
[menic.c]
Type=4
Path=
FileList=
BuildTool=
OptionString=
AdditionalOptionString=
 
[mru-list]
1=menic.c
 
[Windows]
0=0000 menic.c 0 0 796 451 3 0
 
[Opened Files]
1=D:\KAKL\roboti\solarni\2006\scamnum\menic.c
2=D:\KAKL\roboti\solarni\2006\scamnum\menic.h
3=C:\Program Files\PICC\devices\16F88.h
4=D:\KAKL\roboti\solarni\2006\scamnum\AX25.c
5=
[debugperif]
selected=Analog/Digital Conv
[debugram]
autoread=1
[debugeedata]
autoread=1
[debugbreak]
count=0
[pcwdebug]
watchcol0=75
[debugwatch]
count=0
[debugexpr]
expr=
sideeffects=0
[Units]
Count=1
1=D:\KAKL\roboti\solarni\2006\scamnum\menic.c (main)
/roboti/solarni/2006/scamnum/menic.SYM
0,0 → 1,88
003 STATUS
015 CCP_1_LOW
015-016 CCP_1
016 CCP_1_HIGH
020-02F SendData
030.0 bit
031 fcslo
032 fcshi
033 stuff
034 flag_flag
035 fcs_flag
036 i
037-05E AXstring
05F @sprintf_string
060 main.n
061 main.perioda
062 main.razeni
063 main.uclanku
064 main.ble
065.0 pip.beep
065 @PRINTF_U_318.P1
065 SendPacket.data
065 main.@SCRATCH
066 @delay_us1.P1
066 @delay_ms1.P2
066 pip.i
066 @PRINTF_U_318.P1
066 SendPacket.@SCRATCH
066 main.@SCRATCH
067 SendByte.inbyte
067 @DIV88.P1
067 @SPRINTF.P2
068 SendByte.k
068 @DIV88.P1
069 SendByte.bt
069 @DIV88.@SCRATCH
06A fcsbit.tbyte
06A SendByte.@SCRATCH
06B fcsbit.@SCRATCH
06C fcsbit.@SCRATCH
077 @SCRATCH
078 @SCRATCH
078 _RETURN_
079 @SCRATCH
07A @SCRATCH
07B @SCRATCH
09C.6 C1OUT
09C.7 C2OUT
 
0004 @delay_ms1
0176 @delay_us1
00A3 flipout
0105 fcsbit
00AA SendBit
00EA SendByte
0133 SendPacket
0027 pip
001A cvak
0189 main
0051 @SPRINTF
0059 @DIV88
006E @PRINTF_U_318
0189 @cinit
 
Project Files:
D:\KAKL\roboti\solarni\2006\scamnum\menic.c
D:\KAKL\roboti\solarni\2006\scamnum\menic.h
C:\Program Files\PICC\devices\16F88.h
D:\KAKL\roboti\solarni\2006\scamnum\AX25.c
 
Units:
D:\KAKL\roboti\solarni\2006\scamnum\menic.c (main)
 
Compiler Settings:
Processor: PIC16F88
Pointer Size: 8
ADC Range: 0-255
Opt Level: 9
Short,Int,Long: 1,8,16
 
Output Files:
Errors: D:\KAKL\roboti\solarni\2006\scamnum\menic.err
INHX8: D:\KAKL\roboti\solarni\2006\scamnum\menic.hex
Symbols: D:\KAKL\roboti\solarni\2006\scamnum\menic.sym
List: D:\KAKL\roboti\solarni\2006\scamnum\menic.lst
Debug/COFF: D:\KAKL\roboti\solarni\2006\scamnum\menic.cof
Call Tree: D:\KAKL\roboti\solarni\2006\scamnum\menic.tre
Statistics: D:\KAKL\roboti\solarni\2006\scamnum\menic.sta
/roboti/solarni/2006/scamnum/menic.c
0,0 → 1,156
// *************************************
// * Scamnum Specularis ** 20. 9. 2006 *
// *************************************
 
#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 REFSTART 95 // Hodnota odpovidajici 1,2V pri nezatizenych clancich
#define DUTY1 2 // Delka sepnuti PWM v us pro sero
#define DUTY2 19 // Delka sepnuti PWM v us pro jednu zarovku 500W
 
// Tabulka hodnot prevodniku pro ruzna napajeci napeti
// 80 3,99V
// 90 3,54V
// 100 3,20V
// 105 3,04V
// 107 2,99V
// 110 2,91v
// 200 1,61V
 
#define PIEZO PIN_A6 // Jeden pol piezo reproduktoru
#define LED PIN_A7 // LED / druhy pol piezo reproduktoru
#define MENIC PIN_B3 // Spinani tranzistoru menice
#define REFPWR PIN_B1 // Napajeni zdroje referencniho napeti
#define MOTOR PIN_B2 // Spinani tranzistoru motoru
#define SW1 PIN_B6 // DIPswitch 1
#define SW2 PIN_B7 // DIPswitch 2
#define NAPETI 4 // Cislo kanalu DA prevodniku pro mereni napeti
#define PWM 0 // Cislo kanalu DA prevodniku pro nastaveni PWM
#define ROZJEZD 1 // Cislo kanalu DA prevodniku pro nastaveni rozjezdu
 
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;
int8 razeni;
int8 uclanku;
int8 ble;
 
setup_timer_0(RTCC_INTERNAL);setup_wdt(WDT_1152MS);
setup_timer_1(T1_DISABLED);
setup_adc_ports(ADC_CLOCK_INTERNAL|sAN0|sAN1|sAN4|VSS_VDD);
setup_adc(ADC_CLOCK_INTERNAL);
setup_spi(FALSE);
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(NAPETI); // Vyber AD kanal pro pomerne mereni napeti
set_pwm1_duty(0); // Spust PWM, ale zatim s trvalou 0 na vystupu
setup_ccp1(CCP_PWM);
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(DUTY1); // PWM pro zatizeni clanku pri malem osvetleni
n=0;
do
{
output_low(REFPWR); // Vypni napajeni napetove reference, aby se setrilo
delay_ms(100);
if (4==n++) {cvak(); n=0;}; // Kazdy 4. pruchod cvakni
output_high(REFPWR); // Zapni napajeni napetove reference
delay_ms(1); // Pockej na ustaleni napeti
} while (read_adc()>REFSTART); // Odkryl starter clanky?
output_low(REFPWR); // Vypni napajeni napetove reference, aby se setrilo
 
// port_b_pullups(TRUE); // Zapni pullupy, aby slo cist DIPswitch
// do
// {
// Precti trimry
set_adc_channel(PWM); // Zjisteni nastaveni PWM
delay_us(100); // Pockej na prepnuti kanalu A/D prevodniku
perioda=(read_adc()>>2)+40; // rozsah: 40 az 103
 
set_adc_channel(ROZJEZD); // Zjisteni nastaveni rozjezdu
delay_us(100); // Pockej na prepnuti kanalu A/D prevodniku
razeni=read_adc()>>4; // rozsah: 0 az 15
 
// Rozjeti menice
set_pwm1_duty(0); // Zastav PWM, aby slo nastavit jinou frekvenci
setup_timer_2(T2_DIV_BY_1,perioda,1); // perioda
set_pwm1_duty(DUTY2); // PWM pro zatizeni clanku pri jedne 500W zarovce
 
pip(); // potvrzeni odstartovani / servisni mod
delay_ms(500);
 
// } while (input(SW1)); // Je zapnut servisni mod? SW1(OFF)=ANO
// port_b_pullups(FALSE); // Vypni pullupy, aby se setrilo energii
 
// zmereni napeti na clancich
output_high(REFPWR); // Prepni AD na mereni napeti clanku
set_adc_channel(NAPETI); // Prepni Zmer napeti clanku
delay_us(50); // Pockej na prepnuti kanalu A/D prevodniku
uclanku=read_adc();
output_low(REFPWR); // odpoj odpor pro mereni napeti
 
// posli telemetrii
sprintf(AXstring,"p=%u r=%u u=%u", perioda, razeni, uclanku); // Convert DATA to String.
SendPacket(&AXstring[0]);
 
delay_ms(14000); // Pockame do 14.5s
 
// rozjezd
for( ble=1;ble<255;ble++)
{
for(n=0;n<=razeni;n++)
{
output_high(MOTOR);
delay_us(ble);
delay_us(ble);
output_low(MOTOR);
delay_us(255-ble);
delay_us(255-ble);
}
}
 
// jedem co to da
output_high(MOTOR);
 
delay_ms(1300); // Nemeli bysme jet dele nez 1,3s :-)
output_low(MOTOR); // Zastav motor
// Menic je stale zapnut a zatezuje clanky
 
reset_cpu();
}
/roboti/solarni/2006/scamnum/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/scamnum/menic.err
0,0 → 1,2
No Errors
0 Errors, 0 Warnings.
/roboti/solarni/2006/scamnum/menic.h
0,0 → 1,9
#include <16F88.h>
 
#device adc=8
 
#fuses NOWDT,INTRC_IO, NOPUT, MCLR, NOBROWNOUT, NOLVP, NOCPD, \
NOWRT, DEBUG, NOPROTECT, NOFCMEN, NOIESO, CCPB3
 
#use delay(clock=3900000,RESTART_WDT)
 
/roboti/solarni/2006/scamnum/menic.sta
0,0 → 1,40
 
ROM used: 769 (19%)
769 (19%) including unused fragments
 
1 Average locations per line
5 Average locations per statement
 
RAM used: 76 (43%) at main() level
82 (47%) worst case
 
Lines Stmts % Files
----- ----- --- -----
157 75 53 D:\KAKL\roboti\solarni\2006\scamnum\menic.c
10 0 0 D:\KAKL\roboti\solarni\2006\scamnum\menic.h
279 0 0 C:\Program Files\PICC\devices\16F88.h
140 67 31 D:\KAKL\roboti\solarni\2006\scamnum\AX25.c
----- -----
1172 284 Total
 
Page ROM % RAM Functions:
---- --- --- --- ----------
0 22 3 1 @delay_ms1
0 19 2 1 @delay_us1
0 7 1 0 flipout
0 64 8 0 SendBit
0 73 9 4 SendByte
0 67 9 2 SendPacket
0 42 5 2 pip
0 13 2 0 cvak
0 376 49 7 main
0 8 1 1 @SPRINTF
0 21 3 3 @DIV88
0 53 7 2 @PRINTF_U_318
 
Segment Used Free
--------- ---- ----
00000-00003 4 0
00004-007FF 765 1279
00800-00FFF 0 2048
 
/roboti/solarni/2006/scamnum/menic.tre
0,0 → 1,77
ÀÄmenic
ÀÄmain 0/376 Ram=7
ÃÄ??0??
ÃÄ@delay_ms1 0/22 Ram=1
ÃÄcvak 0/13 Ram=0
ÃÄ@delay_ms1 0/22 Ram=1
ÃÄpip 0/42 Ram=2
ÃÄ@delay_ms1 0/22 Ram=1
ÃÄ@SPRINTF 0/8 Ram=1
ÃÄ@SPRINTF 0/8 Ram=1
ÃÄ@PRINTF_U_318 0/53 Ram=2
³ ÃÄ@DIV88 0/21 Ram=3
³ ÃÄ@SPRINTF 0/8 Ram=1
³ ÃÄ@DIV88 0/21 Ram=3
³ ÃÄ@SPRINTF 0/8 Ram=1
³ ÀÄ@SPRINTF 0/8 Ram=1
ÃÄ@SPRINTF 0/8 Ram=1
ÃÄ@SPRINTF 0/8 Ram=1
ÃÄ@SPRINTF 0/8 Ram=1
ÃÄ@PRINTF_U_318 0/53 Ram=2
³ ÃÄ@DIV88 0/21 Ram=3
³ ÃÄ@SPRINTF 0/8 Ram=1
³ ÃÄ@DIV88 0/21 Ram=3
³ ÃÄ@SPRINTF 0/8 Ram=1
³ ÀÄ@SPRINTF 0/8 Ram=1
ÃÄ@SPRINTF 0/8 Ram=1
ÃÄ@SPRINTF 0/8 Ram=1
ÃÄ@SPRINTF 0/8 Ram=1
ÃÄ@PRINTF_U_318 0/53 Ram=2
³ ÃÄ@DIV88 0/21 Ram=3
³ ÃÄ@SPRINTF 0/8 Ram=1
³ ÃÄ@DIV88 0/21 Ram=3
³ ÃÄ@SPRINTF 0/8 Ram=1
³ ÀÄ@SPRINTF 0/8 Ram=1
ÃÄSendPacket 0/67 Ram=2
³ ÃÄSendByte 0/73 Ram=4
³ ³ ÃÄfcsbit (Inline) Ram=3
³ ³ ÃÄflipout 0/7 Ram=0
³ ³ ÃÄSendBit 0/64 Ram=0
³ ³ ÃÄflipout 0/7 Ram=0
³ ³ ÀÄSendBit 0/64 Ram=0
³ ÃÄSendByte 0/73 Ram=4
³ ³ ÃÄfcsbit (Inline) Ram=3
³ ³ ÃÄflipout 0/7 Ram=0
³ ³ ÃÄSendBit 0/64 Ram=0
³ ³ ÃÄflipout 0/7 Ram=0
³ ³ ÀÄSendBit 0/64 Ram=0
³ ÃÄSendByte 0/73 Ram=4
³ ³ ÃÄfcsbit (Inline) Ram=3
³ ³ ÃÄflipout 0/7 Ram=0
³ ³ ÃÄSendBit 0/64 Ram=0
³ ³ ÃÄflipout 0/7 Ram=0
³ ³ ÀÄSendBit 0/64 Ram=0
³ ÃÄSendByte 0/73 Ram=4
³ ³ ÃÄfcsbit (Inline) Ram=3
³ ³ ÃÄflipout 0/7 Ram=0
³ ³ ÃÄSendBit 0/64 Ram=0
³ ³ ÃÄflipout 0/7 Ram=0
³ ³ ÀÄSendBit 0/64 Ram=0
³ ÃÄSendByte 0/73 Ram=4
³ ³ ÃÄfcsbit (Inline) Ram=3
³ ³ ÃÄflipout 0/7 Ram=0
³ ³ ÃÄSendBit 0/64 Ram=0
³ ³ ÃÄflipout 0/7 Ram=0
³ ³ ÀÄSendBit 0/64 Ram=0
³ ÀÄSendByte 0/73 Ram=4
³ ÃÄfcsbit (Inline) Ram=3
³ ÃÄflipout 0/7 Ram=0
³ ÃÄSendBit 0/64 Ram=0
³ ÃÄflipout 0/7 Ram=0
³ ÀÄSendBit 0/64 Ram=0
ÃÄ@delay_ms1 0/22 Ram=1
ÃÄ@delay_us1 0/19 Ram=1
ÃÄ@delay_us1 0/19 Ram=1
ÃÄ@delay_us1 0/19 Ram=1
ÃÄ@delay_us1 0/19 Ram=1
ÀÄ@delay_ms1 0/22 Ram=1