Skip to content
Richard Hodges edited this page Oct 12, 2019 · 6 revisions

This project is a motor control using PWM. It uses the STM8S103 CPU and the TM1638 keypad/display. I bought these on eBay for about $1 and $2

The PWM output is on pin A3. The power circuit (not included here) includes a IRLZ24 MOSFET transistor, which accepts a logic level (5 volts) input on its gate. Pump and circuit in "off" mode. This picture shows the active circuit and pump mounted on a metal base. The pump is a 12 volt "peristaltic" pump that goes for $4 to $5 on eBay. The power supply is not shown.

Note that I have painted the keys except for S3 and S6 white for easy identification. I used appliance touch-up paint for that.

The display currently shows that the pump is "OFF" and the PWM percentage is set to 60%

You can turn the PWM on and off, and change the PWM percentage with the keypad buttons (S1 to S8). The S6 feature can be useful for measuring how much the pump will do in one minute at a PWM setting.

 S1: Choose OFF mode.
 S2: Choose RUN mode.
 S3: Switch between status, hour run time, and cycle display.
 S4: Subtract 10% from PWM.
 S5: Add 10% to PWM.
 S6: Run pump for 60 seconds, then stop.
 S7: Subtract 1% from PWM.
 S8: Add 1% to PWM.

The configuration items are in pwm_pump.h in case you wish to change something.

This project uses SDCC to compile and my stm8_libs library. Please install that first. The Makefile expects stm8_libs and header files in ../libs, change for your layout.

Feel free to use this as a working prototype to develop your own application.

You may contact the author at: richard@hodges.org I am available for embedded projects, large or small.

Clone this wiki locally