You could use a 5.1v zenner diode to reduce the 9v down to 5v, but a small 5v regulator should be a better bet.
You could use a 5.1v zenner diode to reduce the 9v down to 5v, but a small 5v regulator should be a better bet.
I guess this is where I get confused with electronics.
I can take a 9V battery and use a resistor to run a 1.5V led without problem but I can't use a resistor the same way to run a 5V chip.
This seems to make sense to everyone but me lol
Ok on to the coding would this chip be able to handle the timer part of this or would I need a dedicated timer chip?
My guess is that there will be about 100 breaks in the beam in a 30 second time.
Currently I'm testing with this code and a led on RB1.
Main:
if PORTB.0 = 1 then
high PORTB.1
else
low PORTB.1
endif
Now that looks like it will work fine but, if the loop happens more than once before the bean is brought back it could count 10 times for every break...
Would this code work and only count once?
broken var byte
broken = 0
Main:
if PORTB.0 = 1 and broken = 0 then
broken = 1
high PORTB.1
else
low PORTB.1
endif
if PORTB.0 = 0 and broken = 1 then broken = 0
goto Main
Last edited by geckogrotto; - 16th August 2006 at 18:32.
Hi geckogrotto. Try something like this.
START:
LET BROKEN = 0
LOW PORTB.1
Main:
IF PORTB.0 = 1 then ACTIVATE 'BEAM BROKEN
GOTO MAIN 'BEAM NOT BROKEN
ACTIVATE:
IF PORTB.0 = 1 THEN ACTIVATE 'WAIT FOR BEAM TO RETURN
LET BROKEN = BROKEN + 1
IF BROKEN >= 10 THEN LIGHTUP 'BEAM NEEDS TO BE BROKEN 10 TIMES
GOTO MAIN
LIGHTUP:
HIGH PORTB.1
GOTO LIGHTUP
Thanks for your suggestion.
Can anyone tell me how to turn on a timer then turn it off and get the amount of time that was timed?
Hi, yes you can reduce the voltage to any set level you choose.
Using Ohm's Law
V. out = V in X (r2 / r1 + r2)
where r1 is the resistor closest to the power in
and r2 is the resistor closest to ground
Example v out = v in or 10 volts X r2, say 500 ohms . . . 5000
divided by r2 + r1, so if r1= 500 ohms you would get 1000 ohms,
so 5000 / 1000 = 5 volts. Simple huh? The problem here is if you lose the ground
foe even an instant then your input sees full supply voltage, also a voltage divider uses power all the time, in this example .01 amp.
OK the attachment didn't work so basicly two resistors in series, one end attached to + and the otherend to minus and you pull power from the connection in the center.
Last edited by Archangel; - 16th August 2006 at 20:21. Reason: TRy to add BMP of schematic
Ok I don't think these actually exist but lets say they do.Originally Posted by Joe S.
If I had exactly 9V in and used
R2 950
R1 760
That would give me exactly 5V out?
About the connection what your saying is resistor to + and the other resistor connected to that and then to the negative and sandwiched in between the 2 would be my output of 5v?
Also if you want shoot me over the attachment to [email protected]
Thanks![]()
That is correct as would 400/500 (notice it adds up to 900) or any variant of above say 1200 /1500 12k/15k what changes as you go upscale is the circuit impeadance (the ability to load the circuit without significant loss of voltage).
If you only want to drive a PIC input pin and not light leds or run motors then use the larger (higher resistance) resistors, that way if you mess up your code and cause an input to become an output, set to low, you will not create a big short.
Bookmarks