Showing posts with label PSoC. Show all posts
Showing posts with label PSoC. Show all posts

Monday, December 27, 2021

Wireless temperature display with bare glass LCDs

First completed: 2018

Introduction

I had previously developed a simple wireless temperature display system using a network of battery-powered transmitters which transmit the temperature from their current location using low-cost 433MHz AM transmitters spread around the house to a custom-made display unit. I wanted to add a second display to show the temperatures from the same transmitters in another location, and also wanted to take the opportunity to experiment with the LCD drivers that are built into selected Cypress PSoC microcontrollers.

The PSoC 4 is a microcontroller based around the ARM Cortex-M0 processor core which features a comprehensive range of built-in peripherals and a small amount of programmable logic.

The LCD

The DGL-0401YG-4EH LCD was included in the Kemo Electronic S043 "lucky bag" of surplus displays and likely originated as a heating controller display. Such a supply method would be completely inappropriate for a commercial product due to no guarantee of supply, but for a hobby project it's fine.

the LCD has 4 common pins and 12 segment pins, meaning it is designed for 1/4 duty cycle multiplexed operation. The waveforms for multiplexing an LCD are more complex than for multiplexing LED displays because intermediate voltages are required and DC bias must be eliminated to avoid long-term damage to the LCD, so they're usually generated using a dedicated driver IC or by an LCD driver peripheral built into certain microcontrollers.

The PSoC's LCD driver is capable of up to 1/8 duty or 1/16 duty depending on the part chosen, so driving this LCD is no problem. In theory, multiple 1/4 duty LCDs could be wired for 1/8 or 1/16 duty to save I/O compared to using 1/4 duty, but there's a catch! The lower the duty (higher the denominator), the smaller the viewing angle becomes, which means that the LCD only has good contrast over a smaller range of viewing positions.

Ultimately, due to the amount of I/O available on the CY8CKIT-042, 1/8 duty was chosen as a good compromise between the viewing angle and number of I/O used. Some of the heating-related symbols were unused, so not all of the segments needed to be connected either. The segment lines for the °C symbol could also be commoned to save a further I/O line as there would be no need to control these symbols individually.

The one button added to the front switches the backlight brightness between three levels.

Wireless communications

The 433MHz transmission system is a very simple system which does not define a protocol and is unidirectional, which means an unlimited amount of receivers can be added without any changes needing to be made to the firmware in the transmitters. The task of decoding and receiving the data was passed off to an NKM2401 to save time and due to reasons relating to the design of the temperature transmitters which was done previously, but it wouldn't be difficult to implement this directly in the PSoC. For debugging, the 3.5mm jack in the bottom left corner can be connected to a computer serial port with a PICAXE programming cable and serves the dual purpose of allowing the monitoring of the received packets and the generation of test packets.

The data is transmitted in 8 byte packets. The first byte represents the ID of the temperature transmitter and is unique to each transmitter; the display unit uses this ID to decide which of the four LCDs should be updated with the newly received temperature. The second byte represents the type, allowing for future expansion with types other than temperature (e.g. humidity). Bytes 3 and 4 contain the temperature, bytes 5 to 7 are unused/reserved, and byte 8 is a very simple checksum which augments the error detection already implemented in the NKM2401.

Tuesday, January 21, 2020

PSoC USB 3.0 Current Meter



Completed project photo
Completed project photo
First completed: June 2018

This project is a USB current meter based on the Cypress PSoC 5 microcontroller. The PSoC is an innovative microcontroller which combines a CPU with a small amount of programmable digital logic and some advanced analogue peripherals.

The objective was to implement it using as few external components as possible, by utilising the advanced peripherals built into the microcontroller. I also wanted it to support USB 3.0, because many USB power meters only support USB 2.0, meaning they cannot be used to measure the operating current of devices plugged into a USB 3.0 port - a typical use case is seeing if a phone increases its charge current to 900mA when plugged into a USB 3.0 port. Another objective was that the update speed needed to be fast, since many commercial meters have a very slow refresh rate. Additionally, it needed to support higher voltages than normal USB, so that it could be used to measure the voltage of "fast" chargers.

PSoC 5 microcontrollers are only available in surface-mount packages, so I've chosen the CY8CKIT-059 development kit so that I can build the circuit on stripboard.

To avoid potential signal integrity issues, I cut into a cable and just connected the power lines to the stripboard instead of adding my own USB connectors to the board. The current sensing is done using a 0.05-ohm resistor (the metal strip next to the cable) which is connected directly to two PSoC pins, and the voltage sensing is done using a normal potential divider connected to a third pin. The PSoC is powered from a 3.3V regulator in the TO92 package. Finally, the 7-segment displays are connected via current limiting resistors. The display is multiplexed to reduce the number of I/O required.

Top view of stripboard assembly
Bottom view of stripboard assembly

The PSoC design is very simple. The peripherals are easily configured using a block diagram. The differential delta sigma ADC is used to measure the current. The input range and gain can be configured to allow even small voltages to be measured with good precision. The successive approximation ADC is used for the single-ended USB voltage measurement. Both ADCs can use internal voltage references, which should prevent the supply voltage from affecting the ADC readings.


In addition to the block diagram, the CPU needs some code to handle the remaining functions: responding to the ADC ISR, filtering the readings, and converting the readings into digits to display on the 7-segment displays. The LED Driver takes care of the display multiplexing, so there's no need to program a timer ISR for that.

The project met the goals, and it can accurately measure the current and voltage of a USB connection. The PSoC microcontroller enabled a high level of integration not normally possible with traditional microcontrollers, which would enable the PCB to be made much smaller should size be a design consideration.

It should be noted that the delta sigma ADC is only included on the higher-end PSoC chips, and that the lower-end chips have a lot less peripherals and programmable logic. The CY8CKIT-059 is a loss leader with the PSoC chip itself being more expensive, so you must trade off cost for convenience and board space when selecting the PSoC. You can now (2020) buy a USB 3.0 power meter for less than it would cost to build this PSoC-based meter, so the PSoC may not be the best choice for a product where cost is important. I do however think the PSoC is a great fit for low-volume high-margin products, with or without size constraints.

Large dot matrix clock, timer and scrolling message display

First completed: August 2014. Additional work carried out late 2025/early 2026. Introduction Previously, the author had made a very small ...