/Designs/Measuring_instruments/GM_counter/SW/HV_source/main.c
1,40 → 1,49
#include ".\main.h"
//#include <LCD.C>
 
#define LED1 PIN_C6 //CHANGE PIN_XX TO YOUR LED PIN NUMBER, EX: PIN_A5
#define LED2 PIN_C5 //CHANGE PIN_XX TO YOUR LED PIN NUMBER, EX: PIN_A5
#define LED3 PIN_C4 //CHANGE PIN_XX TO YOUR LED PIN NUMBER, EX: PIN_A5
#define LED4 PIN_D3 //CHANGE PIN_XX TO YOUR LED PIN NUMBER, EX: PIN_A5
#define LED3 PIN_C4 //CHANGE PIN_XX TO YOUR LED PIN NUMBER
#define LED4 PIN_D3 //CHANGE PIN_XX TO YOUR LED PIN NUMBER
 
#define S1 PIN_B0 //CHANGE PIN_XX TO YOUR LED PIN NUMBER, EX: PIN_A5
#define S2 PIN_B1 //CHANGE PIN_XX TO YOUR LED PIN NUMBER, EX: PIN_A5
#define S3 PIN_D0 //CHANGE PIN_XX TO YOUR LED PIN NUMBER
#define S4 PIN_D1 //CHANGE PIN_XX TO YOUR LED PIN NUMBER
 
#int_EXT
void EXT_isr(void)
#define BEEP PIN_D2 //piezo beeper
 
#define LCD_ENABLE_PIN PIN_E0 ////
#define LCD_RS_PIN PIN_E1 ////
#define LCD_RW_PIN PIN_E2 ////
#define LCD_DATA4 PIN_D4 ////
#define LCD_DATA5 PIN_D5 ////
#define LCD_DATA6 PIN_D6 ////
#define LCD_DATA7 PIN_D7
#include <lcd.c>
 
void sound_beep( unsigned int lenght, int16 frequency)
{
output_toggle(LED3);
unsigned int i;
for(i=0;i<=lenght;i++)
{
output_toggle(BEEP);
delay_us(1/frequency);
}
}
 
//#define LCD_TYPE 1
//#include <lcd.c>
void main()
{
unsigned int setpoint;
unsigned int napeti;
unsigned int16 setpoint;
unsigned int16 napeti;
unsigned int16 plneni=0;
unsigned int1 button_press; // semafor pro cteni tlacitek
 
/* lcd_init();
lcd_init();
 
lcd_putc("\fReady...\n");
lcd_putc("\fHVPS01A 2013 MLAB\n");
Delay_ms(1000);
 
while (TRUE) {
k=kbd_getc();
if(k!=0)
if(k=='*')
lcd_putc('\f');
else
lcd_putc(k);
}
*/
 
setup_adc_ports(sAN0|VSS_VDD);
setup_adc(ADC_CLOCK_DIV_32);
setup_spi(SPI_SS_DISABLED);
55,19 → 64,19
output_high(LED3);
output_high(LED4);
 
ext_int_edge( L_TO_H ); // Sets up EXT
enable_interrupts(INT_EXT);
enable_interrupts(GLOBAL);
 
// lcd_init();
// ext_int_edge( L_TO_H ); // Sets up EXT
// enable_interrupts(INT_EXT);
// enable_interrupts(GLOBAL);
setpoint = 43;
lcd_putc("\f");
while(true)
{
set_adc_channel(1);
delay_us(100);
napeti = read_adc();
napeti = (napeti+read_adc())/2;
 
if (napeti <= setpoint)
{
79,10 → 88,64
if (plneni > 0) plneni--;
output_high(LED2);
}
set_pwm1_duty(plneni);
set_pwm2_duty(1023-plneni);
lcd_gotoxy(1,1);
printf(lcd_putc,"Actual: %lu V ",napeti);
lcd_gotoxy(1,2);
printf(lcd_putc,"Set: %lu V ",setpoint);
 
set_pwm1_duty(plneni);
set_pwm2_duty(1023-plneni);
 
if(button_press==false ) // tlacitka se ctou znovu pouze pokud v redchozim cyklu nebyla zmacknuta.
{
if(!input(S1))
{
delay_ms(20);
if(!input(S1))
{
button_press=true;
sound_beep(100,700);
if(setpoint < 0xfa )setpoint+=5;
}
}
 
if(!input(S2))
{
delay_ms(20);
if(!input(S2))
{
button_press=true;
sound_beep(100,600);
if(setpoint > 0x05 ) setpoint-=5;
}
}
 
if(!input(S3))
{
delay_ms(20);
if(!input(S3))
{
button_press=true;
sound_beep(100,500);
if(setpoint < 0xff )setpoint++;
}
}
 
if(!input(S4))
{
delay_ms(20);
if(!input(S4))
{
button_press=true;
sound_beep(100,400);
if(setpoint > 0x00 ) setpoint--;
}
}
}
if ( input(S1) && input(S2) && input(S3) && input(S4) ) button_press=false;
 
output_toggle(LED1);
delay_ms(10);
}
/Designs/Measuring_instruments/GM_counter/SW/HV_source/main.hex
1,48 → 1,157
:1000000000308A0050280000FF00030E8301A10089
:100010000A08A0008A010408A2007708A300780853
:10002000A4007908A5007A08A600831383120B1E8A
:100030001B288B182C28220884002308F70024088A
:10004000F8002508F9002608FA0020088A00210E89
:100050008300FF0E7F0E09008A110A122F28271233
:100060002708831687001030831287068B108A11A9
:100070000A121B282C3084008313000803194D2812
:100080000230F800F701F70B4328F80B42289730AD
:10009000F700F70B4928800B40288A110A125929CA
:1000A000840183131F308305713083168F000F087E
:1000B000061383120617831603170908C03989002F
:1000C00003131F129F120030031788008312870149
:1000D00088018901FF300313A700AB01AA01831631
:1000E00003170908C039890003131F129F1201303A
:1000F00003178800831203131F139F1783169F177C
:1001000083121F149412A7122708831687008312E4
:1001100027162708831687008312A711270883163E
:100120008700013083129400003083169400010888
:10013000C73928388100831290010030F800043854
:100140009200FF308316920083122711270883162E
:10015000870083120711831609130C30831297004E
:1001600083169B019C0101309D008312A710270874
:1001700083168700831287100C309D0001308000A9
:1001800003178701880189017130831603138F00DB
:100190000F08831295019B012713270883168700F8
:1001A00083120717A7122708831687008312871662
:1001B00027122708831687008312071683168811D3
:1001C000831288158316011783120B16C0308B0417
:1001D0002B30A8000430F8001F08C33978049F00B2
:1001E0004230F700F70BF22800009F149F18F62802
:1001F00083161E088312A90029082802031C14294B
:100200002B08013C031C0D29031D0A292A082B3C3D
:10021000031C0D29AA0A0319AB0AA7122708831683
:100220008700831287122429AA08031D1A29AB0804
:1002300003191E292A080319AB03AA03A7122708CA
:1002400083168700831287162B08F9002A08F80006
:10025000F90CF80CF90CF80CF90C78089500F90C6D
:10026000790C3039F7001708CF39770497002A083E
:10027000FF3CAC000330AD002B08031C2B0FAD027C
:10028000AD0CAC0CAD0CAC0CAD0C2C089B00AD0C4B
:100290002D0C3039F7001D08CF3977049D00271346
:1002A0002708831687004030831287060A30AC0087
:0602B0003A28EA28630071
:1000000002308A00C12A00000A108A100A118207F1
:1000100028340C34013406340C2456285318B120EB
:100020002019B01833104D2641210A000C00C131AF
:10003000F43A61363A10253675105610201020001B
:10004000D332741D20102010253675105610201044
:100050002000323084008313000803193C2802304A
:10006000F800F701F70B3228F80B31289730F7002A
:10007000F70B3828800B2F28080039184128081260
:1000800042280816831608128312B91849288812C4
:100090004A288816831688128312391951280813A2
:1000A00052280817831608138312B9195928881380
:1000B0005A288817831688130000831209148316A0
:1000C000091062286328831209108316091083120D
:1000D0000800BA018316081600308312081A01308E
:1000E000BA048316881600308312881A0130F7008C
:1000F0000310F70D7708BA0483160817003083122F
:10010000081B0130F700F70DF70DFC30F7057708F5
:10011000BA048316881700308312881B0130F70059
:10012000F70DF70DF70DF830F7057708BA043A0820
:10013000F80008008316091089100911831289102C
:100140008316891008168816081788178312091550
:100150008316091100008312091483160910000088
:10016000831269207808B90009108316091000006D
:100170008312091483160910BD2883126920780898
:10018000B800091083160910081288120813881382
:100190008312390EF700F030F70577083804F800BD
:1001A0007808B800B81FD6288316A228B608031D01
:1001B000DB288910DC28891483168910000083123B
:1001C0000911831609110000831209108316091002
:1001D0008312370EB8000F30B8053808B9003D203B
:1001E00037080F39B800B9003D20080083160812FF
:1001F00088120813881309108910091183128910B5
:1002000083168910831209118316091183120910AC
:10021000831609100F308312B20029200130A80084
:100220002808033C031C1C290330B9003D2005307D
:10023000B2002920A80A10290230B9003D20A801E7
:100240002808033C031C2D2928080420A900B60116
:100250002908B7009A20A80A20298A110A12E12A3F
:10026000330B332936294030B4003729B40101302B
:100270003202B40734088038B500B6013508B7003B
:100280009A2008003108073A031950290B3A03193C
:100290005529063A03195D29023A03196329682989
:1002A0000130B200B30030216E29B6010130B70031
:1002B0009A200230B20029206E290130B2000230AB
:1002C000B30030216E29B6011030B7009A206E2994
:1002D0000130B6003108B7009A206E290800831655
:1002E00003178C170C140000000083120C087F39D0
:1002F0000319B3290313A80003170D080313A9005A
:1003000003170F080313AA002808B1004221290887
:1003100003178D0003132A0803178F0083168C1709
:100320000C140000000083120C0D0E0D7F39031910
:10033000B3290313A80003170D080313A90003171B
:100340000F080313AA002808B10042212908031747
:100350008D0003132A0803178F008D0A03198F0AD3
:1003600003136F29031703130800831603178C1751
:100370000C14000000000318E42983120C087F39D4
:100380000313A90003170D080313AA0003170F088E
:100390000313AB002908B10042212A0803178D007E
:1003A00003132B0803178F0083168C170C140000FF
:1003B000000083120313A80BDE29E129831603171B
:1003C000E429032A8316031783120C0D0E0D7F39BF
:1003D0000313A90003170D080313AA0003170F083E
:1003E0000313AB002908B10042212A0803178D002E
:1003F00003132B0803178F008D0A03198F0A0310AC
:100400000313A80BB5290800B0010408AF00301091
:10041000831B3014290EF038AB00AB07E23EAC0072
:10042000323EAE0029080F39AC07AC07AE07E93EF3
:10043000AD00AD07AD07280E0F39AD07AE07AD0D06
:10044000AE0DAE09AE0D28080F39AE07AB0D073063
:10045000AA000A30AE07AD03031C2A2AAD07AC037D
:10046000031C2E2AAC07AB03031C322AAB07AA03DA
:10047000031C362A2A308400831307302F052F13DC
:1004800084072E30040203192F170008F700031DFC
:10049000512A2F1B512A2F1A632AAF19512A2030B3
:1004A000542AAF152F123030F707A9010408A8000D
:1004B0002910831B29147708B100422128088400E1
:1004C000831329188317840A2F1F412A0800083034
:1004D000AF02031C772A2F30840083130310800C93
:1004E00000080319772A752A0000800B742A080077
:1004F000AB012B082802031CC02A83160811043004
:1005000083128806AD010130AC002A08AF0029082B
:10051000AE00F801F901F701FA012F08031D932A33
:100520002E080319AD2A1030B0000310AC0DAD0D2C
:10053000F70DFA0D2F087A02031DA02A2E08770264
:10054000031CA92A2E08F702031CFA032F08FA023B
:100550000314F80DF90DB00B952A7908AD00780851
:10056000AC002D08AE00AE0AAE030319BB2AFF3063
:10057000AF006722B42A2C08AF006722AB0A792AA1
:100580000800840183131F308305713083168F00A8
:100590000F08061383120617831603170908C039BC
:1005A000890003131F129F12003003178800831263
:1005B000870188018901FF300313A000A601A5016E
:1005C000F6280C3003178D0000308F0003136F21C5
:1005D0000430A800FA30B2002920A80BEA2A8316BA
:1005E00003170908C039890003131F129F12013035
:1005F00003178800831203131F139F1783169F1777
:1006000083121F149412A0122008831687008312ED
:1006100020162008831687008312A0112008831655
:100620008700013083129400003083169400010883
:10063000C73928388100831290010030F80004384F
:100640009200FF3083169200831220112008831637
:10065000870083120711831609130C308312970049
:1006600083169B019C0101309D008312A01020087D
:1006700083168700831287100C309D0001308000A4
:1006800003178701880189017130831603138F00D6
:100690000F08831295019B01201320088316870001
:1006A00083120717A012200883168700831287166B
:1006B00020122008831687008312071683168811DC
:1006C00083128815A2012B30A100163003178D006C
:1006D00000308F0003136F210430F8001F08C33966
:1006E00078049F004230F700F70B742B00009F1432
:1006F0009F18782B83161E0883122307A80024084E
:10070000A9001E0803181E0FA9070310290CA40036
:10071000280CA30024082202031CA82B031D942BE1
:1007200023082102031CA82B2608013C031CA12B33
:10073000031D9E2B25082B3C031CA12BA50A031986
:10074000A60AA01220088316870083128712B82BEE
:10075000A508031DAE2BA6080319B22B2508031903
:10076000A603A503A012200883168700831287160C
:100770002608F9002508F800F90CF80CF90CF80C1B
:10078000F90C78089500F90C790C3039F700170846
:10079000CF39770497002508FF3CA8000330A90053
:1007A0002608031C260FA902A90CA80CA90CA80C4A
:1007B000A90C28089B00A90C290C3039F7001D084A
:1007C000CF3977049D000130B200B30030211730DB
:1007D00003178D0000308F00031008300313A800AA
:1007E000B521103084002408A9002308A8000422A1
:1007F0001C3003178D0000308F00031406300313E4
:10080000A800B5210130B2000230B3003021203001
:1008100003178D0000308F00031008300313A80069
:10082000B521103084002208A9002108A800042264
:10083000253003178D0000308F000314063003139A
:10084000A800B5212718A42C8316061483120618B5
:10085000442C1430B2002920831606148312061883
:10086000442C27146430A8000230AA00BC30A90030
:100870007822A208031D442C2108F93C031C442CB7
:100880000530A1070318A20A83168614831286185E
:10089000662C1430B2002920831686148312861821
:1008A000662C27146430A8000230AA005830A90032
:1008B0007822A208031D602C2108053C0318662C31
:1008C0000530A1020030031C0130A2028316081477
:1008D00083120818852C1430B200292083160814BE
:1008E00083120818852C27146430A8000130AA0050
:1008F000F430A9007822A208031D852C2108FE3CB3
:10090000031C852CA10A0319A20A831688148312DA
:100910008818A42C1430B20029208316881483125E
:100920008818A42C27146430A8000130AA00903045
:10093000A9007822A108031DA02CA2080319A42C49
:1009400021080319A203A103831606148312061CAF
:10095000B82C831686148312861CB82C83160814B0
:100960008312081CB82C8316881483128818271049
:1009700020132008831687004030831287060A3030
:08098000B20029206C2B63007A
:04400E00F52CFF3F4F
:00000001FF
;PIC16F887
;CRC=C04F CREATED="09-II-13 19:58"
;CRC=6BFD CREATED="10-II-13 00:22"
/Designs/Measuring_instruments/GM_counter/SW/HV_source/main.pjt
17,11 → 17,13
0=0000 %S 0 0 796 451 3 0
[Opened Files]
1=main.c
2=
3=
2=main.h
3=C:\Program Files\PICC\devices\16F887.h
4=C:\Program Files\PICC\drivers\lcd.c
5=
[Target Data]
OptionString=-p +FM
FileList=D:\MLAB\Designs\Measuring_instruments\GM_counter\SW\main.c
FileList=D:\MLAB\Designs\Measuring_instruments\GM_counter\SW\HV_source\main.c
[Units]
Count=1
1=main (main)
/Designs/Thermometer/SW/PIC16F887/main.pjt
17,7 → 17,7
0=0000 %S 0 0 796 451 3 0
[Opened Files]
1=main.c
2=main.h
2=
3=C:\Program Files\PICC\devices\16F887.h
4=C:\Program Files\PICC\drivers\lcd.c
5=..\ds1820.c