Example #1
0
void InitPID(void){

	BYTE i;
	//WORD loop;
	for (i=0;i<NUM_PID_GROUPS;i++){
		//DyPID values
		dyPid[i].inputChannel=DYPID_NON_USED;
		dyPid[i].outputChannel=DYPID_NON_USED;
		dyPid[i].inputMode=0;
		dyPid[i].outputMode=0;

		pidGroups[i].Enabled=FALSE;
		pidGroups[i].channel = i;
		vel[i].enabled=FALSE;
		vel[i].K.P=.1;
		limits[i].type=NO_LIMIT;

		LoadPIDvals(&pidGroups[i],&dyPid[i]);
		if(		dyPid[i].inputChannel==DYPID_NON_USED ||
				dyPid[i].outputChannel==DYPID_NON_USED  ||
				dyPid[i].outputChannel==dyPid[i].inputChannel)
		{
			dyPid[i].inputChannel=DYPID_NON_USED;
			dyPid[i].outputChannel=DYPID_NON_USED;
			WritePIDvalues(&pidGroups[i],&dyPid[i]);
		}
		force[i].MsTime=0;
		force[i].setPoint=200;
	}

	InitilizePidController( pidGroups,
							vel,
							NUM_PID_GROUPS,
							&getPositionMine,
							&setOutputMine,
							&resetPositionMine,
							//&asyncCallback,
							&onPidConfigureMine,
							&checkPIDLimitEventsMine);

	for (i=0;i<NUM_PID_GROUPS;i++){
		printPIDvals(i);
		if(pidGroups[i].Enabled){
			initPIDChans(i);
			println_I("Resetting PID channel from init");
			int value = 0;
			if(dyPid[i].inputMode == IS_ANALOG_IN)
				value = 512;
			pidReset(i,value);
		}
	}

}
Example #2
0
void InitPID(void){
	//println_I("Starting PID initialization ");
	uint8_t i;
	//uint16_t loop;
	for (i=0;i<NUM_PID_GROUPS;i++){
		//DyPID values
		dyPid[i].inputChannel=DYPID_NON_USED;
		dyPid[i].outputChannel=DYPID_NON_USED;
		dyPid[i].inputMode=0;
		dyPid[i].outputMode=0;
		dyPid[i].flagValueSync=false;

                pidGroups[i].config.tipsScale=1.0;
                pidGroups[i].config.Enabled = false;
                pidGroups[i].config.Async = 1;
                pidGroups[i].config.IndexLatchValue = 0;
                pidGroups[i].config.stopOnIndex = 0;
                pidGroups[i].config.useIndexLatch = 0;
                pidGroups[i].config.K.P = .1;
                pidGroups[i].config.K.I = 0;
                pidGroups[i].config.K.D = 0;
                pidGroups[i].config.V.P = .1;
                pidGroups[i].config.V.D = 0;
                pidGroups[i].config.Polarity = 0;
                pidGroups[i].config.stop = 0;
                pidGroups[i].config.upperHistoresis = 0;
                pidGroups[i].config.lowerHistoresis = 0;
                pidGroups[i].config.offset = 0.0;
                pidGroups[i].config.calibrationState = CALIBRARTION_DONE;
                pidGroups[i].interpolate.set=0;
                pidGroups[i].interpolate.setTime=0;
                pidGroups[i].interpolate.start=0;
                pidGroups[i].interpolate.startTime=0;

		limits[i].type=NO_LIMIT;

		LoadPIDvals(&pidGroups[i],&dyPid[i],i);
		if(		dyPid[i].inputChannel==DYPID_NON_USED ||
				dyPid[i].outputChannel==DYPID_NON_USED  ||
				dyPid[i].outputChannel==dyPid[i].inputChannel||
				pidGroups[i].config.Enabled !=true)
		{
			dyPid[i].inputChannel=DYPID_NON_USED;
			dyPid[i].outputChannel=DYPID_NON_USED;
			pidGroups[i].config.Enabled = false;
			WritePIDvalues(&pidGroups[i],&dyPid[i],i);
		}
		force[i].MsTime=0;
		force[i].setPoint=200;
	}

	InitilizePidController( pidGroups,
                                NUM_PID_GROUPS,
                                &getPositionMine,
                                &setOutputMine,
                                &resetPositionMine,
                                &onPidConfigureMine,
                                &checkPIDLimitEventsMine);

	for (i=0;i<NUM_PID_GROUPS;i++){
		//
		if(pidGroups[i].config.Enabled){
			println_W("PID ");p_int_W(i);
			printPIDvals(i);
			initPIDChans(i);

			int value = getPositionMine(i);
            pidGroups[i].CurrentState=value;
			pidReset(i,value);
		}
	}

}