How to produce a pulse for 10Microseconds?

8 次查看(过去 30 天)
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

回答(1 个)

Walter Roberson
Walter Roberson 2017-2-21
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 个评论
kintali narendra
kintali narendra 2017-2-22
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 2017-2-22
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 MATLAB Support Package for Arduino Hardware 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by