PDA

View Full Version : MM5451 35way LED driver example



J_norrie
- 10th May 2008, 10:14
Hi There, I hope this example proves to be helpful to someone. I know that this forum has helped me a lot, and I offer this example in way of a thank you.

I use this to drive a 5 by seven segment digital display via a two wire link. It can be modified to provide digital outputs to drive 35 relays for example.

Should anyone need any help using this please don't hesitate to get in touch.

The routines should be easily adapted to any type of pic using picbasic pro.

'MM5451YN Setup
' output portA.2 'CS/Load pin low to enable clock high to load data to dac output
output portA.0
output portA.1
symbol DCK=portA.1
symbol DDA=portA.0
symbol PSU=portb.7

COUNT2 var word
digout var byte
DAout var word
y var byte

start:
high psu
pause 1500
low psu
goto main

Main:
for daout = 0 to 9999
gosub tablex
next
goto Main
' ----------------------------------------------------------------------------
' Get Value and output to MM5451 display driver
' ----------------------------------------------------------------------------
Display:
shiftout DDA,DCK,0,[Digout\7]
return

tablex:
gosub pulse
for y = 4 to 0 step-1 'gfedcba display segments
if DAout dig y = 0 then digout = %0111111
if DAout dig y = 1 then digout = %0000110
if DAout dig y = 2 then digout = %1011011
if DAout dig y = 3 then digout = %1001111
if DAout dig y = 4 then digout = %1100110
if DAout dig y = 5 then digout = %1101101
if DAout dig y = 6 then digout = %1111101
if DAout dig y = 7 then digout = %0000111
if DAout dig y = 8 then digout = %1111111
if DAout dig y = 9 then digout = %1101111
gosub display
next
return

pulse:
high DDA
high DCK
pause 100
low DCK
low DDA
return
end

sayzer
- 10th May 2008, 11:41
It is a nice behavior that people are sharing their work here just because they had some help.

J_norrie,

Here is a code for your TableX subroutine that will reduce your code size to half of it.




<font color="#000000">TableX:
<font color="#000080"><b>GOSUB </b></font>pulse

<font color="#000080"><b>FOR </b></font>y = <font color="#FF0000"><b>4 </b></font><font color="#000080"><b>TO </b></font><font color="#FF0000"><b>0 </b></font><font color="#000080"><b>STEP</b></font>-<font color="#FF0000"><b>1 </b></font><font color="#000080"><i>'gfedcba display segments
</i><b>LOOKUP </b></font>DAOut <font color="#000080"><b>DIG </b></font>y,[<font color="#FF0000"><b>%0111111</b></font>,<font color="#FF0000"><b>%0000110</b></font>,<font color="#FF0000"><b>%1011011</b></font>,<font color="#FF0000"><b>%1001111</b></font>,<font color="#FF0000"><b>%1100110</b></font>,<font color="#FF0000"><b>%1101101</b></font>,<font color="#FF0000"><b>%1111101</b></font>,<font color="#FF0000"><b>%0000111</b></font>,<font color="#FF0000"><b>%1111111</b></font>,<font color="#FF0000"><b>%1101111</b></font>],DigOut
<font color="#000080"><b>GOSUB </b></font>display
<font color="#000080"><b>NEXT

RETURN


END
</b></font>

mackrackit
- 10th May 2008, 12:42
Thank you J_norrie.

Someone helps you, help someone else.:)

J_norrie
- 12th May 2008, 10:16
Thanks Sayzer once again for your assistance.

cheers john