You are currently viewing How to Interface Buzzer with dsPIC30F4011 dsPIC Development Board

How to Interface Buzzer with dsPIC30F4011 dsPIC Development Board

Spread the love

The dsPIC30F4011 Development board is specifically designed to help students to master the required skills in the area of embedded systems. The kit is designed in such way that all the possible features of the microcontroller will be easily used by the students. The kit supports in system programming (ISP) which is done through USB port.

Microchip’s dsPIC30F (dsPIC30F4011), Development Kit is proposed to smooth the progress of developing and debugging of various designs encompassing of High speed 16-bit Microcontrollers.

Buzzer

Buzzer is an electrical device, which is similar to a bell that makes a buzzing noise and is used for signaling. Typical uses of buzzers and beepers include alarm devices, timers and confirmation of user input such as a mouse click or keystroke.

Interfacing Buzzer

Fig. 1 shows how to interface the Buzzer to microcontroller. A piezoelectric element may be driven by an oscillating electronic circuit or other audio signal source, driven with a piezoelectric audio amplifier. Sounds commonly used to indicate that a button has been pressed are a click, a ring or a beep. When the input port pin from microcontroller is changed, the sound wave is changed in Buzzer.

 Interface Buzzer with dsPIC30F4011 dsPIC Development Board
Fig. 1 Interfacing Buzzer to Microcontroller

Interfacing Buzzer with dsPIC30F4011

A small piezoelectric buzzer on the dsPIC30F Development Kit, by pulling pin PORTB.0 low, current will flow through the buzzer and a relatively sharp, single-tone frequency will be heard.

The alternative ADC feature of pin PORTB.0 can be used to modulate the buzzer to oscillate around different voltages. Then the volume of the sound will be changed by alternating the voltage. The buzzer can be disconnected by FRC cable, and this is also the default connection since the buzzer sound can be quite annoying if always left on.

Pin Assignment with dsPIC30F4011

pin assignment for Interface Buzzer with dsPIC30F4011 dsPIC Development Board

Circuit Diagram to Interface Buzzer with dsPIC

circuit diagram for Interface Buzzer with dsPIC30F4011 dsPIC Development Board

Source Code

The Interfacing Buzzer with dsPIC30F4011 program is very simple and straight forward. We now want to generate a sound in dsPIC30F4011 Development board by using a buzzer. The C programs are developed in Mplab software.

C Program to generate sound in dsPIC using Buzzer

#include
#include "p30f4011.h"
#include "delay.c"
_FOSC(CSW_FSCM_OFF & XT);
_FWDT(WDT_OFF);
_FBORPOR(PBOR_ON & MCLR_EN);
_FGS(CODE_PROT_OFF);
#define XTFREQ 10000000
#define FOSC XTFREQ/4
#define BAUDRATE 9600
#define BRGVAL ((FOSC/BAUDRATE)/16)-1 void Serial_init(void);
unsigned char Receive(void);
void main()
{
unsigned int RecDat;
TRISB = 0x0000;
ADPCFG= 0xffff;
LATB = 0xffff;
Serial_init();
Delay_ms10M(20);
putch(0x0c);
printf("Press A to Turn ON\n\rPress B to Turn OFF\n\r");
while(1)
{
RecDat = Receive();
switch(RecDat)
{
case 'A':LATB=0x00;break;
case 'B':LATB=0x01;break;
}
printf("%c ",RecDat);
}
}
void Serial_init(void)
{
U1MODE= 0x8000;
U1STA = 0x8400;
U1BRG = BRGVAL;
IFS0bits.U1TXIF = 1;
}
void putch(unsigned char SendDat)
{
while(IFS0bits.U1TXIF==0);
U1TXREG = SendDat;
IFS0bits.U1TXIF=0;
}
unsigned char Receive(void)
{
while(IFS0bits.U1RXIF==0);
IFS0bits.U1RXIF=0;
return U1RXREG;
}

To compile the above C code you need the Mplab software & Microchip C30 Compiler. They must be properly set up and a project with correct settings must be created in order to compile the code. To compile the above code, the C file must be added to the project.

In Mplab, you want to develop or debug the project without any hardware setup. You must compile the code for generating HEX file. In debugging Mode, you want to check the port output without dsPIC30F4011 Development board.

The PICKIT2 software is used to download the hex file into your microcontroller IC dsPIC30F through USB

Testing the Buzzer with dsPIC30F4011

Give +9V power supply to dsPIC30F4011 Development board; the Buzzer is connected with dsPIC30F4011 Development board. When the program is downloading into dsPIC30F4011 in Development board, the Buzzer output is working that the Buzzer is creating some sound.

If you are not getting any sound from Buzzer, then you just check the jumper connections & check the Buzzer is working or not. Otherwise you just check it with debugging mode in Mplab. If you want to see more details about debugging just see the videos in below link.

☞How to create & Debug a Project in Mplab using dsPIC30F.

General Information

☞For proper working use the components of exact values as shown in Circuit file. Use new components.

☞Solder everything in a clean way. A major problem arises due to improper soldering, solder jumps and loose joints.

☞Use the exact value crystal shown in schematic.

☞More instructions are available in following articles,

dSPIC Development board

User Manual of DSPIC Development Board

Creating & Debugging a Project in MPLAB using dsPIC30F

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.