Multiple LEDs and Time Coount


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2009
    Posts
    5

    Default Multiple LEDs and Time Coount

    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:

    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:
    Code:
    StartTime, Delay
    StartTime = Now
    Loop
      Delay = Now - StartTime
      StartTime = Now
      If(Pin1 = High) Then Pin1Count += Delay
      If(Pin2 = High) Then Pin2Count += Delay
    End Loop
    Pretty 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.

  2. #2
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Hello LexManos,
    Welcome to the forum !
    We usually don't even flame spammers, only arrogant, unappreciative little turds I will take a swing at the first request. I think I would use a PWM output feeding an LM3914 / LM3915 to control the LEDs, only 1 pin on the PIC.
    Regarding the second request: The ir beams you are decoding, are they constantly on, are they different, does the data on each change,and is there a priority of 1 over any other, or a priority hierarchy? Check out BRUCE's website here: http://www.rentron.com
    Last edited by Archangel; - 22nd July 2009 at 17:58.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  3. #3
    Join Date
    Jul 2009
    Posts
    5


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Joe S. View Post
    I think I would use a PWM output feeding an LM3914 / LM3915 to control the LEDs, only 1 pin on the PIC.
    Was kinda hoping that i wouldn't need anything to fancy. But, thats not that big of a deal. I can worry about it later, lower on the priority.

    Quote Originally Posted by Joe S. View Post
    Regarding the second request: The ir beams you are decoding, are they constantly on, are they different, does the data on each change,and is there a priority of 1 over any other, or a priority hierarchy? Check out BRUCE's website here: http://www.rentron.com
    No, they are not always on, the data that would be transfered over them are different. But the format is the same [(byte)ID, (Word) Data] No priority hierarchy they will all be the same.

    This is a vary basic setup we built LED hooked up to PORTA5, TSOP4840 data pin hooked up to PORTC1

    Code:
    TRISA = %00000000  
    TRISC = %11111111
    
    High PORTA.5
    
    loop:
      if (PORTC.1 = 1) then 
    test:
        LOW PORTA.5
        pause 1000
        high PORTA.5  
        pause 1000
        goto test
      Endif
      goto loop
    
    end
    Pretty obvious what we want it to do to test, but, the LED stays solid, no flashing :/

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    http://www.picbasic.co.uk/forum/showthread.php?t=561
    Do not let the thread title fool you, your PIC has analog on PORTC also.
    Try a non analog pin or turn the ADC off and see what happens.
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    http://www.picbasic.co.uk/forum/showthread.php?t=561
    Do not let the thread title fool you, your PIC has analog on PORTC also.
    Try a non analog pin or turn the ADC off and see what happens.
    Data sheet sec4.1 . . . ANSEL and CMCON registers MUST be initialized to configure an analog channel as a digital input. Pins configured as analog inputs will read "0" .
    You have these registers to contend with:
    ADCON
    ADCON1
    ANSEL
    CMCON0
    CMCON1
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

Similar Threads

  1. Hello, long time no post (ADC sample rate)
    By Jhong2 in forum General
    Replies: 0
    Last Post: - 14th April 2009, 04:13
  2. I don't understand this code!
    By Russ Kincaid in forum mel PIC BASIC Pro
    Replies: 46
    Last Post: - 13th February 2008, 02:55
  3. Use of a PIC
    By Edwardo in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 22nd March 2007, 14:11
  4. help with 16f628a
    By thalia in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 3rd May 2006, 08:16
  5. Problem with intensity.. plz help
    By Srigopal007 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 7th October 2004, 17:25

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts