Hi Chris,
I need a synchronization between a task controller running MWorks, a multi-camera and a neural data recording systems. I have a trigger device which sends pulses 100 times per second via BNC cables. The cameras take images at incoming pulses and neural data recording system uses the pulses to synchronize its clock too. To synchronize MWorks and the rest of the set-up I thought to use a Teensy board to forward the pulses to MWorks. I flashed the board with the Firmata software (MWorks fork) and I have been able to forward trigger pulses in my MWorks task. However, I have observed that there is a problem with consistency of intra-pulse time by analyzing times of events in a .mwk2 file.
This is a plot of time intervals between consecutive trigger pulses. You can see that the intervals deviate a lot from 10 ms and, surprisingly, most of the deviation are at ±5 ms. Some are at +1 ms and occasionally there are even bigger jumps. MWorks was configured to sample every millisecond from the Firmata device. I would be okay with ±1 ms jumps and few occasional max. ± 3ms jumps to be sure that the system is reliable.
I have verified that the trigger device is working properly and other devices record pulses reliably. Above is the plot from camera-recording system, which shows that pulses are send and received consistently without any jumps.
Interestingly, non pulses were lost by the Firmata device, even though the inter-pulse times are sometimes multiples of 10 ms. It looks like the system compensates for over-due pulses with early pulses.
I have tried using different BNC, USB cables, different versions of Teensy (LC and 3.6), but nothing changes the behavior from the first plot. I assume that the problem might originate from how the Firmata device works.
Would you have an idea how to solve the issue? Is there maybe another way to pass trigger pulses to MWorks with lower latency?
Best, Vladyslav