Shop OBEX P1 Docs P2 Docs Learn Events
Reading Volts — Parallax Forums

Reading Volts

ghost13ghost13 Posts: 133
edited 2007-06-10 02:41 in BASIC Stamp
Can you read the voltage on an IO pin with the BS1?

Comments

  • metron9metron9 Posts: 1,100
    edited 2007-06-09 17:06
    Ghost13. Do you have a what is a microcontroller book? This site has the information you need with detailed circuit diagrams. Go to the download area as well as the nuts and volts free online materials, I am sure they have one on that.

    The answer is yes but not directly because a pin can only be a 1 or a 0, you use an RC circuit. Basically charge a tiny capacitor that holds the pin high (reads as a 1) then discharge it and see how long it takes to discharge. When it is discharged below a certain voltage the pin then reads zero that is when the timer is checked to see how long it took. Reading very low voltages take additional circuits to amplify, read and then calculate.

    Also search the forums, many discussions on RC circuits as well as how to use external chips that read voltage like ADC chips.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Think Inside the box first and if that doesn't work..
    Re-arrange what's inside the box then...
    Think outside the BOX!
  • ghost13ghost13 Posts: 133
    edited 2007-06-09 18:39
    Thanks!
  • bennettdanbennettdan Posts: 614
    edited 2007-06-09 21:59
    ghost13,
    Tracey Allen a regular on here has an example on how to read voltage with RC time on a BS2 I am sure you can adopt it. http://www.emesystems.com/BS2rct.htm look for battery voltage monitor...
  • ghost13ghost13 Posts: 133
    edited 2007-06-10 00:47
    Hmm... So you can use it as an ADC. Is it as accurate? Hom many bits would it be equivalent to?
  • FranklinFranklin Posts: 4,747
    edited 2007-06-10 02:41
    Have you looked at Tracy's site? It will depend on the voltage and the values of the components you use.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
Sign In or Register to comment.