How to produce a pulse for 10Microseconds?

10 visualizzazioni (ultimi 30 giorni)
kintali narendra
kintali narendra il 12 Feb 2017
Commentato: Walter Roberson il 22 Feb 2017
I am programming my Arduino from matlab(I installed supporting package), in order to use Ultrasonic sensor I need to produce a trigger pulse for 10microseconds(from matlab) and I also need to read the time in microseconds. please tell me how to produce a delay of 10us or produce a constant value for 10us. I am using matlab2014b.
I need to produce the pulse in Yellow from matlab and read the pulse in Red in Matlab. Both are in microseconds thank you

Risposte (1)

Walter Roberson
Walter Roberson il 21 Feb 2017
Technical notes:
Looking at:
Arduino code would look something like
digitalWrite(13, HIGH);
delayMicroseconds(10);
digitalWrite(13, LOW);
where the 13 would have to be adjusted to the appropriate pin number.
The MATLAB interface to digitalWrite is writeDigitalPin: https://www.mathworks.com/help/supportpkg/arduinoio/ref/writedigitalpin.html
The difficulty with using this is the timing: there is no way in MATLAB to pause for less than 1/1000 of a second (and you cannot even do that well on MS Windows.) If you could pause for that short of a period, the time required to send the new data to arduino would add a lot of uncertainty.
It would therefore be better to program the 10 microsecond pulse on the arduino side.
With regards to the TTL signal: is the idea that you get a response by reading the voltage? If so then it becomes important to know the minimum and maximum voltages. Or does "range in proportion" refer to time?
  2 Commenti
kintali narendra
kintali narendra il 22 Feb 2017
Sir, I wont be reading voltage, I need to read, for HOW much time the pulse is HIGH ?, In arduino we have a inbuilt command called PULSEIN. Can you please suggest any equivalent command to that in MATLAB.
Walter Roberson
Walter Roberson il 22 Feb 2017
I would not attempt to trigger a PULSEIN from the MATLAB level: your timing is too strict.
Always keep in mind: your MATLAB session might get suspended for an unknown number of hours while your PC does virus checking, or fetches email, or updates a "Push" page in the web browser you left open, and so on. MS Windows is not a real-time operating system and MATLAB itself does not try to be a real-time program.

Accedi per commentare.

Categorie

Scopri di più su MATLAB Support Package for Arduino Hardware in Help Center e File Exchange

Prodotti

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by