LexManos
- 22nd July 2009, 12:30
I have two questions both unrelated to eachother.
First off I am trying to figure out how I would go about doing something like this: http://www.youtube.com/watch?v=4Hh9FJUTVXU
The catch is, I want this to be controled by as few Pins from a 16f684 as I can (1 if possible). Basically it's going to be a percentage indicator, 10 leds, 0-9% = no lights 10-19% is 1st LED, 20-29% is both 1st and 2nd led, etc...
Next question should be simple, I'm wanting to receive input on multiple pins. As they are PWM IR beams, it's all time based.
Basically, I was thinking:
StartTime, Delay
StartTime = Now
Loop
Delay = Now - StartTime
StartTime = Now
If(Pin1 = High) Then Pin1Count += Delay
If(Pin2 = High) Then Pin2Count += Delay
End LoopPretty straight forward in any other But as I'm completely green to PicBasic, Is there anything like a counter that would give an accurate relative time count in nanoseconds.
Also, my other concern is the actual time delay between each of the comparrisions and increments. I haven't done any of the math on this because as I've said, i'm new to the world of microcontroler programming. I've usually done higher level coding. It needs to be accurate to within like, 50ns (it's pretty straight forward, 600ns pulse is 0, 1200ns pulse is 1, separated by a 600ns low)
Anyways, thats the jist of what i'm trying to do, no flaming me please, if im insane simply tell me.
First off I am trying to figure out how I would go about doing something like this: http://www.youtube.com/watch?v=4Hh9FJUTVXU
The catch is, I want this to be controled by as few Pins from a 16f684 as I can (1 if possible). Basically it's going to be a percentage indicator, 10 leds, 0-9% = no lights 10-19% is 1st LED, 20-29% is both 1st and 2nd led, etc...
Next question should be simple, I'm wanting to receive input on multiple pins. As they are PWM IR beams, it's all time based.
Basically, I was thinking:
StartTime, Delay
StartTime = Now
Loop
Delay = Now - StartTime
StartTime = Now
If(Pin1 = High) Then Pin1Count += Delay
If(Pin2 = High) Then Pin2Count += Delay
End LoopPretty straight forward in any other But as I'm completely green to PicBasic, Is there anything like a counter that would give an accurate relative time count in nanoseconds.
Also, my other concern is the actual time delay between each of the comparrisions and increments. I haven't done any of the math on this because as I've said, i'm new to the world of microcontroler programming. I've usually done higher level coding. It needs to be accurate to within like, 50ns (it's pretty straight forward, 600ns pulse is 0, 1200ns pulse is 1, separated by a 600ns low)
Anyways, thats the jist of what i'm trying to do, no flaming me please, if im insane simply tell me.