29 - 11 - 2020

Temperature control of 12V lamp

Experiment: Temperature control of a surface of 12V electrical lamp.

AltonaLab diagram: KIT_TempControl.nsm

Used hardware:

  • Numato 8 channel USB GPIO Module;
  • Connector board for ADC 5V;
  • AltonaLab temperature sensor;
  • 2 relay controller;
  • Lamp 12V;
  • 5V multi connector power supply board;
  • 220V to 12V, 2A power supply;

The experiment is very interesting, we will control a temperature of a surface of an electrical lamp. For this purpose we will touch the black sensitive element of an AltonaLab temperature sensor to the surface of an electrical lamp.

A view of the hardware diagram is shown below. GPIO 0 of a Numato board is used as analog input where the output of the temperature sensor is connected. One of the relays of a Relay board is controlled by a GPIO 4 of the Numato board. GPIO 4 is set as a Digital Output. The 12V power supply is connected to the first input connectors of a 5V power supply board. The second input connector, which is with the same voltage 12V is connected to the next board - 2 relay controller.

 

A real image of the connected boards. Please note how the black sensitive element of AltonaLab temperature sensor is touched the surface of a lamp!!!

An image of a running diagram:

 

The diagram consists of the following controls:

  • A Text contol in red color in the upper left corner of the diagram - shows the current temperature of the lamp surface;
  • A Lamp control in the upper right corner - indicates whether the lamp is ON. If the Lamp is Turn ON, its temperature increases;
  • A graphic control, where in a blue color is shown the desired temperature, which is set by the scroll bar below, in red color is the real current temperature of the surface of the lamp. The temperatures are shown in range 10..60[C];
  • Under the graphic control is located a blue text control, which shows the desired temperature of the lamp;
  • The bottom control is a scroll bar that sets the desired lamp temperature. It is set to work in range
    20..50[C], which means the desired temperature can be changed in this range;

Before starting the diagram, the ComPort of a Numato block has to be set. Move the temperature sensor by hand so that its black sensitive element to touch the glass of the lamp and then run the diagram. Then move the position of the scroll bar at right, which will increase the desired temperature of the lamp. For example, set the desired temperature to 30[C]. Because the desired temperature is over the temperature of the lamp, the lamp will Turn ON and its temperature will start to increase. When the temperature of the surface of the lamp increases over the desired temperature, the lamp will Turn OFF and the temperature will start to decrease. This loop will continue to infinity.

How the diagram works:

  • Numato block - the block works in the faster possible mode. The parameter CommunicatePerSec is set to Zero, which means that commands to the device are sent immediately one after the other. Additional the parameter FastMode is checked, which means all the software time delays are close to Zero. GPIO 0 is used as analog input, the measured value of the analog input is presented as block's analog output IO00. GPIO 4 is used as digital output and is presented as digital input IO04 of the block. This means, when the digital input of the block IO04 becomes to a high level, the digital output GPIO4 of the Numato device will become to a 5V level. After each reading of the value from the analog input, the OnRead output becomes to a high level for a short time and this event signals the next block to process its calculations.
  • AltonaSensorTemp - the block converts the measured RAW data of the analog input of the Numato board which is in range 0..1023 to temperature. The parameter QueueSize is set to 5, which means the block calculates the average value of the last 5 measurements. Output of the block is a Current temperature of the surface of the lamp and is shown with the red text control at the top left corner of the diagram. The block calculates its values each time when the input Process becomes to a high level.
  • Block ScrollBar is connected to the ScrollBar control. When the scrollbar control is scrolled, the output of the block also changes. The range of the scrollbar is set to 20..50. With right mouse button click over the scrollbar control can be changed its parameters Min and Max which inthis diagram are used for minimal/maximal values of the desired temperature;
  • At the block ExpressionUni, theexpression of the output Y1 is set to X1-X2, which means the block is used to subtract the current temperature from the desired temperature. The block will calculate the expression only when the input DoCalc becomes to a high level. This happens each time when the previous block is ready with its calculations. At this diagram, the calculations are a few times per second;
  • The difference between desired and current temperature is an input of the SchmittTrigger block. The block has two parameters HiHysteresis set to 3 and LowHysteresis set to 0. More about this trigger can be read at the URL below:

https://en.wikipedia.org/wiki/Schmitt_trigger

The block is very interesting and important in diagrams, which are used to control some processes as temperature. When the input value of the block becomes over the HiHysteresis value,the output of the block becomes to a high level. Then the output of the block will become back to a low level, when the input becomes under the LowHysteresis value. So it is important to know that - when the difference between LowHysteresis and HiHysteresis is small, the lamp will Turn ON and OFF very often and this will reduce the life of the lamp and relay, but the error between desired and real temperature of the lamp will be small. If the difference between  LowHysteresis and HiHysteresis is big, the lamp will Turn ON and OFF less often, this will safe the life of the Lamp and relay, but the error between desired and real temperature will be bigger.

  • Logger of desired and current temperatures is organized by blocks DataSetStorage and DataSetImage. DataSetStorage is similar as DBFStorage block, but saves the input values only in the computer's memory instead in DBF database, which is enough for the current experiment. At its parameter Settings are added three values: Temp from analog data type, DesTemp from analog data type and Date from date data type. Inputs with same names are appeared at the block. The block is set to save last 10 min of the values in the computer's memory. The block's parameter DataSet is shown below:

Each time, when the block's input Append becomes to a high level, a new record with current values of inputs Temp, DesTemp, Date is added to the computer's memory. Records oldest than 10 min are deleted automatically from the DataSet.

The next block DataSetImage shows the saved in memory values from the previous block to the Image control.