Hello all!
Here is the code , that I write in parts for verification. Code is not complete. The problem is with writing in eeprom. If an instruction is written - epwrite or epread, not whichever variable is being written, then the LCD display does not want to work. The running display, which is before the main, can shows it, but after then it 1 time flashes and stands dark. I have added bookmarks to the epwrite and epread instructions. But without instructions epwrite or epread, it works. <========
#chip 16F886, 4#config osc=int#define LCD_IO 8#define LCD_RS Portc.5#define LCD_Enable Portc.7#define LCD_RW Portc.6#define LCD_DATA_PORT PortBdirPortc.5outdirPortc.6outdirPortc.7outdirPortBoutcls''#include <maths.h>''+++++DIGITALINPUTS&OUTPUTS#define button_menu porta.1 '' button - SETTINGS DISPLAYS SCHROLLdirporta.1in#define button_up_down_reset porta.0 '' button + , - , resetdirporta.0in#define RUN porta.2 '' run signal from chains drivedirporta.2in#define FAULT portc.2 '' fault relaysdirportc.2out#define LED portc.3 '' LEDdirportc.3out#define sensor_1 porta.4dirporta.4in#define sensor_2 portc.0dirportc.0insetLEDon''---------------------------------------reklamalocate0,0print"WATCHDOG 2017 "wait1s'Scroll display one character right (all lines) lcdcmd 28repeat14lcdcmd28wait100msendrepeatsetLEDoff'Scroll display one character left (all lines) lcdcmd 24''repeat32''lcdcmd24''wait40ms''endrepeatlcdcmd2clsinittimer2PS2_16,0''(8bittimer)full=0sec=0min=0hours=0''sec_detect=0inittimer1Osc,PS1_1cleartimer1sec_disp=0min_disp=0''================pushtime_1=0now1=0prev1=0aa=0pushtime_2=0now2=0prev2=0bb=1now3=0prev3=0now_run=0prev_run=0now2_run=0prev2_run=0now_sens_all=0prev_sens_all=0now_sens1=0prev_sens1=0now_sens2=0prev_sens2=0now_sens3=0prev_sens3=0now_sens4=0prev_sens4=0now2_sens1=0prev2_sens1=0now2_sens2=0prev2_sens2=0now2_sens3=0prev2_sens3=0now2_sens4=0prev2_sens4=0bit_sens1=0bit_sens2=0bit_sens3=0bit_sens4=0bit_sens_all=0''milisekundesmilisec1=0milisec2=0milisec3=0milisec4=0diff_sens1=0diff_sens2=0diff_sens3=0diff_sens4=0ind_time=0ind_time2=0no_pulse_flt=0diff_flt=0epread1,diff_sens1''<================================main:starttimer2''=====================================if!button_menuthen''pogasnospiesanaslaikaieturepushtime_1++sec_disp=0''nometdisplejaparleksanaslaikuuz0min_disp=0elsepushtime_1=0endifnow1=!button_menu&pushtime_1=>50ifnow1>prev1thenpushtime_1=0aa++''beeper=onclsendifprev1=now1''DISPLAYCASESselectcaseaacase0MAIN_dispcase1''test_cyctime''case2set_cyctimecase3test_difftime''''case4''set_difftimecase5''aa=0endselectnow_run=!RUNifnow_run>prev_runthenclssec=0min=0hours=0endifprev_run=now_run''====================if!RUNthen''sensor_1HIGHLEVELFRONT(risingedge)now_sens1=!sensor_1ifnow_sens1>prev_sens1Thenclsbit_sens1=1milisec1=0diff_sens1=0endifprev_sens1=now_sens1'sensor_1 LOW LEVEL FRONT (falling edge)now2_sens1=sensor_1ifnow2_sens1>prev2_sens1Thenclsdiff_sens1=milisec1epwrite1,diff_sens1''<============================================bit_sens1=0milisec1=0''jabutpecdiff_sens1=milisec1endifprev2_sens1=now2_sens1''+++++++++++++++++++++++++++++++' sensor_2 HIGH LEVEL FRONT (rising edge_)now_sens2=!sensor_2ifnow_sens2>prev_sens2Thenclsbit_sens2=1milisec2=0diff_sens2=0endifprev_sens2=now_sens2'sensor_2 LOW LEVEL FRONT (falling edge)now2_sens2=sensor_2ifnow2_sens2>prev2_sens2Thenclsdiff_sens2=milisec2''ierakstamilisekundesmainigajatest_diff_sens2bit_sens2=0milisec2=0''jabutpecdiff_sens2=milisec2endifprev2_sens2=now2_sens2''+++++++++++++++++++++++++++++++++endififmin_disp=>5Then''&!RUNclsaa=0endifendif''==============================================================================wait10msgotomain''CLOCK(Timer2)subInterruptTMR2IF=0full++iffull=244thensec_disp++if!RUNthensec++endifendififsec_disp>59thensec_disp=0min_disp++endififsec>59thenmin++sec=0endififmin_disp>59Thenmin_disp=0ifmin>59thenhours++min=0endififhours>99thenhours=0'''===========STATUS LED (1sec tact)''if full<50 then''set LED on''Else''set LED off''end ifend sub'''=============milisecclock(Timer0)submilisec_timerif!RUNthenmilisec1++milisec2++milisec3++milisec4++endififmilisec1++=>9999thenmilisec1++=0ifmilisec2++=>9999thenmilisec2++=0ifmilisec3++=>9999thenmilisec3++=0ifmilisec4++=>9999thenmilisec4++=0endsub''=====================subMAIN_disp''(aa=0)locate0,0print"RUNTIME="ifhours<10thenlocate0,8print"0"locate0,9printhoursElselocate0,8printhoursendiflocate0,10print":"ifmin<10Thenlocate0,11print"0"locate0,12printminelselocate0,11printminendiflocate0,13print":"ifsec<10Thenlocate0,14print"0"locate0,15printsecElselocate0,14printsecendif''===========================endsubsubtest_cyctime''(aa=1)endsubsubtest_difftime''(aa=3)print"dif1="locate0,10print"2="locate1,0print"3="locate1,7print"4="ifbit_sens1Thenlocate0,5printmilisec1' "RUN"Elselocate0,5printdiff_sens1endif''=====================ifbit_sens2Thenlocate0,12printmilisec2' "RUN"Elselocate0,12printdiff_sens2endif''=====================ifbit_sens3Thenlocate1,2printmilisec3' "RUN"Elselocate1,2printdiff_sens3endif''====================ifbit_sens4Thenlocate1,2printmilisec4' "RUN"Elselocate1,9printdiff_sens4endifendsub
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The code above does not pass a simple syntax check so will be difficult to test. You have not declared any variables with "DIM" and your use of interrupt sub is incorrect. You are also incorrectly using bit tests and have bad code elsewhere.
Example : This will never work: == > if milisec1++ =>9999 then milisec1++=0 '
Please tell us what the code is supposed to do. You have 2 clock routines. Why?
Do you need to count both seconds and mlliseconds ?
If you are constantly interrupting the processor 244 times per second or 1000 times per second , how is the display supposed to operate?
So explain the application. Why do you need timer0, timer1 and timer2 . What is each timer supposed to do?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
My comments will only help in his future post.
1) Structure the code with indents to clarify, paticulary loops
2) Add lots of comments so we know what each instruction was meant to be doing.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I apologize for the late reply. I found the code problem. I will only use one timer. So far, I'm in the process of development, Iwork with code & schema & idea. After that, I'll publish both the code and the code that works.Thanks !!!!!!!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello all!
Here is the code , that I write in parts for verification. Code is not complete. The problem is with writing in eeprom. If an instruction is written - epwrite or epread, not whichever variable is being written, then the LCD display does not want to work. The running display, which is before the main, can shows it, but after then it 1 time flashes and stands dark. I have added bookmarks to the epwrite and epread instructions. But without instructions epwrite or epread, it works. <========
@Janis
The code above does not pass a simple syntax check so will be difficult to test. You have not declared any variables with "DIM" and your use of interrupt sub is incorrect. You are also incorrectly using bit tests and have bad code elsewhere.
Example : This will never work: == > if milisec1++ =>9999 then milisec1++=0 '
Please tell us what the code is supposed to do. You have 2 clock routines. Why?
Do you need to count both seconds and mlliseconds ?
If you are constantly interrupting the processor 244 times per second or 1000 times per second , how is the display supposed to operate?
So explain the application. Why do you need timer0, timer1 and timer2 . What is each timer supposed to do?
My comments will only help in his future post.
1) Structure the code with indents to clarify, paticulary loops
2) Add lots of comments so we know what each instruction was meant to be doing.
I apologize for the late reply. I found the code problem. I will only use one timer. So far, I'm in the process of development, Iwork with code & schema & idea. After that, I'll publish both the code and the code that works.Thanks !!!!!!!