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

📄 ssc32.m

📁 control SSC32 servo control
💻 M
📖 第 1 页 / 共 5 页
字号:
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit6_Callback(hObject, eventdata, handles)
% hObject    handle to edit6 (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 edit6 as text
%        str2double(get(hObject,'String')) returns contents of edit6 as a double
global A
str=get(hObject,'String');
max=str2num(str);
val=get(handles.slider3,'value');
if val>max
    set(handles.slider3,'value',max);
    set(handles.text10,'string',str);
end
set(handles.slider3,'max',max);
min=get(handles.slider3,'min');
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,2)=max;


% --- Executes during object creation, after setting all properties.
function edit6_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit6 (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 edit7_Callback(hObject, eventdata, handles)
% hObject    handle to edit7 (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 edit7 as text
%        str2double(get(hObject,'String')) returns contents of edit7 as a double
global A
snum=get(handles.uipanel6,'title');
num=str2num(snum(7:8));
op=str2num(get(handles.edit7,'string'));
min=str2num(get(handles.edit5,'string'));
max=str2num(get(handles.edit6,'string'));
if op<min
    set(handles.edit7,'string',num2str(min));
    p=min;
elseif op>max
    set(handles.edit7,'string',num2str(max));
    p=max;
else
    p=op;
end
A(num+1,5)=p;


% --- Executes during object creation, after setting all properties.
function edit7_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit7 (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 pushbutton7.
function pushbutton7_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton7 (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.edit7,'string'));
min=str2num(get(handles.edit5,'string'));
max=str2num(get(handles.edit6,'string'));
if op<min
    set(handles.text10,'string',num2str(min));
    set(handles.slider3,'value',min);
    set(handles.edit7,'string',num2str(min));
    p=min;
elseif op>max
    set(handles.text10,'string',num2str(max));
    set(handles.slider3,'value',max);
    set(handles.edit7,'string',num2str(max));
    p=max;
else
    set(handles.text10,'string',num2str(op));
    set(handles.slider3,'value',op);
    p=op;
end

snum=get(handles.uipanel6,'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 checkbox2.
function checkbox2_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox2 (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 checkbox2


% --- Executes on slider movement.
function slider5_Callback(hObject, eventdata, handles)
% hObject    handle to slider5 (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.text16,'string',num2str(p));

snum=get(handles.uipanel7,'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 slider5_CreateFcn(hObject, eventdata, handles)
% hObject    handle to slider5 (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 slider6_Callback(hObject, eventdata, handles)
% hObject    handle to slider6 (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.text17,'string',num2str(p));

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


% --- Executes during object creation, after setting all properties.
function slider6_CreateFcn(hObject, eventdata, handles)
% hObject    handle to slider6 (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 edit8_Callback(hObject, eventdata, handles)
% hObject    handle to edit8 (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 edit8 as text
%        str2double(get(hObject,'String')) returns contents of edit8 as a double
global A
str=get(hObject,'String');
min=str2num(str);
val=get(handles.slider5,'value');
if val<min
    set(handles.slider5,'value',min);
    set(handles.text16,'string',str);
end
set(handles.slider5,'min',min);
max=get(handles.slider5,'max');
step=get(handles.slider5,'sliderstep');
step(1)=1/(max-min);
set(handles.slider5,'sliderstep',step);

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


% --- Executes during object creation, after setting all properties.
function edit8_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit8 (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 edit9_Callback(hObject, eventdata, handles)
% hObject    handle to edit9 (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 edit9 as text
%        str2double(get(hObject,'String')) returns contents of edit9 as a double
global A
str=get(hObject,'String');
max=str2num(str);
val=get(handles.slider5,'value');
if val>max
    set(handles.slider5,'value',max);
    set(handles.text16,'string',str);
end
set(handles.slider5,'max',max);
min=get(handles.slider5,'min');
step=get(handles.slider5,'sliderstep');
step(1)=1/(max-min);
set(handles.slider5,'sliderstep',step);

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


% --- Executes during object creation, after setting all properties.
function edit9_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit9 (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 edit10_Callback(hObject, eventdata, handles)
% hObject    handle to edit10 (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 edit10 as text
%        str2double(get(hObject,'String')) returns contents of edit10 as a double
global A
snum=get(handles.uipanel7,'title');
num=str2num(snum(7:8));
op=str2num(get(handles.edit10,'string'));
min=str2num(get(handles.edit8,'string'));
max=str2num(get(handles.edit9,'string'));
if op<min
    set(handles.edit10,'string',num2str(min));
    p=min;
elseif op>max
    set(handles.edit10,'string',num2str(max));
    p=max;
else
    p=op;
end
A(num+1,5)=p;

% --- Executes during object creation, after setting all properties.
function edit10_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit10 (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 pushbutton8.
function pushbutton8_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton8 (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.edit10,'string'));
min=str2num(get(handles.edit8,'string'));
max=str2num(get(handles.edit9,'string'));
if op<min
    set(handles.text16,'string',num2str(min));
    set(handles.slider5,'value',min);
    set(handles.edit10,'string',num2str(min));
    p=min;
elseif op>max
    set(handles.text16,'string',num2str(max));
    set(handles.slider5,'value',max);
    set(handles.edit10,'string',num2str(max));
    p=max;
else
    set(handles.text16,'string',num2str(op));
    set(handles.slider5,'value',op);
    p=op;
end

snum=get(handles.uipanel7,'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 checkbox3.
function checkbox3_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox3 (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 checkbox3


% --- Executes on slider movement.
function slider7_Callback(hObject, eventdata, handles)
% hObject    handle to slider7 (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.text22,'string',num2str(p));

snum=get(handles.uipanel8,'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 slider7_CreateFcn(hObject, eventdata, handles)
% hObject    handle to slider7 (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 s

⌨️ 快捷键说明

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