Arduino TTL Pulse to control camera frame capture

494 views
Skip to first unread message

lab person

unread,
Dec 9, 2020, 11:00:17 AM12/9/20
to Bonsai Users
Hello,

I would like to use Bonsai to have an arduino send 30 TTL pulses per second to control the frame collection of the camera while also using DeepLabCut's Detect Pose node to track mouse behavior. I have tried to create a workflow where the Digital Input goes to a Spinnaker Capture node and a timestamp finishing at a VideoWriter Node but have had trouble getting it to work. Has anyone used Bonsai for a project like this? If so could someone share a possible workflow for me to use?

Gonçalo Lopes

unread,
Dec 13, 2020, 8:36:13 AM12/13/20
to lab person, Bonsai Users
Hi lab person and welcome to the forums!

It looks like you are interested in triggering the camera by hardware on a frame-by-frame basis. If that is the case, you shouldn't need to change anything in the software at all. The input to SpinnakerCapture is meant to control acquisition start only, and not frame-by-frame acquisition (as software triggering would be jittery anyway, so not very useful).

What you need to do in this case would be to connect the arduino output directly to the Spinnaker camera GPIO input in hardware. You also need to go into the SpinView configuration software and enable trigger mode.

This is all done outside of Bonsai itself and I think there are other questions in this forum that have gone through the process in more detail.

On Wed, 9 Dec 2020 at 16:00, lab person <l...@sjulsonlab.org> wrote:
Hello,

I would like to use Bonsai to have an arduino send 30 TTL pulses per second to control the frame collection of the camera while also using DeepLabCut's Detect Pose node to track mouse behavior. I have tried to create a workflow where the Digital Input goes to a Spinnaker Capture node and a timestamp finishing at a VideoWriter Node but have had trouble getting it to work. Has anyone used Bonsai for a project like this? If so could someone share a possible workflow for me to use?

--
You received this message because you are subscribed to the Google Groups "Bonsai Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bonsai-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bonsai-users/4f8cf2dd-fe33-4d0c-9a50-77dfac6a8da8n%40googlegroups.com.

lab person

unread,
Dec 14, 2020, 4:12:28 PM12/14/20
to Bonsai Users
Hi Goncalo,

Thank you for your response. I think we will use the GPIO to trigger then, however I think I am also having an issue with the Arduino and Bonsai. I had a Digital input node leading to a timestamp node and a CSV Write node and I wasn't getting any input from the Arduino. Do you think it might be an issue in the Arduino code?

Gonçalo Lopes

unread,
Dec 31, 2020, 2:29:14 PM12/31/20
to lab person, Bonsai Users
Hi lab person,

It could be. Have you installed the standard Firmata firmware to communicate with the device? The DigitalInput node requires standard firmata to be installed and configured with a matching baud rate (by default 57600).

Hope this helps.

lab person

unread,
Jan 6, 2021, 10:06:30 AM1/6/21
to Bonsai Users
Hi Goncalo,

I have standardFirmata uploaded to my Arduino, but from there I'm not so sure how to progress. I have never used Firmata and am new to Arduino in general, so this might be a dumb question.

bruno...@neuro.fchampalimaud.org

unread,
Jan 6, 2021, 11:08:58 AM1/6/21
to Bonsai Users
Hey,

Assuming you uploaded firmata (Open the Arduino IDE -->File --> Examples --> Firmata --> Standard Firmata and upload the sketch), the attached workflow should acquire data from and Arduino  pin and save it, timestamped, to a txt. The only thing you should need to set is the COM port in the "CreateArduino" Node and the pin number in the "digitalInput".
Keep in mind that, contrary to analogInput, DigitalInput only sends a sample when the state of the button changes (i.e. LOW to HIGH or HIGH to LOW) and not continuously!

Cheers,
Bruno
arduinoRead.bonsai
Reply all
Reply to author
Forward
0 new messages