Propeller votlmeter--beginner question
scary terry
Posts: 24
in Propeller 1
This is my very first Propeller project so I'm very much a beginner (I have programmed BS2's in the past). I'm building a multi-function display for my pop-up trailer that will show temperatures (current, hi, low and refrigerator) as well as voltages (solar panel output, battery). The temperatures are no problem but I'm struggling with the voltage part. All I need is a voltage readout with two decimal places. I'm using an MCP3202 (right now with just 5volts, the final will use a voltage divider for up to about 20 volts). I was hoping for an "voltmeter object" to make things easy but I could not find one. I tried to adapt the BOE voltmeter tutorial, but at my stage of learning, it's way over my head.
I've attached what I've done so far, it's very simple and I'm sure there is a better and more accurate way to come up with voltage, but this works. I'd like to limit it to just two decimal places. Any suggestions or help would be appreciated.
I've attached what I've done so far, it's very simple and I'm sure there is a better and more accurate way to come up with voltage, but this works. I'd like to limit it to just two decimal places. Any suggestions or help would be appreciated.
Comments
I used an array of seven-segment LEDs for the display. For a serial terminal, this method might be helpful:
As with the ** operator in PBASIC, ** works with fractional values less than 1. Take your fraction and multiply it by 2^32 to get the multiplier for **.
Are you my friend, Scary Terry, from the Halloween world?
And yes Jon, I'm that Scary Terry. I retired last year and one of my retirement goals is to learn to program the Propeller. I'm finding it much harder than the BS2 but right now I'm taking baby steps in learning it. I hope you are doing well.
Please trust me: In a very short time you will have one of those "Aha!" moments where it will all fall into place and you'll wish everything was as easy to use as the Propeller. I wanted to throw myself out a window yesterday having to do a PIC project for a client -- the problem is my apartment is on the second floor and it just would have hurt, not killed me (and the pain of working with a PIC!).
Just in case I haven't updated ObEx in a while, I've attached my latest MCP320x objects. One of the things I do with these when monitoring joysticks for camera controls is average them (to filter out the noise). If that's of interest I will show you how I do it.
I am well, thank you. Happy retirement, and have fun with the Propeller!
I'm fussy about terminal displays so I have my own update of FullDuplexSerial which includes a method called rjdec() (right-justified decimal) that was originated by Dave Hein, and has PST formatting codes. My habit is to create an object called "term" that uses this code.
Most of my programs have a setup() method -- this is where I start the terminal object.
Finally, here's how I would code the output based on what you have in your program:
The third parameter of rjdec is the character used to replace leading zeroes; this allows nicely-formatted displays.
I've attached an archive for my basic template program in case you find it useful. It includes jm_fullduplexserial.