P2 ADC project
in Propeller 2
Brief description:
I have three 12V 300Ah batteries that I want to keep track of. And I will be capturing the data and moving it over to my rpi device, for further data manipulation.
Since the Activity Board is now eol, I am going to start using the P2. On the Activity board it was a simple matter of how to hook the wires to the ADC. For the P2 it is not as obvious as it should be. Their is no add-on board for doing this, that I have seen. So, I guess I need a simple diagram, showing what goes between the battery and the P2 pins.
At this point I am not sure what I will use, Spin2, C, BASIC, or whatever will be the easiest to deal with.
Thanks in advance.
Ray

Comments
Remember that the P2 IOs are 3.3v so you need to keep your ADC input to that. In a recent project I needed to monitor the state of a 12V battery that feeds an offboard 5v regulator. I added a 12v battery input to the PCB and with a voltage divider that will allow me to safely monitor up to 15v.
No matter what language you use, you'll need to activate the smart pin ADC mode to read an analog voltage. I've attached my Spin2 object for simple ADC measurements. It includes scaling factors to convert the ADC reading to match your situation. In my case, I can do this (for my circuit designed for 0-15v).
After this I can use adc.read() to get the battery voltage in millivolts.
Thanks Jon, excellent diagram.
I have created a power station, in the basement, which consists of the three batteries, three inverters, and a solar charge controller. Two of the inverters are ac powered, and one inverter is a plain one. Outside I have six 200 W solar panels, connected to the charge controller. The ac powered inverter has a built in 20 amp battery charger, a circuit that automatically switches to the battery source when it loses ac power.
One ac inverter handles my sump pump, the other ac inverter handles my freezer, and the plain inverter takes care of my cable modem, router, 10 TB NAS unit, Dell computer, the lan distribution unit and some other stuff.
The batteries are connected to a power bar which also has the charge controller connection, and every thing is parallel. Not sure but this might complicate things in terms of the resistors that are shown in the diagram. When the sun is out, I have seen the charge controller getting up to 25 amps, and that is on a partly cloudy day, plus I am not sure what is being provided to the batteries when the ac inverter battery charger kicks in. So, I am not sure how the battery voltage gets when the chargers kick in.
It would also be nice to have some kind of circuit that provides battery power usage, that the P2 could capture. At the moment I have no idea as too what the battery power activity looks like. Can I add more power hungry devices to this setup, and can I distribute the devices I have now between the inverters. This starting to sound pretty complicated to me.
Ray
Lead-acid battery chemistry I presume?
No, these are lithium batteries. I think China was dumping these batteries in the USA, the price was very low, also the solar panels were probably dumped, those prices were very low. I have not checked to see if the prices are now back to being very high.
Ray