venkates2218
Full Member level 6
Please refer the circuit.Concept of my project is to warn the peoples in my factory for their interval times.
It will create sound when switched on by the operator.I will produce sound like blinking LED.At frequent time interval it will switch ON and OFF periodically.
Code:
#define XTAL_FREQ 20MHZ
#include <pic.h>
#include "delay.h"
#include <xc.h>
// CONFIG
#pragma config FOSC = HS // Oscillator Selection bits (HS oscillator: High-speed crystal/resonator on RA6/OSC2/CLKOUT and RA7/OSC1/CLKIN)
#pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled)
#pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled)
#pragma config MCLRE = ON // RA5/MCLR/VPP Pin Function Select bit (RA5/MCLR/VPP pin function is MCLR)
#pragma config BOREN = OFF // Brown-out Detect Enable bit (BOD disabled)
#pragma config LVP = OFF // Low-Voltage Programming Enable bit (RB4/PGM pin has digital I/O function, HV on MCLR must be used for programming)
#pragma config CPD = OFF // Data EE Memory Code Protection bit (Data memory code protection off)
#pragma config CP = OFF // Flash Program Memory Code Protection bit (Code protection off)
int ee_read(unsigned int read_address);
void running_horn();
#define RONE RA2
#define RTWO RA3
void System_init(void) {
TRISA = 0b00010011; //Making O/P and I/P for operation
PORTA = 0b00010011;
CMCON = 0X07; //Disabling Comparators
TRISB = 0b00000000;
PORTB = 0b00000000;
}
void main(void) {
System_init(); //Initialise System
while(1){
RONE=~RONE;
RTWO=~RTWO;
DelayMs(300);
}
}
this is my code to control the horn,
The relay output is connected to DC12V horn to create warning.Simply I connected +12Vdc to common point in relay and NO to horn to create output.
My problem is when I switched on the circuit the controller becoming hanging.It producing warning sound by continuous sound instead of beep sound(like LED blinking).
I dono whats the problem with the circuit and program.Please help me to solve the issue.
Thank you....