Sorry I made the same mistake as you did! Put 10R to the 5V supply and 10K to the ground (in parallel to the capacitor).
Khaled, is it possible to wire the switch to ground and use a pull-up resistor on PortB.0 instead?
Although it still seems like an electrical problem, maybe reversing the switch signal so it senses the input going low instead of high will help.
Brian.
isr:
On Low Interrupt
If INTCON.INT01F = 1 Then
switch_pressed = 1
INTCON.INT01F = 0
Endif
Resume
On High Interrupt
If INTCON.INT01F = 1 Then
switch_pressed = 1
INTCON.INT01F = 0
Endif
Resume
setuppic:
TRISB = 0x03
T1CON = 0x24
INTCON = 0x10
INTCON2 = 0xc0
INTCON3 = 0x00
ADCON1 = 0x0c
Enable Low
Return
isr:
On Low Interrupt
If INTCON.INT0IF = 1 Then
switch_pressed = 1
INTCON.INT0IF = 0
Endif
Resume
Yes, all I want you to do is reverse the switch wiring so it pulls the pin low when the switch is closed and also change INTCON2 so it looks for the falling edge instead of the rising one. Everything else should be as before. PORTB.0 always triggers a high interrupt but if you don't change INTCON2, the interrupt will be triggered when the switch releases instead of when you press it.
Brian.
I think the software is OK. If the circuit breaker 'tricks' the system into thinking the switch was pressed it still points to an electrical issue. I would leave the switch on the ground side of the circuit, it is generally safer to do that because the switch wires do not carry supply voltage. You could filter the switch signal again with the RC network to be doubly sure it isn't picking up interference on the wiring.
A mechanical relay would certainly work because the capacitor would remain connected through the full AC cycle.
I think you explanation of the power factor correction is right. For the most part you would be connecting capacitors across the AC lines to compensate for the inductive load.
For safety, wire a 100K resistor across each capacitor so it discharges quickly when taken out of circuit. The resistor will have almost zero effect on the measurement but it will safely dissipate any remaining charge on the capacitor within a few seconds.
Brian.
prog_end:
Lcdcmdout LcdLine4Home
Lcdout #RCON
Goto prog_end
Did you solve your problem of false interrupts being produced when devices are connected or removed?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?