Jan 24, 2018

Water Level Sensor of Washing Machine (STM32F103C8T6)

Typical work principle of water level sensor of a washing machine shown on the picture. Sensor is located above the water level and connected by an air tight tube to the bottom of the tub. When the water level increase, the pressure in tube increase as well due to gravitational force.

The sensor convert pressure to frequency by placing an ferrite bead on a diaphragm in an inductor. The variation of inductance then converted to frequency by a chip and some passive components.
The frequency has a quite linear correlation to water level. In the curve, 26 kHz generated when water level 0mm, and 23 kHz when water level 200mm. In practice, 400mm water level will generate 20kHz.

The sensor looks like the picture  at left side. There are three pins which are GND, OUT, VCC or sometimes VSS, OUT, VDD (5VDC). If you are not sure, you can check the forward voltage of the pins since there is a protection diode between VDD and VSS. When the forward is about 0.4-0.6V meaning the plus lead of multimeter is VSS and minus lead is VDD because the protection diode is installed in reverse polarity.

Two pin type sensor is not usable for this project because it contains only inductor without L to Fconverter. Two pin type is suitable for the system which converter located in the washing machine controller.

I made 10 sampling per second so the pulse count range is 2627 down to 2000. You can convert the range of reading to 0-100% or 0-400mm depending on your application. Connect a plastic tube to the sensor, blow the tube with your mouth to simulate the water level change.

You can get the code here https://drive.google.com
It was compiled using Coocox CoIDE and GNU Tools ARM Embedded however other compilers will do.

Nov 24, 2017

MAX7219 8-digits 7-segment (STM32F103C8T6)

I made MAX7219 for C51 but now I need it for STM32F103 too.
The wiring is simple:
MAX7219_CLK   hooked up to PORTA0,
MAX7219_DIN  to PORTA1,
MAX7219_CS    to PORTA2.

The software initiate the clock, GPIO, MAX7219 and then display is ready to use.
Just call _DisplayInt procedure and pass the value, it will display the integer on the seven segments.
If you need to turn-on the decimal point, just add 0x80 to the digit to display, example:
0x08 is the digit number, 0x80 is the command to turn on the decimal point.

Get the code here https://drive.google.com

Oct 15, 2017

MCP4725 I2C 12-bit DAC (STM32F103C8T6)

This breakout development board can be bought easily online. The interface is I2C.
For other microcontroller, it's easy to hook up because wire.h library can handle it. For STM32F103, the example codes doesn't work. It seems the I2C interface get some error. That's the reason why I don't use I2C interface but I emulate the GPIO instead.

The code will init the GPIO, then zero the DAC and send increment count from 0 to 4095. The maximum voltage output depends on the VCC, in my case is 3.3V. In many examples found on Google, the address is before left shifted ie. 0x62 or 0x61 but in my code the address is 0xC4 because directly implemented to I2C interface. This circuit will be useful for my 4-20mA project Rev3. Using STM32F103C8T6, 7-segment display, DAC, step up DC/DC and V/I converter, Rev3 will be much easier to build.

You can get the code here https://drive.google.com.
Please send me your comment to silvester.dao(a)gmail.com .

Jul 2, 2017

DHT-11 Humidity and Temperature Sensor (STM32F103C8T6)

This project is to get humidity and temperature readings from DHT-11 and show them on 4-digit seven segment display TM1637.

Microcontroller pin connections are:
PORTA Pin_0 for TM1637_CLK (Display)
PORTA Pin_1 for TM1637_DIO (Display)
PORTA Pin_2 for DHT11_1Wire (Sensor)
and of course VCC and GND to every module.

Get the code here https://drive.google.com.

Aug 2, 2016

4-Digit Seven Segment Display TM1637 (STM32F103C8T6)

TM1367 is a LED drive and keyboard scan controller but in this application it is uses for driving 4 digits seven segment display. There are 4 wires connecting the display and the microcontroller:

Display : MCU 
GND     - GND
VCC     - 5V
DIO     - Port A1
CLK     - Port A0

It communicates using I2C protocol, that's why the code has below procedures:
- TM1637Start(void);
- TM1637Stop(void);
- TM1637ReadAck(void);

The example code init the mcu, init the TM1367 and then display integer counting from 0-9999 repeatedly. Get the code here https://drive.google.com.

Aug 21, 2010

5x32 Matrix SMD LED (AT89C2051)

Part used: AT89C2051 MCU, 74HC595 (8-bit shift register) and FCS9012 general PNP transistors 600mA.

Data is sent to the shift register by MCU through P3.7 and clocked through P1.1. When 32 bits data has been shifted, latch signal on P1.0 activated (positive pulse). Now, time for the row selection works. Initially all P3.0..P3.4 are high, no LED energized then P3.4 turn low to energize first row.  After a while (about 6.7ms) new data sent to shift register, first row turn off (P3.4 high) and the second row turn on (P3.3 low). 1st..5th row scaned continuously by MCU to generate 30 fps, so LED blinking during row multiplexing is not realized by eyes. The multiplexing is done by timer interrupt, not just determinstic time also auto reload meaning it will do the interrupt repeatedly. Forgot to tell that there are 180-220 ohms resistor on each output of 74HC595 before go to the LED cathode.

Get the code here https://docs.google.com

STM32F103C8T6 Blue Pill Pinout