Simulation of alarm mode control for Proteus sensor + gas concentration detection

catalog Simulation of alarm mode control for Proteus sensor + gas concentration detection 1 understanding of experim...
1 understanding of experimental significance
2 main experimental devices
3 experimental reference circuit
4. Problems in the experiment
5 experiment reference code

catalog

1 understanding of experimental significance

Based on the first two experiments, we have successfully implemented:

  • Sampling and conversion of sensor data
  • Fit sample value
  • The fitting data is displayed on the HDG12864F-1 display screen

It seems that the data that should be obtained has been obtained. What else can we do?

Yes, we can also use the data to do something, such as how to control and solve when the gas concentration is out of range.

So that leads to the experiment, how to control the solution?

In fact, we have seen a lot in our daily life, when the gas concentration exceeds a certain range:

  • call the police
    • Turn on the alarm light
    • Buzzer gives out alarm sound
  • Dredge
    • Turn on fan ventilation
    • ......
  • ......

As mentioned above, we have adopted the first three small ways to control the solution.

In addition, we also need to optimize the LCD display, which is to display the rotating fan on the screen.

2 main experimental devices

  1. CPU processor

    • AT89C52
  2. LCD display

    • HDG12864F-1
  3. AD converter

    • ADC0834
  4. sensor

    • Temperature and humidity: SHT10
    • Light sensor: TORCH_LDR
    • Gas concentration sensor: LDR
    • Carbon monoxide concentration sensor: LDR
    • Air pressure sensor: MPX4115
  5. Control related

    • Warning lamp: RGBLED-CC
    • Buzzer: SOUNDER
    • Ventilation control: FAN

3 experimental reference circuit

  1. Not running

  2. Runtime

  3. explain

    • There is a buzzer sound
    • The letter after the channel in the first line of the display will change according to the channel currently being sampled and converted
    • All data is only displayed after conversion, but not stored. To store the display, just open a few global variables to save

4. Problems in the experiment

4.1 fans for turning

To realize this function, we only need to know two key points:

  • HDG12864F-1 liquid crystal display if you do not overwrite the written value of one pixel, the last written value will be maintained
  • Any dynamic effect is essentially a "fast" play of static pictures

So it's easy to do this:

  • Find several static fan diagrams with different rotation angles (the best size is the same, so it is easy to write and completely cover)
  • Mold these static fan diagrams
  • Call HDG12864F-1 draw picture function to write a static graph
  • Let the processor do other things, such as executing a few other statements, or directly delay waiting
  • Call HDG12864F-1 to draw picture function and write another static graph
  • ......

So, why is there "let the processor do other things, such as executing a few other statements, or directly delay waiting"?

In fact, this is a control analog fan rotation speed. You think if you quickly switch between two pictures, your eyes have no visual residue, it's gone. It's estimated that your eyes will be blinded Therefore, it is very important to choose an appropriate switching time interval

Second, there are at least two static pictures, which should be well understood. If there is one picture, there is no change. It's the same thing in exchange

4.2 control part

First, let's take a look at the schematic diagram of the control part:

Next, let's talk about each part separately.

  1. Alarm lamp

    To make this RGBLED-CC work, first of all, give a low level to the K terminal.

    RGB end, input 1 is on, 0 is not on.

    Then, in this experiment, we only need to use red and green colors, so we directly ground the B terminal, and then bind the R and G terminals to the processor pins respectively.

    During operation, it is judged that if the danger value is reached or the safety value is restored, the processor will reset the corresponding pin value.

  2. Buzzer

    It is mainly SOUNDER element, one end is applied with voltage, the other end needs to give pulse signal.

    This pulse signal is very important. At the beginning, our dog didn't set the input pulse signal (the default frequency is very small), so we can't hear it

    Later, double-click the input SW1(A), adjust the following parameters, and then you will hear. Refer to the figure below for my adjustment:

    Of course, how to make it play music??

    Here are two experiences that give me a further understanding of this:

    • During the summer internship in sophomore school, when I was working on the electronic clock, I wrote it with verilog. If I want to let the buzzer out, it's not only that kind of hard to hear scream all the time, but also play music or something. I need to give different frequencies

    • In the third year of college, we used the chip built in the notebook to make a clock based on x86 (written in the assembly language). Among them, what about alarm function and ringing tone? What do I do if I want to change to music?

      • Find music score and corresponding note frequency, relative delay
      • Write "table" for frequency and delay respectively, and delay output in turn

      Here, expand again. What if you want to listen to the fast version of music? If you want to listen to the down tone, what about the up tone version?

      • Frequency: control tone
      • Delay: control speed

    Then, again, how to control the sound switch?

    DSWITCH element is used here, which can be regarded as a three state gate:

    • BP end set to 1, receive input of SW1(A)
    • BP end set to 0, high resistance state, no sound
  3. Shelter control

    This module is mainly implemented by FAN + relay PCJ-112D3MH. I didn't find its DATASHEET on the IC network, so I followed the teacher's principle and made a personal understanding.

    First of all, how to control its switch?

    • We can see that there is a NPN type triode connected on the left side of it, which is mainly used for

      • FAN set to 1, turn on the electric FAN
      • FAN is set to 0, turn on the electric FAN

      As for the specific functions of this type of triode, what's the difference with PNP type triode?

      I searched the Internet for a question and answer, which can be referred to: Detailed explanation and difference of NPN and PNP triode

    Maybe After you write the code as above, we find that Why did I turn off the program? The fan of the simulation is still running?!

    Is the time I input not enough?! FAN=0,FAN=0,FAN=0,FAN=0,…… nm (can't crack rough) or not

    In fact, the actual stop of this fan is determined by the number in the display box below it.

    • When the fan is on, the number will increase;
  • When the fan is off, the number will drop;
    • When it's 0.00, it stops.

Of course, not stopping immediately is also in line with the situation in real life. I think it's mainly because of the problem of relay. This understanding is used to control strong electricity with weak electricity (if you are interested, you can learn by yourself)

Of course, the specific parameters of the fan can be modified by double clicking the component.

5 experiment reference code

The reference code is given below, and the control standard here is:

  • CH4 concentration < 20, normal - Green - fan off - buzzer off
  • CH4 concentration > = 20 & < 40, warning - yellow - fan on - buzzer off
  • CH4 concentration > = 40, danger - red - fan off - buzzer on
#include <reg52.h> #include <intrins.h> #include<math.h> #define NOP _nop_() #define uint unsigned int #define uchar unsigned char #define ACK 1 #define noACK 0 #define DISPLAY_ LEFT_ TO_ Right 1 / / calculates the column position from the left side. After each byte is written, the column number will automatically move to the right one #define DISPLAY_ RIGHT_ TO_ Left 0 / / the column position is calculated from the number on the right. After each byte is written, the column number will automatically move to the left one //SHT10 instruction set //Write status register #define STATUS_REG_W 0x06 //Read status register #define STATUS_REG_R 0x07 //temperature measurement #define MEASURE_TEMP 0x03 //Humidity measurement #define MEASURE_HUMI 0x05 //Soft reset #define RESET 0x1E //Enumerate selected temperature / humidity measurements enum ; //ADC0834 sbit CS=P1^1;//ADC0834 chip selection signal sbit CLK=P1^0;//ADC0834 clock signal //sbit SARS0834=P1^2; / / conversion status output, low level means conversion is completed sbit DO=P1^5;//ADC0834 data interface sbit DI=P1^4;//ADC0834 channel selection //HDG12864F-1 sbit cs1 = P2^4;//-cs, chip selection, low level effective sbit rst = P2^3;//-rst, reset, active low level sbit a0 = P2^2;//Write command, write data control bit. 1=Display data; 0=Control data; sbit scl = P2^1;//Shift clock input sbit si = P2^0;//Serial data input //SHT10 sbit SCK=P1^2; sbit DATA=P1^3; //Control related sbit LEDR=P1^6; sbit LEDG=P1^7; sbit FAN=P2^5; sbit BP=P2^6; //ADC unsigned int temp,humi; unsigned char ad_res = 0; unsigned char ad_res1 = 0; unsigned char ad_res2 = 0; unsigned char ad_res3 = 0; unsigned char ad_res4 = 0; double dat=0.0; //ADC0834 channel switching unsigned int code channel0834[8]=; //Fan uchar code pic_data1[]= { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0xFC,0xFE,0xFE,0xFE, 0xFE,0xFE,0xFE,0xFC,0xF8,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0xC0,0xF0,0xFC,0xFC,0xFE,0xFE,0xFE,0xFE,0xFC,0xFC,0xBC,0xE8,0xF7,0xFF,0xFF, 0xFF,0xFF,0xFF,0xEF,0xEF,0xE3,0xF0,0xF0,0xF8,0xFC,0xFC,0xFC,0xF8,0xF0,0xC0,0x00, 0x00,0x01,0x07,0x0F,0x1F,0x1F,0x1F,0x0F,0x07,0x07,0xE3,0xFB,0xFB,0xFF,0xFF,0xFF, 0xFF,0xFF,0xF7,0x8F,0x0E,0x1F,0x1F,0x3F,0x3F,0x3F,0x3F,0x1F,0x0F,0x07,0x01,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x0F,0x1F,0x3F,0x3F,0x3F, 0x3F,0x3F,0x3F,0x1F,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, }; uchar code pic_data2[]= ; //Character library uchar code BMP[][6]= { //Two dimensional hexadecimal array corresponding to character display , // 0-bit display blank , // 1 , // 2 , // 3 , // 4 , // 5 , // 6 , // 7 , // 8 , // 9 , // 10 , // 11 , // 12 , // 13 , // 14 , // 15 , // 16 , // 17 , // 18 , // 19 , // 20 , // 21 , // 22 , // 23 , // 24 , // 25 , // 26 , // 27 , // 28 , // 29 , // 30 , // 31 , // sp 32 , // ! 33 , // " 34 , // # 35 , // $ 36 , // % 37 , // & 38 , // ' 39 , // ( 40 , // ) 41 , // * 42 , // + 43 , // , 44 , // - 45 , // . 46 , // / 47 , // 0 48 , // 1 49 , // 2 50 , // 3 51 , // 4 52 , // 5 53 , // 6 54 , // 7 55 , // 8 56 , // 9 57 , // : 58 , // ; 59 , // < 60 , // = 61 , // > 62 , // ? 63 , // @ 64 , // A 65 , // B 66 , // C 67 , // D 68 , // E 69 , // F 70 , // G 71 , // H 72 , // I 73 , // J 74 , // K 75 , // L 76 , // M 77 , // N 78 , // O 79 , // P 80 , // Q 81 , // R 82 , // S 83 , // T 84 , // U 85 , // V 86 , // W 87 , // X 88 , // Y 89 , // Z 90 , // [ 91 , //55 92 , // ] 93 , // ^ 94 , // _ 95 , // ' 96 , // a 97 , // b 98 , // c 99 , // d 100 , // e 101 , // f 102 , // g 103 , // h 104 , // i 105 , // j 106 , // k 107 , // l 108 , // m 109 , // n 110 , // o 111 , // p 112 , // q 113 , // r 114 , // s 115 , // t 116 , // u 117 , // v 118 , // w 119 , // x 120 , // y 121 , // z 122 , // <50 123 , //50<= <100 124 , //100<= <150 125 , //>=150 126 // sp 127 }; unsigned char code myChannel[7]={'C','h','a','n','n','e','l'}; unsigned char code myTemp[4]={'T','e','m','p'}; unsigned char code myHumi[4]={'H','u','m','i'}; unsigned char code myCO[2]={'C','O'}; unsigned char code myCH4[3]={'C','H','4'}; unsigned char code myLight[5]={'L','i','g','h','t'}; unsigned char code myAir[7]={'A','i','r','-','p','r','e'}; unsigned char code **msg[7]=; //Delay Functions void Delayms(uint x ) { uint t; while(x--) for (t= 0; t<120; t++); } //HDG12864F-1 //Write command void wrt_cmd(unsigned char command) { unsigned char i = 8;//8 bits cs1 = 0;//Chip selection, low level effective a0 = 0;//0=Control data, command set to 0 while(i--) { scl = 0; si = (bit) (command & 0x80);//Write high first scl = 1;//Rising edge command <<= 1;//Move left one bit } scl = 0; } //Write data void wrt_dt(unsigned char data_) { unsigned char i = 8;//8 bits cs1 = 0;//Chip selection, low level effective a0 = 1;//1=Display data, write data to 1 while(i--) { scl = 0; si = (bit) (data_ & 0x80);//Write high first scl = 1;//Rising edge data_ <<= 1;//Move left one bit 0 } scl = 0; } //Set column position, where parameters address:0~127 void HDG12864F1_SetColumnAddress(unsigned char address) { //Writing columns should be divided into two steps: first write the high four digits, then write the low four digits //Manual Column Address Set wrt_cmd(0x10 + (address >> 4 & 0x0f));//Shift right in C is arithmetic shift right. You must remove the upper 4 bits of & 0x0f to get the correct result wrt_cmd(address & 0x0f); } //Set the longitudinal position, where the parameter pa geAddress:0 ~8 void HDG12864F1_SetPageAddress(unsigned char pageAddress) { //Manual Page Address Set wrt_cmd(0xb0 + pageAddress);//1011 + page } //Write data void HDG12864F1_WriteData(unsigned char data_) { wrt_dt(data_); } //Set write direction: right to left is positive void HDG12864F1_Direction(unsigned char direction) { //Manual ADC Select wrt_cmd(0xa0+direction); } //Scroll up the content of the written screen, and the top part will appear from the bottom of the screen void HDG12864F1_SetStartLine(unsigned char line) { //Parameter line value range 0 ~ 63 wrt_cmd(0x40 + line); } //Write English characters, number up and down 1 8 * 6 dot matrix void HDG12864F1_WriteEnglishChar(unsigned char *pEChar, unsigned char column, unsigned char page) { unsigned char i; HDG12864F1_Direction(DISPLAY_LEFT_TO_RIGHT);//DISPLAY_LEFT_TO_RIGHT is a macro with a value of 1 that represents writing from the left side of the screen HDG12864F1_SetColumnAddress(column);//Set the horizontal coordinate to start writing HDG12864F1_SetPageAddress(page);//Set the vertical Page to start writing for(i=0; i<6; i++) HDG12864F1_WriteData(*(pEChar + i));//Continuous English Writing } //Picture 32 * 32 void HDG12864F1_DrawPic(unsigned char *pChar, unsigned char column, unsigned char page) { unsigned char i,j; HDG12864F1_Direction(DISPLAY_LEFT_TO_RIGHT);//DISPLAY_LEFT_TO_RIGHT is a macro with a value of 1, which represents writing from the left side of the screen for(i=0;i<4;i++) { HDG12864F1_SetColumnAddress(column);//Set the horizontal coordinate to start writing HDG12864F1_SetPageAddress(page+i);//Set the vertical Page to start writing for(j=0;j<32;j++) { HDG12864F1_WriteData(*(pChar + i*32+j));//Continuous English Writing } } } //ADC0834 unsigned char AD0834_conv(unsigned int n) { unsigned char i,com; CS=1; CS=0; _nop_(); _nop_();//CS set low, start conversion DI=1; _nop_(); _nop_();//Start, prepare the first pulse of output data CLK=1; _nop_(); _nop_(); CLK=0; _nop_(); _nop_(); //Select channel, second pulse DI=1; CLK=1; _nop_(); _nop_(); CLK=0; _nop_(); _nop_(); DI=channel0834[n*2]; CLK=1; _nop_(); _nop_(); CLK=0; _nop_(); _nop_(); DI=channel0834[n*2+1]; CLK=1; _nop_(); _nop_(); CLK=0; _nop_(); _nop_(); DI=1; CLK=1; _nop_(); _nop_(); CLK=0; _nop_(); _nop_(); //Start to collect conversion data for(i=8;i>0;i--) { com<<=1;//Move left, take the highest position first if(DO)com=com|0x01;//Collect current data CLK=1; CLK=0; _nop_(); _nop_(); } CS=1;//Close selection, disable return com; } //LDR sensor data fitting unsigned char ChangeDataLDR(unsigned char res) { unsigned char com; com=0.00000000221308*res*res*res*res*res -0.0000009287723*res*res*res*res + 0.0001465584*res*res*res - 0.008997464*res*res + 0.2657836*res - 0.5918848; return com; } //MPX4115 sensor data fitting unsigned char ChangeDataMPX(unsigned char res) { unsigned char com; //Fit yourself com=0.436*res+9.053; return com; } //SHT10 //Write Bytes char s_write_byte(uchar value) { uchar i,error=0; //Take out the corresponding bit string transmission of instructions respectively //From high for(i=0x80;i>0;i>>=1) { if(i&value) DATA=1; else DATA=0; SCK=1; //Keep SCK high _nop_();_nop_();_nop_(); SCK=0; } DATA=1; SCK=1; error=DATA;//ACK _nop_();_nop_();_nop_(); SCK=0; DATA=1; return error; } //Read bytes char s_read_byte(uchar ack) { uchar i,val=0; DATA=1; //Read a byte of data for(i=0x80;i>0;i>>=1) { SCK=1; if(DATA) val=(val|i); SCK=0; } if(ack==1)DATA=0;//Confirm each byte by pulling down DATA to low level else DATA=1; //If it is a check (ack==0), keep the ACK high level to end the communication after reading _nop_();_nop_();_nop_(); //pulswith approx. 3 us SCK=1; //clk #9 for ack _nop_();_nop_();_nop_(); //pulswith approx. 3 us SCK=0; _nop_();_nop_();_nop_(); //pulswith approx. 3 us DATA=1; //Release data line return val; } //Start transfer void s_transstart(void) { DATA=1; SCK=0; _nop_(); SCK=1; _nop_(); DATA=0; _nop_(); SCK=0; _nop_();_nop_();_nop_(); SCK=1; _nop_(); DATA=1; _nop_(); SCK=0; } //Connection reset void s_connectionreset(void) { //Communication interrupt requires communication reset //DATA remains high and triggers SCK clock 9 times or more uchar i; DATA=1;SCK=0; for(i=0;i<9;i++) { SCK=1; SCK=0; } //Send a transmission start sequence s_transstart(); //Reset the serial port while the content of the status register remains } //Temperature and humidity measurement char s_measure(uchar *p_value,uchar *p_checksum,uchar mode) { unsigned error=0; unsigned int i; s_transstart(); switch(mode) { case TEMP: error+=s_write_byte(MEASURE_TEMP); break; case HUMI: error+=s_write_byte(MEASURE_HUMI); break; default: break; } //After the measurement, the Sensor will pull down the DATA line //The waiting time for the end of measurement is different according to the measurement of different digits for(i=0;i<65535;i++) if(DATA==0) break;//2^16 if(DATA) error+=1;//Description not over //Transmit 2 bytes of measurement data and 1 byte of CRC parity *(p_value)=s_read_byte(ACK); *(p_value+1)=s_read_byte(ACK); *p_checksum=s_read_byte(noACK); return error; } //Temperature and humidity value scale transformation and temperature compensation void calc_sth10(float *p_humidity,float *p_temperature) { // input : humi [Ticks] (12 bit) // temp [Ticks] (14 bit) // output: humi [%RH] const float C1=-2.0468; // for 12 Bit const float C2=+0.0367; // for 12 Bit const float C3=-0.0000015955; // for 12 Bit const float T1=+0.01; // for 12 Bit @ 5V const float T2=+0.00008; // for 12 Bit @ 5V float rh=*p_humidity;// rh: Humidity [Ticks] 12 Bit float t=*p_temperature; // t: Temperature [Ticks] 14 Bit float rh_lin;// rh_lin: Humidity linear float rh_ture;// rh_true: Temperature compensated humidity float t_C;// t_C : Temperature [C] t_C=t*0.01-40;//Temperature conversion [C] rh_lin=C3*rh*rh+C2*rh+C1;//Nonlinear compensation of relative humidity: [% RH] rh_ture=(t_C-25)*(T1+T2*rh)+rh_lin;//Temperature compensation of humidity signal: [% RH] //Out of range processing if(rh_ture>100) rh_ture=100; if(rh_ture<0.1) rh_ture=0.1; //Transfer the results back *p_temperature=t_C;//[C] *p_humidity=rh_ture;//[%RH] } typedef union { unsigned int i; float f; }value; void main(void) { int i=0; int j=0; int mycol=0; value humi_val,temp_val; uchar error; uchar check_sum;//Checksums int flag;//Judge temperature symbol BP=0; FAN=0; while(1) { mycol=0; for(i=0;i<7;i++) HDG12864F1_WriteEnglishChar(BMP[myChannel[i]],i*8,mycol); HDG12864F1_WriteEnglishChar(BMP[':'],7*8,mycol); HDG12864F1_WriteEnglishChar(BMP['A'],8*8,mycol); mycol=mycol+1; //Temperature and humidity error=0; error+=s_measure((uchar*)&humi_val.i,&check_sum,HUMI); error+=s_measure((uchar*)&temp_val.i,&check_sum,TEMP); if(error!=0)//The communication is interrupted and the measurement is not completed s_connectionreset(); else//It has been measured { humi_val.f=(float)humi_val.i; temp_val.f=(float)temp_val.i; //Temperature and humidity compensation calc_sth10(&humi_val.f,&temp_val.f); //Judging symbol if(temp_val.f<0) { flag='-'; temp_val.f=-temp_val.f+2; } else flag='+'; //Can display the next decimal place temp=temp_val.f*10; humi=humi_val.f*10; } //temperature for(i=0;i<4;i++) HDG12864F1_WriteEnglishChar(BMP[myTemp[i]],i*8,mycol); HDG12864F1_WriteEnglishChar(BMP[':'],4*8,mycol); HDG12864F1_WriteEnglishChar(BMP[flag],5*8,mycol); HDG12864F1_WriteEnglishChar(BMP[temp/1000+'0'],6*8,mycol); HDG12864F1_WriteEnglishChar(BMP[temp%1000/100+'0'],7*8,mycol); HDG12864F1_WriteEnglishChar(BMP[temp%100/10+'0'],8*8,mycol); HDG12864F1_WriteEnglishChar(BMP['C'],9*8,mycol); mycol=mycol+1; //humidity for(i=0;i<4;i++) HDG12864F1_WriteEnglishChar(BMP[myHumi[i]],i*8,mycol); HDG12864F1_WriteEnglishChar(BMP[':'],4*8,mycol); HDG12864F1_WriteEnglishChar(BMP[humi/1000+'0'],5*8,mycol); HDG12864F1_WriteEnglishChar(BMP[humi%1000/100+'0'],6*8,mycol); HDG12864F1_WriteEnglishChar(BMP[humi%100/10+'0'],7*8,mycol); HDG12864F1_WriteEnglishChar(BMP['%'],8*8,mycol); mycol=mycol+1; ad_res=AD0834_conv(0); ad_res1=ad_res; for(i=0;i<5;i++) HDG12864F1_WriteEnglishChar(BMP[myLight[i]],i*8,mycol); HDG12864F1_WriteEnglishChar(BMP[':'],5*8,mycol); HDG12864F1_WriteEnglishChar(BMP[ad_res1%1000/100+'0'],6*8,mycol); HDG12864F1_WriteEnglishChar(BMP[ad_res1%100/10+'0'],7*8,mycol); HDG12864F1_WriteEnglishChar(BMP[ad_res1%10+'0'],8*8,mycol); HDG12864F1_WriteEnglishChar(BMP['L'],9*8,mycol); HDG12864F1_WriteEnglishChar(BMP['x'],10*8,mycol); mycol=mycol+1; ad_res=AD0834_conv(1); ad_res2=ChangeDataLDR(ad_res); for(i=0;i<2;i++) HDG12864F1_WriteEnglishChar(BMP[myCO[i]],i*8,mycol); HDG12864F1_WriteEnglishChar(BMP[':'],2*8,mycol); HDG12864F1_WriteEnglishChar(BMP[ad_res2%1000/100+'0'],3*8,mycol); HDG12864F1_WriteEnglishChar(BMP[ad_res2%100/10+'0'],4*8,mycol); HDG12864F1_WriteEnglishChar(BMP[ad_res2%10+'0'],5*8,mycol); HDG12864F1_WriteEnglishChar(BMP['p'],6*8,mycol); HDG12864F1_WriteEnglishChar(BMP['p'],7*8,mycol); HDG12864F1_WriteEnglishChar(BMP['m'],8*8,mycol); mycol=mycol+1; ad_res=AD0834_conv(2); ad_res3=ChangeDataLDR(ad_res); //Control RGB-LED and BP and FAN if(ad_res3<20)//Normal - Green - fan off - buzzer off { LEDR=0; LEDG=1; BP=0; FAN=0; } else if(ad_res3>=20 & ad_res3<40)//Warning - yellow - fan on - buzzer off { LEDR=1; LEDG=1; BP=0; FAN=1; } else//Danger - red - fan off - buzzer on { LEDR=1; LEDG=0; BP=1; FAN=0; } for(i=0;i<3;i++) HDG12864F1_WriteEnglishChar(BMP[myCH4[i]],i*8,mycol); HDG12864F1_WriteEnglishChar(BMP[':'],3*8,mycol); HDG12864F1_WriteEnglishChar(BMP[ad_res3%1000/100+'0'],4*8,mycol); HDG12864F1_WriteEnglishChar(BMP[ad_res3%100/10+'0'],5*8,mycol); HDG12864F1_WriteEnglishChar(BMP[ad_res3%10+'0'],6*8,mycol); HDG12864F1_WriteEnglishChar(BMP['p'],7*8,mycol); HDG12864F1_WriteEnglishChar(BMP['p'],8*8,mycol); HDG12864F1_WriteEnglishChar(BMP['m'],9*8,mycol); mycol=mycol+1; ad_res=AD0834_conv(3); ad_res4=ChangeDataMPX(ad_res); for(i=0;i<7;i++) HDG12864F1_WriteEnglishChar(BMP[myAir[i]],i*8,mycol); HDG12864F1_WriteEnglishChar(BMP[':'],7*8,mycol); HDG12864F1_WriteEnglishChar(BMP[ad_res4%1000/100+'0'],8*8,mycol); HDG12864F1_WriteEnglishChar(BMP[ad_res4%100/10+'0'],9*8,mycol); HDG12864F1_WriteEnglishChar(BMP[ad_res4%10+'0'],10*8,mycol); HDG12864F1_WriteEnglishChar(BMP['k'],11*8,mycol); HDG12864F1_WriteEnglishChar(BMP['P'],12*8,mycol); HDG12864F1_WriteEnglishChar(BMP['a'],13*8,mycol); //Rotating fan HDG12864F1_DrawPic(&pic_data1,90,0); Delayms(800);//Delay display HDG12864F1_DrawPic(&pic_data2,90,0); Delayms(700);//Delay display } }

Among them, the procedures in HDG12864F-1 are as follows: Operating HDG12864F-1 LCD with Proteus simulation

25 June 2020, 21:57 | Views: 2369

Add new comment

For adding a comment, please log in
or create account

0 comments