Shop OBEX P1 Docs P2 Docs Learn Events
PLC Questions — Parallax Forums

PLC Questions

PlitchPlitch Posts: 39
edited 2007-05-13 19:05 in General Discussion
Newbie concerns:

My project is an ultrasonic snow measuring device controlled by a Stamp PLC equipped with an ADC and a Basic Stamp 2 module.

Since the device is remote and powered by solar panels and batteries , I would like to transmit the battery voltage each time I transmit snowfall data. The Stamp will "sleep" an hour, wake up, turn on the radio and sensors, get a reading, transmit it, and go back to sleep for an hour to conserve battery power.

The PLC and sensors are 24 volt powered. I therefore made a voltage divider circuit using a 22K and a 100K resistor which should scale the battery & panel voltage range (about 0 - 28 volts) to 0- 5 volts. The 100K resistor is attached to the 24 volt output of the relay power to a sensor (switched battery +) and the 22K is attached to ground (battery -), with the input to the analog PLC circuit taken off between them.

Here's my problem: Each resistor measures correctly on my multimeter, but when the relay kicks in, the voltage that the PLC "sees" measured at the analog input terminal is about .414 VDC. If I remove the lead from the divider to the PLC analog input, the voltage at the divider lead reads 4.55 when the real battery voltage is 25.27 for a ratio of about 5.55 to 1, near the nominal 6 to 1 expected.

I believe the PLC has resistors on the analog inputs. The Nuts & Volts (vol #5 available on this site) article "An Industrial cup o Joe" shows the analog input circuits with a 100K resistor to ground, a 1K in line, and a .1 microfarad capcitor.

Question: What can I do to improve this situation? Are there values for the voltage divider that will work right or should I try an entirely different approach to measuring battery voltage? The ADC in question (MAX1270) can accept 0-5 or 0-10 volt ranges. All my math is set up to correct the 0- 5 volt input, so I'd like to stay with that if possibel.

Thanks (as always!) from a total non-engineer.

Pieter

Post Edited By Moderator (Chris Savage (Parallax)) : 5/8/2007 7:21:25 PM GMT

Comments

  • PlitchPlitch Posts: 39
    edited 2007-05-09 11:43
    Folks:

    I realize it is poor manners to post replies to one's own question, but perhaps this new information will help someone confirm my analysis (I am a very non-engineer).

    First, I measured the resistance from the PLC analog input to ground after I had detacted it from the voltage divider circuit. The analog input pin to ground measured 18.46K ohms.

    I then found a voltage divider calculator on the internet that included the resistance of a load across the output of the voltage divider circuit - in other words, a parallel resistance circuit with R2.

    According to the calculator I used ( http://www.sengpielaudio.com/calculator-voltagedivider.htm ), if I change R1 to a 50.2K value, R2 stays at 22K ohms, and the resistance of the load (the analog pin of the PLC to ground?) is 18.46 K, then an input range of 0-30 volts would correspond to a voltage measured at the analog pin of the PLC of 0 - 4.999 volts.

    I also tried to confirm this by treating the R2 value (22K ohms) and the load resistance (18.46K ohms) as parallel resistors and used a parallel resistance calculator (http://www.pronine.ca/parres.htm) to calculate a theoretical resistance across the two resistor network of 10.037 K ohms. I actually measured 9.99 K Ohms, so it appears that the actual is close enough to confirm the internal resistance of the analog pin circuit on the PLC

    Question #1 : Could one or more of you technical types confirm that my analysis above makes theoretical sense?

    Question #2: It occurs to me I could easily make one of two alternations:

    1. change the value of R1 to 50K . I want to "scale" 0 - 30 VDC to about 0-5 VDC at the PLC analog input pin. I think the calculator shows that if my R1 resistor is 50K ohms, R2 = 22K ohms, load = 18.46 K ohms (as measured), the output voltages will be close to 0 - 5 VDC (5.015 vdc). I could treat the maximum voltage (30 vdc) as a constant in software, then change that so that the software scaling exactly agrees to the actual measurment. In other words, if the actual voltage measured at the batteries is 24.5 volts, then change the software top of scale constant so that the Stamp calculates the current voltage to be the same as actually measured. This would correct for all the odds-and-ends of actual resistance in the circuits, but assumes perfect linear behavior from 0 - max value.

    2. Put a 100K micro potentiometer (using 1 side and center only) to replace the 100K. I could then adjust it to get my 0 - 30 VDC scale to 0-5VDC more exactly. The circuit board will be in an "everything-proof enclosure", but will be hot in the summer, cold in the winter. Would such a part be subject to deterioration that would either rapidly or slowly change the resistance?

    Can anyone express a strong preference for either alternative (assuming I'm right about the circuit at all!)?

    Sorry to pester with so many questions, but this project is a real learning experience for me!

    Pieter
  • stamptrolstamptrol Posts: 1,731
    edited 2007-05-09 12:14
    Pieter,

    You've correctly analyzed the issue. The input resistance to the a/d is significant by being relatively low.

    I'd do a calculation to put either approx 93K in series with the input to the a/d, or carry on with the 100K pot experiment to get "exactly" the right number for your scaling to work best. Be ultra careful that you have the pot turned the right way otherwise you may be putting close to zero ohms in the circuit and grossly overloading the a/d input.

    The resistor values will be relatively stable over the temperature extremes expected. Typically, it will be the more active components that drift a bit.

    Cheers

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tom Sisk

    http://www.siskconsult.com
    ·
  • metron9metron9 Posts: 1,100
    edited 2007-05-09 13:26
    This information may be of help.

    http://www.maxim-ic.com/appnotes.cfm/an_pk/1948

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Think Inside the box first and if that doesn't work..
    Re-arrange what's inside the box then...
    Think outside the BOX!
  • metron9metron9 Posts: 1,100
    edited 2007-05-09 14:10
    I am no EE either but isn't using that high of resistance dropping the current to very low levels? Why could you not use a 2.5K from the battery and 500ohm to ground as the resistor divider or even smaller values to reduce the error? That combination gives a 10mA current flow at 30V and 325ua at 1V using 18.5K as parallel resistance for the ADC input.

    Dropping to 1K and 200 ohms gives 24mA at 30V You could use a switch to turn on the resistive divider when doing the ADC.

    That is how I understand the subject, please correct me if I am off base.

    Ite ADC's I work with are in the ATMEL chips and are 30K Reference Input Resistance (not sure exactly what that is yet) and have an Analog Input Resistance of 100M. I have not thought about their being a problem with resistive dividers to scale voltages for ADC input. I shall have to educate myself on this particular problem.


    <<<<<<<<EDIT>>>>>

    From a quick search on the net, it looks like an OP amp used as a buffer would solve the problem. You drive the op amp with the divided voltage and use the output from the op amp to drive the ADC.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Think Inside the box first and if that doesn't work..
    Re-arrange what's inside the box then...
    Think outside the BOX!

    Post Edited (metron9) : 5/9/2007 2:42:36 PM GMT
  • PlitchPlitch Posts: 39
    edited 2007-05-09 20:06
    Folks:

    I just wanted to post an outcome so we can all learn from the experiences of each other.

    After reviewing your responses, I removed the fixed 100K resistor and replaced it with a 0-100K potentiometer I had on hand. I set it to 5oK ohms and fired up the PLC. Since I could use simple algebra to determine what "scaled" voltage (0-5) should be present at the PLC analog input pin given the current battery voltage, I could skip all the fancy web based models of loaded voltage divider circuits and just use my voltmeter to measure the voltage at the PLC analog input pin while fiddling with the potentiometer. As it turns out I (or the fancy web based models) was pretty close - when I got the voltage dialed in, the resistance was actually 46.4K.

    Thanks for all the input! I'll (hopefully) post a completed project report sometime this year.

    Pieter
  • steve_bsteve_b Posts: 1,563
    edited 2007-05-10 12:25
    Just curious. Are you connecting your solar panel directly to the battery? OR are you using a charge controller/regulator in there? Be sure you have the appropriate diode in series (cathode towards battery) to prevent the solar panel from drawing down the battery at night.

    Are you using 24Volt Solar panels? or have 2 in series?

    I want to mention about the open load output of a solar panel (typically 18V from a 12V panel) and that if a battery "opens" on you, it'll dump a higher current/voltage to your divider. But thinking about it, your voltage divider will still drop things to the right voltage range for you....however, being as solar panels are Current sources/devices, you may need a current limiting resistor to prevent your stamp pin from going poof.

    I don't recall what N/V article this was from, but I recall someone was monitoring battery voltage indirectly using an LED and a CDS photocell. The enclosed both inside a wee box that had no light leakage and the resistance of the photocell was monitored (as the battery voltage went down, the LED dimmed so the photocell resistance changed).
    This offers a form of optical isolation.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·

    Steve

    "Inside each and every one of us is our one, true authentic swing. Something we was born with. Something that's ours and ours alone. Something that can't be learned... something that's got to be remembered."
  • PlitchPlitch Posts: 39
    edited 2007-05-10 13:37
    Thanks for the suggestions about solar panels. I am using two 5AH 12 VDC alarm system lead-acid non-spillable batteries to power the system. Charging will likely be by two 12 volt solar panels, so I could "assign" each panel to a battery at 12 volts each, or put two panels in series for 24 volts. I was not planning on a charge controller.

    The batteries state a normal charge rate of 14.4 - 15 volts at 1.5 A, or trickle at 13.5 - 13.8 at 1.5 A (each).

    The panels I have in mind are rated as (each):
    VPM 17.82 VDC, VOC 21,78 VDC, IMP 0.123 Amps, ISC 0.133 Amps. Yhey have a drain prevention diode installed already.

    As I understand it, the power supply in the Basic Stamp PLC is quite robust. The normal power requirement is 24 VDC, and I believe the maximum allowable input voltage is 50 volts. Even at 50 volts, the voltage divider would reduce the input to the stamp PLC analog pin to within range (it can go to 10 volts.

    If you think a charge controller or other protective circuits would be required, please post a reply.
    Pieter
  • steve_bsteve_b Posts: 1,563
    edited 2007-05-10 15:29
    We use charge controllers in our systems so we don't have problems with batteries. And the only problems we've have are after 4-5years of use and the fact that Canadian winters can get pretty chilly!

    The voltage from your panels will stay pretty well the same...it's the current that changes with light. Just so long as your peak output current doesn't exceed the batteries Charge rate (at least for too long....)then it'll probably be ok. You might not get years out of it, but batteries are considered consumables.
    You could just use a couple of properly Amp rated regulators to charge your batteries for you.

    I believe you are right about the power supplys "forgiveness" wrt input levels. But I was more concerned that your battery monitoring line might kill the stamp pin it's connected to.
    You'd have to do some calculations to determine what the max current would be on that line and remember that the stamp pins can sink about 40mA (or was it 20mA).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·

    Steve

    "Inside each and every one of us is our one, true authentic swing. Something we was born with. Something that's ours and ours alone. Something that can't be learned... something that's got to be remembered."
  • PlitchPlitch Posts: 39
    edited 2007-05-11 02:21
    My solar panels will only be putting out 2.5 watts at 17 volts - a maximum of .15 amps.

    Here's a link to the specs for the panels:
    http://www.powerupco.com/panels/oem/bsp212.php

    The batteries have a maximum charge rate of 1.5 amps at 15 volts, so it sounds like maybe the panels could produce too much voltage, but the amperage seems well within the limits of the batteries.

    I think I understand your comments, but can't find a commercially available charge controller that would limit current - the smallest I've found is an 8 amp controller. Would this kind of controller protect against over voltage?
    Any suggestions?

    Pieter
  • steve_bsteve_b Posts: 1,563
    edited 2007-05-11 12:33
    .15Amps? hmmm, I wonder if this is enough to even trickle charge the batteries appropriately. **just googled and it looks like 50mA is actually the trickle charge rate!

    I don't think you'll really have much for problems. What you may need to do is visit the site on occasion and swap out the batteries with some fresh ones.

    www.rason.org/Projects/gelcell/gelcell.htm
    Here's a link to a 12V Gel Cell charger with fast/slow charge modes (uses a MAX712).

    I would try to avoid excessive voltage directly to your battery...the MAX712 allows for an input voltage of 1.5Vdc higher than the max Battery Voltage (with load).
    So, if you need to charge your battery to 15Volts, you need 16.5-17V for this to work.
    Not sure if you'll have enough current available to run this (couldn't quickly see the line I was looking for in the datasheet)

    Maybe someone else can pipe in!

    Cheers

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·

    Steve

    "Inside each and every one of us is our one, true authentic swing. Something we was born with. Something that's ours and ours alone. Something that can't be learned... something that's got to be remembered."
  • PlitchPlitch Posts: 39
    edited 2007-05-13 19:05
    Thnaks for the response - the charger you suggested might be just the ticket. I think I don't want to exceed 13.8 volts, although iy seems the solar panel amperage should be no problem, high voltage might be. I'll look into it more.

    Since my little device will be in a very low power "sleep" for 58 minutes aout of each hour, I am hopeful that a low power solar panel can keep the batteries charged.

    Pieter
Sign In or Register to comment.