Comparator on 3.5

Status
Not open for further replies.

ehtelion

New member
Hi there,

this is my first post. We are having a university project where we have to measure apparent and real power, cos phi, frequency...and just one phase only. To measure the time difference between current and voltage (to calculate cos phi) our solution is to use comparator. Are comparators on 3.5 version identical to version of 3.0? If not, could you explain me more about it. We read through datasheet but could not find how to implement in our program.
If you have any other suggestions how to compare current and voltage on time basis, it would be of great help.

Best regards, Marko
 
Before you go down this path, you might wish to consider the nature of apparent and real power. From the words you've written, I'd guess you're only considering the case of pure sine waves. Maybe that's good enough for a purely academic project, but if I were you, I'd ask the instructor if that's an ok assumption and if your project will be accepted if it is designed only for pure sine waves. The last thing you want it to do a lot of work, only to have it rejected.

In practice, the voltage waveforms usually are pretty close to sine waves, unless running from a battery or solar with an inverter. But the current waveforms in most buildings are often not very sinusoidal, especially if powering a lot of electronic equipment.

To compute the real and apparent power with arbitrary waveforms, you would sample both the voltage and the current rapidly. Subtract any DC offset. For real power, multiply voltage*current and accumulate. For the apparent power, you'd square and accumulate both voltage and current. Then on regular intervals, copy and clear those accumulators, and use the copies. The voltage*current indicates the real power. You'd take the square root of the others to get the RMS voltage and current, which you then multiply together to get the apparent power. This approach always works, even if the signals aren't sine waves.

Regarding your original question, yes, the comparators are very similar. Technical details can be found here:

http://www.pjrc.com/teensy/datasheets.html

If you also have to produce the phase angle, this might work if the waveforms aren't too distorted.

Or if you're sampling both signals rapidly, you could write code to detect the time index of the positive and negative maximums within the fast data. Or the time index of the zero crossings, which you could refine to sub-sample time with linear interpolation. The difference in those times could give you the phase angle.
 
Using analogComp library with Teensy 3.5 and 3.6

Thank you, we are measuring up to 370 values pro period (50Hz), therefore any waveform can measured and valued. We have already done all what you have written.
Could this https://github.com/orangkucing/analogComp be used on teensy 3.5?

I'm also very interested in using analogComp library with Teensy 3.5 & 3.6, but when I read the current version of the header file (https://github.com/orangkucing/analogComp/blob/teensy3/analogComp.h), I can see the references to Teensy 3.0 (__MK20DX128__), Teensy 3.1 and 3.2 (__MK20DX256__), but not to Teensy 3.5 and Teensy 3.6, which should bee __MK64FX512__ and __MK66FX1M0_ respectively. I hope that the author, Hisashi Ito*, will update this one.

* The original version is from Leonardo Miliani. Hisashi Ito adapted analogComp for use with Teensy 3.x (up to 3.2, it works very well).
 
Status
Not open for further replies.
Back
Top