Go Down

Topic: Help with pulse generation (Read 915 times) previous topic - next topic


Hi, im new to arduino and im working on a project to generate 2 pulses that may overlap in the microseconds scale.
I need to generate a pulse of certain width (square wave), then a variable delay (the delay changes each cycle by a certain amount, and then another pulse of another certain width.
then repeat the whole process after a second.

The thing is that i cannot use the dealy function if i want to overlap pulses aparently, and the professor said we should try using the direct pin control command.

im reading about ddrd and stuff but i would love some help or a link if a project like this already exist

thanks in advance and i apologize for my english.


Please state the required pulse lengths and delays in microseconds.


Jun 03, 2018, 02:45 am Last Edit: Jun 03, 2018, 02:47 am by gabe83
They need to be a variable. Its something like setting an integer at the begining called pulse lenght. Anothet called delay and another called second pulse lenght so it can be modified later
Or something like that?
Its not a fixed value. Each experiment might have settings
Lets start with maybe a 3000us pulse. Then a 2000us delay for the second pulse counting from the beginig of the first pulse. And the  second pulse is 20us wide

Its understandable?


Are these pulses supposed to be on two different output pins?



if you are looking for generation of pulses to microsecond accuracy have a look at the Arduino Due and the tc_lib library


Jun 05, 2018, 03:00 pm Last Edit: Jun 05, 2018, 03:00 pm by wvmarle
Regular Arduino using timer interrupts should be able to get microsecond accuracy. The ISR can be super short as it just has to set a PORT, total 10-20 instructions which is about 1 ┬Ás on a 16 MHz Arduino.

Do look at the port manipulation reference. The direct port manipulation is the easy part. The timing is the hard part.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.


Jun 05, 2018, 11:27 pm Last Edit: Jun 05, 2018, 11:27 pm by jremington
If you want fast interrupt response, you MUST avoid using attachInterrupt(), as described here.

Go Up