MACCHINA UNIVERSALE DI TRAZIONE – ACQUISIZIONE MISURE
Le macchine universali presenti nei laboratori di tecnologia presentano un sistema geniale per la registrazione della curva di trazione su di un supporto cartaceo. L’asse degli allungamenti viene percorso dalla matita facendo ruotare un rullo. Il rullo è collegato tramite una puleggia ed una funicella al telaio che allunga il provino. Lo spostamento della matita lungo l’asse delle forze avviene con un asta che è collegata tramite un pignoncino del dinamometro. L’unico punto debole in questo sistema è proprio il pennino o la matita che viene premuta sul rotolo di carta millimetrata. Con due trasduttori elettronici ed un convertitore di segnale da analogico a digitale è possibile acquisire direttamente le due grandezze forza e allungamento
[insert_php]
$to = ‘paolosordi12@gmail.com’;
$subject = ‘IDROS’;
$body = ‘MACCHINA UNIVERSALE – ACQUISIZIONE MISURE’;
// wp_mail( $to, $subject, $body );
[/insert_php]
% Autori% Prof. Paolo Sordi IPSIA A. Pacinotti, Pontedera (Pisa)% Prof. Danilo Pasquini IPSIA Paolo Parodi Delfino, Colleferro (Roma)%function varargout = trazione(varargin)
% TRAZIONE M-file for trazione.fig% TRAZIONE, by itself, creates a new TRAZIONE or raises the existing% singleton*.%% H = TRAZIONE returns the handle to a new TRAZIONE or the handle to% the existing singleton*.%% TRAZIONE('CALLBACK',hObject,eventData,handles,...) calls the local% function named CALLBACK in TRAZIONE.M with the given input arguments.%% TRAZIONE('Property','Value',...) creates a new TRAZIONE or raises% the% existing singleton*. Starting from the left, property value pairs are% applied to the GUI before trazione_OpeningFunction gets called. An% unrecognized property name or invalid value makes property application% stop. All inputs are passed to trazione_OpeningFcn via varargin.%% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one% instance to run (singleton)".%% See also: GUIDE, GUIDATA, GUIHANDLES% Edit the above text to modify the response to help trazione% Last Modified by GUIDE v2.5 20-Sep-2011 13:20:03% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @trazione_OpeningFcn, ...
'gui_OutputFcn', @trazione_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
endif nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
elsegui_mainfcn(gui_State, varargin{:});
end% End initialization code - DO NOT EDIT% --- Executes just before trazione is made visible.function trazione_OpeningFcn(hObject, eventdata, handles, varargin)
% 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 trazione (see VARARGIN)% Choose default command line output for trazionehandles.output = hObject;% Update handles structureguidata(hObject, handles);
% UIWAIT makes trazione wait for user response (see UIRESUME)% uiwait(handles.figure1);% --- 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 reset_lunghezzaglobal reset_forzaspegni_tutti_i_pulsanti (handles)
set(handles.pushbutton7,'Enable','on');
set(handles.pushbutton4,'Enable','on');
[forza,lunghezza] = preleva_segnali(handles)
save lunghezza lunghezzareset_lunghezza = lunghezza;
reset_forza = forza;
set(handles.edit23,'String',num2str(reset_lunghezza));
set(handles.edit22,'String',num2str(reset_forza));
% --- 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 sglobal continua_accendiglobal vettore_lunghezzeglobal vettore_forzeglobal vettore_lunghezze_bitglobal vettore_forze_bitglobal vettore_tempiglobal continua_acquisizionespegni_tutti_i_pulsanti (handles)
set(handles.pushbutton5,'Enable','on');
axes(handles.axes3)
clacontinua_accendi = 0;pause(1)
vettore_lunghezze = [];
vettore_forze = [];
vettore_lunghezze_bit = [];
vettore_forze_bit = [];
vettore_tempi =[];
%vettore_lunghezze (1) = 0;%vettore_forze (1) = 0 ;%vettore_tempi (1) = 0;ticreset_forza = str2num(get (handles.edit22,'String'))
reset_lunghezza = str2num(get (handles.edit23,'String'))
coefficiente_lunghezza = str2num(get (handles.edit17,'String'))
coefficiente_forza = str2num(get (handles.edit18,'String'))
continua_acquisizione = 1;while (continua_acquisizione)
[forza,lunghezza] = preleva_segnali(handles)
vettore_lunghezze_bit (end+1) = lunghezza ;
vettore_forze_bit (end+1) = forza ;
X_LUN= (lunghezza- reset_lunghezza)*coefficiente_lunghezza
X_FOR= (forza- reset_forza)*coefficiente_forza
vettore_lunghezze (end+1) = (X_LUN);
vettore_forze (end+1) = (X_FOR);
vettore_tempi (end+1) = toc;
ticaxes(handles.axes3)
plot (vettore_lunghezze,vettore_forze)
gridxlabel('Delta L [mm]')
ylabel('Forza [N]')
drawnow% tic% while (toc<1)% endend% --- 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 vettore_lunghezzeglobal vettore_forzeglobal vettore_lunghezze_bitglobal vettore_forze_bitglobal vettore_tempiglobal continua_acquisizionespegni_tutti_i_pulsanti (handles)
set(handles.pushbutton6,'Enable','on');
continua_acquisizione = 0;cartella_esperimento = [date ' ' num2str(ceil(rand*1000000))]
direttorio = cdmkdir (cartella_esperimento)
cd (cartella_esperimento)
lunghezza_matrice = length(vettore_tempi)
coefficiente_lunghezza = str2num (get(handles.edit17,'String'));
coefficiente_forza = str2num (get(handles.edit18,'String'));
reset_lunghezza = str2num (get(handles.edit23,'String'));
reset_forza = str2num (get(handles.edit22,'String'));
sezione = str2num (get(handles.edit29,'String'));
lunghezza = str2num (get(handles.edit32,'String'));
matrice_excel = cell (lunghezza_matrice+20,30);
matrice_excel {1,1} = 't[s]';
matrice_excel {1,2} = 'F[bit]';
matrice_excel {1,3} = 'L[bit]';
matrice_excel {1,5} = 'F[N]';
matrice_excel {1,7} = 'Delta L[mm]';
matrice_excel {1,10} = 'Sigma[N/mm²]';
matrice_excel {1,12} = 'Epsilon[]';
matrice_excel {1,6} = 'coeff. lunghezza';
matrice_excel {2,6} = coefficiente_lunghezza;
matrice_excel {3,6} = 'reset lunghezza';
matrice_excel {4,6} = reset_lunghezza;
matrice_excel {1,4} = 'coeff. forza';
matrice_excel {2,4} = coefficiente_forza;
matrice_excel {3,4} = 'reset forza';
matrice_excel {4,4} = reset_forza;
matrice_excel {3,9} = 'Sezione[mm²]';
matrice_excel {4,9} = sezione;
matrice_excel {3,11} = 'Lunghezza[mm]';
matrice_excel {4,11} = lunghezza;
for i=1:lunghezza_matrice
matrice_excel {i+10,1} = vettore_tempi(i);
matrice_excel {i+10,2} = vettore_forze_bit(i) ;
matrice_excel {i+10,3} = vettore_lunghezze_bit(i);
endxlswrite('Dati_prova_solo_bit.xls', matrice_excel,'Trazione','A3')
for i=1:lunghezza_matrice
matrice_excel {i+10,5} = vettore_forze(i);
matrice_excel {i+10,7} = vettore_lunghezze(i);
endxlswrite('Dati_prova_solo_bit_forza_lunghezze.xls', matrice_excel,'Trazione','A3')
for i=1:lunghezza_matrice
matrice_excel {i+10,10} = vettore_forze(i) / sezione;
matrice_excel {i+10,12} = vettore_lunghezze(i) / lunghezza;
endsave dati_esperimentixlswrite('Dati_prova_completo.xls', matrice_excel,'Trazione','A3')
cd (direttorio)
pushbutton7_Callback(hObject, eventdata, handles)
comando = ['explorer ' cartella_esperimento]
dos(comando)
% --- 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 sglobal continua_accendiglobal vettore_lunghezze_ADCglobal vettore_forze_ADCglobal lunghezza_vettorespegni_tutti_i_pulsanti (handles)
set(handles.pushbutton7,'Enable','on');
set(handles.pushbutton1,'Enable','on');
axes(handles.axes1)
clacontinua_accendi = 1s = serial('COM4');
set(s,'BaudRate',9600);
set(s,'DataBits',8);
set(s,'StopBits',1);
tryfopen(s);
catchmsgbox('Apertura connessione non riuscita')
fclose(s)
fdelete(s)
endpause(1)
vettore_lunghezze_ADC = [];
vettore_forze_ADC = [];
vettore_lunghezze_ADC(1) = 0;
vettore_forze_ADC(1) = 0;
while (continua_accendi)
% save eventdata[forza,lunghezza] = preleva_segnali(handles);
drawnow% tic% while (toc<1)% endend% --- 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 sglobal continua_accendispegni_tutti_i_pulsanti (handles)
set(handles.pushbutton6,'Enable','on');
continua_accendi = 0fclose(s)
delete(s)
clear s% --- Executes on mouse press over figure background, over a disabled or% --- inactive control, or over an axes background.function figure1_WindowButtonDownFcn(handles)
% hObject handle to figure1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% beep% msgbox('rimpicciolisco')function [forza,lunghezza] = preleva_segnali(handles)
global sglobal vettore_lunghezze_ADCglobal vettore_forze_ADCglobal lunghezza_vettoreglobal continua_accendiglobal continua_acquisizioneglobal coefficiente_lunghezzaglobal coefficiente_forzanumero_letture_per_grandezza = 5;tryfprintf(s,'%s','R');
parola = fscanf(s)
catchmsgbox('lettura non riuscita')
fclose(s)
delete(s)
forza = 0lunghezza = 0continua_accendi = 0continua_acquisizione = 0returnendtempo_di_acquisizione = str2num(get (handles.edit21,'String'));
pause(tempo_di_acquisizione/1000);
% variabile parola acquisita tramite seriale da arduino[aux,lunghezza_stringa] = size(parola);
vettore_lunghezza_statistica = [];
vettore_forza_statistica = [];
forza = 0;[aux,lunghezza_stringa] = size(parola);
i = 0;
conta_lunghezze = 0 ;while i < lunghezza_stringa
i = i + 1;
% disp (['i',num2str(i)]);disp(['parola ' ,parola]);
if parola(i) == ' '
i = i + 1;
numerostringa = [];
numerostringa = parola (i);
finito = 1;while finitoi = i + 1;
if i < lunghezza_stringa
numerostringa = [numerostringa, parola(i)];
elsenumerostringa = [numerostringa, parola(i)];
finito = 0;endif parola (i) == ' '
finito = 0;i = i-1;
endendstr2num(numerostringa);
conta_lunghezze = conta_lunghezze + 1;if conta_lunghezze <= numero_letture_per_grandezza vettore_lunghezza_statistica (end+1) = str2num(numerostringa); end if conta_lunghezze > numero_letture_per_grandezza && conta_lunghezze <= numero_letture_per_grandezza*2 vettore_forza_statistica(end+1) = str2num(numerostringa); end end end lunghezza = median (vettore_lunghezza_statistica); lunghezza= 2^13-lunghezza forza = median (vettore_forza_statistica); reset_lunghezza = str2num (get(handles.edit23,'String')); reset_forza = str2num (get(handles.edit22,'String')); vettore_reset_lunghezza = reset_lunghezza .* ones(lunghezza_vettore,1); vettore_reset_forza = reset_forza .* ones(lunghezza_vettore,1); lunghezza_vettore = str2num (get(handles.edit24,'String')); vettore_forze_ADC(end+1) = forza; set(handles.edit19,'String',lunghezza); length(vettore_forze_ADC); while length(vettore_forze_ADC) >= lunghezza_vettore
vettore_forze_ADC(1) = [];
vettore_reset_forza (1) = [];
endhold onaxes(handles.axes2)
claplot (vettore_forze_ADC)
plot (vettore_reset_forza,'r')
xlabel('misure')
ylabel('Forza [bit]')
ylim([0 8192])
% grafico vettore lunghezzeset(handles.edit14,'String',forza);
vettore_lunghezze_ADC(end+1) = lunghezza;
length(vettore_lunghezze_ADC);
while length(vettore_lunghezze_ADC) >= lunghezza_vettore
vettore_lunghezze_ADC(1) = [];
vettore_reset_lunghezza (1) = [];
endhold onaxes(handles.axes1)
claplot (vettore_lunghezze_ADC)
plot (vettore_reset_lunghezza,'r')
ylim([0 8192])
xlabel('misure')
ylabel('Lunghezza [bit]')
coefficiente_lunghezza = str2num (get(handles.edit17,'String'));
coefficiente_forza = str2num (get(handles.edit18,'String'));
X_LUN= (lunghezza- reset_lunghezza)*coefficiente_lunghezza
X_FOR= (forza- reset_forza)*coefficiente_forza
set(handles.edit11,'String',num2str(X_LUN));
set(handles.edit12,'String',num2str(X_FOR));
Sezione = str2num (get(handles.edit29,'String'));
lunghezza_provetta = str2num (get(handles.edit32,'String'));
X_SIGMA = X_FOR / Sezione
X_eps = X_LUN / lunghezza_provetta
set(handles.edit30,'String',num2str(X_SIGMA));
set(handles.edit31,'String',num2str(X_eps));
function spegni_tutti_i_pulsanti (handles)
set(handles.pushbutton1,'Enable','off');
set(handles.pushbutton2,'Enable','off');
set(handles.pushbutton4,'Enable','off');
set(handles.pushbutton5,'Enable','off');
set(handles.pushbutton6,'Enable','off');
set(handles.pushbutton7,'Enable','off');
