I needed to synchronize the image acquisition of our microscope with our field stimulator, which itself needed a patterned TTL signal to create the desired eletric stimulus.
This build is based on an Arduino Nano which conveniently operates in the TTL voltage range of 3.3-5V. The Arduino checks whether a TTL signal was received and creates a square wave with a specified frequency. The Arduino is controlled via USB serial connection with a Python-based GUI.
Digital Pin 2 of the Arduino is configured as input. The input state is set to low with a 10 kΩ pull-down resistor to prevent floating when no input signal is present. Digital Pin 3 is configured as output with a 510 Ω current limiting resistor in series. The output TTL signal is also visualized via a flashing LED driven by digital pin 5 (with a 470Ω serial resistor). The momentary button connects digital pin 4, which uses the Arduino's built-in pull-up resistor, to ground when pushed to manually start the TTL train. Since the device is connected to a stimulator capable of producing hazardous electric currents, both input and output can be cut off with a DPST switch, which also controls two respective indicator LEDs.
For our setup, the input is connected to a Zeiss SVB-1 signal distribution box, which creates a short TTL pulse at the start of image acquisition. The output connects to a Warner Instruments SIU-102 bipolar stimulator, which creates the actual eletric stimulus according to the incoming TTL signal.
- Connect to your PC and power the Arduino via USB
- Upload the .ino file to the Arduino
- Run the compiled TTL Trigger software
- Note: I compiled the python code with PyInstaller, tested on Windows 10
- Select the serial port the Arduino is connected to. If the connection has been established you can proceed to the GUI
- You can now determine the parameters for the output TTL signal:
- Predelay [ms]: how long the delay between the received TTL signal and generated output TTL signal should be
- Pulse on [ms]: duration of each pulse
- At least two of the following parameters have to be determined:
- Train length [ms or s]
- Frequency [Hz]
- Number of stimuli
- Optional:
- the pulse length and train length can both be extended to 1-5000ms and 0.5 - 300s, respectively
- the x-axis range can be manually adjusted
- Click "Send to Arduino" - you are now ready to go!
Part | Price [€] | Note |
---|---|---|
Arduino Nano V3 | 19.80 | Cheaper Atmega328-based variants can be found for less than 7€ |
BNC Socket, 2x | 2x 0.36 | - |
SPDT Momentary Switch | 4.15 | optional |
DPST Switch, 2x | 2x 3.97 | optional |
LED, blue, 3 mm, 3x | 3x 0.10 | optional |
Through Hole PCB, 4x6 cm | 6.49 | Set of 16 |
2.54 mm header socket | 2x 1.20 | optional |
Metal film resistors, 1/4 W, 1% | 4.95 | Set of 600 |
ABS housing, 119x99x45 mm | 8.99 | - |
total costs | 55.74 | Note: not including wire and shrinkwrap |
- The program will crash if it cannot connect to the Arduino or a wrong port has been selected - I tried to include a serial timeout function but failed :-)
- Depending which two parameters are controlled, values for the third might lay outside the slider's display range but are non the less correctly calculated - always check the log box below the graph to check what settings will be sent to the Arduino
- The program will crash if you enter anything but an integer when manually adjusting the x-axis range
- Since I do not need the Arduino to do much, the square wave is generated by simply switching between LOW and HIGH states of the output pin with the delay() function. As this could have limitations if I wanted to add more functionality, I might change this in the future.
- The complete serial communication code is adapted from Robin2's posts here and here in the arduino.cc forum
- The GUI was created using the amazing, easy-to-use PySimpleGUI package
- Similar Arduino-based builds can be found here, here and here
- Great open-source options I would have opted for are Pulse Pal and especially StimJim
- The cheapest commercial option I found is PulserPlus by Prizmatix
I will not be liable for damages or losses to hardware or personal health from using the published code or builds based on the one shown here.