Skip to content

Commit cd21cf6

Browse files
authored
Update README.md
1 parent f9c21dc commit cd21cf6

File tree

1 file changed

+127
-2
lines changed

1 file changed

+127
-2
lines changed

README.md

Lines changed: 127 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,127 @@
1-
# ArduinoTriggerSystem
2-
Catching the TTL trigger signla using Arduino Yun.
1+
# Catching the TTL trigger
2+
3+
4+
5+
Our group need to build a new DAQ system for planned nuclear decay experiments, which require a stable and reliable procedure to remote-control all network-connected devices (a spectrum analyzer, a IQ recorder and a server) to successively collecting large amount of data. However, the original trigger system of IQ recorder can not satisfy the requirment. It can only work steadily when executing the _recording mode_ each time the trigger signal comes.
6+
7+
***An independent trigger system to catch the TTL trigger signal is in high demand!***
8+
9+
10+
**Goal**
11+
12+
Catching the TTL trigger signal and sednding the *triggered* message to server, so that the server can execute the IQ recorder to collect data.
13+
14+
**material**
15+
16+
* Arduino Yun: ATmega 32U4 (16MHz) and built-in Ethernet support
17+
* resistances, PCB, soldering iron (tin)
18+
19+
**Content**
20+
* designing concept
21+
* circuit diagram
22+
* software 1.0: resetting prescaler
23+
* software 2.0: using analog comparator
24+
25+
## Designing concept
26+
27+
The TTL trigger signal:
28+
* falling edge
29+
* width: 50 $\mu$ s
30+
* amplitude range: 0~4V
31+
32+
![image](/Pic/triggerSignal.png)
33+
34+
Design index:
35+
* sampling frequency > 100 kHz
36+
* amplitude < 4V, triggered
37+
38+
Process:
39+
40+
1. measuring TTL signal: when amplitude < 4V, triggered
41+
2. netcat: using `nc` ShellCommand to send the message to server
42+
43+
44+
## Circuit diagram
45+
46+
A simple circuit is for measuring the voltage of the resistance (1k$\Omega$), which is connected with another resistance (the same 1k$\Omega$) in series. The total voltage of this circuit is the input voltage between TTL and GND. The voltage between ADC input A0 and GND is what we measure.
47+
48+
![image](/Pic/Circuit.png)
49+
50+
## software 1.0: resetting prescaler
51+
52+
This idea was used in our beam test 2016.
53+
54+
The main idea is to resetting prescaler. The `analogRead()` usually needs 100$\mu$s to read the analog input. Since the default prescaler is 128.
55+
56+
ADC clock = 16 MHz / 128 = 125 kHz
57+
58+
One ADC transfer needs 13 ticks. The final sampling rate
59+
60+
125 kHz / 13 = 9600 Hz
61+
62+
***It is far from our design index!***
63+
64+
Since we do not need a very high accuracy of the voltage. We reset the prescaler to instead 4 of 128. The ideal sampling rate is 308 kHz (3.24$\mu$s per point). The test result is 9.42 $\mu$s per point.
65+
66+
**Code**
67+
```Arduino
68+
// Define various ADC prescaler
69+
const unsigned char PS_2 = (1 << ADPS0);
70+
const unsigned char PS_4 = (1 << ADPS1);
71+
const unsigned char PS_8 = (1 << ADPS1) | (1 << ADPS0);
72+
const unsigned char PS_16 = (1 << ADPS2);
73+
const unsigned char PS_32 = (1 << ADPS2) | (1 << ADPS0);
74+
const unsigned char PS_64 = (1 << ADPS2) | (1 << ADPS1);
75+
const unsigned char PS_128 = (1 << ADPS2) | (1 << ADPS1) | (1 << ADPS0);
76+
77+
// To change the prescaler modify setup
78+
ADCSRA |= PS_16; // 16 prescaler
79+
ADCSRA |= PS_8; // 8 prescaler
80+
ADCSRA |= PS_4; // 4 prescaler
81+
```
82+
83+
**Reference link**
84+
85+
[Advanced Arduino ADC - Faster analogRead()](http://www.microsmart.co.za/technical/2014/03/01/advanced-arduino-adc/)
86+
87+
[The Analog to Digital Converter(ADC)](http://www.avrbeginners.net/architecture/adc/adc.html)
88+
89+
**Problem**
90+
91+
The new setting has a high risk of shortening life of the Arduino. Since the suggested prescaler is not least than 16.
92+
93+
In our one-week test experiment, 2016, the trigger was working fairly fine all the time. Nevertheless, bad luck comes in 2017.
94+
95+
96+
## software 2.0: using analog comparator
97+
98+
This idea will be used in our beam test 2017.
99+
100+
The main idea is using analog comparator, comparing the input values on the positive pin AIN+ and negative pin AIN-. When the voltage on the AIN+ is higher than the voltage on the AIN-, the Analog Comparator output, ACO, is set.
101+
The comparator can trigger a separate interrupt, exclusive to the Analog Comparator.
102+
103+
In this case, the AIN+ we choose is the Bandgap reference (1.1$\+-$0.1V) and the AIN- is ADC input A0 (ATmega 32U4 mapping pin ADC7).
104+
105+
**Code**
106+
```Arduino
107+
ACSR |= ((1<< ACBG)| // AIN+ set to bandgap reference voltage 1.1(1)V
108+
(1<< ACI)|
109+
(1<< ACIE)| // Analog Comparator interrupt is activated
110+
(1<< ACIS1)|); // Comparator interrupt on falling output edge
111+
ADCSRB |= (1<<ACME); // AIN- set to ADC7(A0)
112+
ADCSRA &= ~(1<<ADEN);
113+
ADMUX |= ((1<<MUX2)|(1<<MUX1)|(1<<MUX0));
114+
DIDR1 |= (1 << AIN0D); // disable the digital input buffer
115+
```
116+
117+
**Reference link**
118+
119+
[ATmega 32U4 datasheet](http://www.atmel.com/Images/Atmel-7766-8-bit-AVR-ATmega16U4-32U4_Datasheet.pdf)
120+
121+
[Using the Arduino Analog Comparator](http://www.gammon.com.au/forum/?id=11916)
122+
123+
**Result**
124+
125+
No one trigger missing!
126+
127+
The DC Characteristics shows the typical propagation delay is 500 ns at VCC = 4.0V, TA = -40 to 85 Celsius degree.

0 commit comments

Comments
 (0)