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.

[SOLVED] using if command in hitec c

Status
Not open for further replies.

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 ;
 

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
 

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
 

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:

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???
 

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.
 

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
 

FvM

Super Moderator
Staff member
Joined
Jan 22, 2008
Messages
49,415
Helped
14,441
Reputation
29,146
Reaction score
13,238
Trophy points
1,393
Location
Bochum, Germany
Activity points
284,375
The code in post #5 and post #8 will keep RB0=0 constantly (because RSL2 = 9). Is this what you intend?
 

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 ;
		}
	}
}
 

FvM

Super Moderator
Staff member
Joined
Jan 22, 2008
Messages
49,415
Helped
14,441
Reputation
29,146
Reaction score
13,238
Trophy points
1,393
Location
Bochum, Germany
Activity points
284,375
How do you check RB0 state? It's supposed to change pretty fast.
 

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.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top