How do I do this?

Palm

New Member
OK, here is my to-be setup. I am using a PICAXE-08M as of now, and I was wondering how to do the following setup.

I am planning to use 6 7-Segment LEDs to create an almost "timer" like display with Minutes, Hours, and Seconds. Would I be able to use more than 1 microcontroller in this project? Can it all be done with one?

Any ideas for this project would be helpful.
 

Tom2000

Senior Member
Well, I'm sure you can do the project with one microcontroller, but I doubt if an 08M would be that micro unless you're a very clever programmer.

Consider the Max7219 to drive your display, and possibly a line-derived timebase as I've shown here: <A href='http://www.mindspring.com/~tom2000/clock.html' Target=_Blank>External Web Link</a>

So far, we're OK (maybe) with an 08M, but you need some way of setting the time. I think you've just run out of pins.

If you step up to the 18X, this would be an easy project to bring off.

Tom


 

Palm

New Member
Do you happen to know of a way that I could do this, if I bought 1 or 2 18X(s), so I wouldn't need the extra clock chip?
 

demonicpicaxeguy

Senior Member
i'd go the whole hog and get the chip with the most pins availble to start with

i would wire it up in a similar fashion to whats in the mauual but using a series of transistors as a ground and switch to each digit do the buisness with that digit then move to the next very quickly a 28x1 or 140x1 at full tilt eg,16mhz should be quick enough to light them all up quick enough, they'll flicker a little but thats mothing a capacitor can't solve

 
 

unigamer

Member
Yesterday I coded a clock without the seconds but has hours and minutes. You could add seconds easily enough. It is untested in real time, I had to go out but I think it worked. The code is very much unoptimised as I have a 40X1 and space isn't really an issue for me. Maybe it will give you ideas though!


' (Eventually a) Binary Clock controlled by a PICAXE
' June 2007
' Copyright unigamer@gmail.com 2007


'Begin Code for clock
'----------------------------------------


'Assinging labels to byte varibles
SYMBOL hour_1 = b1
SYMBOL hour_2 = b2

SYMBOL min_1 = b3
SYMBOL min_2 = b4


' Set the starting time for the clock. An example time of 09:23 shall be
' used to show which variable relates to which digit

hour_1 = 0
hour_2 = 9

min_1 = 3
min_2 = 6


main:
debug

'Now update numbers on display
gosub min_1_display
'gosub min_2_display
'gosub hour_1_display
'gosub hour_2_display

pause 60000 'This waits 60 seconds until the next step of changes 60000
min_2 = min_2 + 1 'Add 1 onto the min_2
if min_2 = 9 then min_1_update
goto main




min_1_update:

min_1 = min_1 + 1
min_2 = 0
if min_1 = 6 then hour_2_update
goto main





hour_2_update:
min_1 = 0
hour_2 = hour_2 + 1
if hour_2 = 10 then hour_1_update
if hour_2 = 3 AND hour_1 = 1 then reset_time
goto main




hour_1_update:

hour_2 = 0
hour_1 = 1
goto main




reset_time:
hour_1 = 0
hour_2 = 1
min_1 = 0
min_2 = 0
goto main


'End code for clock
'--------------------------------------------





'Begin Code for displaying the variables (Giving an output)
'This version is for a 4026 seven segment display IC
'---------------------------------------------------



min_1_display:
pulsout 1,10 &#8216; reset display to 0
if min_1 = 0 then return
endif
for b10 = 1 to min_1 &#8216; start a for...next loop
pulsout 0,10 &#8216; pulse clock line
next b10 &#8216; next loop
return


'min_2, hour_1, hour_2 to be added

 
 

moxhamj

New Member
If you really want to do this with one small microcontroller to prove it can be done it may be possible to do this with one 08M if you use a whole pile of HC595s in series. HH:MM:SS = 42 segments = 5 HC595s in series. But this isn't very practical - what you save on one small micro you lose with all the support chips. Bigger chips like the 28X and 40x with multiplexing are possible, but dedicated 7 segment driver chips are the best solution. Even more practical is an LCD module. What is your project?
 

Tom2000

Senior Member
The main advantage of using the Max7219 (or other multi 7-segment driver chips) is that one resistor is used to set the brightness of your whole array. Many solutions (such as trying to do the multiplexing yourself with a whole lot of processor pins or other gates) aren't as neat and clean.

My suggestion adds one chip, but saves 41 resistors.

Tom
 

Palm

New Member
Wow, thanks for all the support. Thanks for the example program unigamer, that might help me later...

After doing some research, I think I will go for a MAX7219 chip after all. I just had two questions about it.
1.Can it be used with my current 08M easily?
2.How hard is one of those to program?

Thanks again for the support.
 

Tom2000

Senior Member
Howdy, Palm,

I don't know how easy it is to use with an 08M, considering that you're going to be doing stuff other than sending data to the display. Give it a try and see if you run out of program space.

I can't find the code for the project where I actually used a 7219... it was a while ago. But I found the following test routine I wrote for the 18X. As you see, there's not much to the 7219 interface code, so it shouldn't occupy too much of your program memory.

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>
































Edited by - Tom2000 on 08/07/2007 18:43:48
 

Palm

New Member
Well then, I think I'll be upgrading to an 18X sometime soon...

About the programming: Can I have the 7-seg led's display things other than JUST numbers with the 7219?
 

papaof2

Senior Member
7 segment displays can display *limited* characters other than numbers.
You must either have the ability to address each segment individually or the driver chip must accept characters other than 0-9.

John
 

Palm

New Member
Thanks for the help...

I think I will get to purchasing an 18X and the 7219. Anyone know where I can buy both at the same time?
 

Tom2000

Senior Member
Yes, Peter Anderson carries both. <A href='http://www.phanderson.com/' Target=_Blank>External Web Link</a>

Tom
 

Palm

New Member
OK thanks. I checked the site out, and I sent the guy an e-mail.

Any other possible places I can get both chips at, incase Peter Anderson doesn't work out?
 

Palm

New Member
Kind of a late update, but oh well:

I need to buy the 18X chip and the MAX clock chip, but PHAnderson is gone until August 22! Where else can I get said parts?
 
Top