control dc motor speed

4 次查看(过去 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 Control

类别

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