Detecting Zero-Crossings #1537
Replies: 2 comments
-
Posted at 2016-06-22 by @gfwilliams If the voltage really does drop below zero, your best bet is to 'bias' it up so the average voltage is at the point at which Espruino's input flips between a 0 and a 1:
Those values are just total guesses, but they should work. If you have some kind of oscillocope it'd be a massive help so you can see what's going on. If that doesn't work, you may have to resort to using a separate comparator. At that point you should be able to use
Something like the following might be a good start though:
The watch handler is pretty cryptic because it's trying to be fast to execute, but:
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-06-22 by BitMeddler Thanks Gordon, I've been developing the idea fully in JS, but from the outset I suspected I'd have to compile it, or perhaps bash it out in ASM.
Which is pretty heavy, but easier to debug. This method makes no assumptions about the short bit period, and would tolerate a 'ripple' in the transmission rate. First step would be minifying it I guess, and maybe ditching the avg. gap length I'm keeping. I'm then pushing the 'bit' into a Uint16Array - like a LIFO - lots of shifts and carrys (probably better in ASM too) then it's just 'bitfield[4] & 0x3FFD' to find the sync word. I didn't know about the x.y.bind(x) gotcha - thanks for that. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2016-06-22 by BitMeddler
Hi,
I'm developing a system to read LTC timecode (cf wiki, Good Article), which is an audio signal (I'd guess between .32V and .77V RMS). TL;DR the links, it's a binary pattern in Bi-phase mark coding. I want to sense the period between zero crossings to decode the signal. Will reading a Pin in "both" mode:
have the desired result, or should I use a Zero-Crossing detection circuit to condition the signal to a rising edge before sensing it?
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions