In this post, a special purpose circuit, namely Silo Emulator is briefly presented.

Overview

Silo emulator is an arduino-based board implementing the full (incl. mixer and heater) silo interface as described in the liqueur plant case study. It was developed with the intention of testing the control system for an industrial plant, developed as part of my thesis, but at a later time it was used as a lab equipment for “Advanced Programming Techniques” class of Electrical & Computer Engineering department, University of Patras.

Briefly, it emulates a physical industrial liquid silo equipped with sensors (full, empty, thermometer) and actuators (heater, mixer, input valve, output valve).

Silo Emulator's 3D model

Silo Emulator’s complete documentation is available here

Circuit implementation details

I won’t go into too much detail but in order to drive all the necessary LEDs, a power shift register (serial-in parallel-out register integrated with one open-drain DMOS transistor on each of the outputs) was utilized. Conveniently, the total number of the LEDs on the board (apart from the 7-segment display) is exactly 16, hence two 8-bit shift registers were adequate. As for driving the temperature indication (two 7-segment numeric displays) the solution of a LED display driver IC (MAX7219) was adopted.

The circuit was designed to interface directly with 3.3V controllers and arduino nano logic level is at 5V, therefore some level shifting was required. The inputs of the board could be connected directly to the input-declared I/O pins of the arduino nano. That’s because AVR328p’s datasheet states that for Vcc=5V, Vih=3V, which means that a 3.3V signal will register as logic high. The TX signal of the serial connection was shifted to 3.3V with a voltage divider (2KΩ,1KΩ resistors) and the output binary signals were level-shifted with resistive-load single-NMOS inverters. Different technique was used on the latter considering these outputs ought to be active-low.

Software architecture

The firmware was designed in an object oriented fashion and is based on three main classes.

  1. InputsHandler: This singleton class constantly reads the inputs of the circuit, encode their current values in a byte and passes this byte to LogicImplementer by invoking LogicImplementer.setCurrentInputs() method.
  2. LogicImplementer: This (also singleton) class implements the core logic of the emulation. It internally uses two timers for the necessary (for liquid level and temperatures time-dependent changes) time keeping. When a timer event denotes a change of the temperature it invokes method setTemperature() of class OutputsHandler. At the same time, whenever the method LogicImplementer.setCurrentInputs()is invoked, it calculates (according to the current inputs’ state) the current state of the silo and subsequently the value of all the binary outputs of the circuit. If any output’s value has changed and should be updated, it invokes OutputsHandler.setOutputs() method and passes to OutputsHandler the output’s values encoded in a 16-bit word.
  3. OutputsHandler: This class encapsulates the implementation-specific manner of transferring information from the microcontroller to the rest of circuit (SPI interface).

Demonstration

You can see a typical usage scenario of the circuit in the following video:

schematic

eagle cad project in github

silo emulator’s firmware

In this post, a GPIO expansion circuit for arduino pro mini with integrated power regulator is presented.

The circuit is designed to provide 32 input and 32 output extra pins but can be easily modified to provide an arbitrary number as it uses cascaded shift registers for both inputs and outputs.

The integrated 5V voltage regulator (D2PAK package) powers the whole circuit (that includes the arduino) and its input is conveniently exposed via a screw terminal located on the edge of the PCB.

Arduino IO expander schematic diagram

Inputs

Four 74HC165 8-bit parallel-in serial-out shift registers are daisy chained to provide the inputs while using only three pins of arduino(D9,D12,D13). Arduino provides hardware support for SPI protocol on these pins. All the 32 input pins are pulled-up to 5V with 10KΩ resistors. If no pull-up function is required, resistor networks rn0-rn7 can be omitted.

Outputs

The circuit was designed to be able to directly drive medium loads, hence, the power shift register IC TPIC6B595/TPIC6B596 (they are interchangeable) from Texas Instruments was adopted. This IC has a relatively high current sink capacity (outputs are DMOS transistors in open-drain configuration with Rds(on) of 5Ω) and can directly drive relays, solenoids, power leds etc. .The shift registers are cascaded and connected to arduino on pins D3(clock), D5(latch), D6(data). Their communication protocol is compatible with the 74HC595 IC so it is very easy to send them data with arduino’s shiftOut() built-in function.

3D representation of the fully populated PCB

eagle project files