neurogears / vestibular-vr

Closed-loop VR setup for Rancz Lab
2 stars 0 forks source link

Implement synchronisation between HARP and ONIX #48

Open RoboDoig opened 3 months ago

RoboDoig commented 3 months ago

Ideally, HARP interface of ONIX breakout will be used as a master clock for H1/H2.

Implement photodiode synchronisation on screens (flickering square to synchronise draw calls).

Use WithLatestTimestamp approach to log state changes in block state machine.

EleonoraAmbrad commented 2 months ago

we have a stereo RCA cable that we can use for the synchronisation as suggested above, I think.

According to the design files, the harp interface signal should be split between H1 and H2, is this correct? can this signal be used as the master clock? If so, should I find a way to connect the cable to H1 and H2? H2 has a ClockIN connection that is similar to the one on the ONIX, H1 doesn't (only has screw terminals) SignalRoutingDesign

RoboDoig commented 2 months ago

There are a couple of ways to do it, as you say you can take a stereo 3.5mm cable and have one end in H2, then bare wire in the screw terminals for H1.

You can also get the HARP synchronizer (https://www.cf-hw.org/open-source-tools/electronic-devices/clock-synchronizer) which can act as the master clock source and has multiple output channels that you can send to H1, H2 and ONIX

EleonoraAmbrad commented 2 months ago

There are a couple of ways to do it, as you say you can take a stereo 3.5mm cable and have one end in H2, then bare wire in the screw terminals for H1.

if we were to go with this solution, how would the ONIX receive the sync signals? or would the ONIX generate the master clock signals? basically, jack in ONIX, jack in H2 ,wire in H1?

RoboDoig commented 2 months ago

I don't think the ONIX can generate a HARP clock, it would rather be H2 generating the master clock and then H1 and ONIX receiving that clock. But yes, the cable would have to be split out from H2 to go to H1 and ONIX, e.g. with a 3.5mm splitter.

https://www.amazon.co.uk/PENCILUPNOSE%C2%A9-HEADPHONE-SPLITTER-EXTENSION-MOTOROLA-BLACK/dp/B079GBP6CV/ref=asc_df_B079GBP6CV/?tag=googshopuk-21&linkCode=df0&hvadid=375419269630&hvpos=&hvnetw=g&hvrand=17305413413427148390&hvpone=&hvptwo=&hvqmt=&hvdev=c&hvdvcmdl=&hvlocint=&hvlocphy=9046001&hvtargid=pla-1013889856952&psc=1&mcid=d37b23cc42a13f0186f1f5c3478351d8&tag=&ref=&adgrpid=85278568708&hvpone=&hvptwo=&hvadid=375419269630&hvpos=&hvnetw=g&hvrand=17305413413427148390&hvqmt=&hvdev=c&hvdvcmdl=&hvlocint=&hvlocphy=9046001&hvtargid=pla-1013889856952

EleonoraAmbrad commented 2 months ago

photo_2024-04-27 23 30 26 (1) photo_2024-04-23 14 22 57 photo_2024-04-23 14 22 50 I connected the cables as shown in the pictures. the clkIN in H1 is receiving the signal from the RCA, which is connected to the jack on H2, which is also sent to ONIX. Let me know when we can test this or if there is something off!

RoboDoig commented 2 months ago

Hi sorry for the delayed reply. I have a meeting with Filipe next week to discuss the clock synchronisation hardware, we can test it after this - but looks good so far! One way to test is just to look at the output of H1 and H2 events and see if they have similar timestamps. If they are synchronized properly, their timestamps should be similar even if once device was turned on several minutes after the other.

EleonoraAmbrad commented 1 month ago

update after meeting with @RoboDoig : signal should not be split between H1 and ONIX from H2, so we will instead send a randomized synchronisation ANALOG output signal to H2 and ONIX. Analog output will be generated in bonsai.

Ideally, in the future we should rely on https://www.cf-hw.org/open-source-tools/electronic-devices/clock-synchronizer to split clock output to H2 and ONIX, especially because H2 analog input may be needed for playback signal. photo_2024-05-02 12 29 47

RoboDoig commented 1 month ago

After last week's discussion: to synchronize everything correctly it will definitely be necessary to use a clock-synchronizer. The H2 analog input is occupied by the hall sensor so it can't be used as a synchronisation signal. Solution will be to have the clock-sync connected to H2 and ONIX. H2 will then pass its clock signal to H1 via the rotary joint.

EleonoraAmbrad commented 1 month ago

Order for the clock synchroniser will be placed this week, lead time should be 2 days.