필터 지우기
필터 지우기

How can I use writePWMVoltage() in a matlab function ?

조회 수: 1 (최근 30일)
Anthony Auvergnon
Anthony Auvergnon 2017년 11월 2일
댓글: Anthony Auvergnon 2017년 11월 8일
Hello, I'm working on the simulation of a pressure sensor which return 0-5 V signal. So I use an arduino Mega to supply the analog signal. I succeded to simulate the sensor but when I try to set to zero my Ouput at the end of the programm it doesn't work : the voltage value decreases instantly then it increases gradually to a limit. It is very strange because when I execute my program directly in the command windows it works perfectly. I use the "writePWMVoltage()" function to create the analog signal which is read by an automaton M172 (SCHNEIDER ELECTRONIC).
Thank's for your help !
  댓글 수: 2
Madhu Govindarajan
Madhu Govindarajan 2017년 11월 3일
Could you post the critical portions of your function's code so that someone could see if you are doing something differently than intended because based on what you describe everything should work fine.
Anthony Auvergnon
Anthony Auvergnon 2017년 11월 8일
Here is my function :
function [V] = simulationP2()
clear a;
a=arduino('COM5','Mega2560');
configurePin(a,'D6','PWM');
for i=160:10:190
i=i
V=(i+52.503)/223.12;
writePWMVoltage(a,'D6',V);
pause(5);
if i==190
configurePin(a,'D6','DigitalOutput');
writeDigitalPin(a,'D6',0);
pause(5);
end
end
end
if true
% code
end
To be precise I use an M-duino PLC based on arduino Mega2560, it can supply 0-10V output versus 0-5V for arduino Mega2560. So I try this morning an arduino Mega2560 card and my function works, do you think that the problem is due to the m-duino ?
Thanks.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Arduino Hardware에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by