0

I'm a trainee in a research center, I'm studying physics but here I'm working on electronics, so it's not really in my area. I'm using an Arduino DUE witch uses an Atmel SAM3X8E ARM Cortex-M3 and I need to count "precisely" the time between two interruptions (interruption will be ~1µs and I need a precision ~0.2µs), and the libraries made for the whole arduino world are not precise enough. I would like to have access to the Atmel's timer, but I can't manage to find a library which is doing that, I found https://github.com/ivanseidel/DueTimer and this https://github.com/antodom/tc_lib but those libraries are periodically calling back a function or are capturing pulses from outside. I've found nothing else. Do you know a library which would do that on the DUE or a tutorial on who to use the register of the Atmel arm directly in the Arduino IDE ?

Have a nice day !

Edit : Hi, In fact I am testing chips that will be implemented in an experiment in some years. They use "new technologies" (flip chip, vias, etc...) and they will evolved between -40 and 60 Celsius degrees (-40 140 F), with radiations. I have to test the lifetime of these thechnologies in this environment so "I" (with a lot of help) will put them in a oven and do cycle between -40 and 60C. I need to know when there will be a break in the circuit, this will create a glitch of, approximately, 300 ohm during 1 micro second, but I need to know "exactly" (a precision of 0.2 micro second or less, which is, in theory, possible with the 12ns clock cycle of the arduino due) the time between the rising and the falling edge of those glitches. I have 70 inputs to test and nearly no knowledge in electronics that's why I have chosen an Arduino Due with 54 inputs. I use 25 inputs on 3 Arduino. There is nearly no chance that 2 breaks happen in the same time, so my first idea was to launch an timer on the rising edge, attach the interrupt on the falling edge, and read at the end the value in the timer to know the duration (which will be approximately one micro second) with a timeout to avoid noise. But I wasn't thinking that there won't be a function to launch a timer with more precision in the Arduino's libraries ...

F.André
  • 11
  • 1
  • Have you tried micros ? `unsigned long t1 = micros(); unsigned long t2 = micros(); unsigned long t_between = t2 - t1;` – Jot Jul 16 '17 at 20:21
  • Thank you, I thought about it but micros() return an unsigned long so it has a precision of one micro second (for the DUE, for other arduino the precision is sometime worst depending on the clock) so the precision is not enough for what I am trying to do, sorry ... – F.André Jul 16 '17 at 22:18
  • It is what you asked, 1 µs resolution. Could you specify the timing precision that you want ? Could you explain what you want to measure ? What if more interrupts are active, and other interrupts delay your interrupt ? What you describe is something for a logic analyzer. The low end Saleae Logic4 samples with 12MS/s. I suppose you want a Due Timer to run without interrupt and you want to read the 32 bit counter value two times to be able to calculate the difference. I have not found code for that yet. – Jot Jul 17 '17 at 09:18
  • Hi, I precised my question – F.André Jul 17 '17 at 15:57
  • You might need special lab equipment or dedicated hardware. As soon as software is involved and interrupts, there is no guarantee that the Due can measure that accuracy for so many channels. You could ask a electronics hardware engineer to make something for you. I think that a USB logic analyzer with a script is also possible. Perhaps with a script it is possible to continuously read data and measure the pulse width. Try a new question at https://electronics.stackexchange.com/ with a good title. For example "measure rare 1µs pulse with 0.1µs resolution for many channels". – Jot Jul 17 '17 at 17:01
  • Hi, I have to admit this title is far better. In fact my supervisor is actually an electronics engineer. We did a PCB with zener diodes to handle all the inputs, most of the time the tension on the arduino's input will be close to the ground. We also mount a system with switches, multimeters and a computer to measure the resistance of all the inputs. The system will be tested during a long time with a pulse generator before beginning the measures so, normally, everything will work. The only missing piece of this puzzle is the possibility to launch an accurate timer on the Arduino DUE ^^" – F.André Jul 18 '17 at 10:14

0 Answers0