Hello all!
I want to publish a long code - Grain dryers chains damage detector. This project will first be installed on a single grain dryer as an experiment. In the test mode on the stand, it works perfectly. But if it works, there will be a demand for other dryers. Some time ago I already published a code for a project that used an encoder and compared the numbers of the impulses. Installation of encoders is complicated and costly. This project is based on the time difference between 4 inductive sensors. I have written the package leaflet also in English, translated from the Latvian language. The instruction is included in Word format. I do not know English perfectly, so if you see an error in my instructions, please correct it. Maybe someone sees the inaccuracies in the program code and can something be corrected or simplified? I also added a scheme.
#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 portc.0 '' button - SETTINGS DISPLAYS SCHROLLdirportc.0in#define button_up_down_reset portc.1 '' button + , - , resetdirportc.1in#define FAULT portc.2 '' fault relaysdirportc.2out#define LED portc.3 '' status LEDdirportc.3out''=========#define RUN porta.0 '' run signal from chains drivedirporta.0in#define sensor_1 porta.1 '' sensorsdirporta.1in#define sensor_2 porta.2 '' sensorsdirporta.2in#define sensor_3 porta.3 '' sensorsdirporta.3in#define sensor_4 porta.4 '' sensorsdirporta.4insetLEDon''---------------------------------------reklamalocate0,0print"WATCHDOG 2017 "locate1,0print"J.K.egineering "wait1s'Scroll display one character right (all lines) lcdcmd 28repeat15lcdcmd28wait100msendrepeatlcdcmd2cls''===========================================''timer2forCLOCKinittimer2PS2_16,0''(8bittimer)timer2prescaler,postscaler''Fosc=4MHz;Fosc=4/4=1MHz;1000kHz/16=(PS2_16)=62,5kHz=62500Hz''62500/256(8bittimer)=244cleartimer2TMR2IE=1full=0sec=0min=0hours=0sec_disp=0min_disp=0pushtime_1=0now1=0prev1=0aa=0pushtime_2=0now2=0prev2=0bb=1now3=0prev3=0''=========================now_run=0prev_run=0nowFLT=0prevFLT=0now_sens_all=0prev_sens_all=0now2_sens_all=0prev2_sens_all=0now3_sens_all=0prev3_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=0dimpulse_ind,bit_sens1,bit_sens2,bit_sens3,bit_sens4,bit_sens_all,bit_sens_all2asbitbit_sens1=0bit_sens2=0bit_sens3=0bit_sens4=0bit_sens_all=0bit_sens_all2=0''milisecundecisec(sec/100)decsec1=0decsec2=0decsec3=0decsec4=0decsec_all=0full_dec_cyc=0decsec_cyc=0full_dec1=0full_dec2=0full_dec3=0full_dec4=0full_dec_all=0full_dec_all=0ind_time=0ind_time2=0dimincrement,decrement,sens1_difflt,sens2_difflt,sens3_difflt,sens4_difflt,sens_difflt,sens_cycfltasbit''=============epread0,set_diff_dsecepread1,diff_sens1epread2,diff_sens2epread3,diff_sens3epread4,diff_sens4epread5,decsec_cycEPRead6,set_cyc_dsecepread7,sens_diffltepread8,sens_cycfltepread9,sens1_diffltepread10,sens2_diffltepread11,sens3_diffltepread12,sens4_difflt''=======================dowhilebutton_up_down_reset=0setLEDonset_diff_dsec=20set_cyc_dsec=50wait100mssetLEDoffwait100msdiff_sens1=0diff_sens2=0diff_sens3=0diff_sens4=0sens1_difflt=0sens2_difflt=0sens3_difflt=0sens4_difflt=0sens_difflt=0sens_cycflt=0epwrite0,set_diff_dsecEPwrite6,set_cyc_dsecFAULT=0loop''==============setLEDoff''=================main:starttimer2''=====================================if!button_menuthenpushtime_1++sec_disp=0min_disp=0elsepushtime_1=0endif''===============''TOOGLESWnow1=!button_menu&pushtime_1=>50ifnow1>prev1thenpushtime_1=0aa++clsendifprev1=now1''DISPLAYCASESselectcaseaacase0''MAINDISPLEJSMAIN_dispcase1test_difftimecase2set_difftimecase3test_cyctimecase4set_cyctimecase5aa=0endselect''==========================================now_run=!RUNifnow_run>prev_runthenclssec=0min=0hours=0endifprev_run=now_run''=============================ifRUN=0&FAULT=0then''sensor_1HIGHLEVELFRONT(risingedge)now_sens1=!sensor_1ifnow_sens1>prev_sens1Thenclsbit_sens1=1decsec1=0diff_sens1=0endifprev_sens1=now_sens1' sensor_1 LOW LEVEL FRONT (falling edge)now2_sens1=sensor_1ifnow2_sens1>prev2_sens1Thenclsdiff_sens1=decsec1epwrite1,diff_sens1bit_sens1=0decsec1=0endifprev2_sens1=now2_sens1''+++++++++++++++++++++++++++++++' sensor_2 HIGH LEVEL FRONT (rising edge_)now_sens2=!sensor_2ifnow_sens2>prev_sens2Thenclsbit_sens2=1decsec2=0diff_sens2=0endifprev_sens2=now_sens2' sensor_2 LOW LEVEL FRONT (falling edge)now2_sens2=sensor_2ifnow2_sens2>prev2_sens2Thenclsdiff_sens2=decsec2epwrite2,diff_sens2bit_sens2=0decsec2=0endifprev2_sens2=now2_sens2''+++++++++++++++++++++++++++++++++''sensor_3HIGHLEVELFRONT(risingedge)now_sens3=!sensor_3ifnow_sens3>prev_sens3Thenclsbit_sens3=1decsec3=0diff_sens3=0endifprev_sens3=now_sens3' sensor_3 LOW LEVEL FRONT (falling edge)now2_sens3=sensor_3ifnow2_sens3>prev2_sens3Thenclsdiff_sens3=decsec3epwrite3,diff_sens3bit_sens3=0decsec3=0endifprev2_sens3=now2_sens3''+++++++++++++++++++++++++++++++' sensor_4 HIGH LEVEL FRONT (rising edge_)now_sens4=!sensor_4ifnow_sens4>prev_sens4Thenclsbit_sens4=1decsec4=0diff_sens4=0endifprev_sens4=now_sens4' sensor_4 LOW LEVEL FRONT (falling edge)now2_sens4=sensor_4ifnow2_sens4>prev2_sens4Thenclsdiff_sens4=decsec4epwrite4,diff_sens4bit_sens4=0decsec4=0endifprev2_sens4=now2_sens4'=================================' all sensors =1 OR logicnow_sens_all=(bit_sens1orbit_sens2orbit_sens3orbit_sens4)&bit_sens_all=0''ifnow_sens_all>prev_sens_allThenbit_sens_all=1endifprev_sens_all=now_sens_all' all sensors =1 AND logic now3_sens_all=(bit_sens1&bit_sens2&bit_sens3&bit_sens4&bit_sens_all=1)''ifnow3_sens_all>prev3_sens_allThenbit_sens_all2=1epwrite5,decsec_cycendifprev3_sens_all=now3_sens_all''allsensors=0ANDlogicnow2_sens_all=(bit_sens1=0&bit_sens2=0&bit_sens3=0&bit_sens4=0&bit_sens_all&bit_sens_all2)ifnow2_sens_all>prev2_sens_allThen''=====full_dec_cyc=0decsec_cyc=0''====bit_sens_all=0bit_sens_all2=0endifprev2_sens_all=now2_sens_all''==================================endif''======ifaa<>0Thenifmin_disp=2Thenclsaa=0min_disp=0sec_disp=0endifendif''==============================================================================wait10msgotomain''CLOCK(Timer2)subInterruptTMR2IF=0full++iffull=244thensec_disp++ifRUN=0thensec++full=0endififsec_disp>59thensec_disp=0min_disp++endififmin_disp>59Thenmin_disp=0ifRUN=0thenifsec>59thenmin++sec=0endififmin>59thenhours++min=0endififhours>99thenhours=0''===============decisekundesforsensorsfull_dec1++full_dec2++full_dec3++full_dec4++Iffull_dec1=24Thendecsec1++full_dec1=0endifIffull_dec2=24Thendecsec2++full_dec2=0endifIffull_dec3=24Thendecsec3++full_dec3=0endifIffull_dec4=24Thendecsec4++full_dec4=0endif''========difffault==================================''=============================ifbit_sens_allthenfull_dec_all++Iffull_dec_all=24Thendecsec_all++full_dec_all=0endifElsefull_dec_all=0decsec_all=0endif''================''=========cycfltifbit_sens_all2=0Thenfull_dec_cyc++Iffull_dec_cyc=24Thendecsec_cyc++full_dec_cyc=0endifendif''=============endif'''===========STATUS LED (1sec tact)if full<10 thenset LED onElseset LED offend ifend sub''========= MAIN displejssub MAIN_disp '' (aa=0)locate 0,0print "RUNTIME="if hours<10 thenlocate 0,8print "0"locate 0,9print hoursElselocate 0,8print hoursend iflocate 0,10print ":"if min<10 Thenlocate 0,11print "0"locate 0,12print minelselocate 0,11 print minend iflocate 0,13print ":"if sec<10 Thenlocate 0,14print"0"locate 0,15print secElselocate 0,14print secend if''=========================================================''===================== comparators, fault detectors if bit_sens_all=1if decsec_all>set_diff_dsec then ''===DIFF FAULTif decsec1>set_diff_dsec or bit_sens1=1 then sens1_difflt=1if decsec2>set_diff_dsec or bit_sens2=1 then sens2_difflt=1if decsec3>set_diff_dsec or bit_sens3=1 then sens3_difflt=1if decsec4>set_diff_dsec or bit_sens4=1 then sens4_difflt=1sens_difflt=1end ifif decsec_cyc>set_cyc_dsec then sens_cycflt=1 '' ===CYC FAULT'' ====== FOR lcd blinkingif full<122 Thenif sens_difflt=1 & sens_cycflt=0 then locate 1, 0print "FLTsens:"if sens1_difflt thenlocate 1, 8print "1"end ifif sens2_difflt thenlocate 1, 9print "&2"end ifif sens3_difflt thenlocate 1, 11print "&3"end ifif sens4_difflt thenlocate 1, 13print "&4"end ifend ifif sens_cycflt & sens_difflt=0 then locate 1, 0print "CYCFLT:"locate 1, 7print decsec_cyclocate 1, 10print "decsec"end ifElselocate 1, 0print " "end if'''======================================ifsens_difflt=1orsens_cycflt=1thensetFAULTonElsesetFAULToffendifnowFLT=FAULTifnowFLT>prevFLTthenepwrite7,sens_diffltepwrite8,sens_cycfltepwrite9,sens1_diffltepwrite10,sens2_diffltepwrite11,sens3_diffltepwrite12,sens4_diffltendifprevFLT=nowFLT''===========================button_up_down_reset_actifpushtime_2=30Thensens1_difflt=0sens2_difflt=0sens3_difflt=0sens4_difflt=0sens_difflt=0bit_sens_all=0bit_sens_all2=0decsec1=0decsec2=0decsec3=0decsec4=0decsec_all=0sens_cycflt=0decsec_cyc=0epwrite5,decsec_cycepwrite7,sens_diffltepwrite8,sens_cycfltepwrite9,sens1_diffltepwrite10,sens2_diffltepwrite11,sens3_diffltepwrite12,sens4_diffltclsendifendsubsubtest_difftimelocate0,0print"diff:1="locate0,11print"2="locate1,1print"3="locate1,7print"4="''=====================ifbit_sens1Thenlocate0,7printdecsec1' "RUN"Elselocate0,7printdiff_sens1endif''=====================ifbit_sens2Thenlocate0,13printdecsec2' "RUN"Elselocate0,13printdiff_sens2endif''=====================ifbit_sens3Thenlocate1,3printdecsec3' "RUN"Elselocate1,3printdiff_sens3endif''====================ifbit_sens4Thenlocate1,9printdecsec4' "RUN"Elselocate1,9printdiff_sens4endifendsubsubset_difftime''(aa=2)locate0,0print"SET DIFF_TIME: "''======================callbutton_up_down_reset_act''+++++++++++++++++++++++++now3=!button_up_down_reset&pushtime_2>2&pushtime_2<20ifnow3>prev3thenclsifincrement&set_diff_dsec<200Thenset_diff_dsec++ifdecrementThenset_diff_dsec--epwrite0,set_diff_dsecendifprev3=now3''============================locate1,4printset_diff_dseclocate1,9print" decsec"endsub''=========================subtest_cyctime''(aa=3)locate0,0print"test CYCTIME:"locate1,2printdecsec_cyclocate1,6print"secdec"endsubsubset_cyctime''(aa=4)locate0,0print"SET CYC_TIME: "''======================callbutton_up_down_reset_act''+++++++++++++++++++++++++now3=!button_up_down_reset&pushtime_2>2&pushtime_2<20ifnow3>prev3thenclsifincrement&set_cyc_dsec<250Thenset_cyc_dsec++ifdecrementThenset_cyc_dsec--epwrite6,set_cyc_dsecendifprev3=now3''============================locate1,4printset_cyc_dseclocate1,9print" decsec"''=======================endsubsubbutton_up_down_reset_actif!button_up_down_resetthenpushtime_2++sec_disp=0min_disp=0Elsepushtime_2=0endififaa<>0Thennow2=!button_up_down_reset&pushtime_2=50ifnow2>prev2Thenbb++prev2=now2selectcasebbcase1increment=1decrement=0case2increment=0decrement=1case3bb=1''!!!!!!!!!!endselectlocate1,0' inc vai dec indikacijaifbb=1thenprint"(+)"ifbb=2thenprint"(-)"endifendsub
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Very exciting when a project comes together and works. Thanks for sharing!
I too live in a farming community and do ocassional work with dryers and grain storage. Last year I started a project to monitor a grain leg belt type bucket elevator. The drive is at the top and when the operator dumps corn in the bottom too fast the belt/buckets slow down from slipping. Was going to uses an inductive sensor and give an alarm when the "tail pulley" slowed. Similar to your project but not as in depth.
I will look over when time permits.
Too many projects,too little time.
BR
Mike
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Circuit diagramms and pcb I designed with the online program EASYEDA. Very good. I recommend you! There can also be sharing projects. There's also help around the clock, just like here :)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello all!
I want to publish a long code - Grain dryers chains damage detector. This project will first be installed on a single grain dryer as an experiment. In the test mode on the stand, it works perfectly. But if it works, there will be a demand for other dryers. Some time ago I already published a code for a project that used an encoder and compared the numbers of the impulses. Installation of encoders is complicated and costly. This project is based on the time difference between 4 inductive sensors. I have written the package leaflet also in English, translated from the Latvian language. The instruction is included in Word format. I do not know English perfectly, so if you see an error in my instructions, please correct it. Maybe someone sees the inaccuracies in the program code and can something be corrected or simplified? I also added a scheme.
Circuit diagramm
instruction in english
In The program code #include <maths.h> not used. I forgot to delete.</maths.h>
Always interesting to see your projects, thanks for sharing. What, no klaxon/emergency horn to wake up the sleeping operator? haha.
Very exciting when a project comes together and works. Thanks for sharing!
I too live in a farming community and do ocassional work with dryers and grain storage. Last year I started a project to monitor a grain leg belt type bucket elevator. The drive is at the top and when the operator dumps corn in the bottom too fast the belt/buckets slow down from slipping. Was going to uses an inductive sensor and give an alarm when the "tail pulley" slowed. Similar to your project but not as in depth.
I will look over when time permits.
Too many projects,too little time.
BR
Mike
Circuit diagramms and pcb I designed with the online program EASYEDA. Very good. I recommend you! There can also be sharing projects. There's also help around the clock, just like here :)
Thank you to all who help and share information! Information must be shared, otherwise there will be no development! :) GCB rullz :)