Sweet! got a replay with sample code (matlab maybe) and specs on the communication protocol. Guess Dave's video kicked them in the ass. The reply also said they were going to show the factory Dave's review in April when they visit them... We'll see I guess.
Funny, the guy suggest I buy the ATM8811 single out put unit. Would have bought a rigol unit if I was going to spend that much on a single. Beside I already own this unit.
Anyone looking to purchase this unit in the US or Canada Newark has it re-branded as a tenma 72-8795.
function interface_parts = Atten_controller_interface()
%% connect to the device
Atten_conn = serial('COM1','DataBits',8);
interface_parts.Atten_conn = Atten_conn;
fopen(Atten_conn);
interface_parts.is_connected = true;
interface_parts.do_shutdown = false;
%% create GUI
%GUI window
interface_parts.figure = figure('Position',[100,100,800,600], 'CloseRequestFcn', @Atten_disconnect);
%Create plot for values
interface_parts.data_plot = axes('Units','pixels', 'Position', [100 150 600 400]);
%buttons to toggle the device on/off and to exit
interface_parts.output_btn = uicontrol('Style','togglebutton', 'String','output','Position',[350,10,100,50]);
interface_parts.exit_btn = uicontrol('Style','togglebutton', 'String','exit','Position',[475,10,100,50], 'Callback', @Atten_disconnect);
%labels and text boxes for the user to input desired V and i values
interface_parts.V_label = uicontrol('Style','text', 'String','V','Position',[150,10,50,20]);
interface_parts.V_field = uicontrol('Style','edit', 'String','0','Position',[200,10,50,20]);
interface_parts.i_label = uicontrol('Style','text', 'String','i','Position',[150,40,50,20]);
interface_parts.i_field = uicontrol('Style','edit', 'String','0','Position',[200,40,50,20]);
%% Initialise the hex vector
interface_parts.control_vector = ['AA'; '20'; '00'; '00'; '00'; '00'; '00'; '00'; '00'; '00'; '00'; '00'; '00'; '00'; '01'; '00'; '01'; '00'; '00'; '00'; '00'; '00'; '00'; '68'];
interface_parts.default_vec = interface_parts.control_vector;
vals = []; % Initialise the array for measured values
tic; % Start timer
%% keeping going until the user exits
while(true && interface_parts.is_connected)
Atten_apply_vector(1,2); % set device
[input_dec,count,msg] = fread(Atten_conn,24,'uint8'); %read status
%convert and store results
V_val = hex2dec([dec2hex(input_dec(3)) dec2hex(input_dec(4))]) / 100;
i_val = hex2dec([dec2hex(input_dec(5)) dec2hex(input_dec(6))]) / 1000;
vals = [vals; toc V_val i_val];
%show the results
[AX,H1,H2] = plotyy(vals(:,1), vals(:,2), vals(:,1), vals(:,3));
xlabel('time [s]');
set(get(AX(1),'Ylabel'),'String','Potential [V]');
set(get(AX(2),'Ylabel'),'String','Current [A]');
pause(0.05);
end
function Atten_apply_vector(hObject, eventdata)
%note that matlab uses an indexing system starting from 1, whereas
%the protocol pdf assumes an indexing system starting from 0
%process the voltage value chosen by user
V_val = str2num(get(interface_parts.V_field, 'String'));
V_dec = round(V_val * 100);
V_hex = dec2hex(V_dec, 4);
interface_parts.control_vector(3,:) = V_hex(1:2); interface_parts.control_vector(4,:) = V_hex(3:4);
%process the current value chosen by user
i_val = str2num(get(interface_parts.i_field, 'String'));
i_dec = round(i_val * 1000);
i_hex = dec2hex(i_dec, 4);
interface_parts.control_vector(5,:) = i_hex(1:2); interface_parts.control_vector(6,:) = i_hex(3:4);
%update output state
interface_parts.control_vector(16,:) = dec2hex(get(interface_parts.output_btn, 'Value'));
%send suitable vector to the device
if(interface_parts.do_shutdown) %set the device back to the default state before disconnecting
interface_parts.store_control_vector = interface_parts.control_vector;
interface_parts.control_vector = interface_parts.default_vec;
end
output_dec = hex2dec(interface_parts.control_vector);
fwrite(Atten_conn,output_dec,'uint8');
end
function Atten_disconnect(a,b)
if(interface_parts.is_connected)
%shutdown system
interface_parts.do_shutdown = true;
Atten_apply_vector(a,b);
%close connection
fclose(Atten_conn);
delete(Atten_conn);
clear Atten_conn;
display('disconnecting from device');
interface_parts.is_connected = false;
else
display('disconnecting... not connected to device');
end
delete(interface_parts.figure);
end
end