CAN - Controller Area Network

Example C SocketCAN Code

Writing user space C code to talk to CAN devices via the Linux SocketCAN interface is relatively simple and efficient. SocketCAN uses the Berkeley socket API and hence is very similar to communicating with other network socket devices. Below is a simple guide to get you started reading, writing and filtering CAN packets. Official documentation for the SocketCAN interface can be found at: https://www.kernel.org/doc/Documentation/networking/can.txt Complete code for the following examples can be found at the following GitHub repository: https://github.com/craigpeacock/CAN-Examples These examples do not include make files. To build a source file, you can simply use gcc. For example, to build

CAN - Controller Area Network

Adding CAN to the Raspberry PI

The CAN bus (Controller Area Network) was originally designed by Bosch for the automotive market to connect ECUs (Engine/Electronic Control Units) together. Today, this robust communications bus is commonly found, not only in vehicles, but also on the factory floor in automation (e.g. CANOpen) and other applications such as PV solar inverter/battery Energy Storage Systems (ESS). The Raspberry PI doesn’t natively support CAN. The Broadcom SoCs (System on a Chip) used by the Raspberry PI doesn’t include a CAN controller. The Linux kernel supports CAN and includes SocketCAN drivers for the Microchip MCP2515 Stand-alone CAN Controller with SPI Interface. Various

Electronics Hardware

LT8490 MPPT Buck-Boost Multi-Chemistry Battery Charger

Most PV solar regulators are buck (step down) regulators and require the PV panel voltage to be above the battery voltage. This design uses a buck-boost topology and allows the PV solar voltage to be above, below or equal to the battery voltage. For example, you could charge a 48V battery bank from a 72 cell PV panel with a maximum power point voltage (VMP) of around 37V. The LT8490 allows for a PV panel voltage in the range of 6V to 80V. This makes it ideal for commodity 72 cell PV panels that typically have an open-circuit voltage (VOC)

Electronics Hardware

Review: Li-ion LiPo LiFePO4 Lithium Battery Active Equalizer Balancer Energy Transfer Board

Cheap Lithium Battery “Active Balancer” boards have been turning up on Aliexpress and other eCommerce sites. But there has been some scepticism if they are genuinely active balancing and quite a few conflicting forum posts. Some have even claimed the ‘1R0’ inductors are actually 1 ohm resistors. The more traditional passive balancer boards will simply dump any excessive charge into a resistor, wasting this energy. For example, if the maximum voltage threshold was set at 4.2V, once the cell’s terminal voltage exceeded 4.2V, any excess charge would be dumped into a resistor and dissipated as heat until the terminal voltage

Electronics Hardware

LTC4040 5V, 2.5A Uninterruptible Power Supply (UPS) with USB-C

Motivation I have had the requirement to back-up small 5V low-powered devices such as a Foscam C1 security camera and a Raspberry PI based LoRaWAN concentrator. Many commonly available 5V Uninterruptible Power Supplies feature a two chip design with a Li-Ion battery charger to charge the back-up battery, and boost converter to step up the battery voltage back up to 5V. Like most of my personal designs, cost was not a primary driver. I was on the search for a elegant, preferably single chip device that was fit for purpose. Lithium Ion batteries can be stressed when left at full

Electronics Hardware

Review: BQ24650 5A MPPT Solar Controller 3S / 4S Li-Ion, LiFePO4, 12V Lead Acid

Designs based on the Texas Instrument’s bq24650 Synchronous Switch-Mode Battery Charge Controller for Solar Power With Maximum Power Point Tracking are commonplace on Aliexpress, ebay and Amazon. Consumers can purchase assembled PCBs, such as the one pictured above, or complete product enclosed in a relatively nice aluminium extruded housing. According to the silkscreen of versions pictured on-line, different variants are available including: 3S Li-Ion 4S Li-Ion 4S LiFePo4 12V Lead Acid I’m still old-school and wanted to purchase a 12V lead acid version, but couldn’t find any available for sale. And like many similar electronics products from the above mentioned

Software

ATZ97 / M97 Series Programmable DC Load Modbus Interface Software

The Atten ATZ97 / Maynuo M97 Series programmable DC loads has a RS-232 port that can be used for instrument control and acquisition. Rather than using more conventional text based SCPI (Standard Commands for Programmable Instruments) commands, these instruments use Modbus, a protocol designed for PLCs (Programmable Logic Controllers). The M97 series loads come bundled with “M9700 Load Monitor Software” that does a reasonable job in controlling the DC load and recording data. However, I wanted to use the DC load in a test setup with a DC Power Supply to plot the efficiency of DC-DC converters. To accomplish this

Electronics Hardware

Powerpole Distribution Box

For far too long, I have been on the search for the ideal way to distribute power for low voltage systems, typically 12V. I have an small assortment of domestic networking gear, small embedded systems, LED desk lamps, battery chargers and USB chargers that operate from a backed-up 12V PV solar supply. I have finally settled on the “Powerpole” 15-45 connector from Anderson Power Products. The 15-45 denotes that the connector comes with terminals rated from 15 to 45 Amp. The housings are designed for voltages well exceeding 100V AC or DC depending upon your choice of UL or IEC certification.

Electronics Hardware

LT8390 Synchronous Buck-Boost DC-DC Converter

For the past couple of years, I have been powering my Sony 55” LCD TV and charging a couple of laptop computers from a 12V solar system. Both the Sony TV and the laptop computers have an input voltage of 19.5VDC. To step up the voltage from the battery, I purchased two “LTC3780 Automatic lifting pressure constant voltage step up step down 10A 130W” a.k.a. LTC3780 – High Efficiency, Synchronous, 4-Switch Buck-Boost DC-DC Converters from ebay. These boards operated from a moderately wide 5 – 36V input and had an output voltage range of 1 – 30V. The LTC3780 has

Electronics Hardware

Review: RAK8213 LTE Cat M1/NB1 IoT Modem

The RakWireless RAK8213 is a Quectel BG96 based 4G LTE Cat M1/Cat NB1/EGPRS modem in a PCI Express MiniCard Form Factor. LTE categories M1/NB1 combined with innovations including Power Saving Mode (PSM) and Extended Discontinuous Reception (eDRX) can rival power consumption and battery life of other IoT Technologies such as LoRa and Sigfox. The RAK8213 is available from Aliexpress for just $39.90 USD. The BG96 includes an integrated TCP/IP stack with HTTP and MQTT client, greatly simplifying firmware development. The RAK8213 features: LTE Cat M1, Cat NB1 (NB-IoT) and EGPRS. GNSS – Support for GPS, GLONASS, BeiDou/Compass, Galileo and QZSS. Ultra Low Power.

Embedded Linux

An Introduction to chardev GPIO and Libgpiod on the Raspberry PI

Linux 4.8 introduced a new GPIO user space subsystem for accessing GPIO. This tutorial provides an introduction to the new Character Device GPIO and explores how to control GPIO from the command line. sysfs GPIO User-mode GPIO (General Purpose Input/Output) has historically been performed via the legacy “integer-based”sysfs pseudo file system.  For example, to set GPIO25, one would: # echo out > /sys/class/gpio/gpio25/direction # echo 1 > /sys/class/gpio/gpio25/value GPIO access via this legacy sysfs interface has been deprecated since version 4.8 of the Linux kernel. chardev GPIO The new way of doing GPIO is via the “descriptor-based” character device ABI (Application Binary

Electronics Hardware

FTDI FT2232H USB to UART/MPSSE/JTAG Breakout Board

The FTDI FT2232H Hi-Speed Dual USB UART/FIFO Breakout Board provides a variety of standard serial and parallel interfaces: Asynchronous UART JTAG I2C SPI Parallel FIFO The board includes two linear regulators offering either 3.3V or 2.5V IO. An on-board Serial EEPROM stores custom USB descriptors, VID/PIDs and configurations. Design Files Design files can be downloaded from the Circuit Maker website. Circuit Maker is a free EDA tool from Altium. FT2232H Breakout version 1.A.1 Gerbers (Zip) FT2232H Breakout version 1.A.1 Schematics (PDF) The PCB for this design was fabricated by oshpark.com

Embedded Linux

Compiling U-Boot with Device Tree Support for the Raspberry Pi

U-Boot U-Boot (The Universal Bootloader) is a popular, feature rich, open source bootloader for embedded systems. It is licenced under the GNU General Public Licence version 2. While its primary purpose is to boot an operating system, such as Linux, it also provides many useful tools for developing and debugging embedded systems. This includes support for many common file-systems including FAT, ext3, ext4, NFS etc and interfaces such as USB, Ethernet (IP), MMC and even Asynchronous Serial (Kermit/xmodem/ymodem). This allows the developer to load new images and file-systems from a variety of sources for testing and/or reflashing. It also includes

LoRaWAN

RN2903: Using the LoRaWAN™ Library Plug-in for MPLAB® Code Configurator and customising for the AU915 Frequency Plan

The RN2903 Wireless LoRa Module from Microchip ships with an on-board LoRaWAN Class A protocol stack. This stack can be accessed via ASCII based commands over a UART interface. For many, this is the interface of choice, offloading the complexity of the LoRaWAN stack to a dedicated processor contained within the module. Another advantage is Microchip can fully certify the module and stack. I decided not to use the on-board stack for two reasons: Here in Australia, we must use the AU915 frequency plan. Microchip has beta firmware for this frequency plan, but it is not yet publicly available. Developers

LoRaWAN

Microchip RN2903 LoRa Transceiver Breakout Board

A breakout board for Microchip’s series of LoRa transceiver modules: RN2483 fully-certified 433/868 MHz Module (Europe) RN2903 fully-certified 915 MHz Module (North America, Australia) The RN2483/RN2903 LoRa modules contain a Microchip PIC18LF46K22 MCU with a Semtech SX1276 radio transceiver and is intended as a complete certified solution with LoRaWAN Class A protocol stack and an ASCII command interface over a UART connection. However, if you want to get under the hood, MicroChip provide details in the LoRaWAN Library Plug-in for MPLAB Code Configurator User’s Guide on how to target the on-board PIC18LF46K22 and customise the module for your own purposes. RN2903 Pin Out (XLSX) Design Files

Power

ML2032 Coin Cell Charger

This design is intended to recharge Maxell ML2032 Lithium Manganese Dioxide rechargeable coin cell batteries with a nominal voltage of 3.0V. These are ‘special’ coin cell batteries designed specifically as a rechargeable secondary cell. It is not recommended to attempt to recharge a primary CR2032. These cells have not be designed for recharging.  Background Rechargeable replacements of the popular CR2032 3V lithium coin cell battery exist, but one caveat is reduced capacity. The common CR2032 from name brand manufacturers such as Panasonic will have a capacity of approximately 220mAh. Rechargeable replacements of the CR2032 appear to come in a range of different chemistries.

LoRaWAN

RAK833/RAK2247 LoRaWAN Concentrator

This board is a Raspberry PI Hat for the RAK833/RAK2247 LoRa Concentrator Gateway Modules. The RAK2247 is improved version of the RAK833 with better heatsinking, a boost in the maximum transmission power and improved interference immunity. Both are a smaller version of the popular RAK831. The RAK831 is larger, about the same footprint than a Raspberry PI and requires a breakout board to convert the RAK831’s 24 pin connector to the Raspberry PI’s 40 pin connector. The RAK833 is a more elegant industry standard PCI Express Mini Card form factor (Type F2). The RAK833 module consists of a Semtech SX1301 Digital Baseband chip

Power

12V 7Ah SLA Low Voltage Disconnect

The 12V 7Ahr “alarm” battery is still a safe, dependable choice for stationary back-up supplies, running items such as LED lighting or modem/routers. Using two Keystone 3571 female PCB terminals, this PCB assembly attaches directly to the terminals of a 12V 7AH SLA Battery (with 4.75mm spade terminals) and provides a low voltage cut-out to protect the battery, and a fuse to protect wiring. The Maxim Integrated MAX8212 Micro-power Voltage Comparator with 1.15V reference switches a high side P-Channel MOSFET to disconnect the load. The MOSFET has a low on resistance of 4.1mOhms and a maximum current capability of 90 Amps well exceeding that of the battery. The