Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic 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] works with proteus but does not work on bread board

Status
Not open for further replies.

lifiq

Junior Member level 2
Joined
Jan 11, 2011
Messages
22
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,497
#define intruder PORTB.f7
#define button_ON PORTB.f6
#define blockcar PORTD.f7

char j[10] = "AT+CMSS=1"; // COMMAND SEND MESSAGE FROM

int enter = 0X0D; // COMMAND FOR ENTER
char i;
void main()
{
trisb = 0xff; // SET PORTB AS INPUT
portd = 0x00; // SET INITIAL VALUE FOR PORTD
trisd = 0x00; // SET PORTD AS OUTPUT
uart1_init(9600); // SYNCHRONIZE BAUDRATE WITH HANDPHONE
trisc.f7 = 1; // SET Rx DATA IN
trisc.f6 = 0; // SET Tx DATA OUT

while(1)
{
ON:
while(1)
{blockcar=0;
if(button_ON==0)
{
goto ON;
}
else if (button_ON==1)
{
goto INTRUDER;
}
}
INTRUDER:
while(1)
{ if((button_ON==1)&&(intruder==1))
{
goto SSMS;
}
}
SSMS:
while(1)
{ for(i=0;i<10;i++)
uart1_write(j); // SENDING CHARACTER FOR SENDS SMS

uart1_write(enter);
goto USERINT; // GO TO BLOCKING CAR
}
USERINT:
while (1)
{ blockcar=1; // BLOCKING THE CAR
if (button_ON==0) // WAIT FOR USER INTERRUPT
{goto ON; // BACK TO START AFTER USER INTERRUPT
}
}
}
}



this is my code that i wrote on my pic18f452...it works fine on proteus....i have 2 input pins which are pin 39 for start and pin 40 for intruder detection.....but when i implement it on breadboard.....when i put 5v input on the start pin 39....it triggers the output pin 30....but the output is not 5v voltage level but lesser than that....why is this happening....i used pic micro pro 4.15 to compile the code and when i import it onto proteus it works fine....what am i doing wrong?
 

lifiq

Junior Member level 2
Joined
Jan 11, 2011
Messages
22
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,497

this is my image of connection it is very simple circuit
 

alexan_e

Administrator
Joined
Mar 16, 2008
Messages
11,895
Helped
2,021
Reputation
4,158
Reaction score
2,031
Trophy points
1,393
Location
Greece
Activity points
64,377
Proteus lets you do some think that can't be done in reality, one of them is that you are driving the relay directly from the mcu pin, this is not possible in reality because the pin current is low, you need to use a transistor to drive the relay.

Alex

---------- Post added at 20:35 ---------- Previous post was at 20:33 ----------

A second one is that the led doesn't burn when you connect it directly to 5v without a resistor to limit the current, you can't do that in reality either, you will burn the led.
Use a resistor about 270 ohm in series with the led.

Alex
 

alexan_e

Administrator
Joined
Mar 16, 2008
Messages
11,895
Helped
2,021
Reputation
4,158
Reaction score
2,031
Trophy points
1,393
Location
Greece
Activity points
64,377
The way you use your button inputs is not very good, you should use either pull up resistors (internal or external) and gnd the inputs when the button is pressed or do the opposite (pull down and apply Vcc when the button is pressed).
I haven't used pic but I think that your input is floating until you apply the positive supply using the button, this is not good, the state of the pin should be forced with a resistor when nothing is connected to it.

Also avoid goto as much as possible because one wrong goto can make you code stuck, you can do easily what you want without it.

Alex
 

lifiq

Junior Member level 2
Joined
Jan 11, 2011
Messages
22
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,497
ok i have done that....i have replaced the relay with and led for testing purposes as well as connected it in series with 220 ohm resistor....the problem is still the same when i apply input to pin 39 which starts the entire program....it triggers an output on pin 40 for intruder detection without any reason.....i have tried absolutely everything....but it still triggers the output on pin 40 without applying any input to pin 39...

sequence is such....pin 39 high, pin 40 high then ...........pin 30 high

---------- Post added at 01:55 ---------- Previous post was at 01:51 ----------

sorry for my last post pls ignore it.....i did the same as u said replace the relay with led through 220 ohm resistor.....but when i apply input to pin 39 to start program it triggers a high in output pin 30 without any reason......it should be high in pin 39 start program then high in pin 40 intruder sensor then high as output in pin 30.....why is this...????

---------- Post added at 02:04 ---------- Previous post was at 01:55 ----------

alex can u show me in a diagram how to use pull up resistor for the internal external and gnd the inputs thingy....im not that good with circuits......
 

alexan_e

Administrator
Joined
Mar 16, 2008
Messages
11,895
Helped
2,021
Reputation
4,158
Reaction score
2,031
Trophy points
1,393
Location
Greece
Activity points
64,377
I'm not sure about the resources available in pic, I think there is only internal pull up available, in that case you enable the pull up and then connect the button to gnd.
To do it externally you can connect a 10k resistor from the pin to the gnd as pull down (this will work fine with your current button configuration).
The pull up resistor is a resistor from the pin to the Vcc supply, in that case the button should apply the gnd.
The pull resistor defined the pin state when there is no signal connected, so with a pull down the input will read 0 unless the Vcc is connected using the button.

Alex
 

lifiq

Junior Member level 2
Joined
Jan 11, 2011
Messages
22
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,497
thanks dude the pull down resistor did the trick......thank u so much dude
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top