dirkx / SMPTE-EBU-TimecodeGenerator-ESP32

ESP32 based SMPTE/EBU timecode generator, with NTP slaving, for Leitch and similar studio/broadcast clocks.
Apache License 2.0
48 stars 14 forks source link

Clock is syncing but time is wrong #3

Closed m0vse closed 4 years ago

m0vse commented 4 years ago

Hi, I am trying to get your code working with an ADC-5112L Leitch analogue clock and it is definitely syncing (led off) but the time is wrong! I have tried various DIP switch settings but I wasn't sure whether it should be set for SMTPE or EBU? Could you post what your working switch settings are?

If I change the fiddle factor, the clock loses sync for a few seconds so I know it is talking but not sure what is happening? The time is not off by an exact amount (around 2 hours 50 minutes) so I don't think it is an offset.

I am using these from Amazon which are ESP-32 based.

https://www.amazon.co.uk/gp/product/B084BRJSYR/ref=ppx_yo_dt_b_asin_title_o01_s00?ie=UTF8&psc=1

Any ideas?

Thanks

Phil

dirkx commented 4 years ago

Ok - I am using it with exactly that clock I think -- will check the dipswitches on my end.

Are you on 50hz or 60hz (USA?)

m0vse commented 4 years ago

Thanks, I am in the UK (50hz). I have tried 25fps as well as 30fps (changed in both SMTPEGenerator.ino and RMT.ino) but both are the same. What is weird is that it is consistently 2hrs and 55 minutes slow!

m0vse commented 4 years ago

I also have a digital model that I plan to convert as well so I will try that later and see if that is the same!

dirkx commented 4 years ago

Hmm - I do see something silly: https://github.com/dirkx/SMPTE-EBU-TimecodeGenerator-ESP32/blob/2ecdbfdde22f8f8f6fbdd10a01380bf595f2024b/SMPTEGenerator/SMPTEGenerator.ino#L57 -- that bool really be an int. Perhaps some compiler funnyness makes it a -1.

That would examplain away the 2 hours - (on GMT) but not the 5 mins.

m0vse commented 4 years ago

Interestingly, I have built the second unit for the digital clock and that works fine and displays the correct time. I have tried swapping the ESP32 boards between the two clocks but the analogue still shows the wrong time.

One thing I have noticed on the digital clock, sometimes on reboot of the ESP32, it shows a time with 30 hours! I had seen this in the serial console before but a reboot usually clears it. I wonder how the analogue clock would deal with this?

Usually setting a bool to 1 shouldn't cause an issue but I will try that.

m0vse commented 4 years ago

Another thing... In the description, you say a 2K5 resistor between the transistor base and GPIO, but the schematic shows 1K. Do you think this might cause an issue as I am using 1K?

dirkx commented 4 years ago

Ah wait - these clocks (because of multiplexes and delays in transmission pipelines, etc) have pretty advanced adjustors to 'fool' studio staff.

Check the manual and see if that is not set to 2h + 5 mins -- as 5 mins is a fairly standard ISO-DBA delay:

Time Offsets The LEITCH CSD-3901 Master Clock System Driver allows programming of time code user bits. This facility can be used to include a specific time offset in the time code. The operating mode of one or more ADCs in a system can then be set to read this offset. A typical application is the display of GMT in addition to local time. Additionally, ADCs may be preset to display an offset from local time. This local offset allows the display of any or all time zones at one location. This offset is user-programmable.

So check SW4 and the manual

dirkx commented 4 years ago

I used whatever was on my desk at that time. Both should be fine. We're just trying to get a 5v pulse.

m0vse commented 4 years ago

That's good to know. Yes I wondered about the 'offset' as that can add/remove a fixed amount to the time. I have checked that though and it is disabled in the DIP switches.

dirkx commented 4 years ago

If you reset the clock - does it nicely stop at the top - so you re sure that the mechanical arms are where the clock thingks they are?

m0vse commented 4 years ago

How do you reset it? I noticed mention of setting the hands to 12:00:00 in the manual but It seems to be random where the hands end up!

m0vse commented 4 years ago

I wonder if there is an issue with the hand detectors?

dirkx commented 4 years ago

Ah - that may be a clue -- may just mechnically slipped. dac5016.pdf page 28 and page 32

m0vse commented 4 years ago

I have just read the manual positioning instructions on P32 of that so I bet that is the issue!!!

dirkx commented 4 years ago

Cool ! And feel free to sent patches/updates. The code can be cleaned up a lot & is fairly weird in places as it originally ran as an IRQ on an pic12 - where we were limited. Those limits are long gone - so it should now be possible to figure out the exact relative delays (as these are now static) and do a lovely milli-second correct display now.

m0vse commented 4 years ago

Yes that fixed it, thanks! I am thinking about adding proper Timezone support GPS (NMEA) and maybe OTA updating as well as a few other bits so I will definitely send you pull requests for anything that I get working. Thanks again for your help, I did suspect it may be more related to the hand position but I missed that section of the manual!

dirkx commented 4 years ago

OTA should be in there already.

The really nice one is a Phase-Locked-Loop on the NTP. So we get < 5mSec time sync.

m0vse commented 4 years ago

Sorry I just noticed that OTA was already there after I said it. I have been looking at the ezTime library https://github.com/ropg/ezTime this looks to have done all of the heavy-lifting for ntp latency and ms accuracy and also has extensive timezone support, so I may play around with integrating that?

dirkx commented 4 years ago

Right - it is much nicer- but does not do the crucial PLL: https://tools.ietf.org/html/rfc5905#section-11.3 - see http://what-when-how.com/computer-network-time-synchronization/kernel-pllfll-discipline-kernel-timekeeping-support-computer-network-time-synchronization/