7 seg-LED display, serial

Armagon

Member
Dear all:

I need to biuld the 7 seg- LED diplay with 5 digits, I need diplay numbers from 1 to 99999, but no secuncilay, this means that I need to send a ?number? who must to be show into Led display (as LCD display)

Example

serout 6,N2400,(254,"12456")
serout 6,N2400,(254,"79012")
serout 6,N2400,(254,"45678")

________
silver surfer reviews
 
Last edited:

moxhamj

New Member
There are lots of solutions - small picaxes (08s even) running strings of HC595s, big picaxes with lots of outputs or even dedicated 7 segment driver chips of varying complexity. The absolute simplest is to use an LCD display but if you need to use LEDs then it would be helpful to know how fast the digits need to update and also your general level of experience. What is the project for?
 

ylp88

Senior Member
As Dr_Acula said, there are many ways that this could be achieved with each method having advantages and disadvantages over the other possible solutions. My personal preference, and one which sounds like it could suit your needs:

If you want a serial interface, you could use the nice background receive features of the 28X1 to drive your displays while minimising power consumption of the LEDs by multiplexing the display by digit.

The primary output port of the 28X1 can be used to drive the anodes of the LED displays in parallel, while you can then group the cathodes according to digit and multiplex these via some transistors on some other PICAXE outputs. The PICAXE can then continually multiplex these while awaiting new serial data (checking the serial in flag every multiplexing cycle and then checking to see if the required number of bytes has been received).

<b><i>ylp88 </b> </i>
 

inglewoodpete

Senior Member
The project may be simple enough to use an 18X.

The 5 x 7-segment displays would use 12 output pins. 7 output pins would connect to segment LEDs, all commoned together. 5 output pins would drive 5 transistors each connected to the common pin on each digit display. 10 current limiting resistors will be required (5 to the transistor bases and 5 on the transistor collectors). The software would have a 7-segment numeric lookup table and multiplex the displays in a program loop. The actual circuit would depend on whether you have common-anode or common-cathode displays.

With 5 x 7-segment displays and associated components, it may be cheaper to use a 2 x 16 character LCD unit.

Edit: ~sigh~ and I see in the title that you want a serial connection....and Dr_Acula has suggested an LCD already.

Edited by - inglewoodpete on 03/08/2007 07:07:07
 

Tom2000

Senior Member
This looks like a good application for a Max7219 LED driver. <A href='http://www.maxim-ic.com/quick_view2.cfm/qv_pk/1339' Target=_Blank>External Web Link</a>

Tom
 

Armagon

Member
Dear All:

I just download the data sheet from Maxim, but I have some questions

This drive have 3 inputs:

a) CLK- clock
b) LOAD- (CS)
c) DIN- DATA

How connect this 3 inputs, I suppose:

a) CLK- clock connect to SCK- clock picaxe pin output
b) LOAD (CS) no idea where connect this
c) DIN- DATA connect to any output pin for data output

Does the serial PICAXE command change?, or Can I use the same structure?
serout 6,N2400,(254,&quot;12456&quot;) or what will I have to do

Thanks
________
Lincoln Y-block V8 engine
 
Last edited:

womai

Senior Member
The LOAD (or /CS = &quot;not chip select&quot;) pin tells the chip when to listen for data on its input. Connect it to any Picaxe output. You need to pull it low (0V) before you shift in the data, then pull it back high (Vcc=5V) when the data is shifted in. Look at page 6 of the Maxim data sheet.

You can't use the serout command to send the data - this command is for (clock-less) RS-232 type communication. Yes, it's easy to get confused because there is more than one type of transmission scheme that is called &quot;serial&quot;. Instead, look up the shiftout (spiout) command in the Picaxe manual, this is what you need. On the new X1 Picaxes this is a built-in command, for all others the manual shows code that does it manually (although much slower).

Wolfgang
 

MartinM57

Moderator
If you want to know more about PICAXE and MAX7219, then just search the forum - it's been extensively covered....
 

Tom2000

Senior Member
Here's some Picaxe code that drives a Max7219. This is a test routine that just counts from 0 to 9, but it shows you how to connect and drive the chip.

Good luck!

Tom


<code><pre><font size=2 face='Courier'>



;----------------------------------------------------------
;
; Max7219 Test
;
; Tests high performance 7219 write method
; using b1 and b0 bit aliases
;
;----------------------------------------------------------


; Outputs to Max7219

symbol DIN = 0
symbol CLK = 1
symbol CS = 2


; Registers

symbol Opcode = b1 ; used as bit15:b8
symbol Value = b0 ; used as bit7:bit0
symbol Temp = b2
symbol DPMask = b3 ; decimal point mask


; 7219

symbol DCodeReg = $09
symbol DCodeVal = $ff ; B decode for all digits

symbol ScanReg = $0b
symbol ScanVal = $03 ; 4 digits

symbol IntenReg = $0a
symbol IntenVal = $06 ; 17/32

symbol ShutReg = $0c
symbol ShutVal = $01 ; No shutdown


main:

pause 1000 ; Wait for 7219 to power up

gosub Init7219

Temp = 0
DPMask = 0

m1:

Opcode = $01 ; First digit
Value = Temp | DPMask
gosub Send7219

inc Temp

if Temp &gt; 9 then

Temp = 0
DPMask = %10000000 - DPMask ; Toggle decimal point flag

endif

goto m1


end

;---------------------------------

Init7219:

Opcode = DCodeReg
Value = DCodeVal
gosub Send7219

Opcode = ScanReg
Value = ScanVal
gosub Send7219

Opcode = IntenReg
Value = IntenVal
gosub Send7219

Opcode = ShutReg
Value = ShutVal
gosub Send7219

return

;---------------------------------

Send7219:

; Send opcode in b1, data in b0 to 7219

low CS

pin0 = bit15
pulsout CLK,1

pin0 = bit14
pulsout CLK,1

pin0 = bit13
pulsout CLK,1

pin0 = bit12
pulsout CLK,1

pin0 = bit11
pulsout CLK,1

pin0 = bit10
pulsout CLK,1

pin0 = bit9
pulsout CLK,1

pin0 = bit8
pulsout CLK,1

pin0 = bit7
pulsout CLK,1

pin0 = bit6
pulsout CLK,1

pin0 = bit5
pulsout CLK,1

pin0 = bit4
pulsout CLK,1

pin0 = bit3
pulsout CLK,1

pin0 = bit2
pulsout CLK,1

pin0 = bit1
pulsout CLK,1

pin0 = bit0
pulsout CLK,1


high CS

return

</font></pre></code>


























 

Armagon

Member
the format to use as follow:

spiout 1,2,LSB_First, (b1 / 8) ? clock 8 bits from b1

Where:

spiout Command

1 PIN assigned as a CLOCK

2 PIN assigned to send DATA

LSB_First Mode

(b1 / 8) Data

How can I do to assign a extra PIN for LOAD (CS) functions?

________
penny stock picks
 
Last edited:

Tom2000

Senior Member
You'll have to drive the CS lead separately from the spiout operation. In the code posted above, look at the Send7219 sub, and see how I handle the CS lead before and after clocking data to the 7219.

Tom
 

Armagon

Member
Dear All:

I?m trying to use this command ?SPIOUT, but it does not work, the Picaxe editor program (VER 5.1.5), showed me an error ?ERROR: Unknown symbol - LSB_First_L,
I?m not sure if the program is OK or the option is not correct

0 LSB_First_L (LSB first, idles low)
1 MSB_First_L (MSB first, idles low)
4 LSB_First_H (LSB first, idles high)
5 MSB_First_H (MSB first, idles high)

Simple conuter

main:
label_1: let b1 = b1 + 1
low 3 ? Enable LOAD (CS)
pause 10
spiout 1,2,LSB_First_L, (b1 / 8) ? clock 8 bits from b1
high 3 ? Disable LOAD (CS)
pause 500
goto label_1

Where:
PIN 1 = CLK
PIN 2 = DIN
PIN 3 = CS

PICAXE= 20X1

And I saw that this commands works at 8 bits, and the MAXIM MAX7219, works at 16 bit what can I do?

________
Chrysler F platform history
 
Last edited:

hippy

Technical Support
Staff member
My 5.1.5 Manual 2 shows ...<code><pre><font size=2 face='Courier'>Mode is a variable/constant (0-3) which specifies the mode:

0 LSBFirst_L (LSB first, idles low)
1 MSBFirst_L (MSB first, idles low)
4 LSBFirst_H (LSB first, idles high)
5 MSBFirst_H (MSB first, idles high) </font></pre></code> There's only one underline in those named constants ;-)
 

hippy

Technical Support
Staff member
<i>variable/constant (0-3) </i>

Hmmm <img src="smile.gif" width=15 height=15 align=middle>
 

Armagon

Member
I saw that this commands works at 8 bits, and the MAXIM MAX7219, works at 16 bit what can I do?

Note: the Picaxe Editor Programs works OK as follow:

main:
label_1:let b1 = b1 + 1
pause 10
low 3 ? Enable LOAD (CS)
pause 10 spiout 1,2,LSBFirst_L, (b1 / 8) ? clock 8 bits from b1
high 3 Disable LOAD (CS) pause 500
goto label_1


________
Mazda J platform history
 
Last edited:

piclt

Member
Tom2000..... Your Send7219 bit banging SPI shiftout routine looks very simple and handy ! !. Just &quot;rattle&quot; the bits out. Will do MSB first or LSB first just by arranging the order of the bits........
 

Armagon

Member
I saw that this commands works at 8 bits, and the MAXIM MAX7219, works at 16 bit what can I do?,

I suppose that I have to split the 16 bits in 2 separate 8 bits each? And how?
________
vapir air one
 
Last edited:

piclt

Member
Will Tom2000's routine not do it, use two 8 bit bytes, He uses b1 and b0. Send the byte in the right order and also the bits of each byte in right order. I haven't read the Maxim datasheet yet, will look at it and post again
 

piclt

Member
I looked at datasheet....needs 16 bits onlt 12 actually used, D12-D15 dont care probably best Zero.
use two bytes eg.
b1 = %00000101 and b0 = %01010101 or what code you need
You need CS high ie high 3. when no data transfer and also CLK pin1 low
Then
Low 3 to make CS low at start of transfer

then use Tom2000's code to send bits MSB bit15 first. pulsout will give rising CLK for each bit.
Then High 3 to set CS high to end and latch the code into the 7219 register.

If you want to use SPI I think you need to use mode MSBFirst_L and send two bytes.
eg spiout 1,2,MSBFirst_L,(b1 / 8, b / 8)

...........................
 

Tom2000

Senior Member
<i>&quot;Tom2000..... Your Send7219 bit banging SPI shiftout routine looks very simple and handy ! !. Just &quot;rattle&quot; the bits out. Will do MSB first or LSB first just by arranging the order of the bits........&quot; </i>
Actually, I don't think it's my code. I used a 7219 in a project a long time ago, but I wrote the driver in MPASM. I can't find the code, but I don't think it's as elegant as that I posted.

I've been trying to remember where I got the code I posted, or at least the method. I suspect that I got the idea somewhere in this Picaxe forum.

Apologies if I've inadvertently plagiarized anyone in here.

Tom
 
Top