Comparator outputs high right after comp_1_start() api, even when vin is not connected to input.

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
tazhc_4089936
Level 1
Level 1

Comparator outputs high right after comp_1_start() api, even when vin is not connected to input.

0 Likes
1 Solution
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

> The echo pin is actually connected to one of the pins of ultrasonic receiver,

Now, the story is totally different!

So I used my resistor ladder to test the behavior of your circuit,

when reference was 1.020v, the comparator generated 1 even for 0.3V input,

but generated  0 when input is 0V.

Then I modified the schematic as below to see the output of PGA_1

002-schematic.JPG

When echo (= vin) was 0.5V, Vout was 2.4v or so!

So I looked in the configuration of PGA_1

003-PGA_1.JPG

Yes, you set the Gain = 4, which is 4x of input voltage will be output.

So I changed the Gain = 1

004-PGA.JPG

Now Vout_1 was within 0.1V different from the actual input.

So, I hope that with this configuration,

you will get more reasonable reaction from the comparator. (Fingers crossed)

moto

P.S. Oops, in my attached project, the Range of VDAC8_1 was still 0-4.08V.

Please change it to 0-1.02 if you need it.

View solution in original post

0 Likes
7 Replies
tazhc_4089936
Level 1
Level 1

Below are my project. Thanks in advance guys.

0 Likes
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

I could not expand your project, would you do the following?

(1) Select the project in Workspace Explorer

(2) Build > clean <theProject>

(3) Project > Archive Workspace/Project...

(4) Attach the result <theProject>.zip to your post

moto

0 Likes

Here you go, cheers!

0 Likes
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

Thank you for the updated attachment!

I downloaded you project and I could open it this time.

As the project has much more than the  comparator,

I excerpted only the comparator related part.

000-schematic.JPG

When I tested this, yes the output of Comp_1 was always 1 when echo pin (P0[0]) is open.

Then I took a look at the config of echo

001-echo-config.JPG

The echo input is High impedance analog and the initial drive state is set to 0.

But since the physical pin is open (not connected) the value of the input is

at the mercy of the environment and/or board configuration.

When I measured the voltage at P0[0] with my cheap multi-meter,

it read about 2.0V, no wonder the comparator reports high.

Needless to say, when I connect P0[0] to GND with a jumper wire,  the comparator reported low.

So if you want to have some certain value from the comparator,

the echo pin must be connected to GND or some other signal.

moto

0 Likes

Hi, thanks for the quick replies.

The echo pin is actually connected to one of the pins of ultrasonic receiver, while the other is connected to ground but even then the comparator still constantly outputs a logic high unless i set the vref to 4v which is much higher than the noise i measured. And even when i disconnect my echo from the comparator in the schematic, the comparator still outputs a logic high when there is no input on vin.

0 Likes

And also when i printed my echo pin input state when comparator is logic high it shows my echo pin is 0, how could a comparator output 1 when both vin amd vref is 0

0 Likes
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

> The echo pin is actually connected to one of the pins of ultrasonic receiver,

Now, the story is totally different!

So I used my resistor ladder to test the behavior of your circuit,

when reference was 1.020v, the comparator generated 1 even for 0.3V input,

but generated  0 when input is 0V.

Then I modified the schematic as below to see the output of PGA_1

002-schematic.JPG

When echo (= vin) was 0.5V, Vout was 2.4v or so!

So I looked in the configuration of PGA_1

003-PGA_1.JPG

Yes, you set the Gain = 4, which is 4x of input voltage will be output.

So I changed the Gain = 1

004-PGA.JPG

Now Vout_1 was within 0.1V different from the actual input.

So, I hope that with this configuration,

you will get more reasonable reaction from the comparator. (Fingers crossed)

moto

P.S. Oops, in my attached project, the Range of VDAC8_1 was still 0-4.08V.

Please change it to 0-1.02 if you need it.

0 Likes