Results 1 to 2 of 2

Thread: Assign cylinder stroke value from transducer to variables

  1. #1
    Join Date
    Jun 2016
    Location
    IA
    Posts
    16

    Default Assign cylinder stroke value from transducer to variables

    I'm trying to walk through a project file and understand how the calibration portion has been configured. We are using the CR0401 controller and CR0451 display. In short, the operator will run through the setup section of the project and set the minimum and maximum spinner speeds per the hydraulic output available. This portion of the project is working correctly - when the user sets the minimum and maximum output, the values are stored correctly.

    The second portion of the setup requires the operator to set the minimum and maximum stroke of the hydraulic cylinder. The operator is presented the data received from the transducer, and I believe when the cylinder is at its minimum stroke and they select "save", that value should be stored and assigned to the "wMinCylinderStroke" variable. Same thing applies to the maximum stroke section.

    The issue I am having is that the wMinCylinderStroke and wMaxCylinderStroke values never appear to be stored. These values look to be used then for the cylinder output. Essentially, if the operator wanted to the cylinder at the center stroke, it should take the difference between the min and max and divide by two (at least that is how the original creator set it up.)

    Can someone point me in the right direction for capturing and assigning these values correctly? As I stated in my previous post, I am very green with all of this and trying to work through everything with little to no experience.

    If there is a better way to accomplish this I am open to suggestions as well.

    The ultimate goal of the project is a simplified user interface for an operator to spread material. By selecting either left, center, or right lane, the cylinder should move to the correct position based on the available stroke configured during the initial setup. Code of the cylinder calibration section is below.

    Code:
    ELSIF(iSetupSection = 1 AND  iSubsection = 3) THEN (*Cylinder Stroke Minimum - Discharge Right Side*)
    	xHideRunModeIcon := FALSE;
    	IF(xSectionInit)THEN
    		strSubSectionTitle := '';
    		uiNewValue := wMinCylinderStroke;
    		xSectionInit := FALSE;
    		xHideCurrentReading := FALSE;
    	END_IF
    	strSectionTitle := 'Cylinder Calibration - Min';
    	strSubSectionTitle := 'Press left until cylinder recessed';
    	strCurrentReadingTitle := 'Cylinder Stroke Sensor';
    	wCurrentReading := DWORD_TO_WORD(wCylinderActualStroke);
    	uiCurrentValue := wMinCylinderStroke;
    	strCurrentValue := UINT_TO_STRING(uiCurrentValue);
    	strNewValue := UINT_TO_STRING(uiNewValue);
    	xMoveLeft := FALSE;
    	
    	IF(RT_F1) THEN (*Cancel*)
    		iSubSection := 2;
    		iSetupSection := 1;
    		uiCurrentValue := 0;
    		uiNewValue := 0;
    		xInRunMode := FALSE;
    		wSpinnerOutput := 0;
    		xSectionInit := TRUE;
    		strCurrentValue := '';
    		strNewValue := '';
    	ELSIF(RT_F4) THEN(*Save*)
    			wMinCylinderStroke := uiNewValue;
    			iSubSection := 4;
    			iSetupSection := 1;
    			uiCurrentValue := 0;
    			uiNewValue := 0;
    			xInRunMode := FALSE;
    			wSpinnerOutput := 0;
    			xSectionInit := TRUE;
    			strCurrentValue := '';
    			strNewValue := '';
    			wCylinderStrokeRight := wMinCylinderStroke;
    	ELSIF(KEY_LEFT) THEN
    		xMoveLeft := TRUE;
    	ELSIF(RT_OK) THEN
    		xInRunMode := NOT(xInRunMode);
    	END_IF
    
    ELSIF(iSetupSection = 1 AND  iSubsection = 4) THEN (*Cylinder Stroke Maximum - Discharge Left Side*)
    	xHideRunModeIcon := FALSE;
    	IF(xSectionInit)THEN
    		uiNewValue := wMaxCylinderStroke;
    		strSubSectionTitle := '';
    		xSectionInit := FALSE;
    		xHideCurrentReading := FALSE;
    	END_IF
    	strCurrentReadingTitle := 'Cylinder Stroke Sensor';
    	wCurrentReading := DWORD_TO_WORD(wCylinderActualStroke);
    	strSectionTitle := 'Cylinder Calibration - Max';
    	strSubSectionTitle := 'Press right until cylinder extended';
    	uiCurrentValue := wMaxCylinderStroke;
    	strCurrentValue := UINT_TO_STRING(uiCurrentValue);
    	strNewValue := UINT_TO_STRING(uiNewValue);
    	
    	xMoveRight :=FALSE;
    	IF(RT_F1) THEN (*Cancel*)
    		iSubSection := 3;
    		iSetupSection := 1;
    		uiCurrentValue := 0;
    		uiNewValue := 0;
    		xInRunMode := FALSE;
    		wSpinnerOutput := 0;
    		xSectionInit := TRUE;
    		strCurrentValue := '';
    		strNewValue := '';
    
    	ELSIF(RT_F4) THEN(*Save*)
    			wMaxCylinderStroke := uiNewValue;
    			iSubSection := 0;
    			iSetupSection := 0;
    			uiCurrentValue := 0;
    			uiNewValue := 0;
    			xInRunMode := FALSE;
    			wSpinnerOutput := 0;
    			xSectionInit := TRUE;
    			strCurrentValue := '';
    			strNewValue := '';
    			strCurrentReadingTitle := '';
    			wCurrentReading := 0;
    			wCylinderStrokeLeft := wMaxCylinderStroke;
    			wCylinderStrokeCenter := (wCylinderStrokeLeft - wCylinderStrokeRight) / 2;
    
    	ELSIF(KEY_RIGHT) THEN
    		xMoveRight := TRUE;
    	ELSIF(RT_OK) THEN
    		xInRunMode := NOT(xInRunMode);
    	END_IF

    EDIT: Here are some screenshots of the calibration dialog for a better understanding of the variables. When looking at the spinner calibration, the values presented are the spinner RPM from the sensor and then PWM output. This allows the operator to set the max output given the hydraulic capabilities of the truck.

    The cylinder operates off of the same valve with spools for actuating left and right.






    I looked through the output configuration on the controller and it appears that he tried to configure the cylinder output similar to the PWM output of the spinner but was unable to get it working. Is this where the issue resides?

    Code:
    PROGRAM OutputControl
    VAR
    	SpinnerPWM: PWM1000;
    (*	ChuteLeftPWM: PWM1000;
    	ChuteRightPWM: PWM1000; *)
    	outChuteLeft: OUTPUT;
    	outChuteRight: OUTPUT;
    END_VAR
    Code:
    	(*Spinner output - value received from display - range 0-1000 *)
    SpinnerPWM(
    	ENABLE:= (xInRunMode AND NOT(xCommError)),
    	CHANNEL:= 7,
    	FREQUENCY:= 250,
    	VALUE:= wSpinnerOutput,
    	DITHER_FREQUENCY:= ,
    	DITHER_VALUE:= ,
    	CURRENT=> ,
    	RESULT=> );
    
    (*Output to move chute to the left *)
    OUT04 := (NOT(xCommError) AND xInRunMode AND xMoveLeft);
    (*
    outChuteLeft(
    	ENABLE:= (xInRunMode AND xMoveLeft),
    	CHANNEL:= 4,
    	VALUE:= xMoveLeft,
    	MODE:= 2,
    	FILTER:= 0,
    	OUTPUT=> ,
    	CURRENT=> ,
    	RESULT=> );
    *)
    
    (*Output to move chute to the right *)
    OUT05 := (NOT(xCommError) AND xInRunMode AND xMoveRight);
    
    
    (*
    outChuteRight(
    	ENABLE:= (xInRunMode AND xMoveRight),
    	CHANNEL:= 5,
    	VALUE:= xMoveLeft,
    	MODE:= 2,
    	FILTER:= 0,
    	OUTPUT=> ,
    	CURRENT=> ,
    	RESULT=> );
    *)
    Last edited by rbenesch; 06-22-2016 at 09:31 AM. Reason: Additional information

  2. #2
    Join Date
    May 2009
    Location
    Minneapolis, MN
    Posts
    299

    Default

    Are wMinCylinderStroke and wMaxCylinderStroke declared as RETAIN variables?

    For the outputs, it looks like they were setup the first time as PWM, then commented out and just ran as Digital outputs.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •