4 ms·
Won’t you still need an NTP or a GPS time module unless the RTC has a battery backup? How many applications would you have where timing is critical but you won
by dogma1138 3y ago
Won’t you still need an NTP or a GPS time module unless the RTC has a battery backup?
How many applications would you have where timing is critical but you won’t have an external time reference that would be still viable without a guaranteed power backup?
- peteforde 3y agoNobody said anything about not having NTP in the loop! Here's the deal: RPi<5 runs at the speed of the voltage coming in. The OS creates a fake software clock that assumes it's a perfect 5v, but in reality not only does voltage fluctuate, it drops over the length of a cable run. If you have, I dunno, 70 Pis connected, the 5v on the first one is very different than the 5v on the last one, no matter how frequently you ask NTP to broadcast. The first thing we did was deliver 12V down the wire with a high quality power supply. Then we used UBEC buck converter modules (intended for RC quadcopters) to deliver power directly into the Pi via its pins. However, even now you're just chasing physics. There's no way to send a command to all of the Pis to do something right now. Instead, we tell all of them to do something at a very precise moment in about three seconds. In our case, this meant writing a very low-level C program to listen for raw UDP messages and trigger the camera module at the hardware register level. The only way to verify that it was working as well as we believed it did was to create a reference clock. We had a friend build a 20 LED timer that would count 10ms and 1ms increments. We achieved < 1ms syncronization across 70 Pis in this manner.
- uxp8u61q 3y agoI may be completely off base here, but maybe the rpi wasn't the best tool for the project then? What was it, if I may ask?
- peteforde 3y agoI mean, I'd be curious what you'd have suggested! We needed it to be small, low power, low heat, provide hardware level access to a camera module, be ethernet accessible. Oh, and under $100 including a fixed M-mount lens. At the time, it didn't seem like rolling our own hardware would have been faster. I would argue - given we succeeded at sub 1ms syncronization - that the Pi was close to the perfect tool. It just would have been even more perfect if it had an RTC.
- Fnoord 3y agoYou already solved your issue, but still I'll mention it: For my Pi's I buy a separate RTC (uses GPIO pins). There's various available, the DS3231 is the most expensive but also the best. If you buy it in bulk (70+) I suppose you could shave some money off. If you're OK with a cheaper one (less than half the price) which functions less well (but still does the job) then PCF8523. I got mine from a local Adafruit reseller.
- peteforde 3y agoFWIW, the cheapest RTC module we could find that had kernel support was about $31 at the time. Things have gotten a lot better and cheaper since then. Adafruit didn't launch that DS3231 until four years after we did this. We couldn't justify adding ~$2500 to the bottom line, but you can be confident that we sure did argue about it.
- Goz3rr 3y agoMissed this comment when asking why you didn't add a $2 RTC, but given that you mention Adafruit I assume making your own hardware to stick onto a Pi wasn't an option? The DS3231 you mention is a chip with mainline support since 2009. Cheaper options like a DS1307 cost less than a $0.50 a piece when you buy 100 of them, and they've been supported in Linux since 2006.
- peteforde 3y agoTL;DR we were programmers, not engineers. I'd say 50/50 that I didn't know what I2C was in 2014. Still, if we had gone and designed our own RTC daughterboard, it would have replaced the UBEC in our architecture diagram. We were buying those for $3-4 in 1000 unit quantities. So, had you been on hand a decade ago, you might have won the argument although if I put on my board member hat, fabbing our own PCB sounds a lot scarier than buying boxes of buck converters. It's hard to express how wild it is that they just pop right on and guarantee close to perfect voltage to each device. https://www.alibaba.com/product-detail/UBEC-5V-3A-5A-7A-15A_1600691062848.html https://www.alibaba.com/product-detail/UBEC-5V-3A-5A-7A-15A_...
- eurekin 3y agoOh my.. Please, can you share more about it? Some NDAs about the function of that pi fleet?
- peteforde 3y agoUnfortunately, I probably can't share much more than the above. However, if you have more specific technical questions, I'll try to do my best.
- zh3 3y agoWe've synchronised multiple Pi's to fractions of a millisecond, with flash systems with accuracy in the microseconds for specialised motion capture. Happy to discuss if you're interested - I'm on <hn username> at 'tessierlabs . com' (without spaces).
- xorcist 3y agoWhat's with the patching? It sounds like pretty much spot on for what NTP was designed for. Each clock is monotonically increasing, with its individual drift. NTP will pretty soon find out exactly what the right polling interval is. Even if you run it in broadcast mode (why would you though, with only 70 devices).
- peteforde 3y agoIt's been eight years, but if memory serves, the primary need was to force it to broadcast as frequently as possible. Everything you said is totally legit unless you're addressing devices with software clocks that are running at speeds dictated by subtly shifting voltage. Remember, according to the Pi itself, it's 100% in sync. No problem hereeeeeeee (robot voice as voltage dips to 4.9887 volts).
- mytailorisrich 3y agoAt some point, and considering how cheap they are these days, the simplest option is to add a GPS module if your use-case allows for satellites in decent view.
- peteforde 3y agoDoes this work inside? How cheap is cheap?
- mytailorisrich 3y ago> Does this work inside It depends. Hence my previous comment. > How cheap is cheap? Google says unit retail price for module with PPS output can be under $5.
- peteforde 3y agoOur deployment environments were occasionally in places where daylight wasn't a thing. However, if we could have used GPS at a marginal cost of $5 at the time, it's very likely we would have been excited to hear about this. Thanks for the lightbulb moment.
- stavros 3y agoWould it have worked to add something like a single GPS module connected to an ESP8266 that sends a pulse every minute to all the Pis' GPIOs so they can sync?
- Pwngu 3y ago[dead]