Tuesday, August 12, 2014

PIC microcontroller with sensors and constitute a relatively hygrometer

As shown, with a response with a capacitive sensor and a PIC microcontroller (MCU) can constitute a relatively hygrometer.
  Where the capacitance value provided Humirel HS1101 sensor range is 162 ~ 202pF.Use a timer as a TLC555 CMOS oscillator capacitor to complete the conversion from the frequency of the timer frequency equation is as follows: F = 1.44 / (RA + 2RB) × CX here resistors RA and RB, respectively, equal to 421 kΩ and 42.4kΩ, CX sensor capacitance. Timer control voltage input terminal receiving the 1MΩ resistance temperature coefficient of the sensor used to match the timer internal temperature coefficient imbalance.
  MCU measuring input signal cycle, and convert it to a relative humidity of digital reading. This is done by MCU internal counter (TMR1) and capture / compare / PWM module (CCP) to achieve.
  Because the capacitance range of the sensor is very narrow range of the signal period will be very small, so the use of the crystal to get a 8.000MHz 0.5μs instruction cycle.
  Figure.
  In addition, CCP module is configured to input voltage is divided into four parts, so that you can increase the range of different cycle counting pulses provided by the TLC555 in. PIC CCP module can detect a rising or falling edge every 4 or 16 pulses.
  In this case, CCP module is based on four rising edge configuration. CCP1IF flag this detection event is stored in the register PIR1's. When detecting the first rising edge of this flag bit is set by software to enable TMR1 start counting.
  Then the flag must be cleared, waiting to detect the rising edge of the fourth, then stop the timer. Must now represent a total number of cycles respectively CCPR1L and CCPR1H dump memory from a memory TMR1L and TMR1H.
  Using this data, we further subtracting the number of cycles corresponding to the humidity of 0% results from several cycles (in the present example, take the decimal number 62 (3EH))
  Number of cycles to complete the conversion from relative humidity. The frequency of the number of cycles corresponding to the humidity of 0% by the manufacturer can provide TLC555 timer generates equations and calculations to determine.
  16 by subtraction of said first binary value complement operator, and the result is added to the data obtained by TMR1 achieved, i.e., the result of this arithmetic operation corresponding to the relative humidity. Finally completed by the MCU converted from binary to BCD code.
  Binary to BCD conversion uses three external memory: one, ten, one hundred memory, relative humidity (moisture percentage) is sent to a bit memory, and then by 10, save the calculation results by the accumulator W.
  By Carry test status register, we can know the result of the operation is greater than 10. If less than 10, then the result of the operation, only a bit, do not need to continue to do more comparison operations, such conversion is limited to one-bit memory.
  If the result is greater than 10, ten memory plus one, ten memory plus 1:00 bit memory must be the same minus 10 operations.
  When ten-bit memory equal to 10, plus a one hundred memory. The same computation on indefinitely, until the number of memory bits is less than 10. When the conversion is completed, the results of each memory is BCD code, BCD code to seven-segment digital conversion is done by the subroutine OPTABLE.
  Conversion circuit has a total of four multi-cathode LED display, requires the use of a multiplexer to the program to display the correct reading. By multiplexing the switching frequency of 200Hz three 2N2222 transistor, a first excitation method to achieve the display unit.

No comments:

Post a Comment

Please comment