Menu

7 segment led commands Common anode or cath.

Help
2009-02-10
2013-05-30
  • Nobody/Anonymous

    Hi all. Do these commands expect a common anode display to be hooked up, or common anode?

    Is there a way to invert the output from sink to source, for example?

    Is there a way to search this forum so i don't waste people's time answering 'the same old' questions?

    Thanks,

    Chay

     
    • Nobody/Anonymous

      Found the answer by searching the hard way. The command is set up for common cathode.

      To go common anode, use:

      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

      Chay

       
    • kent_twt4

      kent_twt4 - 2009-02-10

      The search function is in the forum drop down menu when scrolled over.  A ticket has been opened with sourceforge.net for a "request for enhancement".  The sourceforge.net first level support has acknowledged he has been pinged on this lately, and suspect the request has been sent up the ladder.  The idea is to get the search box back in plain view, the way it used to be, before the recent website makeover.

      Here's a thought on modifying the 7segment.h include file for common anode displays.  Perhaps a little less confusing than my previous post?

      During code initialization make use of the compilers pre-processor by using the #define statement:

      #define 7segment ComAnode

      Then in 7sement.h modify the DisplayValue and DisplayChar  subs.  There will be four PortX instances (A, B, C, and D) for each sub.  So starting with the first display in the DisplayValue sub, it would be modified like so:
      ;OLD
      DisplayPortA = DispTemp

      ;NEW
      #IFNDEF 7segment ComAnode
      DisplayPortA = DispTemp
      #ENDIF
      #IFDEF 7segment ComAnode
      DisplayPortA = !DispTemp
      #ENDIF

      And so on down the line.

      Save the file, and should be good to go.

       
    • Nobody/Anonymous

      Thanks for the search info...very useful.

      I have common cathode displays, therefore I'm set. But it's good to know it can be made to work if I drop into a bunch of cheap common anodes.

      Chay

       
  • Nobody/Anonymous

    I have done this, and added 7segment ComAnode to my constants, but it still sends negative pins HIGH.  Any help?

     
  • kent_twt4

    kent_twt4 - 2010-02-08

    I think this can be simplified to just one define and two statements, if an old 7segment.h file is to be believed.

    In program before Main, use: #def CommonAnode

    In 7segment.h file from the include/lowlevel folder, insert two statements as follows and save it (Ctrl+S):

    1. In the DisplayValue() sub insert #ifdef CommonAnode lines:

    if DispChar = 9 then DispTemp = 103
    '*****************************
        #ifdef CommonAnode
          DispTemp = !DispTemp
        #endif
    '*****************************
        'Select display and show integer
    

    2. In the DispChar() sub insert #ifdef CommonAnode lines:

    if DispChar = 90 then DispTemp = 27 'Z
    ShowChar:
    '*****************************
        #ifdef CommonAnode
          DispTemp = !DispTemp
        #endif
    '*****************************
        'Select display and show integer
    
     

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.