• 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.

RB0 pic problem

Status
Not open for further replies.

newnew

New Member
hello.
i made a simple circuit attached.
to count interrupt at RB0, the software start and make u edit the number of pulses and then start the interrupt , when the number of pulses reach what u want , it stops
the pic is attached to push-switch and lcd via sockets.
the circuit works very well on easypic 3 where rb0 is attached to pulldown resistor of 10k
when i made the circuit outside the devboard
i get solid blocks all over the lcd, untill i connect RB0 to +v, then it works !!, if i try to pull it down as in easypic3 , it wont work, attach a resistor to +v , dont work
i tried everything
setting pin as input , as output, pulling up/down floating pins , nothing works except connectin RB0 to +5V ,
but then how can it count if its always connected to +5

i will appreciate any help please

thanks
 

ericgibbs

Well-Known Member
Most Helpful Member
hello.
i made a simple circuit attached.
to count interrupt at RB0, the software start and make u edit the number of pulses and then start the interrupt , when the number of pulses reach what u want , it stops
the pic is attached to push-switch and lcd via sockets.
the circuit works very well on easypic 3 where rb0 is attached to pulldown resistor of 10k
when i made the circuit outside the devboard
i get solid blocks all over the lcd, untill i connect RB0 to +v, then it works !!, if i try to pull it down as in easypic3 , it wont work, attach a resistor to +v , dont work
i tried everything
setting pin as input , as output, pulling up/down floating pins , nothing works except connectin RB0 to +5V ,
but then how can it count if its always connected to +5

i will appreciate any help please

thanks
hi,
The circuit is not yet posted.?

Please post your FULL program.:)
 

ericgibbs

Well-Known Member
Most Helpful Member
hi,
I see the EDIT.:)

You should have a pullup resistor on RB0 if you are using a switch as an input.

Please post you program.
 

newnew

New Member
here are the code
its in basic but very easy to understand

program test2
dim LCD_RS as sbit at RB2_bit
LCD_EN as sbit at RB3_bit
LCD_D4 as sbit at RB4_bit
LCD_D5 as sbit at RB5_bit
LCD_D6 as sbit at RB6_bit
LCD_D7 as sbit at RB7_bit


LCD_RS_Direction as sbit at TRISB2_bit
LCD_EN_Direction as sbit at TRISB3_bit
LCD_D4_Direction as sbit at TRISB4_bit
LCD_D5_Direction as sbit at TRISB5_bit
LCD_D6_Direction as sbit at TRISB6_bit
LCD_D7_Direction as sbit at TRISB7_bit
' End Lcd module connections

dim count as word
dim ml as word
dim txt2 as string [5]


sub procedure interrupt
inc (count)
INTCON.intf = 0 ' set T0IE, claer T0IF
end sub




main:

TRISA = %11111111
TRISB = %00000001
portb.1=0
INTCON = 0 ' disbale interrupt for new cycle
CMCON = 7 ' Comparator off
VRCON = 0 ' Voltage Reference off
count = 0
ml = 300 ' Set intial value

Lcd_Init() ' Initialize Lcd
lcd_cmd(_lcd_clear) ' Clear display
Lcd_Cmd(_LCD_CURSOR_OFF) ' Cursor off
Lcd_Out(1,1,"**** READY *****")


' ******** Entering value of ml and checking its value and displaying it ******

Lcd_Out(2,1,"VALUE =" )

while porta.3=0
if portb.1=1 then portb.1=0 end if

Delay_ms(80)

if Porta.1 = 1 then
ml = ml + 5
if ml > 350 then ml = 350 end if
end if

if Porta.2 = 1 then
ml = ml - 5
if ml < 175 then ml = 175 end if
end if

wordtostr (ml,txt2)
Lcd_Out(2,12, txt2 )

wend

'************************************************************************

INTCON = %10010000 ' Start the RB0 interrupt

lcd_cmd(_lcd_clear)
Lcd_Out(1,1,"* wait *")
Lcd_Out(2,9,txt2)



ml = ml*2.38
portb.1=1
while true

if count > 5 then goto main end if
wend

end.



defining the interrupt from hi to low or opposite is not important for me , however i would like to know how can i do it

again this worked fine in the easypic3

i tried offcourse pulling rb0 up and down with no result .

thanks
 

ericgibbs

Well-Known Member
Most Helpful Member
hi,
I have had to modify your Basic statements to suit my compiler.
Which basic are you using.?

The RB.0 interrupt works OK an a high going edge.:)
 

newnew

New Member
the code works fine on the devlopment board but not in my circuit !!
its driving me crazy,
i am using mikrobasic pro
 

ericgibbs

Well-Known Member
Most Helpful Member
COME ON GUYS
i found whats wrong
its so clear :)
i leave u to guess work
Why dont you tell us what YOU did wrong, so that others may benefit.?
 
Last edited:

Mikebits

Well-Known Member

newnew

New Member
not lame at all
i was going to say it anyway, just i felt i am idiot i didnt get it from the start .

look in the circuit above the pic ;)

capacitor in series , now how lame is that

thanks all
 

ericgibbs

Well-Known Member
Most Helpful Member
not lame at all
i was going to say it anyway, just i felt i am idiot i didnt get it from the start .

look in the circuit above the pic ;)

capacitor in series , now how lame is that

thanks all
hi,
Looking at the dwg, the 33pf caps are not in series with the crystal but connected either side of the the crystal to 0V, which is correct.!:p
They are too high a value for a 20MHz xtal.

What did you do to make it work.?
 
Last edited:

newnew

New Member
i didnt mean these caps

i meant the cap connected to PS1 to Vdd , that supply power to the pic
i connected the pic to power through a series cap, it should be parallel which made the pic power fluctuate and make strange things
when i connect the RB0 to power it some how supplied power to the pic and made it works .

i fixed that and connected the pic to power through parallel cap , pulled down RB0 and everything is ok


thanks a lot guys
 
Status
Not open for further replies.

EE World Online Articles

Loading
Top