Comparator module detailed specs?
Tracy Allen
Posts: 6,666
I have an application (kind of like a switched capacitor dual slope converter) where the comparator module on the SX20 might help. I've never used the module and the specs in the data sheet are thin and not encouraging. In particular, the SX20 data sheet specs a 0.4 to Vdd-1.3 input common mode range, while the SX48 data sheet specs rail to rail input common mode range. Is the SX20 really stuck with the poor specs? This project needs to operate on 3 volts, so the input CM range is important. Also, the propagation delay of 250 ns seems slow. That is time to execute 5 instructions on the processor with a 20mhz clock. Is 250ns the time both for the state to appear in the comparator register and also the time for it to propagate to the B0 output?
I wonder if anyone has any advice on it or could point me to more information. Thanks! (and happy new year.)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
I wonder if anyone has any advice on it or could point me to more information. Thanks! (and happy new year.)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Comments
I haven't used the comparitor in any project, but like you I fine the spec very thin. I wonder if you can use it in analog mode with a feedback resistor from the output to the negative input ???
Jon has used the comparitor in his "Serial Line Follower" his code may help. Otherwise I guess you have to use the old "try it and see" method.
Jon's project is under "nuts & volts vol. 5" project # 116 "Basic stamp accessories made easy"
Bean.
-- reference voltage from a pot to rb1
-- switched voltage driven from rb3, a second pot to rb2.
-- trigger the 'scope on rb3, to start a test of propagation time.
---- look at rb0 on 'scope channel 2.
---- With the mode register pointing to CMP_B, also find how many clock cycles it takes before the transition appears in the CMP_RES bit, by inserting different numbers of NOPs before the mov !rb,w.
-- repeat tests for a range of input levels to check the CM input spec.
The diagram in the spec sheet does look like it could be used in analog mode, once enabled. I don't know about negative feedback (op amp) mode. Comparators usually don't make great op amps. I was thinking more in terms of positive analog feedback, to create an upper and lower threshold window.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Paul
Pardon me I didnt fully read your first post, So I didnt really end up answering it. Without investigating completely you are probably correct that the CM voltage is pretty poor especially·@ 3V. You need a rail to rail comparator, since that requires quite a few more transistors to implement it is quite unlikely that the SX is a rail to rail comparator. I believe the comparator feature of the SX is just a convenience feature to implement rudimentary ADC's and what not. Though adding an external rail to rail op amp configured as a comparator (ie no feedback) should not add much cost or space (soic-8's are pretty small, for that matter so is a dip-8 if your not comfortable with surface mount).
Post Edited (Paul Baker) : 1/2/2005 5:47:44 PM GMT
The app is to measure variable unknown capacitances in a physical process using charge transfer switches. The charge transfer pulses have to be on the order of 50ns to minimize and then to measure charge storage effects.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Paul
Post Edited (Paul Baker) : 1/3/2005 12:38:20 AM GMT
The data sheet I have is even more sketchy on the electrical characteristics of the Schmitt trigger than it is on the comparator. No mention of what the thresholds are supposed to be. Like you say, I can measure it on one or a few and assume that is typical. PIC12F6xx Schmitt inputs have thresholds spec'd at V0=Vdd*0.2 maximum and V1=Vdd*0.8 minimum.
The precise threshold value will not matter too much in my application. I already have this working using a single-slope technique, but need to wring a little more accuracy and repeatability out of it. The dual slope or charge balancing measurement puts the burden on a stable reference capacitor and takes the precise thresholds and the integration capacitor out of the equation.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Schmitt trigger inputs, testing for lower and upper threshold, V0 and V1.
Test done with 10kohm potentiometer from Vdd to Vss, with 10uf capacitor on the wiper.
* Vdd = 5 volts
- test on rb1: V0=0.95 volts, V1=3.43 volts (note not symmetrical wrt Vdd/2)
- test on rb2: V0=1.15 volts, V1= 3.51 volts (i.e., small variations pin to pin)
* Vdd = 4.2 volts
- test on rb2: V0=0.75 volts, V1=3.05 volts
* Vdd = 3.0 volts
- test on rb2: V0=0.6 volts, V1=2.1 volts
The Schmitt thresholds do not depend on the setting in the LVL register (CMOS vs TTL)--The Schmitt trigger is a separate signal path.
Comparator threshold common mode input range, SX28.
CMP_B register set to zero to enable comparator action with feedtrough to rb0 output.
Test done with 10k pots from Vdd to Vss as above, one for rb1 and one for rb2.
* Vdd = 5 volts
- Comparator worked from less than 0.05 up to 4.9 volts. However, the offset degrades at the extremes, at the high end especially. For example, with rb2 = 1.5 volts, switching occurred at rb1 = 1.51 volts, a 10 millivolt offset. At rb2 = 4.8 volts, switching occurred at rb1 = 4.57 volts, a 230 millivolt offset. Above 4.9 volts there was no comparator action.
* Vdd = 3 volts
- Comparator functioned from less than 0.05 volt up to a little less than 2.8 volts. The offset degraded above 2 volts.
Comparator response time:
Test done by connecting rb0 (comparator output) to rb1 (comparator inverting input) and a voltage source (potentiometer) to rb2 (comparator non-inverting input). This turns the comparator into an oscillator with a period determined by the propagation delay. Observe the effect of varying the voltage Vref on the (+) input. That changes the oscillator period (indirectly measuring the propagation delay).
* Vdd = 5 volts
- minimum period, 42 nanoseconds, when Vref=1.3 volts
- period stays in the range of 42 to 60 nanoseconds for Vref in the range of 0.1 volt to 3.8 volt
- period lengthens and degrades rapidly above 3.8 volts and below 0.1 volts
* Vdd = 3 volts
- minimum period, ~60 nanoseconds, from Vref=0.9 to 1.5 volts
- period at Vref=0.1 volt is 75 nanoseconds, 195 nanoseconds at Vref=0.03 volts.
- period at Vref=1.9 volts is 90 nanoseconds, degrades rapidly above 2 volts.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Please excuse me if I missed the information in your post.
When you measured the comparitor response time, what speed was the SX clocked at?
I am guessing 50 MHz based on the results.
Ken
More. Bit 0 in the CMP_B register follows the result of the compare (and is synced with the processor clock). I wanted to check its speed. I hooked rb.7 up to rb.1 and left rb.2 hooked up to a variable voltage (potentiometer, Vss to Vdd). The program sets rb.7, reads the CMP_B register, and transfers rb to rc. Like this:
My thought was that at high clock speeds, reading CMP_B immediately after toggling the comparator input might not leave enough time for the bit to propagate through into the bit0 of CMP_B. For this test, the 'scope was triggered by rb.7, the comparator input, and a second probe tested rc.0, which should follow the value of the CMP_B result bit. Looking at the data sheet, where it claims a 250 nanosecond propagation time, I was thinking I might have to insert a NOP or two or more in between setting the comparator input and reading the result. But no, it turns out that even with a 50 megahertz clock, the result appears on rc.0 three clock cycles after the input toggles. And that was true for input levels from 0.04 volts up to 4.2 volts.
I haven't tested it yet with smaller input overdrives, or with a 3 volt Vdd, but I was pleasantly suprised by the input range and by the speed.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
But that may be because of it's lack of documentation.
Bean.
I it performing well.
Ken
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
I just got a project where using the SX comparator makes a lot sense. I'll have to monitor a fan, and issue an alarm if it is stuck, off, or when the air outlet is blocked.
Under normal operating conditions, the fan consumes about 20 Watts. When it is blocked, I'm pretty sure that the power consumption will go up. When it is off, power consumption will be zero, and when the air outlet is blocked, power consumption will be below regular. The last statement may surprise on the first glance - but did you ever notice the sound of a vacuum cleaner when you close the nozzle - it goes up, i.e. the motor turns at higher RPMs because there is no air to be moved, i.e. less workload.
I'll put a small transformer's secondary side in series with the fan, and connect a rectifier to the primary side. The resulting, filtered voltage after the rectifier should be proportional to the fan's power consumption. This DC signal (adjustable by a trim-pot) will be fed into one of the SX comparator inputs. The other (reference) input will be alternatively connected to two different adjustable reference voltages in order to compare the current fan's power consumption against the allowed max/min values.
I have "breadboarded" the hardware, and wrote the SX software, so I'm pretty close to test the system.
I'll keep you informed about my experiences with the comparator later.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Greetings from Germany,
G
I remember my mother saying "now it is working very hard" when her vacuum cleaner's airway was blocked, and I believed this for a long time . Later, I've learned that motors usually make more RPMs when running w/o load.
In the meantime, I have tested the system, and it seems to work as expected. I'll keep you posted when it is finished.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Greetings from Germany,
G
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Knight Designs
324 West Main Street
P.O. Box 97
Montour Falls, NY 14865
(607) 535-6777
Business Page:·· http://www.knightdesigns.com
Personal Page:··· http://www.lightlink.com/dream/chris
Designs Page:··· http://www.lightlink.com/dream/designs
·
I'm still up, although it is more than an hour after midnight here...
You'll definitely will get a good feel for the SX after having done some projects - I'm glad if my book can be of any help on that path.
Maybe, you try to convert your BS-based mouse trap project into "plain SX". As a matter of fact, I had much fun reading your text on that!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Greetings from Germany,
G
Introductions to the various parts over time doesn't work well for me...I need to see everything at once, then break it down.· This doesn't work for most people, but it helped me make excellent use of the Z80 back in the day...I had looked over books here and there, but one day I ran across this book that was like a look inside, and everything was labeled as it's register's use in the assembler.· So once I had that down, as well as how each register worked, and it's various instructions and modes, I was able to start cranking out code and projects.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Knight Designs
324 West Main Street
P.O. Box 97
Montour Falls, NY 14865
(607) 535-6777
Business Page:·· http://www.knightdesigns.com
Personal Page:··· http://www.lightlink.com/dream/chris
Designs Page:··· http://www.lightlink.com/dream/designs
·
Here is a rundown from experiment, where I applied voltage from two poteniometers to the comparator inputs, rb1 and rb2, and then put the chip into eternal SLEEP. (Caveat--observations based on one SX28 chip).
The minimum comparator active current drain is about 110 microamps.
-- both inputs must be near either Vss or Vdd
-- the two inputs must be separated by a certain voltage--20 millivolts is enough.
The current drain increases to ~1 milliamp when the two input voltages are equal (allowing for the input offset voltage), _and_ both near the rails. For example, both are at 0.1 volt or both are at 3.5 volts. The current is difficult to measure, as there is a tendency for self oscillation, 60hz pickup, etc.etc, when near the switching point.
The surprising thing comes when either comparator input is near 1.8 volts, while the other one is near the rails. The current drain is around 2.5 milliamps. The current drain peak is narrow around that threshold. The current drain profile as a function of input voltage is pretty much the same as the profile when the comparator is disabled (That is why we never want to leave inputs floating!).
If both inputs of the comparator are near the 1.8 volt level, the current drain can be as high as 4.5 milliamps, even if the voltage difference is enough to keep the comparator output solidly in one state or the other.
The lesson here for anyone wanting to use the comparator and at the same time to minimize current drain, would be to keep the input voltage levels below 1.3 volts (or above 2.3 volts), and, to include at least 20 mV of hysteresis.
I'll take a look tomorrow and see if the LVL or Schmitt registers have any effect on this. I don't think so, because of the earlier tests. It may be that there is a totem pole type of input circuit in the input structure of the comparator.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Just a brief note to say thank you for posting the work you are doing with the comparitor and current consumption.
Ken
Bean.
I think Gunther's idea might be somewhat akin to a circuit being switch by a Transitor, or FET...When the transistor or FET is switched off (Blocks the flow of electricity, so to speak) the current/work drops, since there is no work being done...At least it may be another interesting way of thinking about the differences...
But Tracy, that was a good point.· I think the Water, being of a different form of matter, would certainly different properties in the same example.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Knight Designs
324 West Main Street
P.O. Box 97
Montour Falls, NY 14865
(607) 535-6777
Business Page:·· http://www.knightdesigns.com
Personal Page:··· http://www.lightlink.com/dream/chris
Designs Page:··· http://www.lightlink.com/dream/designs
Post Edited (Chris Savage) : 1/11/2005 4:35:25 PM GMT
One way of describing the process, without too much physics, is:
Basically, the impeller 'works' by flinging the fluid away from the blade through the outlet; as the·fluid is flung away,·more fluid is 'drawn' into the intake.· When the conditions are such that the fluid surrounding the impeller becomes 'static'--not moving out because either the inlet or outlet are blocked--then the impeller just accelerates to the motor's maximum rpm as the the (remaining) trapped fluid just rotates with the impeller.· Now the 'work' the impeller is doing is just combatting friction, not accelerating fluid mass.
HTH,
Daniel
Daniel
http://www.sxlist.com/techref/ubicom/analogcomparator.htm
A VERY heart felt thanks to you sir for bothering to do the testing and for sharing it with us. I will, of course, remove my copies of your posts from sxlist.com if you request.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
---
James Newton, Host of SXList.com
james@sxlist.com 1-619-652-0593 fax:1-208-279-8767
SX FAQ / Code / Tutorials / Documentation:
http://www.sxlist.com Pick faster!
thanks for that very clear and understandable explanation. I think the same explanation is valid for a fan "pumping" air as well, as a fan does not differ much from an impeller type liquid pump, and air is kind of "liquid" too, only more compressible.
Actually, this discussion is a bit out of thread but it was initiated by my posting where I briefly described one of my current projects using the SX comparator. In the meantime, I have finished a prototype, and it will go into a real live test tomorrow.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Greetings from Germany,
G
The blue curve is the trace followed on the way up, voltage on rb1 increasing. The red curve is the trace followed on the way down, voltage decreasing. The two curves split apart between 1 volt and 3.6 volts. The other two curves are short segments done to repeat the measurement.
There is a peak of current, as expected at 0.5 volts, where the two comparator inputs are equal and the output rb0 makes its transition. The totem pole output of the comparator draws DC current at the mid point.
There was also a peak of current at 1.5 volts. That was more surprising, because whatever is going on inside the chip has nothing to do with the comparator output. I would guess there is another totem pole structure that is biased on at that point, maybe connected with the standard SX input. By the way, this kind of peak in current is characteristic of the SX or PIC chip as the input voltage passes through the switching threshold. Keep that in mind as you use RCTIME!
From the graph it appears that there is a big peak on the decreasing (red) curve at 1.5 volts, but not on the increasing (blue) curve. Don't count on that. On the blue curve I was stepping up by 0.1 volt units, and missed the peak. The peak is that narrow. On the way down, I decremented by 0.01 volt from 1.6 down to 1.4 volts, and that caught it.
One conclusion: If you want to use the comparator and draw minimum current, too, then do the comparasons between 0 and 1 volt, and add positive feedback to keep away from the switching point.
I have not yet tested with any care to see if these currents are affected by the setting of the LVL_B or Schmitt_B registers. I don't think so, but as you see, it is pretty complicated. I have no idea how to explain the hysteresis.
By the way, thank you for your kind words about the investigation. James, please do add these numbers and the graph too if you please, to www.sxlist.com/techref/ubicom/analogcomparator.htm.
Daniel, thank you for the great explanation of the physics of the impeller pump. I did listen to a vacuum cleaner and a hair dryer with the air flow blocked, and sure enough the pitch went up. I'm curious to hear the result of Gunther's comparator project. How about this: Take a sump pump and attach the outlet to a tall vertical pipe, so the pump pushes water up as far as it can. At that point, there is no flow, but it seems that the pump would be working "as hard as it can" to maintain the pressure head. But maybe not, as the blocked vacuum cleaner would by the same logic be "working as hard as it can" to maintain the vacuum.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com