capacitance meter with a comparator

A catchall for PSoC5 discussions not captured by the other forums.

Moderator: ericb

capacitance meter with a comparator

Postby simonyounger » Fri Feb 14, 2014 4:48 am

here is a capmeter idea with PIC:
http://www.romanblack.com/onesec/CapMeter.htm

I wanna use it with PSoC5, but the comparator output seemed some problems.
so any good ideas about translating that diagram?

thanks
simonyounger
Newbie
Newbie
 
Posts: 8
Joined: Fri Feb 14, 2014 4:41 am

Re: capacitance meter with a comparator

Postby bobmarlowe » Fri Feb 14, 2014 7:53 am

There are 4 OpAmps within a PSoC5, so better use one of them. Take care for the dedicated in-and output pins. You may use other pins, but at he additional cost of some more resistance in the routing path.

Bob
User avatar
bobmarlowe
The Big Cheese
The Big Cheese
 
Posts: 1490
Joined: Thu Oct 06, 2011 2:03 am
Location: Germany

Re: capacitance meter with a comparator

Postby simonyounger » Sat Feb 15, 2014 5:20 am

bobmarlowe wrote:There are 4 OpAmps within a PSoC5, so better use one of them. Take care for the dedicated in-and output pins. You may use other pins, but at he additional cost of some more resistance in the routing path.

Bob


but there is a comparator in the design.
My pin problem was solved, but signal didn't show as the request
simonyounger
Newbie
Newbie
 
Posts: 8
Joined: Fri Feb 14, 2014 4:41 am

Re: capacitance meter with a comparator

Postby bobmarlowe » Sat Feb 15, 2014 5:34 am

There is not a comparator in the design, but an OpAmp routed as a comparator. I would suggest you to use one of the internal OpAmps.

Bob
User avatar
bobmarlowe
The Big Cheese
The Big Cheese
 
Posts: 1490
Joined: Thu Oct 06, 2011 2:03 am
Location: Germany

Re: capacitance meter with a comparator

Postby simonyounger » Wed Feb 19, 2014 6:43 am

Sorry, it is a comparator. And I have some problem to do with counter
How to count the capacitor charge times?
simonyounger
Newbie
Newbie
 
Posts: 8
Joined: Fri Feb 14, 2014 4:41 am

Re: capacitance meter with a comparator

Postby bobmarlowe » Wed Feb 19, 2014 7:30 am

You may use a counter fed with a fixed frequency and use the capture input to count the time or you can use a timer and the enable input to gate the counting. Setup, reset and other basic functions are best done in a small interrupt handler.

Bob
User avatar
bobmarlowe
The Big Cheese
The Big Cheese
 
Posts: 1490
Joined: Thu Oct 06, 2011 2:03 am
Location: Germany

Re: capacitance meter with a comparator

Postby simonyounger » Wed Feb 19, 2014 7:59 am

thank you
but why the output of the comparator was not square wave.
simonyounger
Newbie
Newbie
 
Posts: 8
Joined: Fri Feb 14, 2014 4:41 am

Re: capacitance meter with a comparator

Postby danadak » Thu Feb 20, 2014 7:08 am

As you can see from the PIC design a comparator is being used.

C Oscillator.jpg
C Oscillator.jpg (33.48 KiB) Viewed 3424 times


You can use an OpAmp as a comparator, but due to internal compensation the range
of operation may be more limited, eg. the range of oscillation, hence capacitance.

PSOC 5 does have comparators.

To get a perfect square wave feed the output of the comparator to a divide by 2 D F-F, that will give you
1/2 the freq, then measure that. Or just measure freq out of comparator. The output is not a square wave
because of the non symmetrical hysteresis due to the need to add offset. But you only care about period,
so this is not of concern.

Regards, Dana.
Field Application Engineer
KB1RHB Mostly listen :)
Semi Retired
User avatar
danadak
The Big Cheese
The Big Cheese
 
Posts: 2008
Joined: Thu Dec 27, 2007 8:42 am
Location: New Hampshire

Re: capacitance meter with a comparator

Postby simonyounger » Thu Feb 20, 2014 7:56 am

I tried to just measure the freq of the output of comp by timer, but it did not work.
function Timer_readperiod() shown the same value even there was no capacitor.

I think the output of comp did not influence the capture of timer.

and is SCCT comp same as normal comp?
simonyounger
Newbie
Newbie
 
Posts: 8
Joined: Fri Feb 14, 2014 4:41 am

Re: capacitance meter with a comparator

Postby danadak » Thu Feb 20, 2014 9:12 am

Post your project and we will take a look at it -

"File"
"Create Workspace Bundle"

The PSOC 1 SCCT block is a litlle more flexible, but functionally the
comparator in PSOC 5 same.

The attached might be useful -

Frequency Measurement.pdf
(300.42 KiB) Downloaded 128 times


Freq Counter.zip
(758.44 KiB) Downloaded 117 times


Regards, Dana.
Field Application Engineer
KB1RHB Mostly listen :)
Semi Retired
User avatar
danadak
The Big Cheese
The Big Cheese
 
Posts: 2008
Joined: Thu Dec 27, 2007 8:42 am
Location: New Hampshire

Re: capacitance meter with a comparator

Postby simonyounger » Wed Feb 26, 2014 8:08 am

So what's the code to output the frequency?
simonyounger
Newbie
Newbie
 
Posts: 8
Joined: Fri Feb 14, 2014 4:41 am

Re: capacitance meter with a comparator

Postby danadak » Wed Feb 26, 2014 11:37 am

Sorry I did not get it posted. Here it is. Note this is a PSOC 1 design, should be easy to port.

BasicFreqCntr.Archive14.zip
(1.08 MiB) Downloaded 127 times


http://www.cypress.com/?docID=33528 PSOC 3 ap note.

Regards, Dana.
Field Application Engineer
KB1RHB Mostly listen :)
Semi Retired
User avatar
danadak
The Big Cheese
The Big Cheese
 
Posts: 2008
Joined: Thu Dec 27, 2007 8:42 am
Location: New Hampshire


Return to “%s” PSoC5 General

Who is online

Users browsing this forum: No registered users and 1 guest

cron