Hee Haw Sound

This experiment creates a Hee Haw sound for an alarm. The diagram shows the number of cycles for the HEE and the time taken for each cycle, equates to a certain length of time. The frequency of the HAW is lower and the number of cycles must be worked out so that the time for the HAW is equal to the time for the HEE.
This is simple when writing the program. The values loaded into the two files for the HEE are reversed for the HAW.

Hee Haw Sound
The routine consists of two sections: HEE and HAW. Each section has two  nested loops. The inner loop creates the length of time for the HIGH and LOW to produce a single cycle and the outer loop creates the number of cycles.

;Expt7a.asm
;Project: Hee Haw Sound
List P = 16F84
#include <p16F84.inc>
__CONFIG 1Bh    ;_CP_OFF & _PWRTE_ON & _WDT_OFF & _RC_OSC

SetUp
Hee1

Hee2

Hee3

Hee4

Haw1

Haw2

Haw3

 

ORG 0
BSF 03,5
CLRF 06
BCF 03,5
CLRF 06
GOTO Hee1
MOVLW 0FFh
MOVWF 14h
MOVLW 0C0h
BSF 06,7
NOP
DECFSZ 15h,1
GOTO Hee3
MOVLW 0C0h
MOVWF 15h
BCF 06,7
NOP
DECFSZ 15h,1
GOTO Hee4
DECFSZ 14h,1
GOTO Hee2

MOVLW 0C0h
MOVWF 14h
MOVLW 0FFh
MOVWF 15h
BSF 06,7
NOP
DECFSZ 15h,1
GOTO Haw2
MOVLW 0FFh
MOVWF 15h
BCF 06,7
NOP
DECFSZ 15h,1
GOTO Haw3
DECFSZ 14h,1
GOTO Haw1
GOTO Hee1

END

;This is the start of memory for the program.
;Go to Bank 1
;Make all port B output
;Go to Bank 0 – the program memory area.
;Clear display
;Number of loops
;The loop file
;Duration of HIGH
;Turn on piezo

;Create the HIGH time

;Duration of the LOW
;The LOW file
;Turn off piezo

;Create the LOW time

;Decrement the loop file
;Do more cycles

;Number of loops
;The loop file

;Turn on piezo

;Create the HIGH time

;Duration of the LOW
;The LOW file
;Turn off piezo

;Create the LOW time

;Decrement the loop file
;Do more cycles

EXPERIMENT 8
A to D Conversion

This experiment shows 0-256 parts of a 10k potentiometer on the 8 LEDs. It is not accurate, but shows the concept of A to D conversion.
Many microcontrollers have an input that can read any value of voltage from 0v to 5v (and higher by using a voltage divider network). Normally there are 256 steps in this range to produce a resolution of approx 20mV for 0-5v scale.  This is called an A to D input (A to D converter – analogue input) and is ideal for measuring voltages and other values that are classified as ANALOGUE. A very simple external circuit can be added to measure different parameters such as the change in resistance of a temperature probe and other analogue devices.
The PIC16F84 does not have an internal A to D converter, however we can create an A to D feature by using two lines and a sub-routine.
To create an analogue input, a capacitor “C” is connected in series with an unknown resistor (R) and charged via one of the lines of the microcontroller. The diagram below shows how this is done.

 

For more detail: Hee Haw Sound

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter