Contemplating a new 8 x 24 LED display

Post here to let others know of a project you're working on.

Moderators: Chuckt, Garth, bitfogav

Post Reply [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
MrDEB
I practically live here!
I practically live here!
Posts: 372
Joined: Fri Feb 18, 2011 4:24 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Contemplating a new 8 x 24 LED display

Post by MrDEB » Wed Jun 25, 2014 1:07 am

While waiting for the ICSP expander boards I have been mulling over ideas for an 8 x 24 led matrix display to display the temperature of the beer cooler I am kinda in charge of. Our membership voted to increase the refrigeration system from 6K BTU's to 12K BTU's ($4100 worth of equipment) and wanting to display the present cooler temperature which we try to keep at 34 degrees. We serve draft beer and going from a cooler temp of 40 degrees down to 34 has saved a-lot of beer foam-over (the beer foams less the cooler it is We went from 10 gallons over-foam to 1 quart aprox in a 7 day period.)
Anyway contemplating how to best achieve the desired results. Using basically the same code as my 8 x 8 scrolling matrix project but using a 200 ohm resistor for each of the 24 anodes (using 3-common cathode 8 x 8 matrix displays)then use 3 - uln 2803 to sink the current (idea from Graham Mitchel's Tetris game).Yes maybe could get by with one uln2803 but may exceed the chips sinking spec.
My idea hangup is converting the DS18B20 output to the led matrix.
Using

Code: Select all

IF DS18B20.Find THEN
                DS18B20.Convert
                GetTemp(TempA, TempB)
                TempF = ((TempA*10+TempB/1000)*9/5+320)/10
Then using CONST arrays to display the value of TempF on the LED matrix. Basically converting TempF to a 16bit longword I think?? Unless there is a method to directly convert the DS18B20 10 bit output to a 16 bit output (Pretty sure I need the 16bit output for the display (8 bits per digit) but need more research.
Any ideas are welcomed.

User avatar
brad
Site Admin
Site Admin
Posts: 2578
Joined: Fri Mar 26, 2010 10:30 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Contemplating a new 8 x 24 LED display

Post by brad » Fri Jun 27, 2014 10:10 am

My current project will certainly help you with this. I'm at work at the moment but will be able to write something up for you when I get home.

User avatar
brad
Site Admin
Site Admin
Posts: 2578
Joined: Fri Mar 26, 2010 10:30 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Contemplating a new 8 x 24 LED display

Post by brad » Fri Jun 27, 2014 11:21 pm

Okay now I'm home.

My latest project is the USB meter device. It uses a current / voltage / power measuring chip that outputs data to the microcontroller via the i2c bus. It is quite a nice little chip to use really. Anyway, the microcontroller will request these values one at a time from the chip.

I then display this current / voltage / power data on a little 5x10 LED matrix. (the numbers are 5 pixels high by 3 pixels wide - the screen scrolls so you can see all of the info). Here's an example of you to display the current data:

:arrow: The microcontroller will request current data from the sense chip.
:arrow: The sense chip will send back the current data e.g. 512mA
:arrow: The microcontroller will then use this number in conjunction with data from a number table stored in program memory to display '512 mA' on the LED display.

Here's the code that contains the digits 0 - 9 in a program memory number table:

Code: Select all

Const NumberTable(30) As Byte = (%00011111,%00010001,%00011111,%00001001,%00011111,%00000001,%00010111,%00010101,%00011101,%00010001,%00010101,%00011111,%00011100,%00000100,%00011111,%00011101,%00010101,%00010111,%00011111,%00010101,%00010111,%00010000,%00010000,%00011111,%00011111,%00010101,%00011111,%00011101,%00010101,%00011111)
Here's the code to separate the three digits contained within '512' into their own digit. I.E. Number1 will hold '5', then number 2 will hold '1' and number3 will hold '2':

Code: Select all

	    Number1 = CurrentReading
	    Number1 = Number1 Mod 10   
	    Number2 = CurrentReading * 10 
	    Number2 = Number2 Mod 10     
	    Number3 = CurrentReading * 100
	    Number3 = Number3 Mod 10
Then to display these digits in the form of 512 mA on the screen, I have this code:

Code: Select all


ScreenData(0) = NumberTable(Number1 * 3)
ScreenData(1) = NumberTable(Number1 * 3 + 1) 
ScreenData(2) = NumberTable(Number1 * 3 + 2) 
ScreenData(3) = %00000000
ScreenData(4) = NumberTable(Number2 * 3)  
ScreenData(5) = NumberTable(Number2 * 3 + 1)  
ScreenData(6) = NumberTable(Number2 * 3 + 2) 
ScreenData(7) = %00000000 
ScreenData(8) = NumberTable(Number3 * 3) 
ScreenData(9) = NumberTable(Number3 * 3 + 1)  
ScreenData(10) = NumberTable(Number3 * 3 + 2)  
ScreenData(11) = %00000000  
ScreenData(12) = %00000000  
ScreenData(13) = %00000111  
ScreenData(14) = %00001000  
ScreenData(15) = %00000111  
ScreenData(16) = %00001000  
ScreenData(17) = %00000111  
ScreenData(18) = %00000000
ScreenData(19) = %00011111  
ScreenData(20) = %00010100  
ScreenData(21) = %00011111 
Hopefully some of that at least will make sense!

MrDEB
I practically live here!
I practically live here!
Posts: 372
Joined: Fri Feb 18, 2011 4:24 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Contemplating a new 8 x 24 LED display

Post by MrDEB » Sat Jun 28, 2014 10:37 pm

Looks interesting I might give it a whirl but first I need to assemble an ICSPexpander board (got the boards from DIRTY PCB)
Lots of minor customizing on the enclosure to fit it all in.
THANKS

MrDEB
I practically live here!
I practically live here!
Posts: 372
Joined: Fri Feb 18, 2011 4:24 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Contemplating a new 8 x 24 LED display

Post by MrDEB » Sat Aug 02, 2014 12:45 am

Finally got the 8 x 32 matrixs connected up, checked all connections and voltages. Now on to writing code to scroll across the 8 x 32 display.
Using 74hc595's to drive the leds common cathode displays and uln2803 to sink.
Having only done one 8 x 8 matrix that scrolled I am apprehensive about trying the 8 x 32. Going to test code using only one 8 x 8 then progress to 8 x 32.
The shift,bas is what concerns me and using a loop to scan the cathodes.
Here is my beginning code that needs to be tested so not even sure it will even begin to work. Hopefully have time Saturday to give it a whirl. Suggestions are appreciated.

Code: Select all

{

}
DEVICE = 18F4520
CLOCK = 8
 
// external xtal
CONFIG OSC = HS
 
// uncomment next line to use internal osc
//Include "InternalOscillator.bas"          // module sets Config OSC = INTIO7 for you
 
INCLUDE "shift.bas"
INCLUDE "utils.bas"
'INCLUDE "convert.bas"
 
  
    INCLUDE "convert.bas"
   ' INCLUDE "DS18B20.bas"
    INCLUDE "Utils.bas"
    INCLUDE "internaloscillator.bas"
   
 
// SHIFT REGISTER STUFF 
' pin 18 RC3 = LATCH
' pin 24 RC4 = DATA
' pin 25 RC5 = CLOCK

DIM LE  AS PORTC.3   // LATCH
DIM SDI AS PORTC.4  // DATA
DIM CLK AS PORTC.5  // CLOCK

DIM DataPin  AS SDI  
DIM ClockPin AS CLK
DIM latch    AS LE



//ULN 2803 inputs enable = LOW
DIM C_athodes AS portB
 
DIM count AS BYTE 
DIM X AS BYTE   




CONST Anodes(25)AS BYTE = (%00010000, %00000001, %00000100, %00001000, %00000100, 
                         %00010000, %00000001, %00000100, %00001000, %00000100,
                         %00010000, %00000001, %00000100, %00001000, %00000100,
                         %00010000, %00000001, %00000100, %00001000, %00000100,
                         %00010000, %00000001, %00000100, %00001000, %00000100)
 
CONST Cathodes(25) AS BYTE = (%11111111, %00000001, %00000010, %00000010, %00000100, 
                              %00000010, %00000010, %00000100, %00000100, %00001000,
                              %00000100, %00000100, %00010000 ,%00001000, %00010000,
                              %00001000, %00001000, %00100000, %00010000, %00100000,
                              %00010000 ,%00100000, %00010000 ,%00100000, %01000000)
SUB RIGHT()
    DIM index AS BYTE 
    DIM X AS BYTE
 
    FOR index = 0 TO BOUND (Anodes)
        DELAYMS(10)//10 500us for constant on
        X = Anodes(index)
 
        LE = 0
       
        Shift.Out(MSB_FIRST, X ,8)  
        LE = 1         //Latch data
        PORTB = Cathodes(index)  
        DELAYUS(20) //20 us
       
     
        LE = 0
    NEXT
 
END SUB
 

 
END SUB
 
// start of main
SetAllDigital
 
Shift.SetOutput(DataPin)   // data out pin  (RC4)
Shift.SetClock(ClockPin)   // shift reg clock (RC5)
 

HIGH(LE)             // make output and set low
FOR X = 0 TO 7 
PORTB = 1         // outputs are off
NEXT
TRISB = %00000000       // make PORTB outputs
TRISC = %00000000       // make PORTC as outputs
// clears out registers.
DataPin = 0
ClockPin = 0
 
 
WHILE true                   // durring RIDE the code jumps to here if switch = 1
 
  //  Dim index As Byte 
  //  Dim X As Byte
 
    FOR index = 0 TO BOUND (Anodes)
        DELAYMS(500)//10 500us for constant on
        X= Anodes(index)
 
        LE = 1
      
        //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        
 
    //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx  
 
        Shift.Out(MSB_FIRST, X ,8)  
        LE = 1         //Latch data
        PORTB = Cathodes(index)  
        DELAYUS(200) //20 us
       
        LE = 0
 
    NEXT
 
WEND
END

MrDEB
I practically live here!
I practically live here!
Posts: 372
Joined: Fri Feb 18, 2011 4:24 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Contemplating a new 8 x 24 LED display

Post by MrDEB » Sun Aug 03, 2014 1:26 pm

Got the previous code somewhat working but needs work. In the mean time I had ordered some MAX7219 kits off eBay so working with one 8 x 8 matrix I got the display to come on but that's it. It needs less tweeking than the board w/ 4 - 74hc595s but I just got started.I figure I might as well go the KISS route.

Code: Select all

{
*****************************************************************************
*  Name    : UNTITLED.BAS                                                   *
*  Author  : [select VIEW...EDITOR OPTIONS]                                 *
*  Notice  : Copyright (c) 2014 [select VIEW...EDITOR OPTIONS]              *
*          : All Rights Reserved                                            *
*  Date    : 7/21/2014                                                      *
*  Version : 1.0                                                            *
*  Notes   :  Using the MAX7219 kit from Ebay and Tap 28 w/ crystal                                                              *
*          :                                                                *
*****************************************************************************
}

DEVICE = 18F2420
CLOCK = 20
 

 
INCLUDE "shift.bas"
INCLUDE "utils.bas"
INCLUDE "convert.bas"
   ' INCLUDE "DS18B20.bas"
INCLUDE "Utils.bas"


DIM Loadpin  AS PORTC.3   // LATCH
DIM Datapin AS PORTC.4  // DATA
DIM Clockpin AS PORTC.3  // CLOCK
DIM count AS BYTE 
DIM X AS BYTE   
DIM index AS BYTE 


 
CONST Anodes(32)AS BYTE = (%00000001, %00000010, %00000100, %00001000, %00010000,%00000001, %00000010, %00000100, 
                          %00001000, %00010000, %00100000, %01000000, %10000000,%00100000, %01000000, %10000000,
                          %00000001, %00000010, %00000100, %00001000, %00010000,%00000001, %00000010, %00000100, 
                          %00001000, %00010000, %00100000, %01000000, %10000000,%00100000, %01000000, %10000000)   
                         
                           
CONST Cathodes(2) AS BYTE = (%11111111, %00000000) 
                            
                              
                             
SUB RIGHT()
    DIM index AS BYTE 
    DIM X AS BYTE
     
    FOR index = 0 TO BOUND (Anodes)
      Loadpin = 0
       ' DELAYuS(100)//10 500us for constant on
        X = Anodes(index)
        Shift.Out(MSB_FIRST, X ,8)  
      
        DELAYUS(20) //20 us
     
    NEXT
 
END SUB
 
// start of main
SetAllDigital
Shift.SetOutput(DataPin)   // data out pin  (RC4)
Shift.SetClock(ClockPin)   // shift reg clock (RC5)
loadpin = 0             // make output and set low


TRISB = %00000000       // make PORTB outputs
TRISC = %00000000       // make PORTC as outputs

OUTPUT(loadpin)
 
WHILE true 
RIGHT()

WEND
END

User avatar
brad
Site Admin
Site Admin
Posts: 2578
Joined: Fri Mar 26, 2010 10:30 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Contemplating a new 8 x 24 LED display

Post by brad » Wed Aug 06, 2014 11:26 pm

If you wanted to use the KISS philosophy, I would do away with the constant arrays to scan through your cathodes. Hopefully I'll have a little more time tomorrow to post some helpful advice but, have you connected the 74595's in such a way that they are all connected in series? I.E. the Q7 output of the first 74595 connects to the input of the second 74595 and so forth?

This is certainly a great way to go rather than trying to have different micro controller pins controlling their own 74595.

MrDEB
I practically live here!
I practically live here!
Posts: 372
Joined: Fri Feb 18, 2011 4:24 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Contemplating a new 8 x 24 LED display

Post by MrDEB » Fri Aug 08, 2014 12:49 pm

YES they are in series as per http://embedded-lab.com/blog/?p=2661
Got kinda frustrated and received the Max7219's so trying to get them to work but getting no where when it comes to scrolling more than on matrix.
May step back and go back to the 74595's.

User avatar
bitfogav
Moderator
Moderator
Posts: 915
Joined: Sun Mar 28, 2010 9:03 pm
Location: United Kingdom
Contact:

Re: Contemplating a new 8 x 24 LED display

Post by bitfogav » Fri Aug 08, 2014 7:19 pm

SHughes as given a great explanation on how to control the max7219 on the SF forum.
To help you understand, the DOUT output of the first MAX7219 mirrors the DIN input but 'delayed' by two bytes.

So if you send 4 bytes then do a latch the second MAX7219 will get the first two bytes and the first MAX7219 will get the second two.

You only do one latch per transmission, don't latch after every two bytes.

So if you want to update the second device only, send two data bytes (one 16 bit word) followed by two zero (NOP) bytes then latch.

To update the first device send two NOP bytes then two data bytes then latch.

To update both send four data bytes then latch.

Remember that once you transmit data it will carry on moving through the devices on each clock so it is easiest to always transmit enough data for the number of devices you have cascaded. For example, if you only send 2 bytes to change the first device then send two more, the first two will end up being loaded in to the second device.
If you don't know what Voltage your country is using, you shouldn't be doing electronics ;-)

User avatar
brad
Site Admin
Site Admin
Posts: 2578
Joined: Fri Mar 26, 2010 10:30 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Contemplating a new 8 x 24 LED display

Post by brad » Sat Aug 09, 2014 11:53 pm

That write up looks spot on bitfogav!

Post Reply
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Who is online

Users browsing this forum: No registered users and 7 guests