Friday, September 11, 2020

PLC reads temperature data from LM35 with display

Overview

In PLC control application, a thermometer is required to get the environment's temperature. For example, keeping a water heating system at a preset temperature.

With a tiny open-source DIY PLC such as LDMicro, this job could be done easily at low cost for a dozen of Dollars. Using this DIY features, all system set up and maintenance is in the hands of the system designer. It doesn't require any expensive industrial standard PLC. The overall system needs only a dozen of most typical electronics components with a noticeable 8-bit microcontroller.

PLC reads temperature data from LM35 with display
The PLC reads analog temperature data from LM35

The input to the PLC is an analog temperature data linear to the analog voltage. LM35 create an analog voltage output of 10 mV per degree Celsius. Without any floating data type support in this PLC platform I can only use the unsigned 16-bit integer data type. This analog temperature device could convert the temperature between -55 to 150 degree Celsius. However, to read an analog temperature value we need a negative voltage reference. Using the external voltage reference pins need more ladder diagram instruction and external voltage reference circuits. So I ignore the negative temperature reading here.

PIC16F876 is selected as the CPU of this software-based PLC due to a rich of components stock. The CPU clock at 20 MHz, supplied at +5 V DC. The PLC cycle time is 1 mS to make an ability  refreshing the multiplexed seven segments display.

The display is a 4-digit multiplexed common cathode type. The temperature data requires three digit for the 150 degree Celsius maximum reading. The remanding one digit displays "C" represents the degree Celsius.

I assume to make a lamp turn on whenever the temperature reaches the preset temperature value.

Ladder Diagram In LDMicro

A cyclic timer schedule the analog read A/D converter instruction to convert the ADC for every one second.
A circular counter increment instruction increase its value for ever 2 mS. This counter turn on each digit of the multiplexed display 2 mS each.



A piece wise linear table creates a relation between analog voltage and temperature data. Two analog reading value represents one degree Celsius of temperature.

PLC reads temperature data from LM35 with display
Ladder Diagram representation for this example

Division, modulo and MOV instructions are used for processing each digit of temperature data.



PLC reads temperature data from LM35 with display
Schematic Diagram

The remanding PLC configurations and MCU pin selection list below.

PLC reads temperature data from LM35 with display

Click here to download the zip file of this working example.


No comments:

Post a Comment

Labels

ADC (10) Analog (14) Arduino (12) Atmega16 (19) Audio (2) AVR (20) Charger (1) Cortex-M0 (1) Counter (10) CPLD (25) Digital I/O (22) Display (34) EEPROM (2) Environment Sensor (1) esp8266 (2) Experiment Board (10) I2C (4) Interrupt (7) LCD (1) LDmicro (29) measurement and instrumentation (7) Microchip Studio (3) MikroC (1) One-Shot (3) OpAmp (1) PCB (31) PIC16 Microcontrollers (16) PIC16F877A (2) PIC16F887 MikroC (22) PLC (35) PWM (11) Regulator (1) RTC (2) Sensor (8) Shift Registers (5) SPI (5) Timer (34) UART (2) ultra-sonic sensor (1) USB (1) VHDL (21) xc8 (1) XC95108 (9) XC9536 (15) XC9572 (1) Xilinx (23) Xilinx ISE (22)