I wanted to use a teensy board for triggering and synchronizing some different sensors.
Taking a simple example, I'll have two sensors: one high rate (~200 Hz) and one low rate (~20Hz). The simplest triggering, AFAIK, is generating a PWM at their respective frequencies. But I will also need a timestamp of each rising edge which I can use to stamp the signals. I figured I can build a system to work in the following way:
Note, another couple of important aspects for the performance
My uncertainties are:
Taking a simple example, I'll have two sensors: one high rate (~200 Hz) and one low rate (~20Hz). The simplest triggering, AFAIK, is generating a PWM at their respective frequencies. But I will also need a timestamp of each rising edge which I can use to stamp the signals. I figured I can build a system to work in the following way:
- send one pulse in the beginning to synchronize start time of teeny with host computer unix stamp, i.e. estimate origin offset
- begin triggering relevant sensors, sending a timestamp to host computer in the form of "micro-seconds since start"
- apply origin offset in host computer: unixtime of teensy start + micro seconds since start = rising edge stamp in unixtime
Note, another couple of important aspects for the performance
- Trigger signals should ideally start as close to at the same time as possible. If not possible it's okay if the offset between starting times is constant and known.
- Trigger signals don't drift from each other, it's fine if they don't line up perfectly as some sensors rates won't allow this to happen, but they should be consistent with respect to one another.
- Trigger signal duty cycle doesn't really matter, there is some minimum to be registered by the sensor (~10us) but assuming this prerequisite is fulfilled, the precise duration doesn't matter.
My uncertainties are:
- is this a reasonable way to go about doing this?
- how can I get the teensy clock time of the pwm rising edge?
- will i need to bitbang the pwm to accurately get the rising edge time