Elektroda.pl
Elektroda.pl
X
Proszę, dodaj wyjątek www.elektroda.pl do Adblock.
Dzięki temu, że oglądasz reklamy, wspierasz portal i użytkowników.

Zmiana danych w programie [pic12F675]

kamil_Ziomek 05 Lut 2010 19:09 1113 0
  • #1 05 Lut 2010 19:09
    kamil_Ziomek
    Poziom 19  

    Znalazłem w internecie stronę z modułem zapłonowym na procesorze pic12f675 ( adres http://www.sportdevices.com/ignition/ignition.htm ) Chciałbym wykonać zapłon w wersji TCI (dla silnika 2T). Na stronie można pobrać program który wylicza dane dla programu i kod źródłowy C i ams. Problem polega na tym że nie wiem jak zmienić dane w kodach źródłowych. Wyliczenia z programu to

    Code:
    #define prescaler   9
    
    #define delay_multiple   18
    #define high_rpm_multiple   3
    #define low_rpm_multiple   95
    #define scr_pulse   200
    #define silent_time   1000
    #define min_rpm   500
    #define min_period   16
    #define ignition_cut_off   0
    const byte ignition0[218]={
    61,64,68,72,76,80,83,87,91,95,99,102,106,110,114,118,121,125,129,133,137,140,144,148,152,156,159,163,167,
    171,174,178,182,186,190,193,197,201,205,209,212,216,220,224,228,231,235,239,243,247,250,254,258,262,265,269,273,277,281,
    284,288,292,296,300,303,307,311,315,319,322,326,330,334,337,341,345,349,353,356,360,364,368,372,375,379,383,387,391,394,
    398,402,406,410,413,417,421,425,429,432,436,440,444,449,455,460,466,471,477,483,489,495,500,506,512,518,523,529,534,540,
    546,551,558,563,569,574,580,586,592,597,603,608,614,620,626,631,637,642,648,654,660,665,671,676,682,689,694,700,705,710,
    717,722,727,733,740,745,751,757,763,768,773,779,785,791,796,802,808,813,819,824,831,836,841,848,853,858,864,871,876,882,
    887,893,898,904,910,915,921,927,933,939,943,949,956,962,966,973,979,983,990,994,1001,1006,1012,1017,1024,1029,1036,1040,1045,1052,
    1057,1062,1070,1075,1080,1085,1093,1098,1103,1108};

    Trochę dużo liczb wyszło (jeżeli ktoś pomoże to może uda się skrócić tą listę) ale nie wiem czy to przeszkadza.
    Tutaj trochę uporządkowany kod źródłowy c :
    Code:
     //***************************************************************************
    
    //******
    //****** PIC12F675. TCI ignition
    //******
    //****** SPORTDEVICES 3/3/2008
    //******
    //****** Tested on Kymco MXU250 ATV
    //******
    //****************************************************************************
    #include <12F675.H>
    #fuses HS,NOWDT,PUT,NOMCLR
    #use fast_io(a)
    #use delay(clock=10000000) //setup values
    #define prescaler 8 //2^8=256
    #define silent_time 500 //silent time after spark to avoid false triggers
    #define rpm_cte (60*10000000/4/256)
    #define cut_off rpm_cte / 9000
    #define ralenti rpm_cte / 2000
    #define max_period rpm_cte / 200
    #define dwell_constant 10000000/4/256 * 0.005 //5 ms const byte ignition0[52]={ //9000 rpm //20,21,22,23,24,25,26,27 5,5,5,6,6,6,6,6 //8000 rpm //28,29,33,38,44,50,55,60,65,70 9,9,11,12,12,15,20,25,30,32 //7000 rpm //69,74,77,80,81,82,83,84,85,86,87,89,91,93 34,37,38,40,50,61,83,84,85,86,87,89,91,93 //6000 rpm 97,100,103,107,113,119,124,131,137,140,145,150,157,160,165,170,175,176,177,178 //5000 rpm };
    #define pickup_hi PIN_A3 //pin 4
    #define pickup_lo PIN_A2 //pin 5
    #define coil PIN_A1 //pin 6
    #byte TMR0=0x01
    #byte STATUS=0x03
    #byte PORTB=0x06
    #byte INTCON=0x0b
    #byte OPTION_REG=0x81
    #byte CMCON=0x19
    #byte ANSEL=0x9f int tmr0h=0,del; int16 dwell,per; boolean low_rpm=true,hi_rpm=false;
    #byte W_TEMP=0x7f int STATUS_TEMP;
    #int_ext void ext() { //low pulse //if(low_rpm) output_low(coil); //fire or turn off the coil }
    #int_timer0 void timer0() { tmr0h++; if(tmr0h>2) low_rpm=true; if(tmr0h>(max_period/256)) output_low(coil); //turn off the coil (residual spark will be made) } void wait_pulse() { int16 tmp; while (input(pickup_hi)); //wait line goes low //wait dwell if(!low_rpm && !hi_rpm) { do tmp=make16(tmr0h,TMR0); while((tmpralenti) per=per<<1;
    #asm incf &per+1,f incf &per,f bucle2:
    #endasm delay_cycles(9);
    #asm decfsz &per,f goto bucle2 decfsz &per+1,f goto bucle2
    #endasm } } if(!low_rpm) output_low(coil); //fire or turn off the coil dwell-=dwell_constant; delay_us(silent_time); //time after spark to avoid false triggers } //while } //main

    0 0