Shop OBEX P1 Docs P2 Docs Learn Events
schematics of voltage comparator BS2PX — Parallax Forums

schematics of voltage comparator BS2PX

celestino_galancelestino_galan Posts: 44
edited 2005-08-12 18:10 in BASIC Stamp
Please, could anyone draw for me an schematics of voltage comparator with ·BS2PX.

The battery to measure is 7,2 V.

Thanks

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-08-08 12:55
    Assuming you want to measure the voltage, you can connect the circuit attached.· Note that you need to bring the voltage into the 0 - 5v range witha couple precision resistors (see attached schematic).· Using an RC circuit and the Stamp's PWM instruction, you can "read" the voltage input with this subroutine:

    Get_ADC:
    · FOR adcVal = 0 TO 255
    ··· PWM DacOut, adcVal, 1
    ··· COMPARE 2, result
    ··· IF (result = 1) THEN EXIT
    · NEXT
    · RETURN

    This will return a value to 0 - 255.· In your case you could multiply adcVal by 28.235 (7200 / 255) to get 0 - 7200 millivolts.· Do that like this:

    · mVolts = adcVal */ $1C3C······· ' adcVal x 28.235

    Now you can do things like this:

    · IF (mVolts < 5500) THEN
    ··· ' batter is less than 5.5 volts -- do something
    · ENDIF

    You may need to adjust the numbers a tiny bit -- but this should get you started.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax

    Post Edited (Jon Williams (Parallax)) : 8/11/2005 1:18:57 PM GMT
    654 x 394 - 22K
  • celestino_galancelestino_galan Posts: 44
    edited 2005-08-08 13:13
    Thank you very much.
  • celestino_galancelestino_galan Posts: 44
    edited 2005-08-09 11:19
    Please, jon:

    ¿what is DacOut ?
    Thanks
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-08-09 11:21
    DacOut is the name of one of the pins -- download the full program that is attached to my post above.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • celestino_galancelestino_galan Posts: 44
    edited 2005-08-09 11:34
    oh! I didn't see the program attached.

    Thank you
  • celestino_galancelestino_galan Posts: 44
    edited 2005-08-10 19:08
    Hi, jon.



    I did the schema (but with 5% resistors at the moment) a C1 100nK but I don't have result just

    0.000 volts is·what could be the problem?

    Like the diagram I put 1 wire, throught R1 to + 7.2V (...) of my battery·to P1 and other R2 to VSS of the "Board of Education"

    P3 ---· R3
    |c1|----VSS

    ··················· |

    P2

    Thanks for help

    Post Edited (celestino_galan) : 8/10/2005 7:33:02 PM GMT
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-08-10 21:01
    What are you getting between the junction of the 4.7K and 10K resistors? Start there with a meter. Once you know what that is you can start on the ADC side. BTW, is 100nK = 0.1 uF?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • celestino_galancelestino_galan Posts: 44
    edited 2005-08-11 08:08
    Thanks, I would do it this evening (Spain GMT+1) when I arrived to my home.
  • celestino_galancelestino_galan Posts: 44
    edited 2005-08-11 12:42
    Maybe I did something wrong.

    The VSS on P1 is from the battery and the VSS P2,P3 is from the board? isn't it?

    Because I used only the board one.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-08-11 13:22
    I redrew the schematic to make it more verbose -- see the post above for the update; it should make things clear.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • celestino_galancelestino_galan Posts: 44
    edited 2005-08-11 14:46
    Thanks for your interest I would try this eschema.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-08-11 15:08
    I have connected and run that circuit (using a 5v input to P1) more than once -- the circuit and code will work for you when you get the connections sorted.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • celestino_galancelestino_galan Posts: 44
    edited 2005-08-11 18:21
    is the cap necessary? the one I puted is labeled: 100nK100 (no polarity one...)
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-08-12 01:03
    Yes, the cap is critical and the values need to be as in the diagram (unless you want to change the code).

    The code uses P3 to create a voltage on P2 using PW (through a 10K and 0.1 uF) cap; by knowing what the P3 output voltage is the ADC software can know what the voltage on P1 is when the comparator state changes.

    The point is that the BS2px does not have an ADC -- one is being created using a trick with the comparator.· See this article (using a BS1 and a hardware comparator) to an explanation: http://www.parallax.com/dl/docs/cols/nv/vol1/col/nv25.pdf

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax

    Post Edited (Jon Williams (Parallax)) : 8/12/2005 1:05:43 AM GMT
  • ManuelManuel Posts: 105
    edited 2005-08-12 03:56
    Is there a way to use less BS pins and not use PWM, like by using a ADC?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Best Regards

    Manuel C. Reinhard
  • celestino_galancelestino_galan Posts: 44
    edited 2005-08-12 08:23
    Here is what I have done. (image attached).

    It is curious that when I Umplug cumpletely (H) the cap it start measuring...

    Is my cap wrong?

    I have checked in (E) and it is 4,96 V, in (F-G) and it is like 3,2V or so...

    Please have a look at the image and if you could see something...

    Thanks
    637 x 847 - 102K
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-08-12 15:33
    You could use an ADC0831, but you'd still be using three pins.
    Manuel said...
    Is there a way to use less BS pins and not use PWM, like by using a ADC?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-08-12 15:54
    ·· The best information I have is that is a 100nF capacitor.· As for the trailing 100, all I can guess is it's a 100V rating?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • celestino_galancelestino_galan Posts: 44
    edited 2005-08-12 18:10
    in fact. I don't know.
    Now, in Spain everybody is in hollydais and most shops are closed, so I have to wait till september for the capacitor.
    ...

    thanks
Sign In or Register to comment.