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
Bookmarks