Overview
The Corey-VR-01 controller board (PCB) is based around a Raspberry Pi Compute Module 4 (CM4), to control the gas bottle vending machine. Things connected to the PCB are;
-
Computer Graphics Display, via HDMI
-
Cameras, via USB
-
4G Router, via Ethernet
-
Payment Terminal, via USB
-
Touch interface on Display, via USB
-
12VDC controllable power supply for 4G Router.
-
12VDC controllable power supply for Payment Terminal.
-
12VDC controllable power supply for Display/Touch screen.
-
Motor Driver for primary Carousel
-
3 Solenoids to open doors
-
3 Door sensors
-
4 Auxiliary outputs, for instance Lighting.
-
Totally 12 USB 2.0 ports
-
Optional, Secondary Carousel interface
-
Colibri Subsystem
-
1 MCU slot
-
7 I/O Expansion slots
There are many CPUs in this system.
-
CM4 - running Linux, imaging, and business-oriented software
-
Machine Interface - A STM32F103CBT6 that communicates with CM4 via serial port, and handles the primary external hardware.
-
Colibri MCU - Responsible for handling the Colibri subsystem, i.e. the 7 I/O expansion ports and the interface circuitry used. Several options are available and more to come. Communicates with the CM4 over a serial port.
CM4 GPIO
The PCB is somewhat compatible with previous system, although a migration path exist to use the Machine Interface MCU instead (selectable via jumpers on the PCB).
-
GPIO0 - Subsystem Reset
-
GPIO1 - Colibri "Boot" pin, for reprogramming
-
GPIO2 - RCMP output
-
GPIO3 - F/R output
-
GPIO4 - UART3 Tx
-
GPIO5 - UART3 Rx
-
GPIO6 - Home Sensor
-
GPIO7 - Door Sensor 3
-
GPIO8 - UART4 Tx
-
GPIO9 - UART4 Rx
-
GPIO10 - Door Activator 2
-
GPIO11 - Door Sensor 2
-
GPIO12 - UART5 Tx
-
GPIO13 - UART5 Rx
-
GPIO14 - UART0 Tx
-
GPIO15 - UART0 Rx
-
GPIO16 - SV Out
-
GPIO17 - Gas Sensor
-
GPIO18 - (future use)
-
GPIO19 - Watchdog Enable, Active LOW
-
GPIO20 - Watchdog Kick (toggle <1 second)
-
GPIO21 - Compartment Sensor
-
GPIO22 - HV input
-
GPIO23 - HW input
-
GPIO24 - Door Activator 1
-
GPIO25 - Door Sensor 1
-
GPIO26 - Door Activator 3
-
GPIO27 - HU input
Note that most legacy GPIO pins are expected to be migrated to be handled by the Machine Interface MCU, with the notable exception "Gas Sensor"
Machine Interface
Raspberry Pi running Linux is not suitable for real-time (or near real-time) tasks. So there is a separate STM32F103CBT6 MCU to handle the inputs/outputs of the device. The MCU has 20kBytes of RAM and 128kB of Flash memory. The CM4 is connected via a serial port (UART4) and a protocol needs to be established.
Digital Outputs
None of the digital outputs are current limited, and they will most likely be destroyed if too much current is flowing. The exception is the RCMP that has a fuse that will blow, and need to be re-soldered in that case.
The following outputs are driven directly with power MOSFETs, capable of sinking 250mA and have a 1kΩ pull-up resistor to +5V. They are not driving any heavy load.
-
SV, a PWM signalling output to control the speed to the motor driver
-
F/R, Forward/Reverse control to the motor driver
The following digital outputs are capable of driving additional loads.
-
RCMP, on ON/OFF power switch to the Motor itself. +24VDC, max 25Amp.
-
Door Activator 1, 2 and 3
-
OUT1 - OUT4, general purpose output that SINK 3 to 5 Amp (voltage and temperature dependent) to GND
Digital Inputs
The following digital inputs are MOSFET inputs, with ~1-2V threshold voltage.
-
Door Sensor 1, 2 and 3
-
Compartment Sensor
-
Home Sensor
I2C Devices
Inter-Intergrate-Circuit (or I2C for short) is a well-established standard for communicating within a PCB or directly coupled (without cabling) PCBs. There are countless number of devices available on the market, and interoperability is extremely high. Physically I2C consists of Clock (SCL) and Data (SDA), both being pulled to VCC externally. Each device that are driving either of these lines are so called Open-Drain outputs, i.e. can only sink to GND. This means that it is possible to detect that multiple devices are trying to access the line at the same time, hence Multi-Master is possible, and utilized in Corey-VR-01 (more later).
Devices either have 7-bit addresses or 10-bit addresses, where the latter is not very common. Addresses are left-shifted by one, so they occupy Bit1 to Bit7 in the first byte being sent. Bit0 indicates whether a read or write operation will follow. This is a little bit unfortunate, as some vendors state the address without the left shift and some with the left shift. Most vendors includes bit-level diagram on which 1s and 0s are sent, and that is what to rely on.
The Colibri subsystem uses I2C to communicate with each of the IO Expandion slots. And to ensure that I2C address conflicts is not a problem, there is a TCA9548 I2C Multiplexer. Each IO slot has its own dedicated multiplexed I2C bus.
But then there is C_SCL0 and C_SDA0, that is the Bus0 on the TCA9548 and connects everything on the PCB itself. There are TWO masters for the TCA9548 and it is important that very strict access rules are in place. The Colibri MCU should be able to assume that it has full control of the I2C bus. For the CM4 to get access, a protocol over UART3 should exist where the CM4 tells the MCU to relinquish the control. This is important. Technically it is possible to instead put the MCU into BOOT mode, but not recommended.
TCA9548 I2C Multiplexer
One simply write a bit mask of which busses should be turned on. It is very seldom useful to enable more than one bus at a time.
SHT40I Temperature & Humidity sensor
This sensor should be used to monitor at the PCB level. It is recommended that these values are logged once every hour and stored in, for instance, RRDtool which is a cyclic database that allocates all disk space needed up front.
TCA6424 Digital Expansion
There are two TCA6424 on the PCB. One (U37) is for the Colibri system to manage power, reset and a chip select for SPI for the IO Expansion slots. The CM4 should not bother with this device at all. The second (U58) is to allow the CM4 to turn off the power to USB ports and the 3 external power jacks.
EMC2301 Fan Controller
The CM4 has a heat sink on it to keep it cool. If/when that is not enough, we mount a small fan as well. There should be a driver in BalenaOS for using this controller to keep the internals of the CPU cool enough.
M24C64 EEPROM
64kBits of EEPROM is not a lot and it is meant for Fabrication Data only, i.e. Bali Automation writes testing results into this. Exact layout will follow later.
SPI Devices
The SPI bus is only accessible from the Colibri MCU as the master. Each IO Expansion slot has SPI connection and chip select for each. The PCB has a 128Mbit SPI flash memory for general-purpose use. The intention is to store code, parameters, configuration and/or collected data that are associated with the PCB (indirectly the machine) and not necessarily the CM4 (in case it needs to be changed). That could be name, id and/or location information, service data, malfunction codes and more.
USB
The USB subsystem is fairly extensive, with 12 external USB ports plus a separate USB hub for the Colibri system with one USB going to each expansion card. Note that only the Colibri MCU can access the Colibri IO Expansion system directly. Each USB port has two LEDs, to indicate whether something is connected and whether it is "High Speed" (up to 480Mbps) or "Full Speed" (up to 12Mbps). The USB-C connector on the middle of the PCB is for loading boot image on the CM4. It can possibly be used for some service tasks, as USB OTG, but when it is connected, the CM4 is disconnected from the USB hubs on the PCB.
Power Supplies
The PCB must have a voltage higher than 12VDC as input. The exact number various from unit to unit, but a safe value is that 15VDC is the guaranteed minimum input voltage. The maximum input voltage is a little bit more complicated. It depends on the ambient temperature, the load current on each regulator and the total load current on the whole device. Thermal analysis shows that at 60 ºC ambient temperature, the max input voltage is somewhere around 33VDC at max load current. At cooler than 30 ºC, 36VDC is the maximum voltage and doesn’t increase higher than that. 24VDC is the recommended input voltage.
Switching power supplies have the advantage that they preserve "power" as the voltage is converted up or down. So, if our 5V uses 4Amp, that is 20 Watts and that will require less than 1Amp at 24VDC input voltage. The efficiencies are depending on load current (goes up with higher load), so at maximum load current, the efficiencies in the LMR33630 that are used is ~95%, i.e. only ~5% will become heat. The PCB design is such that this heat is lead into PCB copper planes to dissipate. No forced cooling should be needed (experiments will be needed).
There are
-
Six 5V power supplies for the USB ports. Each connected to 2 USB ports and the power to such a pair can be turned off via the TCA6424. USB 2.0 has a specified max power delivery of 500mA (100mA before handshake) and these are current limited to ~650mA each.
-
One 5V/3A power supply for the CM4 module, Colibri subsystem and as input for the 3.3V power supply. This power supply has an optional hardware watchdog. If enabled (GPIO19 low), the CM4 MUST toggle the WD_KICK (GPIO20) at least twice every second. If not, then the power will be cut to this power supply and hence all the internal peripherals, and system will reboot. This is a common fail-safe mechanism, in case the CPU hangs due to electromagnetic shock (not that common nowadays) or there is a severe software problem that can’t be recovered remotely.
-
One 3.3V/3A power supply for most peripheral circuitry, incl the Colibri subsystem.
-
Three 12V/3A power supplies for the three external power supply jacks, marked Screen, Router and Payment.
Carousel 2 (optional)
The Carousel 2 expansion board is a second Machine Interface that can be plugged into the expansion socket on the lower half of the PCB. Functionality is identical to the Machine Interface with the following exceptions;
-
UART5 instead of UART4 to communicate with the MCU.
-
No CM4 pins can reach the digital inputs and outputs. It must be done via the MCU.
Colibri Subsystem
The Colibri system is a Bali Automation effort that was started before the creation of this PCB. It is a flexible I/O expansion system, with many I/O interfaces already available and more to come. Colibri is normally focused on LoraWAN communications and the primary MCU (MCU1) is a RAK3172 module, which in turn uses a STM32WLE5 MCU, that has the LoraWAN radio circuitry built-in. Colibri MCU2 and MCU3 are based on ESP32 MCUs and intended for ESPHome and Home Assistant users. Bali Automation will provide an additional MCU for VendingRobotics, based on STM32F103CBT6 to keep all MCUs in the system the same.
Bali Automation uses Mecrisp, a FORTH implementation for STM32 MCUs. This enables source code to be uploaded/stored on in the MCU, in each I/O module and on the carrier board’s memory. And source code can easily be uploaded via slow uplink, such as LoraWAN, or interactively via serial port.
Colibri has at the time of writing the following I/O modules available;
-
Colibri AIC - 0-20mA analog input, 2 channels
-
Colibri AIV - 0-10V analog input, 2 channels
-
Colibri AQV - 0-10V analog output, 2 channels
-
Colibri DII - Digital input Isolated, 2 channels, with co-processor for things like pulse counting.
-
Colibri DIU - Digital input Unisolated, 4 channels, with co-processor for things like pulse counting.
-
Colibri FET - Digital output, MOSFET, 2 channels
-
Colibri SSR - Digital output, Solid State Relay
-
Colibri PID1 - Pt1000/Ni1000 temperature input, 0-10V output, co-processor with PID algorithm
-
Colibri Pt1000 - Pt1000/Ni1000 temperature sensor interface, 2 channels
-
Colibri RS485U - RS-485 tranceiver and co-processor for protocol implementations.
-
Colibri Triac1 - Triac digital output, 4 channels (NOT AVAILABLE for Corey-VR-01, as it requires 24VAC power supply)