How is the display connected to the MCU? How are you sending data to it.
How is the display connected to the MCU? How are you sending data to it.
Dave
Always wear safety glasses while programming.
Using an alegro A6276, so the pic shifts the data out. The displays thems selfs are working fine. I was just wondering if there was a quicker way to set all bits up to a certain bit number on with out having to use a look up table.
<strike>GraphVal = $FFFF >> ((X * 16) / (GraphMax - GraphMin))</strike>
GraphVal = $FFFF >> (((X - GraphMin) * 16) / (GraphMax - GraphMin))
<br>
<br>
Last edited by Darrel Taylor; - 23rd October 2010 at 02:22. Reason: oops
DT
DOH!
I knew there was something I wasnt thinking of...
The key was right shifting the $FFFF. If anyone else is following this, here is the final formula I came up with and it works perfectly.
GraphVal = $FFFF >> (16 - (X / ((GraphMax - GraphMin) / 16)))
This is for auto guages so the scale of the graph can swing. For instance, a fuel level gauge might read 0 to 16 galons, where a water temp guage might read 180° - 290°, so it was important to note that the bottom number might change as well as the top.
Last edited by bearpawz; - 23rd October 2010 at 03:16. Reason: It works now...
And probably something I wasn't thinking of too.
That might go backwards, and need to be inverted.
GraphVal = $FFFF >> (16-(((X - GraphMin) * 16) / (GraphMax - GraphMin)))
I'll test it and see.
Doh, you beat me to it.
Oops again.![]()
DT
Uh Oh. Ok, it work flawlessly until you start working with a very tight scale. An example is the volt meter. It usually displays information from 8V to 18V with the guages I am replacing. Unfortunatly, based on the formula there ends up being too small of a number to even light one LED. (or at least its not lighting anything up). I passed in a value of 13 for my test data. This is a valid number between 8 and 18. However, when you start using the formula (the one I came up with) here is what happens:
GraphVal = (16 - (X / ((GraphMax - GraphMin) / 16)))
GraphVal = (16-(13/((18 - 8)/16)))
GraphVal = (16-(13/(10/16)))
GraphVal= (16-(13/.625)
GraphVal = 16-20
GraphVal = -4!
Sorry, Ive never been horribly great at actual math. Now what? lol.
You will not be getting a value volts at the ADC. You will have something between 0 and 255 or 0 and 1023. 8 or 10 bits.
So maybe we should start there.
Dave
Always wear safety glasses while programming.
What about this for you ADC in
http://www.picbasic.co.uk/forum/content.php?r=249
Oversample to get you 16bit rez. Then you are done.
Or am I missing something.
Dave
Always wear safety glasses while programming.
Not even worried about that part right now. What will be monitoring the actual car will be a whole other system. At the moment just need to know how to get the displays to display correctly.
Try the last formula I gave in post #6
Testing here, making animation to prove it.
It works.
DT
Bookmarks