I have developed a circuit to process the PMT pulse output. For the testing, I need an artificial signal which is similar to the PMT pulse. How can I use AnalogWrite() to create such type of signal?
- 1,775
- 3
- 11
- 24
2 Answers
Short answer: You can't.
The Arduino can't do analog output at all, much less matching a specific analog waveform of ≈40ns duration.
PWM on the Arduino simulates constant analog voltages using square wave pulses of variable duty cycle. It has no support for creating analog waveforms of any type, much less ones with such a short duration.
EDIT
As mentioned in this thread: Generate a ramp input with an Arduino Uno
You could use a resistor ladder to create a roll-your-own DAC, and then use direct port register manipulation (not digitalWrite) to set the pins controlling your resistor ladder and get a crude approximation of your waveform.
Edit #2
There is no way you'll be able to generate nanosecond scale waveforms with a normal Arduino. It just isn't fast enough.
- 5,682
- 3
- 17
- 29
I doubt very much AVR-based Arduinos could do that.
SAMD21-based Arduinos do have a DAC, but their conversion time is about 2.85 μs. Their timer/counters can be clocked at 96 MHz, so about 10.5 ns/tick, but would yield a square pulse (that may or may not degenerate into what you need 8-).
Overall, I don't think an Arduino is the right tool for the job. Maybe something like the (very fast) Teensy 4.0 could do it, but I don't know much about those.
- 1,775
- 3
- 11
- 24

analogWrite(PIN, 1)would last 8000ns. – RJPlog Mar 23 '19 at 15:50