Home > other >  Very simple and can be accurate step frequency modulation frequency square wave generator
Very simple and can be accurate step frequency modulation frequency square wave generator

Time:05-05

Due to certain requirements, to do a measuring step and square wave frequency response of a variety of small power transformer, feel with micropython PWM is the most convenient and accurate, get rid of, and an inverter and power output component, 32 templates can be realized with a piece of ESP WROOM (including no other hardware switch), inverter and power output is configure according to the demand,
Characteristics and material:
1. The output pulse frequency of up to 3 MHZ
2. The output pulse frequency value, minimum value and stepping frequency square wave frequency, can be accurately set to 1 hz
3. The duty ratio can be set up according to demand to 1-1023
Step 4. Use the touch switch into the square wave frequency
5. ESP WROOM 32 template
6. Touch switch with ESP32 GPIO27 and GPIO32 feet, don't add any hardware

Procedure is as follows:
# test POWER PWM ESP32 20210504. Py
From the machine import Pin, PWM, freq, TouchPad
Freq (240000000) # set working frequency 240 MHZ CPU
# pinLED=Pin (2, Pin OUT)
Lowest pwmFreqLow=1000 # PWM frequency set to 1 KHZ, can be set up to 10 hz
PwmFreqHigh=3000000 # a PWM high frequency MHZ 3
PwmFreq=100000 # starting frequency PWM is set to 100 KHZ
PwmStep=1000 # PWM step frequency set to 1 KHZ
Pwm20=PWM (Pin (16), freq=pwmFreq, duty=512) # output PWM duty ratio 0.5
Print (' initial PWM frequency + STR (pwmFreq) + 'Hertz')
While True:
Touch32=the TouchPad (Pin (32)). The read () + # touch key, PWM frequency add
Touch33=the TouchPad (Pin (27)). The read () - # touch key, PWM frequency reduction
# print (STR (Touch32) + "" + STR (Touch33) # print touch keys
If Touch32 & lt; # 800: touch the key value effective
PwmFreq=pwmFreq + # pwmStep PWM frequency
If (pwmFreq & gt; PwmFreqHigh) : pwmFreq -=pwmStep
If Touch33 & lt; # 800: touch the key value effective
PwmFreq=pwmFreq - pwmStep # PWM frequency reduction
If (pwmFreq & lt; PwmFreqLow) : pwmFreq +=pwmStep
Pwm20=PWM (Pin (16), freq=pwmFreq, duty=512) # PWM duty ratio 0.5 losing
Print (" pwmFreq="+ STR (pwmFreq) # print PWM frequency values

Welcome to clap brick, must be all ears,
  • Related