DIY Function Generator With STC MCU Easily

by CreativeLau in Circuits > Electronics

4865 Views, 32 Favorites, 0 Comments

DIY Function Generator With STC MCU Easily

IMG_6223.JPG

This is a Function Generator made with STC MCU. Need only several components and the circuit is simple.

Specification

  • Output: Single Channel
  • Square Waveform Frequency: 1Hz~2MHz
  • Sine Waveform Frequency: 1Hz~10kHz
  • Amplitude: VCC, about 5V
  • Load ability: Not available
  • MCU: STC15W4K32S4 @24MHz
  • Display: LCD1602
  • Controller: EC11 Encoder


Watch the Video!

How to Make Function Generator with MCU to Generate Square and Sine Wave

In this video, I will show you how to DIY this Function Generator step by step.

Prepare Your Parts!

IMG_6187.JPG

Parts List

Scheme and Circuit!

Function Generator00_04_20_07.Still002.jpg
波形发生器_Taobao.00_02_56_26.Still006.jpg
波形发生器_Taobao.00_03_14_28.Still005.jpg
circuit V0.3.jpg
Scheme V0.3.jpg

Please refer to the circuit and the step in video, you could arrange the components on circuit board easily.

Download the Code!

波形发生器_Taobao.00_03_43_39.Still003.jpg
波形发生器_Taobao.00_03_56_08.Still002.jpg
波形发生器_Taobao.00_03_46_29.Still004.jpg

Download the package below. There are source code and compiled hex file.

If you do not want to read the codes, just burn the .hex file into the MCU. Use a USB to TTL downloader and STC-ISP software to download the code to MCU. Connect TXD, RXD and GND.

Download STC-ISP software here: http://www.stcmicro.com/rjxz.html

If the interface of STC-ISP is Chinese, you could click upper left icon to change the language to English. For the detail configuration of STC-ISP please refer to the video in Step 1.

The codes were written in C. Use Keil software to edit and compile it.

Downloads

Success!

波形发生器_Taobao.00_05_21_07.Still001.jpg
波形发生器.00_07_53_43.Still006.jpg
波形发生器.00_10_11_29.Still005.jpg
波形发生器_Taobao.00_09_09_13.Still007.jpg

You could use this DIY Function Generator to output Square waveform or Sine waveform signal.

Interface:

  • Bottom left shows the type of waveform(Square/Sine) and output status(ON/OFF)
  • F: Frequency
  • D: Duty of Square Waveform
  • CD: Clock Division Coefficient (For information only)
  • P: PWM frequency for generating Sine Waveform (For information only)
  • Pt: Number of points for generating Sine Waveform (For information only)

Operations:

  • Single Click Encoder: Switch Frequency and Duty in Square Waveform Interface
  • Double Click Encoder: Start/Stop Signal Output
  • Long Press Encoder: Switch between Square Waveform/Sine Waveform/Voltage Information
  • Rotate Encoder: Adjust Parameters

Tips

The output signal do not have load ability. If you want to drive other component, please be advised that using an operational amplifier to enhance the load ability.

Future Plan

stm32.jpg

I plan to make another Function Generator with STM32.

Expecting it

  • Could generate Triangle and Saw waveform additionally.
  • The frequency of Sine waveform could be higher than 10kHz.

If you have advices or requirements about this project, please kindly tell me.

Hope you like it.

Feel free to check out my YouTube Channel: https://www.youtube.com/c/CreativeLau