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
댓글 수: 0
답변 (1개)
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
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.
I see https://www.mathworks.com/matlabcentral/answers/33710-how-to-replicate-an-arduino-timer-function-in-matlab showing code you can use on the Arduino side.
참고 항목
카테고리
Help Center 및 File 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!