Usual way is to use a lookup table to display the numerical representation of your number.
Usual way is to use a lookup table to display the numerical representation of your number.
If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
.
Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
.
There simply is no "Happy Spam" If you do it you will disappear from this forum.
if you mean 'lookup '3' and get code '1111001' then i'm good with that but i do'nt get how that helps writing to the specific lcddata registers and the individual bits as above.
Picbasic manual suggests that QUOTE - "All of the PICmicro registers, including the ports, can be accessed just like any other byte-sized variable in PICBASIC PRO™. " but can variables be defined in an array, table etc
It's the code ( in this case displaying '0' ) that i'm trying to change:-
LCDDATA2.6 = 1
LCDDATA2.7 = 1
LCDDATA8.7 = 1
LCDDATA11.6 = 1
LCDDATA8.6 = 1
LCDDATA5.6 = 1
LCDDATA5.7 = 0
'cos to display 10 numbers (0-9) as above requires 10 repeats of the above code, and of course the other two 7-seg display requires a further 20 code blocks of the above.
Any suggestions for cutting all of that down would be appreciated
alastair
Let's see the code in context as to how you are using it, The little bit you posted I cannot make heads or tails of it. Basically you assign a port to the displays and your number to a variable . . . Index var byte . . then from the manual . . ..var is where the segment patterns are stored, then port = var . . . value is the segment pattern of each number. Use the DIG statement to select each individual digit to cycle through the lookup loop.Code:LOOKUP2 Index,[value, value, value . . .],var
Last edited by Archangel; - 17th January 2009 at 18:14.
If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
.
Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
.
There simply is no "Happy Spam" If you do it you will disappear from this forum.
Thanks Joe S for sticking with this !
Mabye a little more detail on the mechaatronics demo board. Its pre-wired to drive directly an on-board 3 1/2 digit 7 segment numeric display via the SEG pins . The right hand charactor segments are labeled 1a,1b,1c,1d,1e,1f,1g. the middle charactor segments are labled 2a,2b,2c -- etc through to the left hand third charactor 3g.
The fourth charactor is only a '1' and is labled 4b and 4c.
Also on the display are numerous logos ie battery,negative sign,speaker,diode,Volts,Amps etc (like a cheap multimeter digital display)
(i hope the below formats properly)
---3a-- --2a-- --1a--
| | | | | | |
4b 3f 3b 2f 2b 1f 1b
| | | | | | |
---3g-- ---2g-- --1g--
| | | | | | |
4c 3e 3c 2e 2c 1e 1c
| | | | | | |
---3d--- ---3d--- --1d--
Now these are mapped onto the 16f917 registers LCDDATA0 through to LCDDATA11 in what seems almost at random. To give you a small flavour ( if this formats correctly) of the first four registers:-
LCDDATA0 LCDDATA1 LCDDATA2 LCDDATA3
bit0 A - s1 V
bit1 RC - - BATT
bit2 DH - - RH
bit3 3a 3b - 3f
bit4 - - - -
bit5 - - 2b -
bit6 2a - 1a 2f
bit7 - - 1b -
where -=not connected, and A,RC,DH,BATT,RH,s1 are some of the logos mentioned above
this mapping continues all the way to register LCDDATA11
As for my code. This is very initial playing with the demo board, no actual programs yet, just seeing how it works. 'Hello world' stuff on the display
So appart from initial initialisation of the LCDSE0,LCDSE1 and LCDSE2 registers to allow for using the pins as lcd direct drive (SEG0 to SEG23 on the pic16917 pins) - Thats all im doing so far. Each code line sets just one bit in a LCDDARA register which maps to one lcd display element ie
LCDDATA2.6 = 1 switches on lcd element 1a
LCDDATA2.7 = 0 switches off lcd element 1b
by doing this one by one Im able to swith on/off all elements in the diplay, and so in my code displayed above :-
" lcddata2.6=1 'seg a
lcddata2.7=1 'seg b
lcddata8.7=1 'seg c
lcddata11.6=1 'seg d
lcddata8.6=1 'seg e
lcddata5.6=1 'seg f
lcddata5.7=1 'seg g "
im switching on all the elements in the 1st charactor 7-segment display.
My real problem is therefore that these display elements are spread all over the LCDDATA registers and im creating charactor displays by manipulating register bits one by one.
Im therefore trying to cut down on the above by trying to see if i can group the sets of register bits in some way in array or table etc,
for example :- ( in pseudocode 'cos i dont know if it can be done in picbasic)
CHR0 var byte(lcddata2.6,lcddata2.7,lcddata8.7,lcddata11.6, lcddata8.6,lcddata5.6,lcddata5.7)
if this can be done ( my original question) then i can feed the byte patterns to VAR CHR0 (directly or by lookup table) to change the Right hand numeric display charactor as needed.
I hope the above explains things
Alastair
The below re-done cos i am not allowedto edit the post above - changed cos the formatting changes when displayed in the forum.
Thanks Joe S for sticking with this !
Mabye a little more detail on the mechaatronics demo board. Its pre-wired to drive directly an on-board 3 1/2 digit 7 segment numeric display via the SEG pins . The right hand charactor segments are labeled 1a,1b,1c,1d,1e,1f,1g. the middle charactor segments are labled 2a,2b,2c -- etc through to the left hand third charactor 3g.
The fourth charactor is only a '1' and is labled 4b and 4c.
Also on the display are numerous logos ie battery,negative sign,speaker,diode,Volts,Amps etc (like a cheap multimeter digital display)
(i hope the below formats properly)
---3a-- --2a-- --1a--
| | | | | | |
4b 3f 3b 2f 2b 1f 1b
| | | | | | |
---3g-- ---2g-- --1g--
| | | | | | |
4c 3e 3c 2e 2c 1e 1c
| | | | | | |
---3d--- ---3d--- --1d--
(edited cos the above doesnt show correctly in the forum - think of 1888 with the top cross bar of the '8' s being ( from left to right) 3a,2a,1a then in normal 7 segment labeling a to g for each segment)
Now these are mapped onto the 16f917 registers LCDDATA0 through to LCDDATA11 in what seems almost at random. To give you a small flavour ( if this formats correctly) of the first four registers:-
LCDDATA0 bit0 = A, LCDDATA0 bit1 =RC, ALCDDATA0 bit2 = DH, ALCDDATA0 bit3 = 3a ALCDDATA0 bit4 = *,ALCDDATA0 bit5 = *, ALCDDATA0 bit6 = 2a, LCDDATA0 bit7 = *
LCDDATA1 bit0 = *, LCDDATA0 bit1 =*, ALCDDATA0 bit2 = *, ALCDDATA0 bit3 = 3b ALCDDATA0 bit4 = *,ALCDDATA0 bit5 = *, ALCDDATA0 bit6 = *, LCDDATA0 bit7 = *
LCDDATA2 bit0 = s1, LCDDATA0 bit1 =*, ALCDDATA0 bit2 = *, ALCDDATA0 bit3 = *, ALCDDATA0 bit4 = *,ALCDDATA0 bit5 = 2b, ALCDDATA0 bit6 = 1a, LCDDATA0 bit7 = 1b
( just edited above cos the table layout didnt work out of edit mode, its easier to see in a table)
where *=not connected, and A,RC,DH,BATT,RH,s1 are some of the logos mentioned above
this mapping continues all the way to register LCDDATA11
As for my code. This is very initial playing with the demo board, no actual programs yet, just seeing how it works. 'Hello world' stuff on the display
So appart from initial initialisation of the LCDSE0,LCDSE1 and LCDSE2 registers to allow for using the pins as lcd direct drive (SEG0 to SEG23 on the pic16917 pins) - Thats all im doing so far. Each code line sets just one bit in a LCDDARA register which maps to one lcd display element ie
LCDDATA2.6 = 1 switches on lcd element 1a
LCDDATA2.7 = 0 switches off lcd element 1b
by doing this one by one Im able to swith on/off all elements in the diplay, and so in my code displayed above :-
" lcddata2.6=1 'seg a
lcddata2.7=1 'seg b
lcddata8.7=1 'seg c
lcddata11.6=1 'seg d
lcddata8.6=1 'seg e
lcddata5.6=1 'seg f
lcddata5.7=1 'seg g "
im switching on all the elements in the 1st charactor 7-segment display.
My real problem is therefore that these display elements are spread all over the LCDDATA registers and im creating charactor displays by manipulating register bits one by one.
Im therefore trying to cut down on the above by trying to see if i can group the sets of register bits in some way in array or table etc,
for example :- ( in pseudocode 'cos i dont know if it can be done in picbasic)
CHR0 var byte(lcddata2.6,lcddata2.7,lcddata8.7,lcddata11.6, lcddata8.6,lcddata5.6,lcddata5.7)
if this can be done ( my original question) then i can feed the byte patterns to VAR CHR0 (directly or by lookup table) to change the Right hand numeric display charactor as needed.
I hope the above explains things
Alastair
Hi Alistar-
I too am getting ready to design a system using either the '914 or the '917. I am curious how this board of yours is wired. Can you provide a schematic of it? Why would it be wired "apparently at random". It is my understanding that there must be a pin on the PIC dedicated to every segment of the display, correct? I agree with you that being able to use an array some how should make programming easier. I will follow these posts with interest, and provide my experiences as I progress with my project (this week or next).
Dave
jderson
the demo board is made by Microchip Mechatronics Demonstration Kit
Part Number: DM163029
try http://www.microchip.com/stellent/id...&part=DM163029
on page 50 of the demo users guide the connections are straight links, no buffering or interfacing.
16f917
pin name display
37 com0 -- lcd pin1
38 com1 -- 2
19 com2 -- 3
34 seg1 -- 4
35 seg2 -- 5
36 seg3 -- 6
23 seg11 -- 7
18 seg6 -- 8
8 seg21 -- 9
9 seg22 -- 10
10 seg23 -- 11
22 seg16 -- 12
33 seg0 -- 13
dunno why they made the pin assignments ( other than com1,2,3 which the display needs)
page 19 shows the mapping of the segments onto LCDDATA registers depending on the COM/SEG pins
if you get anywhere let me know. Via google i know that the CCS (whisper here when you say that) C compiler can do it,http://www.ccsinfo.com/forum/viewtop...ght=16f917+lcd - i was just hoping my understanding and syntax was limited and theres some workaround in picbasic
good luck
alastair
Bookmarks