Value of ADC to 7 Seg. Display


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2006
    Location
    INDIA
    Posts
    89

    Default Value of ADC to 7 Seg. Display

    Hi all
    My code is

    adcin 0, B0

    The value of B0 is 1021

    if i send to lcd code is

    LCDOUT $FE,1
    LCDOUT "VALUE ",DEC B0

    But how can B0 value (1021) send to 4, comn. anod 7 seg. display ?
    becoz with lookup table we send first 1 and second 2 third 0 and forth 1

    but value is combined how we extract this in four variable, eg B0, B1, B2, B3

    Please HELP

  2. #2
    Join Date
    Feb 2005
    Location
    Kolkata-India
    Posts
    563


    Did you find this post helpful? Yes | No

    Default Cheap is to multiplex

    Hi,

    There are two solutions to your problem. One is hardwiring some 7-Segment Decoder/Driver chips to drive the LED displays like CD4543.The other is to multiplex the LED displays and drive them from the PIC directly. The first one is not cheap but leaves you room (time) for other tasks if you are doing plenty. The second one is cheap and most opted method. You drive all the segments (of all the displays) from a PIC port and use four additional transistors to switch the common cathods.

    PBP has got a DIG function that gets you the BCD equivalent from a varaiable. So you just get DIG0,DIG1,DIG2,DIG3 to some different variables and throw them to the display. If you are using multiplexing then you need to convert this value into suitable segment drives by the lookup (63,6,91,79,102,109,125,7,127,111) assuming you a-g (common catode) is connected to PORT.0-PORT.6

    I don't have the schematics handy. May be someone else does.

    Regards

    Sougata

  3. #3
    Join Date
    Feb 2008
    Location
    Michigan, USA
    Posts
    231


    Did you find this post helpful? Yes | No

    Default Re: Value of ADC to 7 Seg. Display

    Having a problem that I don't understand concerning this subject, wonder if I can resurrect it?

    I'm driving 8 digits of LED 7 segment display multiplexed with a 18F4431. The display elements are decoded with a lookup table. All is well with numbers 0-9, but I'm having trouble understanding how to add a few Alpha characters.

    Another bit of info is that this is a menu portion of the code and is selected using a rotary encoder with a push button for entry. It just increments Temp.

    What I believe are the relevant lines of code are below:
    Code:
    FOR Idx = 0 TO 7
      SELECT CASE Idx
        CASE 0
         Temp = ValueD DIG 0
        CASE 1
         Temp = ValueD DIG 1
        CASE 2
         Temp = ValueD DIG 2
    ......
       END SELECT
    '                      0, 1, 2, 3,  4,   5,   6,  7,  8,   9,  dp,  L,  H,  C,  S,    A,  n, blank   ( what they represent)
    LOOKUP Temp,[63,6,91,79,102,109,125,7,127,111,128,56,119,57,109,119,84,0] DigDef
    
    SEGDIF (Idx) = DigDef
    The problem is that I don't seem to be able to incorporate a single digit value to a lookup table more than 0-9. I realize that the table is 18 elements long , and I can drop 2 to get it into a HEX representation (16), but I can't even get past 9 (10). Any ideas?

    Thanks for looking
    Mark

  4. #4
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,597


    Did you find this post helpful? Yes | No

    Default Re: Value of ADC to 7 Seg. Display

    Your loop will only convert first 8 characters (0-7).

    Robert

  5. #5
    Join Date
    Feb 2008
    Location
    Michigan, USA
    Posts
    231


    Did you find this post helpful? Yes | No

    Default Re: Value of ADC to 7 Seg. Display

    Thanks Demon

    I may not have explained very clearly, sorry.
    The Idx sequence is to separate the different digits. There are 8 digits total. I'm trying to use the lookup table to access the values that will activate the segments to display properly on a 7 seg display.

    It does 0-9 properly, The issue that I'm having is getting it to display a few more characters...

    My way of thinking is that I should be able to have the variable with a value of 0-15 with a single value in the variable (in HEX), and it should be able to access that many steps into the table. Evidently, I'm wrong, because I haven't gotten it to work.

    The issue revolves around accessing >10 indexes in the table with a variable that I have to separate into digits for the 7 seg display (using the DIG modifier). I may have to rethink how I'm doing that part to get this to work.

    Thanks for any input.
    Mark

  6. #6
    Join Date
    Apr 2011
    Location
    Welches, Oregon
    Posts
    198


    Did you find this post helpful? Yes | No

    Default Re: Value of ADC to 7 Seg. Display

    I'm going to try...

    Lets look at displaying 123S4n

    First, I think, you will need to convert the segment definition for each character you wish to display to decimal and place it in the lookup table. For the digits this is easy because the index = the number you wish to display: For the first digit (1) the lookup index is 1, so DigDef is loaded correctly (1=1)... Same for 2 (2=2) and 3 (3=3)... Each digit you want displayed occupies the correct index, so all is fine.

    Now we come to "S". What is the index of the definition of "S"? S=?? There is no numerical equivalent to S... So, I think, in order to make it work, you'll have to change your CASE statements to decode the character rather than the position like:

    If your byte array contains 6 elements [0] being 1 ... [5] being "n" - from the example above, then:

    FOR IDX = 0 to 5
    SELECT CASE STRING[IDX] 'Return the character in position IDX
    CASE 0
    TEMP=0 'CHARACTER 0 is at index 0
    CASE 1
    TEMP=1 ' 1 is at index 1...
    CASE 2
    TEMP=2
    CASE 4
    TEMP=4
    ...
    CASE "S" ' I think you'll need the ASCII value for "S" here
    TEMP=15 ' "S" is at index 15
    CASE "n"
    TEMP = 17 ' "n" is at index 17
    ...
    END SELECT
    NEXT IDX

    My thought, if I understand correctly, is that you will want to select the correct index based on the character rather than the position. I'm something of a noob myself and I don't know for sure that you can decode strings like I've demonstrated ("S"). You may need to use the ASCII value of the letter 83(?).
    Last edited by Amoque; - 28th October 2014 at 23:27.

Similar Threads

  1. LED Machine Tach For Tired Eyes
    By Archangel in forum mel PIC BASIC Pro
    Replies: 33
    Last Post: - 27th January 2010, 14:55
  2. Single digit 7 Seg LED clock - PIC16F88
    By thirsty in forum Code Examples
    Replies: 4
    Last Post: - 17th July 2009, 08:42
  3. Replies: 14
    Last Post: - 26th September 2007, 05:41
  4. 7 segment digit problem (using Mister E's code)
    By jmgelba in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 9th September 2005, 20:25
  5. WRITE not working
    By servo260 in forum mel PIC BASIC Pro
    Replies: 31
    Last Post: - 29th December 2004, 02:02

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