Commits

Jinyang Liu committed 2c698e3 Draft

Upgrade from Rev1.2 to Rev1.3 which has super fast mode. Please see what is changed in Rev1.3 for details.

Comments (0)

Files changed (11)

Matlab Codes/IO_tools/choose_functions.m

 
 function button_add_function_Callback(hObject, eventdata, handles)
 % --- Executes on button press in button_add_function.
-load('Pcontol_paths.mat');
+load('Pcontrol_paths.mat');
 cd(function_path)
 [FileName,PathName] = uigetfile('*function*.mat','Select a FUNCTION file');
 % returns a 0 if cancel is pressed

Matlab Codes/IO_tools/choose_pats.fig

Binary file modified.

Matlab Codes/IO_tools/make_function_image.m

 num_functions = length(file_list);
 Header_block = zeros(1, block_size);
 SD.numfunc = num_functions;
-
+FUNCTION_LENGTH = 100;  % this is the buffer read size in panel controller
+OFFSET = 0;
 %clean the temp folder
 load('Pcontrol_paths.mat');
 %dos(['del /Q ' temp_path '\*.fun']); %SS
 dos(['del /Q "' temp_path '\*.fun"']); %SS
 pos_func_counter = 0;
+
 vel_func_counter = 0;
 
 for j = 1:num_functions
-    load([file_list(j).PathName '\' file_list(j).FileName]);
+    load([file_list(j).PathName file_list(j).FileName]);
     
     Header_block(1:4) = dec2char(length(func)*2, 4);     %each function datum is stored in two bytes in the SD card
     Header_block(5) = length(file_list(j).FileName);
     % set up SD structure with function info
     SD.functionName{j} = file_list(j).FileName;
     SD.functionSize{j} = length(func)*2; 
+%     num_blocks_needed(j) = ceil(SD.functionSize{j}/FUNCTION_LENGTH);
+%     last_load_data(j) = mod(SD.functionSize{j},FUNCTION_LENGTH);
+%     padded_function_Data = zeros(1, num_blocks_needed(j)*block_size);
+    
     %each function datum is stored in two bytes in the SD card
-    
     if strncmp(file_list(j).FileName, 'function', 8)
         vel_func_counter = vel_func_counter + 1;
         switch length(num2str(vel_func_counter))
         end
         SD.posFunctionName{pos_func_counter} = file_list(j).FileName;
         function_Data = signed_16Bit_to_char(func);     
-        
+    
     else
         disp('The function name %s is incorrect\n',file_list(j).FileName);
     end
-    
+    %now we add 100 byte OFFSET to speed up the sd card reading spead
+    % now write all of the frame info
+%     if last_load_data(j) == 0
+%         for i = 1:num_blocks_needed(j)
+%             sd_start_address = (i - 1)*block_size + OFFSET + 1;
+%             sd_end_address = sd_start_address + FUNCTION_LENGTH - 1;
+%             % always forced to start frame at a block boundary
+%             func_start_address = (i - 1)* FUNCTION_LENGTH + 1;
+%             func_end_address = func_start_address + FUNCTION_LENGTH - 1;
+%             padded_function_Data(sd_start_address:sd_end_address) = function_Data(func_start_address:func_end_address);
+%         end
+%         
+%     else
+%         for i = 1:num_blocks_needed(j)-1
+%             sd_start_address = (i - 1)*block_size + OFFSET + 1;
+%             sd_end_address = sd_start_address + FUNCTION_LENGTH - 1;
+%             % always forced to start frame at a block boundary
+%             func_start_address = (i - 1)* FUNCTION_LENGTH + 1;
+%             func_end_address = func_start_address + FUNCTION_LENGTH - 1;
+%             padded_function_Data(sd_start_address:sd_end_address) = function_Data(func_start_address:func_end_address);
+%         end
+%         
+%         sd_start_address = (num_blocks_needed(j) - 1)*block_size + OFFSET + 1;
+%         sd_end_address = sd_start_address + last_load_data(j) - 1;
+%         % always forced to start frame at a block boundary
+%         func_start_address = (num_blocks_needed(j) - 1)* FUNCTION_LENGTH + 1;
+%         func_end_address = func_start_address + last_load_data(j) - 1;
+%         padded_function_Data(sd_start_address:sd_end_address) = function_Data(func_start_address:func_end_address);
+%     end
+        
     Data_to_write = [Header_block function_Data]; 
     fid = fopen([temp_path '\' funcFileName] , 'w');
     fwrite(fid, Data_to_write(:),'uchar');

Matlab Codes/arena_config/arena.cfg

Binary file modified.

Matlab Codes/controller/PControl.fig

Binary file modified.

Matlab Codes/controller/PControl.m

 currentState.pattName = 'default';
 
 
-
-
 % --- Executes when user attempts to close figure1.
 function figure1_CloseRequestFcn(hObject, eventdata, handles)
 %close the serial port connection
 
 % --- Executes on slider movement.
 function x_gain_slider_Callback(hObject, eventdata, handles)
-handles.PC.x_gain_val = round(get(hObject,'Value')*10)/10;   % this is done so only one dec place
+handles.PC.x_gain_val = round(get(hObject,'Value')*100)/10;   % this is done so only one dec place
 set(handles.x_gain_val, 'String', [num2str(handles.PC.x_gain_val) ' X']);
 guidata(hObject, handles);
 %send command to controller
 
 % --- Executes on slider movement.
 function x_offset_slider_Callback(hObject, eventdata, handles)
-handles.PC.x_offset_val = round(get(hObject,'Value')*10)/10;
+handles.PC.x_offset_val = round(get(hObject,'Value')*200)/10;
 set(handles.x_offset_val, 'String', [num2str(handles.PC.x_offset_val) ' V']);
 guidata(hObject, handles);
 %send command to controller
 % --- Executes on slider movement.
 function y_gain_slider_Callback(hObject, eventdata, handles)
 
-handles.PC.y_gain_val = round(get(hObject,'Value')*10)/10;
+handles.PC.y_gain_val = round(get(hObject,'Value')*100)/10;
 set(handles.y_gain_val, 'String', [num2str(handles.PC.y_gain_val) ' X']);
 guidata(hObject, handles);
 %send command to controller
 
 % --- Executes on slider movement.
 function y_offset_slider_Callback(hObject, eventdata, handles)
-handles.PC.y_offset_val = round(get(hObject,'Value')*10)/10;
+handles.PC.y_offset_val = round(get(hObject,'Value')*200)/10;
 set(handles.y_offset_val, 'String', [num2str(handles.PC.y_offset_val) ' V']);
 guidata(hObject, handles);
 %send command to controller
 function Send_Gain_Bias(handles)
 % this function sends out the new gain and bias values to the controller
 Panel_com('stop')
-gain_x = round(100*handles.PC.x_gain_val/(handles.PC.x_gain_max));
-gain_y = round(100*handles.PC.y_gain_val/(handles.PC.y_gain_max));
-bias_x = round(100*handles.PC.x_offset_val/(handles.PC.x_offset_max));
-bias_y = round(100*handles.PC.y_offset_val/(handles.PC.y_offset_max));
+gain_x = round(10*handles.PC.x_gain_val/(handles.PC.x_gain_max));
+gain_y = round(10*handles.PC.y_gain_val/(handles.PC.y_gain_max));
+bias_x = round(5*handles.PC.x_offset_val/(handles.PC.x_offset_max));
+bias_y = round(5*handles.PC.y_offset_val/(handles.PC.y_offset_max));
 Panel_com('send_gain_bias', [gain_x, bias_x, gain_y, bias_y]);
 update_status_display(['Sending: gain_x = ' num2str(gain_x) ', bias_x = ' num2str(bias_x) ...
     ', gain_y = ' num2str(gain_y) ', bias_y = ' num2str(bias_y)]);
 
 % --------------------------------------------------------------------
 function menu_set_Pat_ID_Callback(hObject, eventdata, handles)
-global currentState newString SD;
+global currentState SD;
 
 if SD.pattern.num_patterns ~=0
     setPattern;

Matlab Codes/controller/Panel_com.m

         send_serial( char([2 2 argument(1)]));
         
     case 'set_pattern_id'
-        if ((~isequal(length(argument),1))||(~isnumeric(argument))||(argument(1) >99)||(argument(1) <= 0))
-            error('Pattern ID command requires 1 numerical argument that is between 1 and 99');
+        if ((~isequal(length(argument),1))||(~isnumeric(argument))||(argument(1) >255)||(argument(1) <= 0))
+            error('Pattern ID command requires 1 numerical argument that is between 1 and 255');
         end
         % panel ID:  0x03, Panel_ID
         send_serial( char([2 3 argument(1)]));
         end
         
         send_serial( char([2 hex2dec('10') argument(1)]));
-       
+        
+    case 'load_pattern_2panels' 
+        global SD;
+        if ((~isequal(length(argument),1))||(~isnumeric(argument))||(argument(1) >99)||(argument(1) <= 0))
+            error('Pattern ID command requires 1 numerical argument that is between 1 and 99');
+        end
+        % panel ID:  0x03, Panel_ID
+        bytesPerFramePerPanel = SD.pattern.frame_size(argument(1))/SD.pattern.num_panels(argument(1));
+        bytesPerPatternPerPanel = bytesPerFramePerPanel*SD.pattern.x_num(argument(1))*SD.pattern.y_num(argument(1));
+        
+        if bytesPerPatternPerPanel <= 800
+            send_serial( char([2 hex2dec('11') argument(1)]));
+        else
+            error('The size of pattern %d is bigger than 800 bytes, it cannot be loaded to the panels. Please use set_pattern_id instead.', argument(1));
+        end
 %     case 'set_max_adc23'
 %         
 %         if ((~isequal(length(argument),1))||(~isnumeric(argument))||(argument(1) >10)||(argument(1) <= 0))
         send_serial( char([3 hex2dec('20') argument(1) argument(2)]));
         
     case 'set_funcx_freq'
-        if (~isequal(length(argument),1)||(~isnumeric(argument))||(argument(1) > 500)||(argument(1) < 0))
-            error('function X update rate requires 1 argument that is a number between 0 and 500');
+        if (~isequal(length(argument),1)||(~isnumeric(argument))||(argument(1) > 2000)||(argument(1) < 0))
+            error('function X update rate requires 1 argument that is a number between 0 and 2000');
         end
         
         send_serial( char([3 hex2dec('25') dec2char(argument(1),2)]));
         
     case 'set_funcy_freq'
-        if (~isequal(length(argument),1)||(~isnumeric(argument))||(argument(1) > 500)||(argument(1) < 0))
-            error('function Y update rate requires 1 argument that is a number between 0 and 500');
+        if (~isequal(length(argument),1)||(~isnumeric(argument))||(argument(1) > 2000)||(argument(1) < 0))
+            error('function Y update rate requires 1 argument that is a number between 0 and 2000');
         end
         
         send_serial( char([3 hex2dec('30') dec2char(argument(1),2)]));
         %subtract -1 from each argument
         % beacause in matlab use 1 as start index, and controller uses 0
         send_serial([5 hex2dec('70') dec2char(argument(1)-1,2) dec2char(argument(2)-1,2)]);
-        
+
+% nine byte commands:
     case 'send_gain_bias'
-        % 5 bytes to set gain and bias values: 0x71, then 1 byte each for gain_x, bias_x, gain_y, bias_y
+        % 9 bytes to set gain and bias values: 0x01, then 2 byte each for gain_x, bias_x, gain_y, bias_y
         if (~isequal(length(argument),4)||(~isnumeric(argument)))
             error('gain & bias setting command requires 4 numerical arguments');
         end
         %Note: these are all signed arguments, so we need to convert to 2's complement if necessary
-        send_serial( [5 hex2dec('71') signed_byte_to_char(argument)]);
-        
+        send_serial( [9 hex2dec('01') signed_16Bit_to_char(argument(1)), signed_16Bit_to_char(argument(2)), signed_16Bit_to_char(argument(3)), signed_16Bit_to_char(argument(4))]);
+
+        %send_serial([5 hex2dec('71') signed_byte_to_char(argument)]);
         %compress the 1000 0/1 laser pattern into a 125 bytes data
         %Panel_com('send_laser_pattern',pattern);
         %argument pattern is a binary vector with length from 1 to 1000.

Matlab Codes/controller/SD.mat

Binary file modified.

Matlab Codes/controller/setPattern.fig

Binary file modified.

Matlab Codes/controller/setPattern.m

 
 % Edit the above text to modify the response to help setAPattern
 
-% Last Modified by GUIDE v2.5 28-May-2010 15:38:59
+% Last Modified by GUIDE v2.5 24-Jul-2012 11:14:44
 % Begin initialization code - DO NOT EDIT
 gui_Singleton = 1;
 gui_State = struct('gui_Name',       mfilename, ...
 % hObject    handle to setAPattern (see GCBO)
 % eventdata  reserved - to be defined in a future version of MATLAB
 % handles    structure with handles and user data (see GUIDATA)
+
+
+% --- Executes on button press in loadPattern2Panels.
+function loadPattern2Panels_Callback(hObject, eventdata, handles)
+% hObject    handle to loadPattern2Panels (see GCBO)
+% eventdata  reserved - to be defined in a future version of MATLAB
+% handles    structure with handles and user data (see GUIDATA)
+global currentState SD;
+if SD.pattern.num_patterns ~=0
+    currentState.chosePat =1;
+    currentState.closeSetPat = 1;
+    pattID = currentState.pattID;
+    Panel_com('load_pattern_2panels', [pattID]);
+    close(gcf);
+end

Matlab Codes/controller/update_status_display.m

     
     temp_cell_array = get(handles.status_display, 'String');
     
+    disp(new_string);
     for i = 1:rowNum
         if (i == 1)
             temp_cell_array{end+1} = [' > ' new_string];