View previous topic :: View next topic |
Author |
Message |
artohautala
Joined: 17 Nov 2011 Posts: 187
|
SOLVED mystery boot |
Posted: Sun Sep 25, 2016 10:02 am |
|
|
Hello...
My question is maybe very simple ...
But I can't solve it so I'll be happy if you can help me !
So I have door switch ... it's open when door is open and closed when door is closed... when door is open there's +5V to PIC16F877A pin 7 A5
because resistor going to + 5V ...
... but when I open the door and closed it again it seems to me it boots ??
Because function led_demo() is running again...
Why opening the door make it boot and run led_demo() again ?
I've checked hardware many times and I think there's no problems ...
I've changed my PIC16F877A processor no help...
This is part of big program and everything works fine ...
I'm very confused...
Here is part of my code:
Code: |
void main(){
int1 i;
/* here my LEDS
#define peltier_led_ON output_high(pin_C2)
#define peltier_led_OFF output_low(pin_C2)
#define pump_led_ON output_high(pin_C3)
#define pump_led_OFF output_low(pin_C3)
#define door_led_ON output_high(pin_A1)
#define door_led_OFF output_low(pin_A1)
#define fan_led_ON output_high(pin_B2)
#define fan_led_OFF output_low(pin_B2)
*/
/* here's my led demo
void led_demo(void){
int8 i;
for(i=0; i<5;++i){
tank_led_ON; delay_ms(50); tank_led_OFF; delay_ms(50);
fan_led_ON; delay_ms(50); fan_led_OFF; delay_ms(50);
peltier_led_ON; delay_ms(50); peltier_led_OFF; delay_ms(50);
pump_led_ON; delay_ms(50); pump_led_OFF; delay_ms(50);
}
}
*/
//#define door_open input(pin_A5) --- this my door switch
delay_ms(2000); //start delay
set_tris_a(0B11111111); //A - port all inputs
disable_interrupts(GLOBAL);
delay_ms(50);
led_demo();
delay_ms(2000);
// my simple test program stop here:
here:;goto here ;
|
Thank you very much if you got some idea to solve this problem
All the best for you all
best regards
-arto-
Last edited by artohautala on Mon Sep 26, 2016 7:41 am; edited 1 time in total |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9241 Location: Greensville,Ontario
|
|
Posted: Sun Sep 25, 2016 10:24 am |
|
|
points to ponder...
What's the value of the pull resistor on A5 ?
Have you disabled any other peripherals that can use A5 ?
Do you have a small cap across the switch ?
Jay |
|
|
artohautala
Joined: 17 Nov 2011 Posts: 187
|
|
Posted: Sun Sep 25, 2016 10:36 am |
|
|
temtronic wrote: | points to ponder...
What's the value of the pull resistor on A5 ?
Have you disabled any other peripherals that can use A5 ?
Do you have a small cap across the switch ?
Jay |
Hello Jay lot of thanks for answering me ...
pullup resistor in A5 is 2200 ohms... no other peripherals using A5
and I have 1 uF capacitor accross that door switch ...
I have tried delays and so on ... but nothing seems to help ...
Maybe I'll try to change that processor again ...
but I'm very sure it will not help because everything elsewhere in program works fine...
thank you
-arto- |
|
|
rikotech8
Joined: 10 Dec 2011 Posts: 376 Location: Sofiq,Bulgariq
|
|
Posted: Sun Sep 25, 2016 10:45 am |
|
|
Remove the commented code if you respect the efforts and the time of the people in this forum. Present clean code, without redundant complexities. _________________ A person who never made a mistake never tried anything new. |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Sun Sep 25, 2016 12:09 pm |
|
|
Is there a RESISTOR in series with the LED ?
If so -what value in ohms please?
This matters .......also
Post your SCHEMATIC please
and yes fix your code so it compiles- duh !!
i think i might know what's wrong..... |
|
|
artohautala
Joined: 17 Nov 2011 Posts: 187
|
|
Posted: Mon Sep 26, 2016 7:36 am |
|
|
temtronic wrote: | points to ponder...
What's the value of the pull resistor on A5 ?
Have you disabled any other peripherals that can use A5 ?
Do you have a small cap across the switch ?
Jay |
I removed this capacitor and now there's no problems anymore...
<pullup resistor in A5 is 2200 ohms... no other peripherals using A5
and I have 1 uF capacitor across that door switch ... >
maybe when it discharged via door switch contacts the current pulse was too big...
My purpose was backward to avoid any voltage spikes ...
thanks for your help ...
best regards
-arto- |
|
|
artohautala
Joined: 17 Nov 2011 Posts: 187
|
|
Posted: Mon Sep 26, 2016 7:37 am |
|
|
rikotech8 wrote: | Remove the commented code if you respect the efforts and the time of the people in this forum. Present clean code, without redundant complexities. |
Sorry I really respect this forum... thank for your answer I found the reason
I removed this capacitor and now there's no problems anymore...
<pullup resistor in A5 is 2200 ohms... no other peripherals using A5
and I have 1 uF capacitor accross that door switch ... >
maybe when it discharced via door switch contacts the current pulse was too big...
My purpose was backward to avoid any voltage spikes ...
thanks for your help ...
best regards
-arto- |
|
|
artohautala
Joined: 17 Nov 2011 Posts: 187
|
|
Posted: Mon Sep 26, 2016 7:40 am |
|
|
asmboy wrote: | Is there a RESISTOR in series with the LED ?
If so -what value in ohms please?
This matters .......also
Post your SCHEMATIC please
and yes fix your code so it compiles- duh !!
i think i might know what's wrong..... |
I removed this capacitor and now there's no problems anymore...
<pullup resistor in A5 is 2200 ohms... no other peripherals using A5
and I have 1 uF capacitor accross that door switch ... >
maybe when it discharced via door switch contacts the current pulse was too big...
My purpose was backward to avoid any voltage spikes ...
thanks for your help ...
best regards
-arto- |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19537
|
|
Posted: Mon Sep 26, 2016 7:58 am |
|
|
1uF across a switch is a good way of damaging something. A typical 'snubber' circuit, has 0.1uF in series with perhaps 10 to 50R to limit the current. Asking a switch to discharge a 1uF capacitor, with nothing to limit the current, could result in many amps of current flowing. Quite possibly destroy the switch long term....
<http://electronics.stackexchange.com/questions/225903/how-to-determine-a-capacitor-value-across-a-switch-carrying-dc> |
|
|
artohautala
Joined: 17 Nov 2011 Posts: 187
|
|
Posted: Mon Sep 26, 2016 9:58 am |
|
|
Ttelmah wrote: | 1uF across a switch is a good way of damaging something. A typical 'snubber' circuit, has 0.1uF in series with perhaps 10 to 50R to limit the current. Asking a switch to discharge a 1uF capacitor, with nothing to limit the current, could result in many amps of current flowing. Quite possibly destroy the switch long term....
<http://electronics.stackexchange.com/questions/225903/how-to-determine-a-capacitor-value-across-a-switch-carrying-dc> |
Hello and lot of thanks for your answer Ttelmah !
Ttelmah wrote: | A typical 'snubber' circuit, has 0.1uF in series with perhaps 10 to 50R to limit the current. Asking a switch to discharge a 1uF capacitor, with nothing to limit the current, could result in many amps of current flowing. Quite possibly destroy the switch long term.... |
This is really true I experienced it in practice ... I understand now that it's good advice.
Yes I did not think about that carefully enough ... it's very embarrassed !
So I find my door switch "welded" contacts together but after many open close periods with magnet it started to work again ... (lucky me)
So I replace capacitor with suitable delay and now it seems to work OK !
All the best and have fun'
-arto- |
|
|
|