daharoni / Miniscope_DAQ_Software

Data acquisition source code for Miniscope project.
MIT License
15 stars 16 forks source link

Trigger Ext #11

Open fxpena opened 5 years ago

fxpena commented 5 years ago

How do I use the "Trigger Ext" feature? My goal is to trigger a recording based on input from an arduino microcontroller. I tried to send a TTL pulse from arduino to the DAQ via a coaxial cable but it didn't seem to do anything. Does the duration of the pulse matter? Should it even be a pulse or should it be a sustained HIGH signal for the number of seconds that I want to record? I tried the latter as well for a 2 second duration but that didn't seem to do anything either. Does it matter which port on the DAQ I connect to? I tried a little bit with both.

Alternatively, I would like arduino to keep track of the timestamps by detecting each time a frame is recorded. I had successfully done this with nVista by using the SYNC feature in their software and the SYNC port on their DAQ. Is there a way for MiniscopeControl to tell the DAQ to send a TTL pulse each time a frame is recorded?

DenisPolygalov commented 5 years ago

Hi @fxpena I can only comment on a part of your question. Hope it helps. "Alternatively, I would like arduino to keep track of the timestamps by detecting each time a frame is recorded." - be careful with this. The first thing to check is - are you sure the DAQ box gives you electical signal related to the "frame recording finished" event without involving Windows? Any data recording that involves Windows is not precise by definition. Windows is not a real time operating system. Same is about Linux and MacOS. In order to achieve really good timing you need to timestamp your frames on a hardware level. I'm not sure nVista is doing this. Company that ask for a e-mail and other credentials in order to download their white papers doesn't look good in general :) To my knowledge only few recording systems can acheve real sychronization of multiple video streams and these are nothing like Arduino which is only a toy. For example this one is THE real one: https://www.tdt.com/rv2-video-capture-and-tracker.html

daharoni commented 5 years ago

Hi @fxpena, I have been meaning to write up a tutorial on external triggering the Miniscope system for a very long time but haven't gotten around to doing it. Please see below:

In the 3.2 version of the DAQ PCB the "trigger in" port isn't one of the 2 ports that come assembled with an SMA connector. Here, http://imgur.com/a/hgzua, is a picture of where the connections of this port are located. You can solder one of these coax cables, https://www.digikey.com/products/en?keywords=0897611670, to the 2 pads and then run it out of the DAQ Box.

The DAQ can accept either a 3.3V trigger or a 5V trigger. Once you select "Trigger Ext." in the Miniscope DAQ software, the Miniscope system will start recording when the digital input signal goes HIGH and will stop recording when the signal goes LOW. So in other words, the system will record whenever the trigger remains HIGH. Everytime the trigger signal goes high the Miniscope software will create a new recording session.

As for your other question, when the Miniscope is recording data, one of the SMA connections (labeled J5 on the PCB) on the DAQ will toggle a digital output signal on every frame acquired (0V -> 3.3V -> 0V -> 3.3V and so on). This will provide a SYNC signal for other hardware like an arduino. This hardware SYNC output has an accuracy on the order of microseconds. It is important to note though that this SYNC signal is unaware of if a frame gets dropped across the USB connections. I suggest looking through the supplement of this recent paper, https://doi.org/10.1016/j.neuron.2018.09.050, from the Tank lab for an approach to match saved Miniscope frames and SYNC signals.

If you need more help just let me know.

fxpena commented 5 years ago

Ok then I will try use the hardware SYNC signal. Accuracy on the order of microseconds seems quite reasonable given that calcium dynamics are on the order of hundreds of milliseconds. Thank you for the paper and the picture of the labelled PCB.

fxpena commented 5 years ago

It worked; thanks! By the way, using the SYNC signal works when I use each CHANGE in the digital signal. Using only the RISING parts of the signal results in catching only half of the frames.

daharoni commented 5 years ago

This is correct. Each toggle of the signal (high to low as well as low to high) denotes a new frame acquisition.

desouzaf commented 2 years ago

I am trying to setup the trigger for DAQ on Miniscope V4 too, but it does not work. I did the soldering on the signal and gnd terminals as suggested, but the +5V does not trigger the miniscope even with the triggerable button enabled on the control panel. If I click Record(Ext. Trig. Enabled) it starts acquiring without waiting for a trigger too. Can you please help me to figure out what is wrong?

hmfeng commented 1 year ago

Hi @desouzaf I get stuck with the same problem now. It seems the TTL cannot trigger the recording through the signal & gnd pins. Did you solve your problem and can you please share your solution? Thank you!

desouzaf commented 1 year ago

Hi hmfeng,

I solved it. You need to solder two wires on the DAQ board as follows. Then, use those wires to provide a TTL pulse with +5V to trigger on an 0V to trigger off.

https://optogeneticsandneuralengineeringcore.gitlab.io/ONECoreSite/assets/img/projects/MiniScope/TTL%20Over.png

Regards,

Fabio

Em 2023-01-30 16:10, hmfeng escreveu:

Hi @desouzaf [1] I get stuck with the same problem now. It seems the TTL cannot trigger the recording through the signal & gnd pins. Did you solve your problem and can you please share your solution? Thank you!

-- Reply to this email directly, view it on GitHub [2], or unsubscribe [3]. You are receiving this because you were mentioned.Message ID: @.***>

Links:

[1] https://github.com/desouzaf [2] https://github.com/daharoni/Miniscope_DAQ_Software/issues/11#issuecomment-1409498558 [3] https://github.com/notifications/unsubscribe-auth/AEINSHWI7TQZWC7SCYVB2UDWVBC67ANCNFSM4GLMLODQ

--

HE675 commented 1 year ago

Does anybody knows how to unsolder and solder a Right Angle SMA Thru Hole RF Connector. In the DAQ in order trigger it