# Inconsitent trigger pulse (TTL) durations with firmata device (teensy)

**URL:** https://mworks.discourse.group/t/inconsitent-trigger-pulse-ttl-durations-with-firmata-device-teensy/1112
**Category:** Support
**Created:** [September 5, 2025, 7:50pm UTC](https://mworks.discourse.group/t/inconsitent-trigger-pulse-ttl-durations-with-firmata-device-teensy/1112 "2025-09-05T19:50:50Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![vonaviv](https://avatars.discourse-cdn.com/v4/letter/v/b19c9b/32.png) [@vonaviv](https://mworks.discourse.group/u/vonaviv)
#### Post date: [September 5, 2025, 7:50pm UTC](https://mworks.discourse.group/t/inconsitent-trigger-pulse-ttl-durations-with-firmata-device-teensy/1112/1 "2025-09-05T19:50:50Z")

</div>

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.

 ![TaskController_trigger_test](https://canada1.discourse-cdn.com/flex031/uploads/mworks/original/1X/097d84b97ce7edf79d984dcfa421dc18d98b8b62.png)

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.

 ![Camera_trigger_test](https://canada1.discourse-cdn.com/flex031/uploads/mworks/original/1X/92ff6eff1d4e48e6f0cfd8f7611ae50795db7427.png)

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

---

<div class="post-metadata">

### Author: ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)
#### Post date: [September 9, 2025, 2:53pm UTC](https://mworks.discourse.group/t/inconsitent-trigger-pulse-ttl-durations-with-firmata-device-teensy/1112/2 "2025-09-09T14:53:39Z")

</div>

Hi Vladyslav,

I’m not sure what to make of the apparent 5ms quantization of the pulses.

You’re using a [digital input](https://mworks.github.io/documentation/latest/components/firmata_digital_input_channel.html) to receive the pulses, correct? The Firmata firmware reads and sends updates about digital inputs as quickly as possible, and MWorks is continually receiving messages from the device. There are no built-in waits on either end that would cause messages to “stack up” at 5ms intervals. (Note that the [data\_interval](https://mworks.github.io/documentation/latest/components/firmata_device.html#data-interval) parameter sets the rate at which the Firmata firmware reads _analog_ inputs. It has no effect on how often digital inputs are checked, and it has no effect at all on the MWorks side.)

The first thing I’d do is make sure that the Arduino IDE is closed when MWorks is running. It doesn’t need to be open unless you’re updating the board’s firmware, and if it is open, it may be interfering with serial communication between the board and MWorks.

Assuming the Arduino IDE isn’t causing the issue, I’d next consider whether something about the Teensy hardware or its supporting firmware libraries is causing this behavior. Do you have a non-Teensy device (e.g. an Arduino board) that you could test with MWorks instead? I don’t know why the Teensy would behave this way, but it would be good to know whether you see this behavior with other boards, too.

As for alternative ways to get the trigger pulses to MWorks: You could try using a [LabJack](https://mworks.github.io/documentation/latest/components/labjack_ljm_device.html). However, I’d expect the latency to be _higher_ than with a Firmata device, since MWorks must poll the LabJack at a [fixed interval](https://mworks.github.io/documentation/latest/components/labjack_ljm_device.html#update-interval) to learn about input changes.

I hope that helps!

Cheers,  
Chris

---

<div class="post-metadata">

### Author: ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)
#### Post date: [August 25, 2026, 3:04pm UTC](https://mworks.discourse.group/t/inconsitent-trigger-pulse-ttl-durations-with-firmata-device-teensy/1112/3 "2026-08-25T15:04:08Z")

</div>


