Sep 10, 2012 #1 P prasad70 Member level 3 Joined Mar 24, 2011 Messages 67 Helped 3 Reputation 6 Reaction score 3 Trophy points 1,288 Activity points 1,690 Can some one please explain what is the wrong with below expressions. if (( X1>9)&&(Y1>12)) RB0 =1 else RB0 =0 ;
Can some one please explain what is the wrong with below expressions. if (( X1>9)&&(Y1>12)) RB0 =1 else RB0 =0 ;
Sep 10, 2012 #2 ismbn Full Member level 3 Joined Feb 11, 2012 Messages 160 Helped 4 Reputation 8 Reaction score 4 Trophy points 1,308 Location Mumbai. india Activity points 2,444 yes you have to make it like this if (( X1>9)&&(Y1>12)) RB0 =1; else RB0 =0 ; try it now it will work ISMAIL
yes you have to make it like this if (( X1>9)&&(Y1>12)) RB0 =1; else RB0 =0 ; try it now it will work ISMAIL
Sep 10, 2012 #3 P prasad70 Member level 3 Joined Mar 24, 2011 Messages 67 Helped 3 Reputation 6 Reaction score 3 Trophy points 1,288 Activity points 1,690 sorry . It was my typing mistake. It doesnt work . thk
Sep 10, 2012 #4 ismbn Full Member level 3 Joined Feb 11, 2012 Messages 160 Helped 4 Reputation 8 Reaction score 4 Trophy points 1,308 Location Mumbai. india Activity points 2,444 is it working now????
Sep 10, 2012 #5 P prasad70 Member level 3 Joined Mar 24, 2011 Messages 67 Helped 3 Reputation 6 Reaction score 3 Trophy points 1,288 Activity points 1,690 no it doesnt work. Compiler doesn't give any error but i dont get any output. - - - Updated - - - below is my code. Code: unsigned char D1=0,D2=0,D3=0 ; unsigned int RSL1=0 ,S2=0, RSL2 =9 ; void main(void) { TRISB = 0x00 ; for(;;) { RSL1++ ; if (( RSL1 >5)&&(RSL2<9)) RB0=1; else RB0 =0 ; if (RSL1 >=9) RSL1 =0 ; } } Last edited by a moderator: Sep 10, 2012
no it doesnt work. Compiler doesn't give any error but i dont get any output. - - - Updated - - - below is my code. Code: unsigned char D1=0,D2=0,D3=0 ; unsigned int RSL1=0 ,S2=0, RSL2 =9 ; void main(void) { TRISB = 0x00 ; for(;;) { RSL1++ ; if (( RSL1 >5)&&(RSL2<9)) RB0=1; else RB0 =0 ; if (RSL1 >=9) RSL1 =0 ; } }
Sep 10, 2012 #6 ismbn Full Member level 3 Joined Feb 11, 2012 Messages 160 Helped 4 Reputation 8 Reaction score 4 Trophy points 1,308 Location Mumbai. india Activity points 2,444 You r making code for what elaborate completely... Are you using any uC here or what???
Sep 10, 2012 #7 P prasad70 Member level 3 Joined Mar 24, 2011 Messages 67 Helped 3 Reputation 6 Reaction score 3 Trophy points 1,288 Activity points 1,690 I am using HI-TECH C® for PIC10/12/16.
Sep 10, 2012 #8 ismbn Full Member level 3 Joined Feb 11, 2012 Messages 160 Helped 4 Reputation 8 Reaction score 4 Trophy points 1,308 Location Mumbai. india Activity points 2,444 I don't have any idea about PIC 10/12... but the program is working fine..may be you are doing some sapling mistake in (TRISB or RB0) ... Code: unsigned char D1=0,D2=0,D3=0 ; unsigned int RSL1=0 ,S2=0, RSL2 =9 ; void main(void) { TRISB = 0x00 ; for(;;) { RSL1++ ; if (( RSL1 >5)&&(RSL2<9)) { RB0=1; } else { RB0 =0 ; } if (RSL1 >=9) { RSL1 =0 ; } } } Ismail
I don't have any idea about PIC 10/12... but the program is working fine..may be you are doing some sapling mistake in (TRISB or RB0) ... Code: unsigned char D1=0,D2=0,D3=0 ; unsigned int RSL1=0 ,S2=0, RSL2 =9 ; void main(void) { TRISB = 0x00 ; for(;;) { RSL1++ ; if (( RSL1 >5)&&(RSL2<9)) { RB0=1; } else { RB0 =0 ; } if (RSL1 >=9) { RSL1 =0 ; } } } Ismail
Sep 10, 2012 #9 P prasad70 Member level 3 Joined Mar 24, 2011 Messages 67 Helped 3 Reputation 6 Reaction score 3 Trophy points 1,288 Activity points 1,690 thks. I will check again.
Sep 10, 2012 #10 FvM Super Moderator Staff member Joined Jan 22, 2008 Messages 52,400 Helped 14,748 Reputation 29,778 Reaction score 14,093 Trophy points 1,393 Location Bochum, Germany Activity points 298,003 The code in post #5 and post #8 will keep RB0=0 constantly (because RSL2 = 9). Is this what you intend?
The code in post #5 and post #8 will keep RB0=0 constantly (because RSL2 = 9). Is this what you intend?
Sep 10, 2012 #11 P prasad70 Member level 3 Joined Mar 24, 2011 Messages 67 Helped 3 Reputation 6 Reaction score 3 Trophy points 1,288 Activity points 1,690 No. I intend to keep RB0 high only when predefined RSL2 < 9 and internal variable RSL1 >5 . During other ranges, RB0 should be low. thks - - - Updated - - - I changed the code like below but still I dont see RB0 changes when program run. Code: unsigned int RSL1=0 , RSL2 =9 ; void main(void) { TRISB = 0x00 ; for(;;) { RSL1++ ; if (( RSL2 <5)&&(RSL1<8)) { RB0=1; } else { RB0 =0 ; } if (RSL1 >=9) { RSL1 =0 ; } } }
No. I intend to keep RB0 high only when predefined RSL2 < 9 and internal variable RSL1 >5 . During other ranges, RB0 should be low. thks - - - Updated - - - I changed the code like below but still I dont see RB0 changes when program run. Code: unsigned int RSL1=0 , RSL2 =9 ; void main(void) { TRISB = 0x00 ; for(;;) { RSL1++ ; if (( RSL2 <5)&&(RSL1<8)) { RB0=1; } else { RB0 =0 ; } if (RSL1 >=9) { RSL1 =0 ; } } }
Sep 10, 2012 #12 FvM Super Moderator Staff member Joined Jan 22, 2008 Messages 52,400 Helped 14,748 Reputation 29,778 Reaction score 14,093 Trophy points 1,393 Location Bochum, Germany Activity points 298,003 How do you check RB0 state? It's supposed to change pretty fast.
Sep 10, 2012 #13 P prasad70 Member level 3 Joined Mar 24, 2011 Messages 67 Helped 3 Reputation 6 Reaction score 3 Trophy points 1,288 Activity points 1,690 I am using MPLAB SIM . - - - Updated - - - once i chnaged if (( RSL2 <5)&&(RSL1<8)) to if ( RSL2 <5 && RSL1<8) probelm dissapered. Now it's solved.
I am using MPLAB SIM . - - - Updated - - - once i chnaged if (( RSL2 <5)&&(RSL1<8)) to if ( RSL2 <5 && RSL1<8) probelm dissapered. Now it's solved.