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.

Inexperience with microcontroller

Status
Not open for further replies.

japl

New Member
Hi

Ive build a counter routine using a PIC16f84, just a basic counter and LCD at a press of a button the counter starts from 5 down to 1 then stops and it's diplayed on a LCD. when i use a 9V battery as supply it's ok but when i use the variable supply at my school it starts to count even without pressing the button wat am I doin or not doin right ive tried a couple times and it still has the same result the counter starts immediately after i turn on the supply.

thank u :D
 
japl said:
Hi

Ive build a counter routine using a PIC16f84, just a basic counter and LCD at a press of a button the counter starts from 5 down to 1 then stops and it's diplayed on a LCD. when i use a 9V battery as supply it's ok but when i use the variable supply at my school it starts to count even without pressing the button wat am I doin or not doin right ive tried a couple times and it still has the same result the counter starts immediately after i turn on the supply.

thank u :D

Try posting the circuit diagram, it sounds like you may not have wired the switch properly?.
 
Try posting the circuit diagram, it sounds like you may not have wired the switch properly?.

Here's the partial routine for U6(SN54HC165)

CBLOCK 0CH
input
bitcount
ENDC


#Define IN PORTB,0 ; Qh
#Define read PORTA,2 ; clk
#Define shiftinclk PORTA,3 ; sh/ld

Push_but
clrf input :delay/debounce routine
movlw .8
movwf bitcount
bsf read
read_input_loop_one
bsf STATUS,C
btfsc IN
bcf STATUS,C
rrf input,f
bsf shiftinclk
bcf shiftinclk
decfsz bitcount,f
goto read_input_loop_one
bcf read

btfss input, 0
goto $+2
call coundown ;coundown routine from 5 to 1
end
 

Attachments

  • drawing2.jpg
    drawing2.jpg
    60 KB · Views: 906
Shouldn't there be pull-up resistors on U6's inputs to keep them high when the switches are not pressed ?
 
japl said:
Try posting the circuit diagram, it sounds like you may not have wired the switch properly?.

Here's the partial routine for U6(SN54HC165)

I've never used that port expander chip, but generally you need pullup resistors on the switches - so I should try adding those and see if it helps.
 
japl said:
Hi

Ive build a counter routine using a PIC16f84, just a basic counter and LCD at a press of a button the counter starts from 5 down to 1 then stops and it's diplayed on a LCD. when i use a 9V battery as supply it's ok but when i use the variable supply at my school it starts to count even without pressing the button wat am I doin or not doin right ive tried a couple times and it still has the same result the counter starts immediately after i turn on the supply.

thank u :D

I have had a similar problem before,(works with a battery but not with a wall wart or mains power supply) mine turned out to be "dirty" power
a 100uF cap sorted it out........just a suggestion
:lol:
 
I've had power supplies that have actualy put out AC power when they were to be DC. If you can check the wave of the power.
Add caps, Pics like clean power.

Kent
 
Your circuit seam to require 5V power, how do you power it from 9V battery (or the regulator is not shown?)
 
Or, three 0.1uF as close to the power inputs to each chip may also resolve, but I think it's the lack of pull-ups combined with noise in the supply.
 
any suggestion on how the best way to handle a pin with no connection and thanks for everyones help :D :D :D
 
If you mean PIC I/O pins with no input, then you can just leave them unconnected and defined as inputs in your TRIS registers.

Set the inital output levels to low for a pin that is an imput, and the PIC will use less power, and the pin will become hi-Z. (from datasheet)


Note that the correct order is:

1. Set output level for the port (PORTA / PORTB)
2. Set Input / Output for port (TRISA / TRISB)
 
kybert said:
If you mean PIC I/O pins with no input, then you can just leave them unconnected and defined as inputs in your TRIS registers.

Set the inital output levels to low for a pin that is an imput, and the PIC will use less power, and the pin will become hi-Z. (from datasheet)

This is something which gets discussed a lot, personally I've found it makes very little difference setting them as inputs or outputs, likewise setting them high or low.

If you're trying to build an extremely low consumption device, using a very slow oscillator, you might be able to reduce it slightly - but I would advise trying the different options and measuring the current consumption.

If your device uses a regulator to provide it's power (7805 or similar) there's not much point, the regulator will waste far more power than the PIC even uses.

I don't even pay any attention now to which way the pins are set, except for the ones I'm using of course!.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top