PDA

View Full Version : schematics of voltage comparator BS2PX

celestino_galan
08-08-2005, 04:08 PM
Please, could anyone draw for me an schematics of voltage comparator with ·BS2PX.

The battery to measure is 7,2 V.

Thanks

Jon Williams
08-08-2005, 07:55 PM
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:

· FOR adcVal = 0 TO 255
··· 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:

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

celestino_galan
08-08-2005, 08:13 PM
Thank you very much.

celestino_galan
08-09-2005, 06:19 PM

¿what is DacOut ?
Thanks

Jon Williams
08-09-2005, 06:21 PM
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_galan
08-09-2005, 06:34 PM
oh! I didn't see the program attached.

Thank you

celestino_galan
08-11-2005, 02:08 AM
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 Williams
08-11-2005, 04:01 AM
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_galan
08-11-2005, 03:08 PM
Thanks, I would do it this evening (Spain GMT+1) when I arrived to my home.

celestino_galan
08-11-2005, 07:42 PM
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 Williams
08-11-2005, 08:22 PM
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_galan
08-11-2005, 09:46 PM
Thanks for your interest I would try this eschema.

Jon Williams
08-11-2005, 10:08 PM
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_galan
08-12-2005, 01:21 AM
is the cap necessary? the one I puted is labeled: 100nK100 (no polarity one...)

Jon Williams
08-12-2005, 08:03 AM
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

Manuel
08-12-2005, 10:56 AM
Is there a way to use less BS pins and not use PWM, like by using a ADC?

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

Manuel C. Reinhard

celestino_galan
08-12-2005, 03:23 PM
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

Jon Williams
08-12-2005, 10:33 PM
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 Savage
08-12-2005, 10:54 PM
·· 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 (mailto:csavage@parallax.com)

celestino_galan
08-13-2005, 01:10 AM
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