From: In Soo Kim on
I'm looking to move a piezoelectric scanner by applying voltages using analog outputs on an NI DAQ PCI-6259. I've been having trouble getting the script I've created to work, and I'm not really sure why it's not working. I think it's something fundamental that I'm missing, but any help would be much appreciated.

The problem seems to start at the movement push button callbacks (when I ask to read in values from the text box there is an error with the 'handles' command which I don't understand).

%Callbacks for the text boxes which store a value inputted by the user
%as a double
function edit1_Callback(hObject, eventdata, handles)
input1 = str2double(get(hObject,'String'));
if (isempty(input1))
set(hObject,'String','0')
end
guidata(hObject, handles);
end

%Push button callbacks which read in values from their respective text
%boxes to determine how much voltage to apply to the given analogoutput
function xmove_Callback(hObject, eventdata)
%This particular part of the function a=get(handles.hedit,
%'String'). It worked in other programs but something seems to be
%wrong here.
a=get(handles.hedit1, 'String');
val1=str2double(a);
for x=1:10
putdata(ao, [0 0 0 val1]);
end
start(ao);
wait(ao, 30);
stop(ao);
guidata(hObject, handles);
end

The other issue is when I tell the voltages to be put to the instrument, it only does this once, despite being placed in a loop that should do this multiple times with varying values.

Any help would be much appreciated.

Thanks,

Kyle J