WOLFRAM SYSTEM MODELER

SimpleONOFF

A simple On/Off controller

Diagram

Wolfram Language

In[1]:=
SystemModel["ModelPlug.Examples.SimpleONOFF"]
Out[1]:=

Information

Hardware Components Used

  • 1 Arduino
  • 1 LM35 temperature sensor
  • 1 2N2222 transistor
  • 1 1N4001 diode
  • 1 resistor 1 kOhm
  • 1 relay 5 V
  • 1 external 5 V power source
  • 1 heater or fan

Description

This example is a simple ON/OFF controller and can be used for either heating or cooling. It uses an LM35 to read the temperature, and based on that temperature, the controller switches a relay on or off. You can attach a fan or a heater to the relay, depending on the operation you want to perform. You can find the diagram in the figure below.

The target temperature is set by a constant component. The measured temperature is subtracted from the reference in order to obtain the error. The error signal is fed into the hysteresis component, which will send a Boolean signal to control the relay. If you want cooling instead of heating, you need to invert the logic of this signal.

Pin A0 for the Arduino UNO corresponds to pin number 14 for the Firmata. For other boards, the pin numbering may be different. If you have a different board, you can refer to the board capabilities that is printed when the simulation is started to see what pins are mapped to what ports. For the Arduino Lenoardo, A0 is mapped to pin number 18.

Note: You need to be careful when using relays that control electrical equipment using AC voltage, as an incorrect connection may damage your board.

Components (6)

arduino

Type: Arduino

Description: Component with default configuration for Arduino boards

analogInput1

Type: AnalogInput

Description: Reads an analog signal from the specified pin

reference

Type: Constant

Description: Generate constant signal of type Real

add1

Type: Add

Description: Output the sum of the two inputs

digitalOutput

Type: DigitalOutput

Description: Writes a digital signal to the specified pin

hysteresis

Type: Hysteresis

Description: Transform Real to Boolean signal with Hysteresis