Hi again ;)
I`m not sure it`s a problem so much as something not quite right (probably on my part), but I`m trying the 7 segment function out using a 4x common cathode display, and all works well when using 2 digits, in fact the example code that counts to 99 works perfectly.
so i`m trying to expand this to 3 or more digits and this is where I`m hitting a brick wall.
my code is:
;Chip Settings
#chip 16F877A,20
#config BODEN=OFF, WDT=OFF, OSC=HS
'Shows the digits
Repeat 250
DisplayValue 1, num1
Wait 1 ms
DisplayValue 2, num2
Wait 1 ms
DisplayValue 3, num3
Wait 1 ms
End Repeat
Loop
this should display 123, but instead i get something that looks like "a3a".
I was hoping to use all 4 segments to display the AN0 as 0 to 1024 and other things.
can anyone tell me where I`v gone wrong please.
Thanks!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
on the off chance that it IS coded just for 2 digits, I`v writen a simple work-around, that will let you use 4x7 seg displays, and More!
this is based on Common Cathode types that are multiplexed, the cathodes are fed with port B and the digit segments with port D.
if you`re using an 877a like me, then you can "cheat" and use port E and get that to count in Binary for each stage and feed a 74138 to drive 8x 7 segments in only 3 bits, and lets be honest, port E is pretty useless for most stuff anyway ;)
here`s the code, it will output the number "2095" on your display:
dir portd out
dir portb out
Do Forever
num1=3
num2=1
num3=10
num4=6
portb = 254
readtable display,num1,temp
portd = temp
wait 5 ms
portb = 253
readtable display,num2,temp
portd = temp
wait 5 ms
portb = 251
readtable display,num3,temp
portd = temp
wait 5 ms
portb = 247
readtable display,num4,temp
portd = temp
wait 5 ms
loop
the 5 MS delay doesn`t really need to be there, it`s left over from debugging when it`s value was 500MS (lets me see what`s happening).
the Num values can be whatever you like, and if you parse with /1000 /100 /10 etc… to separate the digits, then you could use a 10 bit Analogue value to display if you wanted :)
Have fun :)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi again ;)
I`m not sure it`s a problem so much as something not quite right (probably on my part), but I`m trying the 7 segment function out using a 4x common cathode display, and all works well when using 2 digits, in fact the example code that counts to 99 works perfectly.
so i`m trying to expand this to 3 or more digits and this is where I`m hitting a brick wall.
my code is:
;Chip Settings
#chip 16F877A,20
#config BODEN=OFF, WDT=OFF, OSC=HS
;Defines (Constants)
#define DISP_SEG_A PORTd.0
#define DISP_SEG_B PORTd.1
#define DISP_SEG_C PORTd.2
#define DISP_SEG_D PORTd.3
#define DISP_SEG_E PORTd.4
#define DISP_SEG_F PORTd.5
#define DISP_SEG_G PORTd.6
#define DISP_SEL_1 PORTb.0
#define DISP_SEL_2 PORTb.1
#define DISP_SEL_3 PORTb.2
Do Forever
Num1 = 1
Num2 = 2
Num3 = 3
'Shows the digits
Repeat 250
DisplayValue 1, num1
Wait 1 ms
DisplayValue 2, num2
Wait 1 ms
DisplayValue 3, num3
Wait 1 ms
End Repeat
Loop
this should display 123, but instead i get something that looks like "a3a".
I was hoping to use all 4 segments to display the AN0 as 0 to 1024 and other things.
can anyone tell me where I`v gone wrong please.
Thanks!
on the off chance that it IS coded just for 2 digits, I`v writen a simple work-around, that will let you use 4x7 seg displays, and More!
this is based on Common Cathode types that are multiplexed, the cathodes are fed with port B and the digit segments with port D.
if you`re using an 877a like me, then you can "cheat" and use port E and get that to count in Binary for each stage and feed a 74138 to drive 8x 7 segments in only 3 bits, and lets be honest, port E is pretty useless for most stuff anyway ;)
here`s the code, it will output the number "2095" on your display:
;Chip Settings
#chip 16F877A,20
#config BODEN=OFF, WDT=OFF, OSC=HS
;Data tables
Table display
b'01111110'
b'00110000'
b'01101101'
b'01111001'
b'00110011'
b'01011011'
b'01011111'
b'01110000'
b'01111111'
b'01110011'
End Table
dir portd out
dir portb out
Do Forever
num1=3
num2=1
num3=10
num4=6
portb = 254
readtable display,num1,temp
portd = temp
wait 5 ms
portb = 253
readtable display,num2,temp
portd = temp
wait 5 ms
portb = 251
readtable display,num3,temp
portd = temp
wait 5 ms
portb = 247
readtable display,num4,temp
portd = temp
wait 5 ms
loop
the 5 MS delay doesn`t really need to be there, it`s left over from debugging when it`s value was 500MS (lets me see what`s happening).
the Num values can be whatever you like, and if you parse with /1000 /100 /10 etc… to separate the digits, then you could use a 10 bit Analogue value to display if you wanted :)
Have fun :)