Maybe some one can help me wrap my brain around this problem. I have a display which will eventually indicate all kinds of information in an automotive environment. For instants, Fuel gallons, oil pressure, water temp etc.
I am using a micro to control a MAX7219 LED driver. I am using 6 of the 8 banks and using my own custom font so all banks are in direct addressing mode. The first 4 banks display the digits, the last two display a bargraph. The bargaph consists of 16 LED's (8 each with common annode)
Problem 1: How to turn the LED's on
I need to turn on the LED's by sending out the "on" bit for each LED or "Segment". So for instance, to turn on all LED's I would have to send %11111111 to both banks 5 and 6 (banks are labeled 0 - 7). So lets say I know I have to display the number 12. I need 12 bits set (%1111111111110000)
Since the actual value is going to be calculated, is there a pic basic command to set x number of bits on in picbasic? I have been reading through the manual and just cant seem to find it. At the moment I am resorting to a look up table but that brings me to problem #2
Problem 2: The scale for the bargraph will be constantly changing. For instance take oil pressure. A typical guage will show 0psi to 32psi. So the scale will want to indicate 0 PSI as all 16 LED's off and 32psi as all 16 on. In this case its prety easy to calculate because that works out to be 2 led's per psi. But now lets say we want to indicate Water temp. Now we are on a whole different playing feild. The guage wants to show anywhere from say 100F to 260F. So at 100F we want either no LED's on or just one at most, and at 260F we want them all on (along with all kinds of warning buzzers your engine is about to seize lol). So anyway, now we want a resolution of 1 LED / every 10 degrees. (260 - 100 = 160. 160/16 = 10). For this reason I am thinking my look up table is not going to work out too well. Hopefully this makes sense to some one because right now, while it seems like this should be cake I just cant seem to figure out what formulas to use.
Bookmarks