Shop OBEX P1 Docs P2 Docs Learn Events
BS A2D C and voltage comparator — Parallax Forums

BS A2D C and voltage comparator

celestino_galancelestino_galan Posts: 44
edited 2005-05-15 16:53 in BASIC Stamp
Does anybody know in any BASIC Stamp has analog to digital converter and/or is it possible (and how)to use the "voltage comparator" from the BASIC Stamp 2px to measure a voltage?

Thanks

Comments

  • KenMKenM Posts: 657
    edited 2005-05-15 16:07
    The basic stamp has a "form" of analog to digital converter. It is using the command RCTIME.

    RCTIME is generally used to measure an unkown resistance. Please see the help file, then post more questions if needed.

    The voltage comparitor can easily be used to indicate when an unknown voltage is greater than or less than a known voltage. The comparitor returns a boolean result (yes or no, true or false....).

    Just like google......the help tool is your friend.

    I typically use it to sense when the voltage on a 12 volt battery drops below some threshold. I can give more details regarding use if you can give a specific description of the application.

    The comparitor uses two pins. A common use is the user (you), puts a known voltage on one pin, and feeds an unknown voltage into another pin. A logic 1 or logic 0 is returned based on the comparison of the two voltages.

    k

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    トヨタは すばらし です!!

    Post Edited (KenM) : 5/15/2005 4:18:46 PM GMT
  • celestino_galancelestino_galan Posts: 44
    edited 2005-05-15 16:22
    If you explain me how do you sense the 12v battery it would be very usefull for me, ThANKs
  • Tracy AllenTracy Allen Posts: 6,658
    edited 2005-05-15 16:29
    If you want to measure a voltage using the BS2px comparator, with minimum extra parts, I think you could use PWM to generate the reference voltage on one input, to compare with the unknown voltage on the other input. Use a DO-LOOP with a binary search algorithm to vary the PWM value and fix in on the unknown. The PWM pin would require an RC filter.

    You can add an ADC externally. There are lots of references on that. Here is a module with Stamp and ADC on board: www.emesys.com/OWL2pepr.htm

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • KenMKenM Posts: 657
    edited 2005-05-15 16:30
    In the schematic shown below, I used it to detect when a 12 volt battery drops below 10 volts.

    Works as follows:

    The tag labeled "To comparitor input" monitors a ratio of the battery voltage (variable input).

    The tag labeled "Other comparitor input" is fixed at 2.5 volts and does not change.

    When the battery voltage is at 13 volts, the variable input will be 3.22 volts....greater than the fixed input (2.5v), and the comparitor result is logic 0.

    When the battery voltage is at 12 volts, the variable input will be 2.97 volts....greater than the fixed input, and the comparitor result is again 0.

    When the battery voltage is 10 volts, the variable input will be 2.48 volts....less than the fixed input, and the comparitor result will now be 1.

    This is an ideal case, on paper·with EXACT resistor values. In the real world your result will be off from the calculated voltages described above.

    You can use a 20k ohm pot in place of R1, and that will allow you to adjust the fixed input from about 1.7 volts up to 5 volts, but setting the fixed voltage at 5 volts is useless.

    This is assuming the fixed input is wired to P2

    attachment.php?attachmentid=73648

    Write back if this does not make sense or you have more questions.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    トヨタは すばらし です!!

    Post Edited (KenM) : 5/15/2005 5:24:28 PM GMT
    617 x 534 - 18K
    380 x 66 - 3K
  • celestino_galancelestino_galan Posts: 44
    edited 2005-05-15 16:53
    thank you everybody, It is very well explained and it is perfect for what I need.

    Thanks again

    Post Edited (celestino_galan) : 5/15/2005 5:16:38 PM GMT
Sign In or Register to comment.