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.

Problem with timer code in PIC15F628

Status
Not open for further replies.

kiks

Member level 1
Joined
Jun 1, 2004
Messages
35
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,288
Activity points
349
I need help. I built a circuit using a PIC16f628 for timing. On power up a relay must be energised after a delay set on a dip switch (RA1, RA2, RA3). A microswitch is connected on RA0. When the microswitch is closed momentarily, the relay must switch off for a time period set on a dip switch (RA4, RA5, RA6), and then switch on again. I have written the program in assembler. It seems to work in the MPLAB simulator, but when I program the chip and use it in circuit strange things seem to happen. The timing does not seem to function. The relay (on RB1) does not come on unless RA1, RA2 and RA3 is high. The dip switches have 10k pull up resistors. I have attached the code. After spending many hours on this I am not sure what is wrong. Any help will be apperciated! The time code was generated by the Delay Code Generator found on the PICLIST.
 

Re: Timer Problem

Hi,

1. Check with a multimeter if RA0 pin is in low state when micro switch is not pressed. Test the status changes as required when switch is pressed and released.

2. Also check if the Zero flag is to be cleared before every XOR operation.

Regards,
Laktronics
 

Re: Timer Problem

Thanks for that, but I managed to sort out the problem. I am using a TOPWIN TOP2004 programmer (Chinese). It seems to be doing some funny things (or maybe its me!) When I read the chip back after programming, the config word is different. I eventually programmed the chip using my home built programmer and Nigel Goodwin's WINPICPROG software and the chip was programmed correctly.

Another question - what is the best way to protect an input pin from damage if it is connected externally to say a microswitch? Also when switching an inductive load like a motor with a relay driven by a pic, will the pic be affected by spikes or arcing on the relay contacts. If so how do we get around this?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top