Пример #1
0
int pwm_pulse_test( )
{
	int LoopCtrl;
	int trip_code=0;
	int command;
	double ref_in0;

	IER &= ~M_INT3;      // debug for PWM
	InitEPwm_ACIM_Inverter(); 	// debug
	EPwm1Regs.ETSEL.bit.INTEN = 1;    		            // Enable INT
	IER |= M_INT3;      // debug for PWM

	strncpy(MonitorMsg," INIT MOTOR RUN     ",20);

	LoopCtrl = 1;		
	test_pulse_count = 0;
	gMachineState = STATE_RUN;
 	EPwm_ISC_Enable();

	while(LoopCtrl == 1)
	{
		trip_code = trip_check();
		if( trip_code !=0 ){
			LoopCtrl = 0;
		}
		else if( test_pulse_count >= code_set_pulse_number){
			LoopCtrl = 0;
		}
		else{
			monitor_proc();
			get_command( & command, & ref_in0);	// Command를 입력 받음 
			if( command == CMD_STOP){
				gMachineState = STATE_READY;
				LoopCtrl = 0;
			}
		}						
	}

	EPwm_CONVT_Disable();
	LoopCtrl=1;
	while(LoopCtrl == 1)
	{
		trip_code = trip_check();
		if( trip_code !=0 ){
			LoopCtrl = 0;
		}
		else{
			monitor_proc();
			get_command( & command, & ref_in0);	// Command를 입력 받음 
			if( command != CMD_START){
				gMachineState = STATE_READY;
				LoopCtrl = 0;
			}
		}						
	}
	return trip_code;
}		
Пример #2
0
int test_run()
{
	int LoopCtrl;
	int iTripCode=0;

	int iCommand;
	double fReference;

//	common_variable_init();

	iTripCode = HardwareParameterVerification();
	if( iTripCode !=0 ) return iTripCode;

	iTripCode = SL_SPEED_CNTL_Parameter();        
	if( iTripCode != 0)
			return iTripCode;			// debug

	IER &= ~M_INT3;      // debug for PWM
	InitEPwm_ACIM_Inverter(); 	// debug
	EPwm1Regs.ETSEL.bit.INTEN = 1;    		            // Enable INT
	IER |= M_INT3;      // debug for PWM

	VariInit();

	gRunFlag =1;
	strncpy(MonitorMsg," INIT MOTOR RUN     ",20);
	gfRunTime = 0.0; 
	LoopCtrl = 1;		

	reference_in = code_btn_start_ref;
//	gMachineState = STATE_INIT_RUN;
	gMachineState = STATE_RUN;
	reference_out = 0.0;
	
	while(LoopCtrl == 1)
	{

		if(gPWMTripCode != 0){iTripCode = gPWMTripCode;	LoopCtrl = 0;}		
		iTripCode = trip_check();
		if(iTripCode != 0)	LoopCtrl = 0;		
		else{ 
			get_command(&iCommand,&fReference);	// Command를 입력 받음 				
			monitor_proc();

			if( iCommand == CMD_START) reference_in = fReference;
			else if( iCommand == CMD_STOP) reference_in = 0.0;
			switch( gMachineState )
			{
/*
			case STATE_INIT_RUN:
				// STOP 신호에는 즉각 반응을 해야 한다. 
				if( iCommand == CMD_STOP){
					LoopCtrl= 0; 
					// INVERTER_RUN_CLEAR;		// debug 브레이크 개방 
				}						
				else if( gfRunTime < 0.2 ){
					Freq_ref=0.0;	wr_ref=0.0;	rpm_ref=0.0;
					reference_out = 0.0;				
				}
				else{
					strncpy(MonitorMsg," INVERTER RUN       ",20);
					gMachineState = STATE_RUN;
				}
				break;
*/
			case STATE_RUN:
				if		 (  iCommand == CMD_NULL ) 			ramp_proc( reference_in, &reference_out);
				else if(( iCommand == CMD_SPEED_UP   ) && (reference_in <  1.0  )) reference_in += 0.01;
				else if(( iCommand == CMD_SPEED_DOWN ) && ( reference_in > 0.01 )) reference_in -= 0.01;
				else if(  iCommand == CMD_STOP ) { 
										  //"01234567890123456789"	
					strncpy(MonitorMsg," INV GO STOP        ",20);
					reference_in = 0.0; gMachineState = STATE_GO_STOP;
				}
				else if(  iCommand == CMD_START ) ramp_proc( reference_in, &reference_out);
				else{
					reference_in = 0.0; gMachineState = STATE_GO_STOP;
				}
				break;

			case STATE_GO_STOP:
	//---- 재 시동 
				if( iCommand == CMD_START ) {
										  //"01234567890123456789"	
					strncpy(MonitorMsg," INVERTER RUN       ",20);
					gMachineState = STATE_RUN;
					reference_in = fReference; 
				}				
				else if( fabs( reference_out ) < 0.01 ){
					strncpy(MonitorMsg," INVERTER READY     ",20);
					gMachineState = STATE_READY;
					LoopCtrl =0;
				}
				else{
					reference_in = 0.0;
					ramp_proc(reference_in, &reference_out);
				}
				break;
			}
		}
	}
	return iTripCode;
}
Пример #3
0
int hyd_unit_loop_proc()
{
	int LoopCtrl;
	int iTripCode=0;

	int cmd;
	double fReference;

	VariableInitialization();

	iTripCode = HardwareParameterVerification();
	if( iTripCode !=0 ) return iTripCode;

	iTripCode = SL_SPEED_CNTL_Parameter();        	// csk_debug
	if( iTripCode != 0)	return iTripCode;			// csk_debug

	IER &= ~M_INT3;      // debug for PWM
	InitEPwm_ACIM_Inverter(); 	// debug
	EPwm1Regs.ETSEL.bit.INTEN = 1;    		            // Enable INT
	IER |= M_INT3;      // debug for PWM

	gRunFlag =1;
	strncpy(MonitorMsg," INIT MOTOR RUN     ",20);
	gfRunTime = 0.0; 
	LoopCtrl = 1;		

	reference_in = btn_start_ref;
	gMachineState = STATE_RUN;
	
	while(LoopCtrl == 1)
	{
		if(gPWMTripCode != 0){
			iTripCode = gPWMTripCode;
			LoopCtrl = 0;
			break;
		}		
		get_command(& cmd ,&fReference);	// Command를 입력 받음 				
		monitor_proc();

		if( cmd == CMD_START) reference_in = fReference;
		else if( cmd == CMD_STOP) reference_in = 0.0;

		switch( gMachineState )
		{
		case STATE_RUN:
			if(  cmd == CMD_STOP ){
				strncpy(MonitorMsg," INV GO STOP        ",20);
				reference_in = 0.0; gMachineState = STATE_GO_STOP;
			}
			else{ 
//				if( gfRunTime < 0.25 )	reference_out = 0.05;	// debug
				// else hyd_unit_proc( gMachineState, & reference_out);
				hyd_unit_proc( gMachineState, & reference_out);
			}
		case STATE_GO_STOP:
//---- 재 시동 
			if( cmd == CMD_START ) {
									  //"01234567890123456789"	
				strncpy(MonitorMsg," INVERTER RUN       ",20);
				gMachineState = STATE_RUN;
				hyd_unit_proc( gMachineState, & reference_out);
			}				
			else if( fabs( reference_out ) < 0.005 ){
				strncpy(MonitorMsg," INVERTER READY     ",20);
				gMachineState = STATE_READY;
				LoopCtrl =0;
			}
			else{		// debug
				hyd_unit_proc(  gMachineState, & reference_out);
			}
			break;
		}
	}
	return iTripCode;
}
Пример #4
0
int test_run()
{
	int LoopCtrl;
	int iTripCode=0;

	int iCommand;
	double fReference;

	VariableInitialization();

	iTripCode = HardwareParameterVerification();
	if( iTripCode !=0 ) return iTripCode;

	iTripCode = SL_SPEED_CNTL_Parameter();        
	if( iTripCode != 0)
			return iTripCode;			// debug

	IER &= ~M_INT3;      // debug for PWM
	InitEPwm_ACIM_Inverter(); 	// debug
	EPwm1Regs.ETSEL.bit.INTEN = 1;    		            // Enable INT
	IER |= M_INT3;      // debug for PWM

	gRunFlag =1;
	strncpy(MonitorMsg," INIT MOTOR RUN     ",20);
	gfRunTime = 0.0; 
	LoopCtrl = 1;		

	reference_in = btn_start_ref;
	gMachineState = STATE_RUN;
	
	while(LoopCtrl == 1)
	{
		if(gPWMTripCode != 0){
			iTripCode = gPWMTripCode;
			LoopCtrl = 0;
			break;
		}		

		get_command(&iCommand,&fReference);	// Command를 입력 받음 				

		monitor_proc();

		if( iCommand == CMD_START) reference_in = fReference;
		else if( iCommand == CMD_STOP) reference_in = 0.0;

		switch( gMachineState )
		{
		case STATE_RUN:
			if		 (  iCommand == CMD_NULL ) 			ramp_proc( reference_in, &reference_out);
			else if(( iCommand == CMD_SPEED_UP   ) && (reference_in <  1.0  )) reference_in += 0.01;
			else if(( iCommand == CMD_SPEED_DOWN ) && ( reference_in > 0.01 )) reference_in -= 0.01;
			else if(  iCommand == CMD_STOP ) { 
									  //"01234567890123456789"	
				strncpy(MonitorMsg," INV GO STOP        ",20);
				reference_in = 0.0; gMachineState = STATE_GO_STOP;
			}
			else if(  iCommand == CMD_START ) ramp_proc( reference_in, &reference_out);
			else{
				reference_in = 0.0; gMachineState = STATE_GO_STOP;
			}
			break;

		case STATE_GO_STOP:
//---- 재 시동 
			if( iCommand == CMD_START ) {
									  //"01234567890123456789"	
				strncpy(MonitorMsg," INVERTER RUN       ",20);
				gMachineState = STATE_RUN;
				reference_in = fReference; 
			}				
			else if( fabs( reference_out ) < 0.01 ){
				strncpy(MonitorMsg," INVERTER READY     ",20);
				gMachineState = STATE_READY;
				LoopCtrl =0;
			}
			else{
				reference_in = 0.0;
				ramp_proc(reference_in, &reference_out);
			}
			break;
		}
	}
	return iTripCode;
}