Skip to content

A very basic TTL square wave generator based on an Arduino Nano controlled via serial communication with Python

License

Notifications You must be signed in to change notification settings

lukasjarzembowski/Arduino-TTL-Trigger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Arduino-TTL-Trigger

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.

How to use

  1. Connect to your PC and power the Arduino via USB
  2. Upload the .ino file to the Arduino
  3. Run the compiled TTL Trigger software
    • Note: I compiled the python code with PyInstaller, tested on Windows 10
  4. Select the serial port the Arduino is connected to. If the connection has been established you can proceed to the GUI

  1. 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

  1. Click "Send to Arduino" - you are now ready to go!

Bill of materials

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

Known bugs / Limitations

  • 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.

References

Limitation of Liability

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.

About

A very basic TTL square wave generator based on an Arduino Nano controlled via serial communication with Python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published