Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > sci.electronics.design > #466652
| From | Don Y <blockedofcourse@foo.invalid> |
|---|---|
| Newsgroups | sci.electronics.design |
| Subject | Re: F to bits |
| Date | 2017-07-02 21:29 -0700 |
| Organization | A noiseless patient Spider |
| Message-ID | <ojch0p$guf$1@dont-email.me> (permalink) |
| References | <oj9occ$nvk$1@reader2.panix.com> <oja0eu$9ag$1@dont-email.me> <ojc4kq$mml$1@reader2.panix.com> <ojc5ik$96v$1@dont-email.me> <ojcadc$l8c$1@reader2.panix.com> |
On 7/2/2017 7:33 PM, David Lesher wrote: > Don Y <blockedofcourse@foo.invalid> writes: > > >> So, you're interested in the current instantaneous frequency >> AFTER you're reasonably sure the genset has "come online" >> (it may stumble a bit as it takes on the load) AND the >> *change* in frequency as the load is increasing beyond what >> it can handle. > >> But, you still haven't indicated the range of values that you >> consider significant to convey this information. A 20KW genset >> overloaded by 1KW will respond differently than a 2KW overloaded >> by 100W. > > Well, it's 10KW, but experimentation will tell us what > amount of overload gets us a slowdown. And > >> Likewise, an inverter might exhibit perfect frequency control >> but just start losing voltage... > > This is spinning iron....But we're debating if voltage drop is > a valid metric... > >>> Sure, it will be next to the other stuph. > >> Next to the other stuff *outdoors* or other stuff being *powered* >> (presumably -- though not necessarily -- INdoors). > > Quite indoors. OK, so you won't see large temperature fluctuations (esp over short time intervals). The first thing you need to address is gaining access to the mains. I.e., if you're using a DC wall wart to power your kit, then the AC component of the mains is hidden behind (in front of) the power supply. OTOH, if using an AC wall wart (aka XFORMER) and rectifying, filtering and regulating *this*, then you can tap off the AC ahead of the rectifier and use this as a reflection of the mains voltage (which, in turn, tells you the frequency when examined over time). This can be as simple as feeding the signal through a (high) resistance with clamps to gnd and "Vcc", then a buffer/op amp/etc. to get to a clean digital signal. You can also use an optoisolator, etc. Your goal here is to have a (digital) signal that has a consistent phase/timing relationship with some portion of the mains signal (e.g., a zero-crossing). Any variation, here, introduces jitter to your measurement. (e.g., if you ran the signal through a comparator and tried to slice it at something close to its peak expected voltage, then if that voltage dips or climbs, the point in *time* when the ATTENUATED mains voltage reaches that fixed voltage threshold will change) You can do this for both "legs" of the transformer to get 120 events per second (60Hz mains) or just one -- leaving the portion of the mains waveform when the signal is "negative" to be unobserved. The transformer will help act as a hash filter to cut down on some of the high frequency noise on the line. You can also add some filtering (a cap) at the input to the comparator/buffer (sized carefully lest it add more variation to the signal skew). Once you have a signal that is roughly 60 (120) Hz in periodicity, you have to capture the time at which this "event" occurs. There are many ways to do this -- each with different hardware requirements and costs -- as well as software latency consequences. The straightforward way of doing this is to feed an edge-triggered interrupt pin and write an ISR that grabs the value of a free-running (actually, it need not be but its easier to describe if it is) counter and passes that to a "handler" that can do the math at its leisure (the ISR wants to do as little as possible). However, a problem with this lies in the variations in "interrupt points" in the instruction stream -- that you probably have no control over (unless you want to halt the processor periodically to *wait* for the next interrupt; work on something for a while and then pause so you know the processor isn't doing anything "unpredictable" when the interrupt occurs; service the ISR, then start working, again, confident that the next ISR won't happen for many milliseconds). Additionally, if there are other interrupt sources competing for the processor, then these may be active (being serviced) at the time the LFC interrupt comes along. So, the other ISR may cause the LFC ISR to be delayed by a (variable!) amount, depending on where the other ISR happens to be in its service routine when the LFC event comes along. Finally, if the run-time package installs a default handler for each ISR and dispatches those through some sort of MTOS structure, *it* might introduce delays that you can't control (e.g., ISR sets a flag that the scheduler examines AT ITS CONVENIENCE and conditionally invokes *your* ISR... much delayed from the actual event of interest! There are numerous ways to get this sort of edge-to-trigger-interrupt. One is a dedicated interrupt pin (often programmable as to which edge is active). You can also program a timer to *start* when the edge is detected and have *it* (the timer) generate an interrupt when it "times out" (i.e., preload the timer with a count of "1" and some fixed clock source; when the event occurs, the timer arms and "1 fixed clock" later, it generates an interrupt -- which you use to examine another free-running timer, as above) [Note that you don't care that the interrupt is delayed by that "1 fixed clock" as long as it is ALWAYS delayed by the same amount! OTOH, you can't delay by a length of time that exceeds the amount of time between your LFC events as the "next" one will be missed while the first one is still timing out] You can use a serial port "modem control" signal. You can use the RxD signal for an unused serial port (if you can ensure the signal from your detector is wide enough to look like a start bit -- then, some number of bit times later, the "data" on the RxD pin is received by the UART and an interrupt signaled) I.e., look at every interrupt source and see how you can trick one that you aren't using to perform this function for you... reliably! A better approach is to use the capture register present in many MCU's (incl the Mega). Instead of generating an interrupt and HOPING you can carefully and CONSISTENTLY get around to noticing that "free-running counter" value (in the ISR), you let hardware in the MCU take a snapshot of *a* free-running counter and signal an interrupt. The interrupt then can leisurely examine the CAPTURED timer value when the hardware event was signaled. This lets the software get sloppy in its timeliness (how quickly it gets around to handling the interrupt/event) AND consistency (the latency need not be constant/consistent cuz the time-critical aspect of the problem has been handled by the capture hardware. The free-running counter is typically the counter that your "timing services" use (e.g., the mechanism that lets you note that "1 millisecond" has expired) -- unless you don't have a *real* service (i.e., the timing/delay functions twiddle the hardware directly <frown> ) *Ideally*, the timer will not wrap around more than once between events. I.e., if the counter counts from 0 to 9 and then wraps to 0, again, you would ideally like to see events at, for example, 2... then 8 (for a difference of 6), then 4 (another difference of 6 cuz 4+10-8=6), then 0, etc. If the timer wraps more often, you have a few choices: - slower clock/timebase (more time between wraps) - wider timer (more counts between wraps) The slower clock comes at the expense of more granularity in your measurements. You lose precision. The wider timer can be implemented by cascading two (or more) hardware timers (so one wraps causing the other to advance by a count). Or, by implementing the "wrap counter" in software. This requires an interrupt at each wrap of the (one!) hardware timer and an update of some internal variable that acts as the more significant portion of the "virtual timer". This adds yet another (trivial) ISR. But, complicates the design of the original ISR as it now has to read the hardware timer AND the "software variable" that acts as its extension. All the while taking into account the fact that other ISRs may be interspersed in the process. At the very least, it requires a more complicated "atomic read" of this combined hardware+software timer: how do you know that the hardware timer hasn't changed while you're reading the software counter -- and vice versa? However, a bit of clearer thinking can often eliminate the need for this extra counter/timer and the overhead/complexity that comes with it. If, for example, you can guarantee that the variation between expected observations will always be within the range of one "hardware timer timeout period", you can *infer* the number of "wraps" that must have occurred between events! For example, assume the counter counts [0..99]. Now, assume the range of valid "intervals" (between events) is [528..619] (pick two values that differ by less than 100 counts). Assume *an* event is noted as occurring at a HARDWARE count value of 42. Assume the next event occurs at a count of 95. It *looks* like the interval was 53 counts. But, we know that 53 isn't possible! The only value in the range supported would be 553. So, we can infer that the timer had wrapped 5 times. If the second read had been 41, we'd know that the difference (99) could only be accounted for if the interval had been 599. Where this falls down is if the range of valid intervals exceeds the period covered by the hardware timer. E.g., imagine if the valid range was [500..619] and the two observations were 42 and 43 -- an apparent difference of "1". Would this be 501? Or, 601?? <shrug> Hopefully enough to get you started... As for your "load detector", you could either hard-code limits *or* take a snapshot of the current frequency and watch to see if it degrades by a percentage in a particular time interval (you want to react quickly enough to not damage the genset *or* end up with a low-line condition; but, not too quickly that you shed load unnecessarily). Also keep in mind that the genset will appear to be performing BETTER once the load is shed -- don't get caught thinking you can now reacquire the load that you just shed (add some hysteresis to your decision loop so it doesn't oscillate).
Back to sci.electronics.design | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
F to bits David Lesher <wb8foz@panix.com> - 2017-07-02 03:13 +0000
Re: F to bits Lasse Langwadt Christensen <langwadt@fonz.dk> - 2017-07-01 20:27 -0700
Re: F to bits David Lesher <wb8foz@panix.com> - 2017-07-02 05:21 +0000
Re: F to bits edward.ming.lee@gmail.com - 2017-07-02 07:36 -0700
Re: F to bits Don Y <blockedofcourse@foo.invalid> - 2017-07-01 22:34 -0700
Re: F to bits edward.ming.lee@gmail.com - 2017-07-02 07:55 -0700
Re: F to bits rickman <gnuarm@gmail.com> - 2017-07-02 11:44 -0400
Re: F to bits edward.ming.lee@gmail.com - 2017-07-02 08:51 -0700
Re: F to bits rickman <gnuarm@gmail.com> - 2017-07-02 12:00 -0400
Re: F to bits edward.ming.lee@gmail.com - 2017-07-02 10:20 -0700
Re: F to bits rickman <gnuarm@gmail.com> - 2017-07-02 13:52 -0400
Re: F to bits Neon John <no@never.com> - 2017-07-02 13:41 -0400
Re: F to bits Don Y <blockedofcourse@foo.invalid> - 2017-07-02 11:22 -0700
Re: F to bits "John Miles, KE5FX" <jmiles@gmail.com> - 2017-07-02 12:55 -0700
Re: F to bits Lasse Langwadt Christensen <langwadt@fonz.dk> - 2017-07-02 13:12 -0700
Re: F to bits Don Y <blockedofcourse@foo.invalid> - 2017-07-02 13:27 -0700
Re: F to bits edward.ming.lee@gmail.com - 2017-07-02 14:18 -0700
Re: F to bits Lasse Langwadt Christensen <langwadt@fonz.dk> - 2017-07-02 14:37 -0700
Re: F to bits edward.ming.lee@gmail.com - 2017-07-02 14:44 -0700
Re: F to bits edward.ming.lee@gmail.com - 2017-07-02 14:48 -0700
Re: F to bits edward.ming.lee@gmail.com - 2017-07-02 15:44 -0700
Re: F to bits Lasse Langwadt Christensen <langwadt@fonz.dk> - 2017-07-02 16:23 -0700
Re: F to bits edward.ming.lee@gmail.com - 2017-07-02 16:26 -0700
Re: F to bits Lasse Langwadt Christensen <langwadt@fonz.dk> - 2017-07-02 16:36 -0700
Re: F to bits edward.ming.lee@gmail.com - 2017-07-02 16:44 -0700
Re: F to bits Lasse Langwadt Christensen <langwadt@fonz.dk> - 2017-07-02 17:13 -0700
Re: F to bits krw@notreal.com - 2017-07-02 19:53 -0400
Re: F to bits Tauno Voipio <tauno.voipio@notused.fi.invalid> - 2017-07-03 10:30 +0300
Re: F to bits Don Y <blockedofcourse@foo.invalid> - 2017-07-03 09:44 -0700
Re: F to bits Don Y <blockedofcourse@foo.invalid> - 2017-07-03 09:50 -0700
Re: F to bits Jasen Betts <jasen@xnet.co.nz> - 2017-07-04 05:18 +0000
Re: F to bits Les Cargill <lcargill99@comcast.com> - 2017-07-03 00:44 -0500
Re: F to bits Les Cargill <lcargill99@comcast.com> - 2017-07-03 00:42 -0500
Re: F to bits Jasen Betts <jasen@xnet.co.nz> - 2017-07-04 05:11 +0000
Re: F to bits rickman <gnuarm@gmail.com> - 2017-07-02 19:32 -0400
Re: F to bits Lasse Langwadt Christensen <langwadt@fonz.dk> - 2017-07-02 16:40 -0700
Re: F to bits klaus.kragelund@gmail.com - 2017-07-02 16:45 -0700
Re: F to bits rickman <gnuarm@gmail.com> - 2017-07-02 19:55 -0400
Re: F to bits Lasse Langwadt Christensen <langwadt@fonz.dk> - 2017-07-02 17:07 -0700
Re: F to bits rickman <gnuarm@gmail.com> - 2017-07-02 20:30 -0400
Re: F to bits edward.ming.lee@gmail.com - 2017-07-02 17:39 -0700
Re: F to bits klaus.kragelund@gmail.com - 2017-07-02 18:09 -0700
Re: F to bits edward.ming.lee@gmail.com - 2017-07-02 18:45 -0700
Re: F to bits "John Miles, KE5FX" <jmiles@gmail.com> - 2017-07-02 17:49 -0700
Re: F to bits rickman <gnuarm@gmail.com> - 2017-07-02 22:56 -0400
Re: F to bits "John Miles, KE5FX" <jmiles@gmail.com> - 2017-07-02 21:52 -0700
Re: F to bits rickman <gnuarm@gmail.com> - 2017-07-03 01:38 -0400
Re: F to bits David Brown <david.brown@hesbynett.no> - 2017-07-03 12:37 +0200
Re: F to bits edward.ming.lee@gmail.com - 2017-07-03 04:23 -0700
Re: F to bits David Brown <david.brown@hesbynett.no> - 2017-07-03 14:10 +0200
Re: F to bits leongdentalsf@gmail.com - 2017-07-03 06:14 -0700
Re: F to bits Tom Gardner <spamjunk@blueyonder.co.uk> - 2017-07-03 15:46 +0100
Re: F to bits edward.ming.lee@gmail.com - 2017-07-03 08:24 -0700
Re: F to bits Tom Gardner <spamjunk@blueyonder.co.uk> - 2017-07-03 17:12 +0100
Re: F to bits rickman <gnuarm@gmail.com> - 2017-07-03 12:50 -0400
Re: F to bits Tom Gardner <spamjunk@blueyonder.co.uk> - 2017-07-03 18:36 +0100
Re: F to bits rickman <gnuarm@gmail.com> - 2017-07-05 02:01 -0400
Re: F to bits Lasse Langwadt Christensen <langwadt@fonz.dk> - 2017-07-03 09:30 -0700
Re: F to bits Tom Gardner <spamjunk@blueyonder.co.uk> - 2017-07-03 12:32 +0100
Re: F to bits David Lesher <wb8foz@panix.com> - 2017-07-03 00:54 +0000
Re: F to bits Don Y <blockedofcourse@foo.invalid> - 2017-07-02 18:14 -0700
Re: F to bits David Lesher <wb8foz@panix.com> - 2017-07-03 02:33 +0000
Re: F to bits Don Y <blockedofcourse@foo.invalid> - 2017-07-02 21:29 -0700
Re: F to bits edward.ming.lee@gmail.com - 2017-07-02 22:46 -0700
Re: F to bits Les Cargill <lcargill99@comcast.com> - 2017-07-02 12:40 -0500
Re: F to bits Don Y <blockedofcourse@foo.invalid> - 2017-07-02 11:38 -0700
Re: F to bits Les Cargill <lcargill99@comcast.com> - 2017-07-03 00:51 -0500
csiph-web