Aug 21, 2018

P10 Module x2 Running Text (STM32F103C8T6)

Interested to build a running text display made of two P10 modules?


The text looks shaky on video but actually not, recording quality effect I guess.

 What you need:
- 2 pcs P10 LED modules
- ribbon cable
- few jumper wires
- 5VDC 5A power supply
- STM31F103C8T6 blue pill module
- ST-Link V2



There are four wires connecting ST-Link V2 to STM32F103C8T6 module (for programming only):
- 3.3V to 3.3V
- SWCLK to DCLK
- SWDIO to DIO
- GND to GND

There are seven wires connecting STM32F103C8T6 module to first P10 module:
- PA0 to EN
- PA1 to SCLK
- PA2 to A
- PA3 to B
- PA5 to CLK
- PA7 to R
- GND to GND

Ribbon cable connects 1st module to 2nd module.
Power supply cables are a pair of 0.75-1.5 mmsq cable so it can handle 5A max. Power cable for STM32F103C8T6 module can be smaller mmsq as it draws few mA only.

The C code is prepared for CooCox IDE and GNU Tools ARM Embedded compiler.
Display scan is done by timer interrupt.
void TIM1_UP_IRQHandler ()
{
    if ((TIM1->SR & 0x0001) != 0)                  // check interrupt source
    {
        GPIO_ResetBits(GPIOA, OutEna); //IOCLR0 = OutEna;
        for (spi_count=0; spi_count<4; spi_count++) SPI0SendByte (~(((uchar *) &displaymemory[spi_count*4+rowscan])[7]));
        for (spi_count=0; spi_count<4; spi_count++) SPI0SendByte (~(((uchar *) &displaymemory[spi_count*4+rowscan])[6]));
        for (spi_count=0; spi_count<4; spi_count++) SPI0SendByte (~(((uchar *) &displaymemory[spi_count*4+rowscan])[5]));
        for (spi_count=0; spi_count<4; spi_count++) SPI0SendByte (~(((uchar *) &displaymemory[spi_count*4+rowscan])[4]));

Main function displays shifting left text in three different size font.
int main(void)
{
    SetSysClockTo72();
    mcu_init();
    shift_delay = 50;

    while (1)

    {
        LED_puts_font8x16("Font8x16        ");
        LED_puts_font8x8 ("Font8x8        ",0);
        LED_puts ("Font 5x8           ", 0);
    }
}


You can buy the code here. After payment, the code will be sent to your email.
You can contact me on silvester.dao(a)gmail.com or +62 813 7171 25 twoseven.



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.








Typically 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 F converter. 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 from the link https://drive.google.com
The code was compiled using Coocox CoIDE and GNU Tools ARM Embedded.
Anyway 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:
MAX7219_SendAddrDat(0x08,LEDcode[(a/10000000)]+0x80);
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 https://drive.google.com.
Please send me your comment to silvester.dao(_)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.

You can get the code 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 communicate with 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 https://drive.google.com.

Feb 24, 2015

Midicom vs RPi2

Once in microcontroller lab I was coding  Midicom 8085 based microprocessor. The speed was 4MHz, 64kB external ROM and 64kB RAM also external. It could run monitor program or simple BASIC. It had off chip video, keyboard, 7segmens, tape and speaker (not audio) interface. RS232 was there but no ethernet.





And now... I got Raspberry Pi 2 with quad-core ARM Cortex A7 microcontroller, internal flash and 1G RAM, running on 900MHz clock. It has HDMI, AV, microphone, camera, LCD, Ethernet. USB ports can be connected to keyboard, mouse, thumb drive, hard disk, wifi dongle or any other USB device if you have the driver. The more important thing is ethernet because IA and IoT is predicted to be potentially very dangerous in future.














Oct 5, 2014

P10 LED Controller (AT89S52)

This is P10 LED module. Each module contains 16x32 single color LEDs, could be red, yellow,
green, blue, white or purple. The controller normally using SPI of ARM mcu which powerful enough to handle several module connected in series and  more than one module rows.
There are two types of P10, semioutdoor and outdoor; the difference is obvious but the enclosure you use determine the protection level (drizzle, rain or heavy rain).
Example from ebay: http://www.ebay.com/itm/Red-LED-Display-Module-Board-Window-Sign-P10-PH10-16X32-Matrix-DIY-/190502734646

This is for experimental purpose only, I try to show small, medium and large font running text on single LED module. I use AT89X52 this time, because it doesn't have SPI then I have to simulate the SPI by the software.




Put attention on the horizontal arrow, it shows the flow of data, the controller must be connected to the connector behind the arrow. The vertical arrow shows the counting direction of the row but never mind because we use only one module this time.

Here below the connector configuration
OE: Output Enable for tuning on/off the entire LED
A and B: selection of row to turn on. 4 rows turn on at a time.
Row sequence: 1,5,9,13 then 2,6,10,14 then 3,7,11,15 then 4,8,12,16
CLK: SPI clock
SCLK: Latch register data to LED
R: SPI DATA
Connector configuration at controller module are similar with connector at the LED module. They can be connected 1 to 1 with 2x8 female header with ribbon cable.

Crystal is 24MHz. Internally microcontroller has internal pull-ups so external pull-ups are optional. Just in case you P10 module very uncommon specification. Decoupling capacitor at power and another capacitor for reset. A little revision, pin 1 of the connector is A and pin 2 is B, in the schematic they are misplaced. LED module and controller require one 5V/2A power supply.

Get the code here https://play.google.com/store/apps/details?id=com.silvesterdao.c51forp10led



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.

Here below the complete code.
https://docs.google.com/file/d/0Bz15eKH_erJrYXdNcDhxdWJOaUE/edit?usp=sharing

P10 Module x2 Running Text (STM32F103C8T6)

Interested to build a running text display made of two P10 modules? The text looks shaky on video but actually not, recording quality ...