Hi there
I'm using the attached module for a dual 7-segment decoder. It works fine except one thing: the segment should show "1" if the BCD-code has got the value of 0, so the display shows numbers starting from 1 up to 100 instead of 0 up to 99.
I gues the answer is pretty easy but I'm not very familar with ABEL code. So in my opinion the solution is to add 1 to the current BCD-value (= Zahl) and then can very easily go through the truth table.
Can somebody help and tell me, where I have to change my code???
Timo
module bcd7_2seg title 'seven segment display decoder'
" angepasst auf ein Ausgabe a-g und einer Ansteuerung für " LowerSegment und HigherSegment
" The 5 -bit binary (0 - 64) score is converted into two BCD outputs. " The integer division '/' and the modulus operator '%' are used to " extract the individual digits from the two digit score. " 'Score % 10' will yield the 'units' and " 'Score / 10' will yield the 'tens'
" a " --- " f| g |b " --- " e| d |c " ---
" Zwischengrössen V7..V0 node;
EN,S5..S0,Clock pin; "Steuereingänge
a,b,c,d,e,f,g pin istype 'com'; "7Seg.Ausgänge Einer Seg pin istype 'com'; Zahl=[S5..S0];
bcd1 =[V3..V0]; bcd2 =[V7..V4];
ON,OFF = 0,1; " for common anode LEDs L,H,X,Z = 0,1,.X.,.Z.;
binary = 0; "scratch variable clear macro (a) {@const ?a=0}; inc macro (a) {@const ?a=?a+1;};
equations when !EN&Clock then Seg=ON else when !EN&!Clock then Seg=OFF;
@dcset
truth_table ( Zahl -> [bcd2,bcd1]) clear(binary); @repeat 64 {binary -> [binary/10,binary%10]; inc(binary);}
truth_table ([bcd2,bcd1,Seg] -> [ a , b , c , d, e , f , g ]) [X,0,ON] -> [ ON, ON, ON, ON, ON, ON, OFF];" [X,1,ON] -> [OFF, ON, ON, OFF, OFF, OFF, OFF]; [X,2,ON] -> [ ON, ON, OFF, ON, ON, OFF, ON]; [X,3,ON] -> [ ON, ON, ON, ON, OFF, OFF, ON]; [X,4,ON] -> [OFF, ON, ON, OFF, OFF, ON, ON]; [X,5,ON] -> [ ON, OFF, ON, ON, OFF, ON, ON]; [X,6,ON] -> [ ON, OFF, ON, ON, ON, ON, ON]; [X,7,ON] -> [ ON, ON, ON, OFF, OFF, OFF, OFF]; [X,8,ON] -> [ ON, ON, ON, ON, ON, ON, ON]; [X,9,ON] -> [ ON, ON, ON, ON, OFF, ON, ON]; [0,X,OFF] -> [ OFF, OFF, OFF, OFF, OFF, OFF, OFF]; "führende Nullen aus [1,X,OFF] -> [OFF, ON, ON, OFF, OFF, OFF, OFF]; [2,X,OFF] -> [ ON, ON, OFF, ON, ON, OFF, ON]; [3,X,OFF] -> [ ON, ON, ON, ON, OFF, OFF, ON]; [4,X,OFF] -> [OFF, ON, ON, OFF, OFF, ON, ON]; [5,X,OFF] -> [ ON, OFF, ON, ON, OFF, ON, ON]; [6,X,OFF] -> [ ON, OFF, ON, ON, ON, ON, ON]; [7,X,OFF] -> [ ON, ON, ON, OFF, OFF, OFF, OFF]; [8,X,OFF] -> [ ON, ON, ON, ON, ON, ON, ON]; [9,X,OFF] -> [ ON, ON, ON, ON, OFF, ON, ON];
end