Menu

Newbie Question - 7 segment displays

Help
2007-04-10
2013-05-30
  • Nobody/Anonymous

    Probably a total newbie question here (I only installed GCBASIC today!), but I'm using the DisplayChar and DisplayValue commands to display characters/numbers on a common anode seven-segment display. Unfortunately, these commands appear to be written for common cathode displays as they are sending the pins that connect to the segments to be lit high and those that should not be lit low.

    This is all good when using a common cathode display as this will switch the appropriate segments on, however when using a common anode display it completes the circuit for the wrong segments and this results in a "negative" image.

    Is there a way of using these commands with the reverse happening? That is, I want the segments to be lit sent low and the others high. Eg to display the number 1, I would want the pins connected to segments b and c to be low and the others all to be high.

    I know I can do this if I use a Darlington Array (ULN2803 for example), however if I could do it programatically, then this would save space on the board.

    I definitely need to use common anode displays as I will be replacing them with much larger displays that would require more current than I would want to source from a PIC.

    Thanks,

    Grant

     
    • Nobody/Anonymous

      For values up to 255 I believe you could use the NOT command, (e.g. value = NOT value), then send it to the the display.  At first glance, a word value will not work?

      If you need to send out a serial word, say to a cascadable 74HC595 serial 8 bit latch, then an invert word sub program like below might work.  As noted in previous posts, you need to break the word down LSByte first, and same on reassembling.

      One must be careful if negative numbers are to be displayed, as in a temperature reading.  Then a two's complement or increment of the LSByte must be performed also.

      The multiple led and seven segment issues have been discussed a lot over at http://www.electro-tech-online.com/micro-controllers/

      Kent

      InvertWord(InvertW)
        InvertWLow = InvertW    'Split word into bytes so byte size
        InvertWHigh = InvertW_H 'assembler operations can be used
         comf  InvertWLow       'Invert Low byte bits in the Register
         'incf  OWTempL         'Add One to Low byte to turn into 2's compliment
         comf  InvertWHigh      'Invert High byte bits
        InvertW = InvertWLow    'Reassemble bytes back into word
        InvertW_H = InvertWHigh
      End Sub

      Note:  The incf is for two's compliment only

       
    • Nobody/Anonymous

      Oops, the OWTempL is an artifact from last program.  Also make sure you initialize your program with all your word variables like, Dim InvertW As Word.

      Kent

       
    • Hugh Considine

      Hugh Considine - 2007-04-10

      If you open 7segment.h and replace:

      DisplayPortA = DispTemp

      with

      DisplayPortA = !DispTemp

      the routines should work with the common cathode displays. You'll need to do this twice, once in DisplayChar and once in DisplayValue. This is the same as what Kent is suggesting - ! and NOT have the same meaning in GCBASIC.

       
    • Nobody/Anonymous

      Thanks Kent and Hugh,

      Hugh's suggestion worked a treat... and best yet, it was so simple!

      Grant

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.