Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Controller hanging up

Status
Not open for further replies.

venkates2218

Full Member level 6
Joined
Sep 30, 2016
Messages
354
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,298
Activity points
4,306
up.png
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....
 

Try changing these lines:
Code:
#define	RONE RA2	
#define	RTWO RA3
to:
#define RONE PORTA,2
#define RTWO PORTA,3

It would be better programming to avoid the '~' to invert the bits because it forces a read of the whole port to toggle one bit. It would be better to toggle bits in a variable then write them to the port.

Brian.
 

I presume you didn't post the real code. The only signals that are modified during program operation "left" and "right" are undefined. Respectively we can only guess how the real code might behave.

Circuitwise, the capacitors across relays coils cause high inrush current and might cause problems. You should remove it. Depending on the load switched by the relays, there may be contact arcing, possibly affecting a not well layouted circuit.

- - - Updated - - -

O.K., I see the code listing was updated in between.
 
I presume you didn't post the real code. The only signals that are modified during program operation "left" and "right" are undefined. Respectively we can only guess how the real code might behave.

Circuitwise, the capacitors across relays coils cause high inrush current and might cause problems. You should remove it. Depending on the load switched by the relays, there may be contact arcing, possibly affecting a not well layouted circuit.

- - - Updated - - -

O.K., I see the code listing was updated in between.

No the code edited from another code.
The load will be 7A in every relay.
 

Does the problem also occur if the load is unconnected?
 

Does the problem also occur if the load is unconnected?

no the problem not occurring while removing the load..
It working fine...
Sorry I forgot to update this one....

- - - Updated - - -

Try changing these lines:
Code:
#define	RONE RA2	
#define	RTWO RA3
to:
#define RONE PORTA,2
#define RTWO PORTA,3

It would be better programming to avoid the '~' to invert the bits because it forces a read of the whole port to toggle one bit. It would be better to toggle bits in a variable then write them to the port.

Brian.
Can you explain this one..?
It would be better to toggle bits in a variable then write them to the port.
S
 

Hi,

no the problem not occurring while removing the load..
Then it is very likely that the problem is caused by a bad PCB layout. (Like already assumed in post#3)

--> Show us your PCB layout.


Klaus
 

Can you explain this one..?
It would be better to toggle bits in a variable then write them to the port.
It can cause problems in PICs without output latches, particularly PIC16F devices. The reason is the state of the port pin is read in, inverted and then written back. If for any reason the pin voltage isn't stable or it is loaded down, the wrong state will be read. What you really want to do is write 1 or 0 to the bits in the port rather than invert what is already there.

However, if removing the load fixes the problem, it means you have a hardware fault. Follow the instructions from FvM in post #3 and try again. Also make sure you have a good ground connection between pin 5 and C1,C2,C3 and C4 as any interference picked up on the wiring between them may stop the PIC working.

Brian.
 
Hi,


Then it is very likely that the problem is caused by a bad PCB layout. (Like already assumed in post#3)

--> Show us your PCB layout.


Klaus

sorry I connected everything in breadboard....

- - - Updated - - -

Try changing these lines:
Code:
#define	RONE RA2	
#define	RTWO RA3
to:
#define RONE PORTA,2
#define RTWO PORTA,3

It would be better programming to avoid the '~' to invert the bits because it forces a read of the whole port to toggle one bit. It would be better to toggle bits in a variable then write them to the port.

Brian.

I changed the '~' this in program but still facing the problem.When switched on means it hanging up.

- - - Updated - - -

Is their any need to add any components on output side...?Because its inductive load...
 

sorry I connected everything in breadboard....
No further questions. It's nearly impossible to achieve sufficient power supply bypassing with breadboard.
 

Hi,

A breadboard is simply not suitable for such circuits.
No software can compensate this.
Modern electronics are more prone against those EMC problems. With increasing speed of processors they need to react more fast on input signals.
Recently I elaborated a study for a chemical plant about this.
Back in the 60s and 70s there were especially slow logic IC for industrial applications. They were so slow that a 10us pulse is simply not recognized. But your 20MHz PIC needs to safely detect logic inputs with the speed of 200ns (instruction period).
Additionally nowadays there are far more sources of EMV noise like:cellular phones, Bluetooth, WLan, Dect, SMPS...all these operate with frequencies with wavelength in the range of usual PCB sizes...this means the traces and wiring act as good antennas.

Klaus
 
Can you advice what are the point should be observed while designing the PCB to avoid same problem in PCB.
 

Keep load currents well away from MCU currents,
Ensure a good low impedance supply and ground around the MCU,
Fit decoupling capacitors as close as possible to VSS and VDD pins. Use say 10uF and 10nF in parallel to keep impedance low.
Make sure the wiring to the crystal is a short as possible and its loading capacitors have short wires to VSS.
Make sure the MCLR capacitor has short wires to VSS (or use internal MCLR mode).
Add 100nF ceramic capacitors across the regulator input and output pins to GND as close to the regulator as possible.

You don't show where the +12V comes from but make sure it is filtered and it's negative side is close to the power GND point.
Remove the capacitors form across the relay coils.
If any MCU pins are left disconnected, make sure they are configured as outputs or add pull-down resistors to VSS to them all.

Brian.
 
Keep load currents well away from MCU currents,
Ensure a good low impedance supply and ground around the MCU,
Fit decoupling capacitors as close as possible to VSS and VDD pins. Use say 10uF and 10nF in parallel to keep impedance low.
Make sure the wiring to the crystal is a short as possible and its loading capacitors have short wires to VSS.
Make sure the MCLR capacitor has short wires to VSS (or use internal MCLR mode).
Add 100nF ceramic capacitors across the regulator input and output pins to GND as close to the regulator as possible.

You don't show where the +12V comes from but make sure it is filtered and it's negative side is close to the power GND point.
Remove the capacitors form across the relay coils.
If any MCU pins are left disconnected, make sure they are configured as outputs or add pull-down resistors to VSS to them all.

Brian.

The 12V supply comes from an 12Ah battery.Relay and the circuit are operated from the same battery only.
Positive supply from the battery is directly given to the common point of the relay to operate the output and another wire from the battery is given to the controller circuit through an switch to control the circuit.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top