I recently purchased a 4 place 7 segment display. It uses the popular saa1064 to drive the 7 segs.
Looking at this post preview, all the tabs are messed up? I don't know why that is?
Anyway, this works good for my battery monitoring app.
Thanks for looking.
Paul
Looking at this post preview, all the tabs are messed up? I don't know why that is?
Anyway, this works good for my battery monitoring app.
Thanks for looking.
Paul
Code:
; ************************************
; ***** Super Duper Header File *****
; ************************************
; Filename: SAA1064
; Date: 03142013
; File Version: 1.1
; Written by: Paul Tribbey
; Function: 7 seg driver
; Last Revision:
; Target PICAXE: 20M2
; ************************************
symbol thousands = b0
symbol hundreds = b1
symbol tens = b2
symbol ones = b3
symbol seg7input = w2
symbol SAA1064 = %01110000 'SAA1064 i2c address
symbol SAA1064ctrl = %01110111 'SAA1064 display control byte - $70=all current, $07=dynamic, not blanked.
'See SAA1064 datasheet on google if needed.
Main:
readadc10 C.1,seg7input 'read an analog value - a voltmeter maybe.
seg7input = seg7input *48/10 'approximation for 0 to 5V.
call seg7
goto main
seg7: 'SAA1064 output subroutine. data loaded in seg7input.
hi2csetup i2cmaster, SAA1064, i2cslow, i2cbyte 'make sure i2c is pointing at SAA1064.
hi2cout 0, (SAA1064ctrl) 'setup the SAA1064.
bintoascii seg7input, thousands, thousands, hundreds, tens, ones 'the first thousands is not used but has to be there.
thousands=thousands - 48 '$48 is acii "0" so point to 63.
lookup thousands,(63,6,91,79,102,109,125,7,127,111),thousands '7 segment digits 0 to 9.
hundreds=hundreds - 48
lookup hundreds,(63,6,91,79,102,109,125,7,127,111),hundreds
tens=tens - 48
lookup tens,(63,6,91,79,102,109,125,7,127,111),tens
ones=ones - 48
lookup ones,(63,6,91,79,102,109,125,7,127,111),ones
If thousands=63 then 'blanks left digits if zero.
thousands=0
if hundreds=63 then
hundreds=0
if tens=63 then
tens=0
endif
endif
endif 'end zero blanking.
hi2cout 1,(thousands,hundreds,tens,ones) 'output to 7 segment.
pause 100 'helps stabilize display.
return
Last edited: