control dc motor speed

조회 수: 5 (최근 30일)
Tee
Tee 2011년 4월 6일
댓글: Nazrin Zaini 2014년 10월 22일
I have following code to control DC motor through H-Bridge and Arduino :
function motor_control2_OpeningFcn(hObject, eventdata, handles, varargin)
a = arduino('com3');
handles.a = a;
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to motor_control2 (see VARARGIN)
% Choose default command line output for motor_control2
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes motor_control2 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = motor_control2_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.a;
% --- Executes on button press in forwardpushbutton1.
function forwardpushbutton1_Callback(hObject, eventdata, handles)
handles.a.pinMode(9,'output');
handles.a.pinMode(10,'output');
handles.a.pinMode(3, OUTPUT);
handles.a.digitalWrite(9,0)
handles.a.digitalWrite(10,0)
handles.a.analogWrite(3,200) % control the speed 0- 255
Pin 3 is the enablepin which i can control the speed of motor.Now,i have a question, can i just adjust the speed using slider in GUI? How can i do that?I have the analog write value from 0 - 255 to adjust the speed, then i wish to adjust the speed when my motor move using slider. Any expert can help me?thanks
  댓글 수: 1
Nazrin Zaini
Nazrin Zaini 2014년 10월 22일
i want to ask the same question,so did you got the solution?if you dont mind can you share the solution.

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

답변 (1개)

Walter Roberson
Walter Roberson 2011년 4월 6일
I suggest you consult one of the earlier Questions

커뮤니티

더 많은 답변 보기:  Power Electronics Community

카테고리

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