Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Pic16f84

Status
Not open for further replies.

yuchween

New Member
can i ask anyone here
i am doing a project, light guided vehicle and currently my project does not seem fine.

Sometimes my project works very fine and sometimes it is not
i had program my PIC16F84 that is able to receive input from 3 LDRs and then it is suppose to give outputs to 2 motors.
Problem here is there one of my input pins (pin RB7) is giving me trouble. It seems like there is a ground in that pin, but when i reset my PIC(gound pin14,VDD) then reconnect it to the supply), my project works very fine after that.
there is nothing wrong with the program in PIC.

Can someone please tell me what happened to my project? I would appreciate that.
 
maybe you have configured it to be an output. if this is not the problm, then search for shorts (connection betwean GND and RB7). if this aint the problem, then check your sensor. if this is not the problem change the pic. if this is not the problem, then start over again (make a new bot/board).
 
LDR's seem a bit slow for that application - could that be an issue? I know probably not, but I couldnt see components being randomly bad either. Is the circuit bread-boarded? Possible short with jumbers, wires?
 
oops i meant to say i couldnt see components being inconsistantly bad (semiconductors and such). Sorry bout that folks
 
Programming problem this time

Thanks a lot for that infomation. But now i have a new problem with my PIC Program
I wondered what happened to my program
anyone here knows on PicBasicPro compiler?
I used PicBasic Pro to Program my PIC, but at first my vehicle works fine with that program, but later on, the PIC just couldnt work at all.

this is the program

cl var byte
trisb = 224 'port5,port6,port7 input


start:

Low portb
cl = portb

'cl.5 is from left sensor
'cl.6 is from center sensor
'cl.7 is from right sensor
if cl.5 = 1 and cl.7 = 0 and cl.6=1 then left

if cl.5 = 1 and cl.7 = 0 and cl.6=0 then left

if cl.6 = 1 and cl.5 = 0 and cl.7=0 then straight

if cl.5 = 0 and cl.7 = 1 and cl.6=0 then right

if cl.5 = 0 and cl.7 = 1 and cl.6=1 then right

if cl.5 = 0 and cl.6 = 0 and cl.7=0 then stationary


'portb.4 is controlling left motor
'portb.3 is controlling right motor
stationary:
low portb.4
low portb.3
low portb.2
goto start

left:
Low PORTB.4
High PORTB.3
pause 500
high PORTB.2
pause 100
low PORTB.2
goto start

right:
High PORTB.4
LOw PORTB.3
pause 500
high PORTB.2
pause 100
low PORTB.2
goto start

straight:
LOw PORTB.3
LOw PORTB.4
high PORTB.2
goto start



this program was working at first, but now i doesnt know what happened to the PIC even i had changed with a new PIC

Murphy law just happens any time. I project presentation is drawing closer and a lot of things do not seem right.
 
hay help me
i too use pic basic
now i doing projet
i want to computer interfacing
i read resister , to out put pic can read pc ?
 
yuchween said:
anyone here knows on PicBasicPro compiler?

Yup i use it daily
I used PicBasic Pro to Program my PIC, but at first my vehicle works fine with that program, but later on, the PIC just couldnt work at all.
could be hardware of software problem... if you had schematic... it could be sooo handy

Let's try to see what's wrong in your code
Code:
Low portb
MIIP bad practice, you should use
Code:
PORTB=0

Now
Code:
if cl.5 = 1 and cl.7 = 0 and cl.6=1 then left
'
'
'
Could work but you should use the following method
Code:
if (cl.5 = 1) and (cl.7 = 0) and (cl.6=1) then left
kinda fussy way to write IF THEN statements

BUT if it was me i would replace a part of your code by...
Code:
start:
    Low portb
    cl = portb >>5  ' now we keep only Bit 5,6,7
    SELECT CASE cl
        CASE %011,%001 : goto Left  ' if cl.5 = 1 and cl.7 = 0 and cl.6=1 then left
                                    ' if cl.5 = 1 and cl.7 = 0 and cl.6=0 then left

        CASE %010 : goto Straight   ' if cl.6 = 1 and cl.5 = 0 and cl.7=0 then straight

        CASE %100,%110 : Goto Right ' if cl.5 = 0 and cl.7 = 1 and cl.6=0 then right
                                    ' if cl.5 = 0 and cl.7 = 1 and cl.6=1 then right

        CASE %000 : Goto Stationary ' if cl.5 = 0 and cl.6 = 0 and cl.7=0 then stationary
        END SELECT
    GOTO Start

Be sure of the usual PIC practice.. 0.1uF capacitor as close as possible of your PIC and all the plah plah around the motor diving back EMF, PSU sharing... and so on )

You can also use the Melabs forum www.picbasic.co.uk/forum
HTH
 
ye min tun said:
hay help me
i too use pic basic
now i doing projet
i want to computer interfacing
i read resister , to out put pic can read pc ?
Let's making some assumption on that one. You want to interface a PC and a PIC using resistor between them to avoid the use of a hardware inverted like MAX232

YES you can do that if you're going to use a software solution like SERIN/SEROUT/SERIN2/SEROUT2DEBUG/DEBUGIN, you'll need to use the Inverted mode. Pick a resistor between 1-10K and it should work.

HTH
 
Status
Not open for further replies.

Latest threads

Back
Top