ZappBots wishes a warm welcome to everyone.

Especially our visitors from
Savage///Circuits and Parallax!!!


Please take a look our new forums, we hope you register and become an active user.

The ZappBots forums are being run on phpBB 3.1.4 software which is different then the vBulletin used on the Savage///Circuits and Parallax forums.
Therefore, things look and work a little different, especially creating posts and uploading images / attachments.


The important thing is we have a place toTalk, Learn and Showcase our projects.

16 segment display multiplexing

The place for members to talk about their Projects In Progress
User avatar
Electrons-R-Fun
Member
Member
Posts: 143
Joined: Tue May 12, 2015 7:03 pm
Contact:

16 segment display multiplexing

Postby Electrons-R-Fun » Sun Mar 12, 2017 5:07 am

HI,

Here is some code I wrote so I can learn how to multiplex 16 segment display. The project is for a car club trophy, I heard Tesla might bring a car to the show so I wanted to do something different and kinda neat, well neat and different for me. Here is some sample code I wrote to start learning how this procedure works. https://youtu.be/3LXBdAm8L6k
I will post the code below, but I was hoping someone might help me by pointing out some flaws, errors, or thinking style changes that should be made.

Here is the code for the testing I was doing on the PPDB. In the constant section I used a number after the Letters because in SPIN it appears the Letters alone mean something and show up in Green instead of Black. but they are the individual 16 segment locations or layout pattern. The code has lots of lines but is very basic. I feel like there is a more elegant style of doing what I attempted and using fewer lines of code. I was thinking for the "L" in "HELLO" I could shorten it by simply coding in a repeat 2. I am simply turning on then off 1 segment at a time so fast that they all appear to be on at the same time. My goals were, to use as few pins as possible, be able to write any letter, use as little power as possible, Have the segments bright enough to see and not flicker.

As a final note the camera light was on during filming so it did "wash out" some of the brightness to the 16 segment display's.

Code: Select all

CON
  _clkmode = xtal1 + pll16x
  _xinfreq = 5_000_000

Con

A1  = 7
A2  = 8
B1  = 9
C1  = 10
D1  = 11
D2  = 12
E1  = 13
F1  = 14
H1  = 15
I1  = 16
J1  = 17
G2  = 18
K1  = 19
L1  = 20
M1  = 21
G1  = 22

Con

AllSegmentsTime            = 1
BlinkTime                  = 150
WordsTime                  = 2
 
PUB Main

  dira[0..22]~~
  outa[0..5]~~
  outa[7..22]~
 
  REPEAT
     repeat 400

        AllSegments0
        AllSegments1
        AllSegments2
        AllSegments3
        AllSegments4
        AllSegments5
       
     repeat 10
       Blink

    Repeat 200   

      Hello

    Repeat 200
     
      World

    repeat 10
       Blink
   
    repeat 200
     
        Hi
        By
        No
       
    repeat 10
        Blink

         
Pub Hi

'all these are to power each segment for H
  !outa[G1]               
  !outa[G2]
  !outa[F1]
  !outa[E1]
  !outa[C1]
  !outa[B1]

' this grounds the whole display for H
   !outa[5]
   pause(WordsTime)

'this turns off the whole display so I don't power and ground segments at the same time  For H
    !outa[5]
   
    !outa[G1]
    !outa[G2]
    !outa[F1]
    !outa[E1]
    !outa[C1]
    !outa[B1]


'all these are to power each segment for I   
  !outa[A1]
  !outa[A2]
  !outa[I1]
  !outa[L1]
  !outa[D2]
  !outa[D1]

' this grounds the whole display for I   
   !outa[4]
   pause(WordsTime)

'this turns off the whole display so I don't power and ground segments at the same time  For I   
    !outa[4]

     !outa[A1]
     !outa[A2]
     !outa[I1]
     !outa[L1]
     !outa[D2]
     !outa[D1]


Pub By

'all these are to power each segment for B
  !outa[I1]               
  !outa[L1]
  !outa[A1]
  !outa[A2]
  !outa[B1]
  !outa[C1]
  !outa[D1]               
  !outa[D2]
  !outa[G1]
  !outa[G2]
 
' this grounds the whole display for B
   !outa[3]
   pause(WordsTime)

'this turns off the whole display so I don't power and ground segments at the same time for B   
    !outa[3]
   
    !outa[I1]               
    !outa[L1]
    !outa[A1]
    !outa[A2]
    !outa[B1]
    !outa[C1]
    !outa[D1]               
    !outa[D2]
    !outa[G1]
    !outa[G2]

'all these are to power each segment for Y
   
  !outa[F1]
  !outa[B1]
  !outa[L1]
  !outa[G1]
  !outa[G2]

' this grounds the whole display for Y   
   !outa[2]
   pause(WordsTime)

'this turns off the whole display so I don't power and ground segments at the same time for Y   
     !outa[2]

     !outa[F1]
     !outa[B1]
     !outa[L1]
     !outa[G1]
     !outa[G2]



Pub NO

'all these are to power each segment for N
  !outa[E1]               
  !outa[F1]
  !outa[H1]
  !outa[K1]
  !outa[C1]
  !outa[B1]
 
 
' this grounds the whole display for N
   !outa[1]
   pause(WordsTime)

'this turns off the whole display so I don't power and ground segments at the same time for N   
    !outa[1]
   
    !outa[E1]               
    !outa[F1]
    !outa[H1]
    !outa[K1]
    !outa[C1]
    !outa[B1]

'all these are to power each segment for O
   
  !outa[A1]
  !outa[A2]
  !outa[B1]
  !outa[C1]
  !outa[D1]
  !outa[D2]
  !outa[E1]
  !outa[F1]
 
' this grounds the whole display for O   
   !outa[0]
   pause(WordsTime)

'this turns off the whole display so I don't power and ground segments at the same time for O 
     !outa[0]

     !outa[A1]
     !outa[A2]
     !outa[B1]
     !outa[C1]
     !outa[D1]
     !outa[D2]
     !outa[E1]
     !outa[F1]


Pub AllSegments0


    !outa[7..22]
    !outa[0]
    Pause(AllSegmentsTime)

    !outa[7..22]
    !outa[0]

Pub AllSegments1


    !outa[7..22]
    !outa[1]
    Pause(AllSegmentsTime)

    !outa[7..22]
    !outa[1]   

Pub AllSegments2


    !outa[7..22]
    !outa[2]
    Pause(AllSegmentsTime)

    !outa[7..22]
    !outa[2]   

Pub AllSegments3


    !outa[7..22]
    !outa[3]
    Pause(AllSegmentsTime)

    !outa[7..22]
    !outa[3]   

Pub AllSegments4


    !outa[7..22]
    !outa[4]
    Pause(AllSegmentsTime)

    !outa[7..22]
    !outa[4]   

Pub AllSegments5


    !outa[7..22]
    !outa[5]
    Pause(AllSegmentsTime)

    !outa[7..22]
    !outa[5]   


Pub Hello

'all these are to power each segment for H
  !outa[G1]               
  !outa[G2]
  !outa[F1]
  !outa[E1]
  !outa[C1]
  !outa[B1]

' this grounds the whole display for H
   !outa[5]
   pause(WordsTime)

'this turns off the whole display so I don't power and ground segments at the same time  For H
    !outa[5]
   
    !outa[G1]
    !outa[G2]
    !outa[F1]
    !outa[E1]
    !outa[C1]
    !outa[B1]

'all these are to power each segment for E
  !outa[A1]               
  !outa[A2]
  !outa[F1]
  !outa[E1]
  !outa[D1]
  !outa[D2]
  !outa[G1]
  !outa[G2]
 
' this grounds the whole display for E
   !outa[4]
   pause(WordsTime)

'this turns off the whole display so I don't power and ground segments at the same time  For E
    !outa[4]
   
    !outa[A1]               
    !outa[A2]
    !outa[F1]
    !outa[E1]
    !outa[D1]
    !outa[D2]
    !outa[G1]
    !outa[G2]

   
'all these are to power each segment for L
  !outa[D1]               
  !outa[D2]
  !outa[F1]
  !outa[E1]
 

' this grounds the whole display for L
   !outa[3]
   pause(WordsTime)

'this turns off the whole display so I don't power and ground segments at the same time  For L
    !outa[3]
   
    !outa[D1]               
    !outa[D2]
    !outa[F1]
    !outa[E1]

'all these are to power each segment for L
  !outa[D1]               
  !outa[D2]
  !outa[F1]
  !outa[E1]

' this grounds the whole display for L
   !outa[2]
   pause(WordsTime)

'this turns off the whole display so I don't power and ground segments at the same time  For L
    !outa[2]
   
    !outa[D1]               
    !outa[D2]
    !outa[F1]
    !outa[E1]

'all these are to power each segment for O
   
  !outa[A1]
  !outa[A2]
  !outa[B1]
  !outa[C1]
  !outa[D1]
  !outa[D2]
  !outa[E1]
  !outa[F1]
 
' this grounds the whole display for O   
   !outa[1]
   pause(WordsTime)

'this turns off the whole display so I don't power and ground segments at the same time for O 
     !outa[1]

     !outa[A1]
     !outa[A2]
     !outa[B1]
     !outa[C1]
     !outa[D1]
     !outa[D2]
     !outa[E1]
     !outa[F1]




Pub World

'all these are to power each segment for W
  !outa[F1]               
  !outa[E1]
  !outa[M1]
  !outa[K1]
  !outa[C1]
  !outa[B1]

' this grounds the whole display for W
   !outa[5]
   pause(WordsTime)

'this turns off the whole display so I don't power and ground segments at the same time  For W
    !outa[5]
   
    !outa[F1]               
    !outa[E1]
    !outa[M1]
    !outa[K1]
    !outa[C1]
    !outa[B1]

'all these are to power each segment for O
   
  !outa[A1]
  !outa[A2]
  !outa[B1]
  !outa[C1]
  !outa[D1]
  !outa[D2]
  !outa[E1]
  !outa[F1]
 
' this grounds the whole display for O   
   !outa[4]
   pause(WordsTime)

'this turns off the whole display so I don't power and ground segments at the same time for O 
     !outa[4]

     !outa[A1]
     !outa[A2]
     !outa[B1]
     !outa[C1]
     !outa[D1]
     !outa[D2]
     !outa[E1]
     !outa[F1]

   
'all these are to power each segment for R


     !outa[A1]
     !outa[A2]
     !outa[B1]
     !outa[G2]
     !outa[G1]
     !outa[F1]
     !outa[E1]
     !outa[K1]

' this grounds the whole display for R
   !outa[3]
   pause(WordsTime)

'this turns off the whole display so I don't power and ground segments at the same time  For R
    !outa[3]
   
     !outa[A1]
     !outa[A2]
     !outa[B1]
     !outa[G2]
     !outa[G1]
     !outa[F1]
     !outa[E1]
     !outa[K1]

'all these are to power each segment for L
  !outa[D1]               
  !outa[D2]
  !outa[F1]
  !outa[E1]

' this grounds the whole display for L
   !outa[2]
   pause(WordsTime)

'this turns off the whole display so I don't power and ground segments at the same time  For L
    !outa[2]
   
    !outa[D1]               
    !outa[D2]
    !outa[F1]
    !outa[E1]

'all these are to power each segment for D
   
  !outa[A1]
  !outa[A2]
  !outa[B1]
  !outa[C1]
  !outa[D1]
  !outa[D2]
  !outa[I1]
  !outa[L1]
 
' this grounds the whole display for D   
   !outa[1]
   pause(WordsTime)

'this turns off the whole display so I don't power and ground segments at the same time for D 
     !outa[1]

     !outa[A1]
     !outa[A2]
     !outa[B1]
     !outa[C1]
     !outa[D1]
     !outa[D2]
     !outa[I1]
     !outa[L1]





                       
Pub Blink

  !outa[6]
  Pause(BlinkTime)
 
PRI Pause(ms)

  waitcnt(clkfreq / 1000 * ms + cnt)                                            ' Convert to mS

Return to “Projects In Progress”

Who is online

Users browsing this forum: No registered users and 3 guests