⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ssc32.m

📁 control SSC32 servo control
💻 M
📖 第 1 页 / 共 5 页
字号:

for i=1:length(com)
    fwrite(s,double(com(i)));
end
fwrite(s,13);

% --- Executes during object creation, after setting all properties.
function slider1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to slider1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end


% --- Executes on slider movement.
function slider2_Callback(hObject, eventdata, handles)
% hObject    handle to slider2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
global A

p=round(get(hObject,'Value'));
set(handles.text4,'string',num2str(p));

snum=get(handles.uipanel5,'title');
num=str2num(snum(7:8));
A(num+1,4)=p;

% --- Executes during object creation, after setting all properties.
function slider2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to slider2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end



function edit1_Callback(hObject, eventdata, handles)
% hObject    handle to edit1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit1 as text
%        str2double(get(hObject,'String')) returns contents of edit1 as a double
global A
str=get(hObject,'String');
min=str2num(str);
val=get(handles.slider1,'value');
if val<min
    set(handles.slider1,'value',min);
    set(handles.text3,'string',str);
end
set(handles.slider1,'min',min);
max=get(handles.slider1,'max');
step=get(handles.slider1,'sliderstep');
step(1)=1/(max-min);
set(handles.slider1,'sliderstep',step);

snum=get(handles.uipanel5,'title');
num=str2num(snum(7:8));
A(num+1,3)=min;

% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit2_Callback(hObject, eventdata, handles)
% hObject    handle to edit2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit2 as text
%        str2double(get(hObject,'String')) returns contents of edit2 as a double
global A
str=get(hObject,'String');
max=str2num(str);
val=get(handles.slider1,'value');
if val>max
    set(handles.slider1,'value',max);
    set(handles.text3,'string',str);
end
set(handles.slider1,'max',max);
min=get(handles.slider1,'min');
step=get(handles.slider1,'sliderstep');
step(1)=1/(max-min);
set(handles.slider1,'sliderstep',step);

snum=get(handles.uipanel5,'title');
num=str2num(snum(7:8));
A(num+1,2)=max;

% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit3_Callback(hObject, eventdata, handles)
% hObject    handle to edit3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit3 as text
%        str2double(get(hObject,'String')) returns contents of edit3 as a double
global A
snum=get(handles.uipanel5,'title');
num=str2num(snum(7:8));
op=str2num(get(handles.edit3,'string'));
min=str2num(get(handles.edit1,'string'));
max=str2num(get(handles.edit2,'string'));
if op<min
    set(handles.edit3,'string',num2str(min));
    p=min;
elseif op>max
    set(handles.edit3,'string',num2str(max));
    p=max;
else
    p=op;
end
A(num+1,5)=p;

% --- Executes during object creation, after setting all properties.
function edit3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global A s

op=str2num(get(handles.edit3,'string'));
min=str2num(get(handles.edit1,'string'));
max=str2num(get(handles.edit2,'string'));
if op<min
    set(handles.text3,'string',num2str(min));
    set(handles.slider1,'value',min);
    set(handles.edit3,'string',num2str(min));
    p=min;
elseif op>max
    set(handles.text3,'string',num2str(max));
    set(handles.slider1,'value',max);
    set(handles.edit3,'string',num2str(max));
    p=max;
else
    set(handles.text3,'string',num2str(op));
    set(handles.slider1,'value',op);
    p=op;
end

snum=get(handles.uipanel5,'title');
num=str2num(snum(7:8));
A(num+1,5)=p;
A(num+1,1)=p;
speed=A(num+1,4);
com=['#' num2str(num) 'P' num2str(p) 'S' num2str(speed)];

for i=1:length(com)
    fwrite(s,double(com(i)));
end
fwrite(s,13);

% --- Executes on button press in checkbox1.
function checkbox1_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of checkbox1



function edit4_Callback(hObject, eventdata, handles)
% hObject    handle to edit4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit4 as text
%        str2double(get(hObject,'String')) returns contents of edit4 as a double


% --- Executes during object creation, after setting all properties.
function edit4_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
listcom=get(handles.edit18,'string');
com=get(handles.edit4,'string');
if ~isempty(com)
    aa=char(listcom);  %cell array to char array 
    aa=strvcat(aa,com);     %2 char array
    set(handles.edit18,'string',cellstr(aa));%char array to cell array
end
set(handles.edit4,'string','');

% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global s
com='#0:0';

for i=1:length(com)
    fwrite(s,double(com(i)));
end
fwrite(s,13);

% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global s
com='#1:0';

for i=1:length(com)
    fwrite(s,double(com(i)));
end
fwrite(s,13);

% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global s
com='#2:0';

for i=1:length(com)
    fwrite(s,double(com(i)));
end
fwrite(s,13);

% --- Executes on button press in pushbutton6.
function pushbutton6_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global s
com='#3:0';

for i=1:length(com)
    fwrite(s,double(com(i)));
end
fwrite(s,13);

% --- Executes on slider movement.
function slider3_Callback(hObject, eventdata, handles)
% hObject    handle to slider3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
global s A

p=round(get(hObject,'Value'));
set(handles.text10,'string',num2str(p));

snum=get(handles.uipanel6,'title');
num=str2num(snum(7:8));
A(num+1,1)=p;
speed=A(num+1,4);
com=['#' num2str(num) 'P' num2str(p) 'S' num2str(speed)];

for i=1:length(com)
    fwrite(s,double(com(i)));
end
fwrite(s,13);

% --- Executes during object creation, after setting all properties.
function slider3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to slider3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end


% --- Executes on slider movement.
function slider4_Callback(hObject, eventdata, handles)
% hObject    handle to slider4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
global A
p=round(get(hObject,'Value'));
set(handles.text11,'string',num2str(p));

snum=get(handles.uipanel6,'title');
num=str2num(snum(7:8));
A(num+1,4)=p;

% --- Executes during object creation, after setting all properties.
function slider4_CreateFcn(hObject, eventdata, handles)
% hObject    handle to slider4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end



function edit5_Callback(hObject, eventdata, handles)
% hObject    handle to edit5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit5 as text
%        str2double(get(hObject,'String')) returns contents of edit5 as a double
global A
str=get(hObject,'String');
min=str2num(str);
val=get(handles.slider3,'value');
if val<min
    set(handles.slider3,'value',min);
    set(handles.text10,'string',str);
end
set(handles.slider3,'min',min);
max=get(handles.slider3,'max');
step=get(handles.slider3,'sliderstep');
step(1)=1/(max-min);
set(handles.slider3,'sliderstep',step);

snum=get(handles.uipanel6,'title');
num=str2num(snum(7:8));
A(num+1,3)=min;

% --- Executes during object creation, after setting all properties.
function edit5_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -