This program is based on EvanV's blinky for 16F628A. (Thank You) I am posting it as an example of how to use hardware PWM to generate ultrasonic square waves.
'''PWM Rat Botherer based on EvanV LED Blinker
'''--------------------------------------------------------------------------------------------------------------------------------
'''This program emits square waves on pin 9.
'''
'''@author EvanV plus works of others including Chip V.
'''@licence GPL
'''@version 1.0a
'''@date 31.01.2015
'''**************
; ----- Configuration
#chip 16F628A, 4
#config LVP = Off
' #include
' no solution specifc includes, default includes are always included ; no solution specifc includes, default includes are always included
; ----- Define Hardware settings
' this is required to tell the microprocessor the port is an output
' (PORTB.3 = Pin 9 on PIC16f628A)
Dir PORTB.3 Out
; ----- Variables
' none specified in the example. All byte variables are defined upon use.
; ----- Main body of program commences here.
Start:
HPWM 1,22,128 'PWM to output 1 at 22 KHz, 50% duty cycle
wait 1 second
PWMOff
wait 1 second
This program is based on EvanV's blinky for 16F628A. (Thank You) I am posting it as an example of how to use hardware PWM to generate ultrasonic square waves.
'''PWM Rat Botherer based on EvanV LED Blinker
'''--------------------------------------------------------------------------------------------------------------------------------
'''This program emits square waves on pin 9.
'''
'''@author EvanV plus works of others including Chip V.
'''@licence GPL
'''@version 1.0a
'''@date 31.01.2015
'''**************
; ----- Configuration
#chip 16F628A, 4
#config LVP = Off
' #include
' no solution specifc includes, default includes are always included ; no solution specifc includes, default includes are always included
; ----- Define Hardware settings
' this is required to tell the microprocessor the port is an output
' (PORTB.3 = Pin 9 on PIC16f628A)
Dir PORTB.3 Out
; ----- Variables
' none specified in the example. All byte variables are defined upon use.
; ----- Main body of program commences here.
Start:
HPWM 1,22,128 'PWM to output 1 at 22 KHz, 50% duty cycle
wait 1 second
PWMOff
wait 1 second
goto Start
Thanks again, Chip V.
Nice one!
How do the rats like this?