## Tuesday, 14 February 2012

### Arduino Nanosecond Signal Delay

At the Photon Factory (a laser lab at the University of Auckland) I have just completed a summer studentship building the electronics for a nanosecond transient absorption spectrometer. This spectrometer will be able to excite molecules and then detect the excited state. Another laser will work out for how long the excited states are stable. This will be used to help research of photoactive molecules, made of nano particles that can convert sunlight into energy, such as those in Figure 1.

Figure 1 | Fullerene triad molecule in which light excites an electron in the porphyrin (to the left and right of the fullerene containing a metal). The electron is then taken up by the fullerene. The iron is oxidised at the top of the molecule and gives the electron to the porphyrin, resulted in charge being separated (like a battery separates charge). This can be used to turn sunlight into usable energy. In the spectrometer we work out how long these charge separated states last for in order to design efficient fullerene triad molecules.

At the Photon Factory, we have an ultrafast transient absorption spectrometer that can send pulses femtoseconds (1*10^-15 seconds) across to excite and probe very fast chemical reactions. This system is limited to the femto- to pico- time scales due to the delay being set by making one laser pulse travel a slightly further distance than the other. To probe molecules that have excited states in the nanosecond to millisecond range a new laser system was built that could delay the pulses electronically. Delay generators can be purchased for thousands of dollars, however an in-house Arduino-based delay generator was constructed and computer-controlled using Arduino in order to set the delay.

Figure 2 | Animation of transient absorption spectroscopy for simple formaldehyde C=O group. (Click on the image to see the animation in your browser.)

My part of the project was to construct the electronic delay that could delay a pulse coming from the pumping laser by nanoseconds to milliseconds in order to fire the probing laser at varying times to look at the excited state as it decays. Digital delay generators are common in laser applications where timing down to the nanoseconds is needed to look at processes that happen in the nanosecond scale and below. Most commercial delay generators cost around $US1600 and up. These digital delays use oscillating clocks to do the timing but in the lab we only wanted resolution down to a nanosecond scale. For this, I used the Arduino nanosecond delay generator which is capable of delaying a signal by 4 ns to 10 ms. Electronics Analog The delay was set up using monostable multivibrator chips (TC74HC123(F)$NZ1.56). These chips used two timers whose time constants were determined through a capacitor and resistor. When a pulse is detected the output becomes high via a Schmitt trigger. This discharges the capacitor and then charges it again. When the voltage in the capacitor is 66% the output pulse is toggled low. This gives the delay time in seconds as the product of the resistor and capacitor values. I used three dual timing ICs. The first two have four delays which are variable between 4 ns to 10 ms by using four different capacitor values and 100kOhm variable resistors. The output pulse then triggers the next timer, which has a PCB mounted pot for referencing between the lasers. Finally, the pulse is lengthened in a fixed delay, giving the laser the right pulse length for it to trigger. This can be seen in figure 3. The impedance was not taken into account and a simple signal generator was used to provide the needed current for the high speed electronics which uses input impedances of 50 Ohms. As I understand it (and you can test this yourself) a lot of electronics have a long decay after a pulse has passed through due to the current having nowhere to discharge. Using drop down resistors from the signal line to ground it gives the current a place to quickly discharge. However, this usually leads to a voltage drop due to the load this resistor places on the circuit. In a lot of high speed systems impedance (another way of thinking about resistance if taken in the context of DC circuits) is very low. This leads to no trailing of the pulse as the current is quickly removed, however this requires that enough current is outputted current to keep the voltage above the triggering threshold. There are other things to take into account, like reflection caused by ill-matched impedance. To put it simply, I did not plan for it in the design so I used a circuit which had built-in impedance.

Figure 3 | Timing and delay of the pulse in the various chips.

Digital
To vary the four variable timing chips, digital dual chips' potentiometers were used (MCP42100 \$NZ2.56). These were used as variable resistors with 8-bit resolution, giving 256 different values between 0-100kOhm which it could be switched to. The capacitor values chosen were 10pF, 100pF, 1nF and 100nF. This gave a range of 4 ns to 10 ms by using one of the four delay timers. The chips were switched off and on using the clear pins and the Arduino.

An Arduino clone, the Etherten, from Freetronics was used to set the value of the digipots using simple SPI interface. The chip select pin was toggled low and two bytes were sent. The first byte was a command byte that told the chip which pot to set. The second was the 8-bit number 0-255 to set the pot. The clear pin on the vibrator chips are used to turn on and off the chips when the pin is set low.

Figure 4 | Schematic of the nanosecond signal delaydone on Eagle CAD.

Figure 5 | PCB design done on Eagle CAD. Surface-mounted capacitors and resistors were used for cost and also space efficiency.

Software

Arduino
The code to run the Arduino is attached in the link at the bottom of the page. Serial commands set the pot values and turn on the various timing chips. The Arduino can also sum the number of pulses that have passed and disable the chips when a certain shot number has been reached.

Minimum Arduino code to set the pots and turn on one of the delays is below.

 #include SPI.h int Aselect = 3; //Assign variables int Bselect = 2; int Cselect = 5; int Dselect = 4; int varcalselect = 7; int Outputselect = 6; void setup() { pinMode (Aselect, OUTPUT); //Set pins as outputs pinMode (Bselect, OUTPUT); pinMode (Cselect, OUTPUT); pinMode (Dselect, OUTPUT); pinMode (varcalselect, OUTPUT); pinMode (Outputselect, OUTPUT); pinMode (10, OUTPUT); pinMode (9, OUTPUT); digitalWrite (Aselect, LOW); //Write high or low digital value to pins digitalWrite (Bselect, LOW); digitalWrite (Cselect, LOW); digitalWrite (Dselect, LOW); digitalWrite (varcalselect, HIGH); digitalWrite (Outputselect, HIGH); digitalWrite (10, HIGH); digitalWrite (9, HIGH); SPI.begin(); digitalWrite(10, LOW); //Set the chip select for the first pot SPI.transfer(B00010011); //B00010001 writes pot 0 B00010010 writes pot 1 B00010011 writes both pots SPI.transfer(200); //transfer the byte that sets the value digitalWrite(10, HIGH); digitalWrite(9, LOW); SPI.transfer(B00010011); SPI.transfer(100); digitalWrite(9, HIGH); digitalWrite(Dselect, HIGH); //Turn on the correct } void loop(){ } 

Labview

A very simple program was built in Labview to control the Arduino through serial interface to send the commands and receive the number of shots. Labview was used as the equipment in the lab all runs on Labview and the program is quick and easy to set up. However, the serial communication makes it easy to control the delay using other programs such as any serial terminal or a simple Python program using pyserial.
Figure 6 | Labview VI for the sending of serial commands to the Arduino to control the delay.

Figure 7 | The front panel for the Labview program.

Finished project

The enclosure was designed in Inkscape, a free vector art drawing program and printed using the Ponoko laser cut service in New Zealand. The cost of the laser cutting was NZ20 dollars including the postage. There was some room on the template so I put in some micro/milli-fluidics which I will post about soon. The PCB board was built as described in the previous blog entry.

The Etherten was already in the lab when I started the project and can be bought for around NZ81 dollars in New Zealand, however an Arduino Uno is all that is needed and would be under NZ50 dollars. The rest of the components cost NZ49.47 dollars, bought from RS New Zealand.

Figure 8 |  Electronics mounted in the laser cut enclosure.

Figure 9 | The shield with the two digital pots as well as the three timing chips can be seen mounted onto the Etherten, an Arduino clone.

Testing of the device using a signal generator and an oscilloscope found the jitter of the unit to be below 3 ns and the overall delay precision 4 ns. This gives us the needed 10 ns timing which is our limit with the laser pulse width. The main limitation is the jitter which at high resistor values of above approximately 70 kOhms can increase to ~25 ns. More delays would be needed in order to get the resolution at the longest delay. The reference delay was kept at 1kOhm and the signal generator that the signal went into to match the impedance has a simple timer that can be used to set the pump and probe to zero - it basically lines the laser pulses up so that they both trigger at the same moment.

Figure 10 | Testing of the nanosecond signal delay at the Photon Factory.

Figure 11 | Presentation for summer studentship at the University of Auckland put together with Powerpoint and Prezi.