TTL generator

928 views
Skip to first unread message

paolo...@gmail.com

unread,
Oct 27, 2020, 11:01:06 AM10/27/20
to Bonsai Users
Dear Goncalo,

I have read different posts in order to build a BONSAI Workflow to generate a TTL and turn on/off an LED light connected via Arduino, but it turned out that I am having difficulties in generating it.

I would like to have three BONSAI Workflows:
1) Every 30 seconds for n times a single square pulse of 50ms length is repeated.
2) Every 30 seconds for n times, the square pulse of 50ms can be given at variable frequencies that I could adjust prior playing the workflow (up to 40Hz).
3) Same as above but intermixed 50ms output pulses (single or at different frequencies) every 30 minutes for n times.

Any recommendation or feedback is greatly appreciated.

Best,
Paolo

These are the links and codes that I read:

Ori Yarden

unread,
Oct 27, 2020, 1:56:03 PM10/27/20
to paolo...@gmail.com, Bonsai Users
Dear Paolo,

In order to have Bonsai and Arduino communicate, you must incorporate the DigitalOutput node in your workflow; it functions as a binary ON/OFF or TRUE/FALSE node which signals to Arduino the same. To relay the signal to your Arduino, you must first relay the signal via an Arduino using the StandardFirmata.io code. Using a second Arduino (that receives the relay signal from the first Arduino), you can apply a TTL pulse whenever your condition (TRUE/FALSE--from DigitalOutput node) by coding in that Arduino a pattern of HIGH/LOW. If you need help with the Arduino coding for a TTL pulse feel free to ask.

Best,

On Tue, Oct 27, 2020 at 11:01 AM paolo...@gmail.com <paolo...@gmail.com> wrote:
    EXTERNAL EMAIL : Exercise caution when responding, opening links, or opening attachments.
 
--
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/f0f53dd6-4095-4b69-bb58-e8e199c524cen%40googlegroups.com.


--
Ori Yarden
Teacher's Assistant
Psychology Department
Florida Atlantic University
BS-12, room 123
Boca Raton, FL 33431

Paolo Botta

unread,
Oct 29, 2020, 2:12:07 AM10/29/20
to Ori Yarden, Bonsai Users
Hi Goncalo,

As arduino and firmata were already set properly, would you have any suggestion on how to generate a periodic pulse (50ms every 30s for example)? If possible, also a node able to generate a 40 Hz pulse.

If this is not possible, I might need to find another solution using Arduino directly.

Thank you for letting me know.

Best,
Paolo
--
Paolo Botta

Giuseppe Giannotti

unread,
Oct 29, 2020, 12:07:32 PM10/29/20
to Paolo Botta, Bonsai Users

Hi Paolo,

As far as I know there are different ways to do what are you trying to do. You can use the digital output node in Bonsai with fermata protocol uploaded on your Arduino to drive a pin on HIGH and use that pin to drive a second Arduino (with a frequency defined loop and an if statement [if digitalRead(Pin x == High)]. I personally don’t like using Arduino with fermata protocol. Another possibility is to set a function generator node in bonsai to define the desired frequency. Moreover, you can change the digitalWriteCallback function in the fermata protocol to generate a simple stimulation (I believe most of these topic are already covered in previous threads).

The option that I like is to send from bonsai a String (with the serial string write node) an let Arduino do the rest. In your Arduino sketch you can Serial.readStringUntill(‘\n’) and with an if statement (if == “x”), drive the frequency loop. You may want to set a millis() timer to drive the stimulation for a specific amount of time or a counter for a specific number of times.

But of course it depends on your goal and your experimental setting.

 

G

Giuseppe Giannotti

unread,
Oct 29, 2020, 12:20:02 PM10/29/20
to Paolo Botta, Bonsai Users

Of course I meant “Firmata” but my laptop didn’t like the word 😉

Kip Keller

unread,
Feb 5, 2021, 5:50:00 PM2/5/21
to Bonsai Users
HI -  Might it be easier, if you have an unused channel on your sound card, to send a 'TTL'-like pulse out the soundcard?
Reply all
Reply to author
Forward
0 new messages