control dc motor speed

4 visualizaciones (últimos 30 días)
Tee
Tee el 6 de Abr. de 2011
Comentada: Nazrin Zaini el 22 de Oct. de 2014
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 comentario
Nazrin Zaini
Nazrin Zaini el 22 de Oct. de 2014
i want to ask the same question,so did you got the solution?if you dont mind can you share the solution.

Iniciar sesión para comentar.

Respuestas (1)

Walter Roberson
Walter Roberson el 6 de Abr. de 2011
I suggest you consult one of the earlier Questions

Comunidades de usuarios

Más respuestas en  Power Electronics Control

Categorías

Más información sobre Arduino Hardware en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by