• AVR Freaks

Hot!Dimmer bouncing whenever any remote button pressed

Page: < 123 > Showing page 2 of 3
Author
PStechPaul
Super Member
  • Total Posts : 2294
  • Reward points : 0
  • Joined: 2006/06/27 16:11:32
  • Location: Cockeysville, MD, USA
  • Status: offline
Re: Dimmer bouncing whenever any remote button pressed 2018/10/31 17:09:06 (permalink)
+1 (1)
This seems like a hardware problem, but also possibly software. It is really difficult to follow without the formatting that is provided by [ code][ /code] tags, as suggested. There should also be comments in the code describing what each line is supposed to do. The full code should be provided, including config bits, and perhaps the entire project could be exported to a zip file and posted here.
 
Please provide a complete schematic, as well as pictures of the PC board or prototype.
 
There could be problems using the 4N35 for zero crossing detector. If it is used on 220V mains, it would need a 10k 5 watt resistor to get RMS current of 22 mA (31 mA peak), and that will be just 2.7 mA at 5 degrees. It appears you are performing a phase shift modulation on the waveform using the TRIAC, and there are better ways to do that than implementing a variable delay in the ISR that does not allow the main code to run.

 
#21
akibsk
New Member
  • Total Posts : 28
  • Reward points : 0
  • Joined: 2018/10/30 07:07:04
  • Location: 0
  • Status: offline
Re: Dimmer bouncing whenever any remote button pressed 2018/10/31 23:23:58 (permalink)
0
KK Sir,

"Can you answer the question about the functionality of the ISR in your program? That code toggles the RB1 output in response to the RB2 input, is that what you wanted? That would appear to be the reason for "going OFF and again ON on every pressing of any remote keys".


Exactly not I dont want to toggle the RB1 output in response to the RB2 input.
I want, while variable 
else if(cmd == 0x5f)
or 
else if(cmd == 0x9f)
is received by RB2 input then its variable 'speed' will go inc and dec respectively and it comes to ISR  then this INC/DEC will update the argument here of delay(speed) function and delay() would be called with with the speed argument.
In simple, I want ISR will work only when inc/dec variable cmd is change, not for others cmd variable.
pl suggest sir, because i have not such depth knowledge like you.
I think u understand me and my poor knowledge.
tnx
#22
PStechPaul
Super Member
  • Total Posts : 2294
  • Reward points : 0
  • Joined: 2006/06/27 16:11:32
  • Location: Cockeysville, MD, USA
  • Status: offline
Re: Dimmer bouncing whenever any remote button pressed 2018/11/01 00:41:42 (permalink)
+1 (1)
You need to explain just what you are trying to do, and show full code, schematic, and other information. It's impossible to determine what's going on and what is supposed to happen.

 
#23
akibsk
New Member
  • Total Posts : 28
  • Reward points : 0
  • Joined: 2018/10/30 07:07:04
  • Location: 0
  • Status: offline
Re: Dimmer bouncing whenever any remote button pressed 2018/11/01 07:08:15 (permalink)
0
Hi Paul sir,
Here is zipped.
Issues: At MCU Power-up  bulb connected at triac ckt gets ON and when Any remote key pressed gets OFF and again ON.
Please note- on/off controled relay ckt working properly.
Required: At power-up bulb will be at OFF state. when only inc/dec botton pressed then it will go to respective dim/bright only. 
 
TNX FOR YOU ADVICE.
#24
jack@kksound
code tags!
  • Total Posts : 3198
  • Reward points : 0
  • Joined: 2014/05/14 10:03:19
  • Location: 0
  • Status: offline
Re: Dimmer bouncing whenever any remote button pressed 2018/11/01 07:58:37 (permalink)
+2 (2)
akibsk
Issues: At MCU Power-up  bulb connected at triac ckt gets ON and when Any remote key pressed gets OFF and again ON.

However this behavior is exactly what the code you have posted is written to do. I think you may need to do some more basic description (outline,flow chart, pseudo code, whatever works for you) to better get a grasp on your program. It appears to be doing exactly what you wrote it to do.
#25
akibsk
New Member
  • Total Posts : 28
  • Reward points : 0
  • Joined: 2018/10/30 07:07:04
  • Location: 0
  • Status: offline
Re: Dimmer bouncing whenever any remote button pressed 2018/11/01 08:27:11 (permalink)
0
Tnx
how do i stop that debounce(any key press)? could u correct with the code or tell me what to correct or to add line?? 
 
tnx
#26
jack@kksound
code tags!
  • Total Posts : 3198
  • Reward points : 0
  • Joined: 2014/05/14 10:03:19
  • Location: 0
  • Status: offline
Re: Dimmer bouncing whenever any remote button pressed 2018/11/01 08:51:03 (permalink)
0
This code in your ISR results in a pulse on RB1 for every ext. interrupt:

LATBbits.LATB1=1; //tric=1;
for(int t=0;t<50;t++);
LATBbits.LATB1=0; //tric=0;

#27
jack@kksound
code tags!
  • Total Posts : 3198
  • Reward points : 0
  • Joined: 2014/05/14 10:03:19
  • Location: 0
  • Status: offline
Re: Dimmer bouncing whenever any remote button pressed 2018/11/01 09:08:19 (permalink)
0
Also this bit of code probably does not do what you are expecting:
while(LATBbits.LATB2==1);    

Probably should be:
while(PORTBbits.PORTB2==1);    

or
while(RB2==1);    

Also the other similar lines should be changed accordingly.
 
READ from PORTx, WRITE to LATx.
post edited by jack@kksound - 2018/11/01 09:12:27
#28
akibsk
New Member
  • Total Posts : 28
  • Reward points : 0
  • Joined: 2018/10/30 07:07:04
  • Location: 0
  • Status: offline
Re: Dimmer bouncing whenever any remote button pressed 2018/11/01 09:29:01 (permalink)
0
jack@kksound
This code in your ISR results in a pulse on RB1 for every ext. interrupt:

 
LATBbits.LATB1=1; //tric=1;
for(int t=0;t<50;t++);
LATBbits.LATB1=0; //tric=0;



 
tnx jack sir for coming.
 
its the issue , i was trying to tell u from start of topics by saying  INT0IE issues when u said for debounce routine. I do not have strong knowledge but started to collect from u people.
now point is that how do i add/correct or re-arrange the code. suggestion please??
 
tnx
 
#29
jack@kksound
code tags!
  • Total Posts : 3198
  • Reward points : 0
  • Joined: 2014/05/14 10:03:19
  • Location: 0
  • Status: offline
Re: Dimmer bouncing whenever any remote button pressed 2018/11/01 10:06:23 (permalink)
0
As I suggested, you must start with a clear, concise description of what you are trying to accomplish, step by step, with what are the inputs, outputs and functions. Only then will anyone be able to help much.
#30
akibsk
New Member
  • Total Posts : 28
  • Reward points : 0
  • Joined: 2018/10/30 07:07:04
  • Location: 0
  • Status: offline
Re: Dimmer bouncing whenever any remote button pressed 2018/11/01 11:14:09 (permalink)
0
in operational language: as simple as it will be remote control ir receiver which will have 4 output(relay as in prog shown) and one more output which will be uesd as dimmer upto five speed level, total system will be controlled from it remote controller(ir transmitter). it is not transmitter ckt , it will be a ir receiver.
relay part is working correctly but dimmer is bouncing in any keys is pressed. how do i resolve issue so called bouncing just i need it to be solve now. if any arises then problems wil come to forum.  
I think the matter will be resolve now!!!!
tnx sir.
 
#31
PStechPaul
Super Member
  • Total Posts : 2294
  • Reward points : 0
  • Joined: 2006/06/27 16:11:32
  • Location: Cockeysville, MD, USA
  • Status: offline
Re: Dimmer bouncing whenever any remote button pressed 2018/11/01 21:35:15 (permalink)
+3 (3)
The schematic and code are helpful in understanding what you are doing. You are using a TV type IR remote that uses a 39 kHz carrier and an NEC coding scheme, which is decoded in your main loop as commands (cmd). This is sensed by the PIC's RB2 input. However, your code is checking LATB2, which will not work. You must use PB2 for input.
 
You are using TMR0 to parse the command. You are enabling the TMR0 interrupt but the ISR only clears the TMR0IF.
 
You use INT0 (RB0) for zero cross detection on the falling edge and the ISR sends a trigger pulse to the TRIAC after a variable delay. One problem is that you immediately clear the INT0IF flag, so noise could cause additional interrupts while processing. Another problem is that you are using a 47k resistor on a probably 15 VAC rectified (22V peak) signal, which is a maximum of 500 uA into the 4N35 opto, which has nominally 100% CTR. So at peak input, the output current through the 10 k resistor would also be 500 uA, but at 500 uA the CTR is only about 20%, so the output current would be just 100 uA, and logic low would be only 4 volts. Within 10 degrees of zero crossing, the current will be less than 87 uA. The LED in the opto can handle 22 mA, so I suggest a 1k resistor.
 
You defined "tric" an "ir" but have not used them in your code. As noted these should be:
#define tric LATBbits.LATB1; // NOT PORTBbits.RB1
#define ir PORTBbits.RB2;  //NOT LATBbits.LAT2

 
Actually, you have commented out your defines, including relay1..4. And your commands only turn the relays ON, not toggling as previously done:
LATCbits.LATC2=1; //relay1^=1; //=~relay1;

 
There was another (long) thread a little while ago that concerned parsing the IR remote codes. And now there seems to be a new thread about a very similar application. Is this homework?
 
post edited by PStechPaul - 2018/11/01 21:36:54

 
#32
akibsk
New Member
  • Total Posts : 28
  • Reward points : 0
  • Joined: 2018/10/30 07:07:04
  • Location: 0
  • Status: offline
Re: Dimmer bouncing whenever any remote button pressed 2018/11/02 08:05:44 (permalink)
0
hi,
All have been changed(like as u said) but the bouncing  on dimmer-controlled-pin 'RB1' for each key pressed still not stopped.
A flow chart as u asked is attached for ref. please.
tnx
 

Attached Image(s)

#33
jack@kksound
code tags!
  • Total Posts : 3198
  • Reward points : 0
  • Joined: 2014/05/14 10:03:19
  • Location: 0
  • Status: offline
Re: Dimmer bouncing whenever any remote button pressed 2018/11/02 08:52:56 (permalink)
+1 (1)
As I told you,

This code in your ISR results in a pulse on RB1 for every ext. interrupt:
LATBbits.LATB1=1; //tric=1;

for(int t=0;t<50;t++);

LATBbits.LATB1=0; //tric=0;
in your ISR you set the RB1 output high, wait a short time, then set it low. This "bounce" occurs EVERY time the INT0 ISR is triggered. Is this the "bounce" you are concerned with?
#34
akibsk
New Member
  • Total Posts : 28
  • Reward points : 0
  • Joined: 2018/10/30 07:07:04
  • Location: 0
  • Status: offline
Re: Dimmer bouncing whenever any remote button pressed 2018/11/02 10:18:47 (permalink)
0
tnx for being with me so long sir.
This is dimming pulse need to fire triac it nedd to be such narrow.
And if it is so, then bounce 100 times in each seconds(for 50hz) automatically and does not allow me to prsess any keys from tv remote.
As shown in schematics in zip, all the relay is working properly and there ware no disturbance for its assigned key as well as others key pressing from the tv remote.
But for dimmer, whenever any keys including its inc/dec, relays-assigned and left-out keys of the tv remote is pressed just bounce once back (off>again on).
Further more, if inc/dec keys from tv remote is pressed the desired dim/brt is also working and getting updated brt/dim  but with just bounce once back on pressing and till releasing the keys.
 
 
If it would enter into RB0 ISR only when the INC/DEC keys pressed, then something may happen toward positive in results.
the algo if wouls be,
1)IR Acquisition & decode
2)control decision
3) RB1 toggle(triac connected pin/INT0IE enable here /then the delay() called through RB0 ISR to fire triac )
4) inc/dec keys pressed(Will check INT0IE enable/  then calculate delay/ call delay() thru isr/fire triac with updated delay)
can be try.
so can u suggest how do i rearrange code for above??
i think RB0 interrupt enabling is being mistake, whenever keys is being pressed its going RB0 ISR routine and thats why goes off/on but for inc/dec keys going on/off but with the desired dim/brt. 
tnx
#35
jack@kksound
code tags!
  • Total Posts : 3198
  • Reward points : 0
  • Joined: 2014/05/14 10:03:19
  • Location: 0
  • Status: offline
Re: Dimmer bouncing whenever any remote button pressed 2018/11/02 10:36:45 (permalink)
+1 (1)
You disable the INT0 interrupt (INT0IE = 0; ) during the IR signal decode, this results in NO calls to the ISR and so your triac is not pulsed during this interval so you get a "bounce" in the output. Why do you disable the interrupt?
#36
akibsk
New Member
  • Total Posts : 28
  • Reward points : 0
  • Joined: 2018/10/30 07:07:04
  • Location: 0
  • Status: offline
Re: Dimmer bouncing whenever any remote button pressed 2018/11/02 10:48:38 (permalink)
0
i thought i will get rid of that bounce. then how the issue will be solved??
i think i make u understand that actual bounce ??
is there any recommendation to resolve the issue sir??
tnx for quick reply 
#37
jack@kksound
code tags!
  • Total Posts : 3198
  • Reward points : 0
  • Joined: 2014/05/14 10:03:19
  • Location: 0
  • Status: offline
Re: Dimmer bouncing whenever any remote button pressed 2018/11/02 10:50:16 (permalink)
+1 (1)
Do not disable the INT0 interrupt, just leave it enabled. Leave all the interrupts enabled.
#38
akibsk
New Member
  • Total Posts : 28
  • Reward points : 0
  • Joined: 2018/10/30 07:07:04
  • Location: 0
  • Status: offline
Re: Dimmer bouncing whenever any remote button pressed 2018/11/02 10:54:04 (permalink)
-1 (1)
so, where is the issue please what should i need to stop the boumce please once go thru my code please sir????? 
#39
jack@kksound
code tags!
  • Total Posts : 3198
  • Reward points : 0
  • Joined: 2014/05/14 10:03:19
  • Location: 0
  • Status: offline
Re: Dimmer bouncing whenever any remote button pressed 2018/11/02 11:03:39 (permalink)
+1 (1)
Read my answer, remove the lines that disable the interrupts:
 INT0IE = 0;

or 
 GIE = 0;

#40
Page: < 123 > Showing page 2 of 3
Jump to:
© 2019 APG vNext Commercial Version 4.5