PID support function, next code part, ref'd code used here.

by

 
The code in the message I am responding to was used as a function call from this following piece of code. In this following piece of code, you can see my attempts to deal with a motor whose response in the system had been characterized several times. When the interpolation function was started, I did a quality check (see RMS as quality check) and took the best value I could. Some of this is the stuff that John was talking about when he said that the PID function is not everything, that many support functions must also be programmed. This is a partial attempt to help supply one type of support function.

/******************************************************************************
ScaleTorchMotor

Description:
This function takes the input, in inches per minute,
and scales it to counts per second. The counts are counts from the leading
edge, but the time needed is time from the trailing edge. This edge is
unknown, but is more then 15K counts away from the leading edge.
So maximum inches per minute is zero counts, and zero inches per minute
is maximum counts. Actually maximum counts may not be enough, so we will
add more counts in a later function.

This function also addresses the problem of the nonlinear counts to
voltage to rpm to ipm functions. Currently it assumes that the transfer
function between two points on the curve is linear, and only deals with
the curve inside those two points. So it changes slope and intercept points.
This part of the function is different for the Slave and the Torch motors.

Parameters:
*scaled pointer to the value that is to be scaled.

Globals:
MAXTIME should be changed to maxtimed sometime, but right now Maxtimed.

Returns: None

Assumptions:
This assumes that the motor to motor variations are mininmal,
that the curve's intercept point and slope is both know and correct.

//While motor control is a timer/interrupt function that times a off time and fires a phase angle dependent SCR, the basic idea can be incorporated with modification into any controler.


Real/Protected Mode: Protected mode only

******************************************************************************/
void ScaleTorchMotor(INT32U *scaled)
{
if ( MINTIME <= *scaled )
{
// input scale is to be 0-10k, output is 1000 to about 4000 (no load)
// only leading digits are needed, divide can be rough
#ifdef oldnormal
*scaled = ((*scaled * 4) / 10) + 1000;
*scaled = (*scaled * (MAXTIME)) / 10000L;
#else
// *scaled = ((*scaled * 74) / 100) + 1000; //max available scale .1 to .85
// *scaled = ((*scaled * 55) / 100) + 1000; //max useful scale .1 to .65
*scaled = Interpolate( *scaled, TachIPM2Time,
TachIPMresult, TachIPMMax);
*scaled = (*scaled * (MAXTIME)) / 10000L;
#endif
// subtract to find last
if (*scaled < MAXTIME)
{
*scaled = MAXTIME - *scaled;
}
else
{
*scaled = 0; // fire immediately
}
}
else
{
*scaled = MAXEDTIME; // never fire
}
}




Posted on Jul 19, 2000, 12:14 PM

Respond to this message

Goto Forum Home

Find more forums on Science and TechnologyCreate your own forum at Network54
 Copyright © 1999-2009 Network54. All rights reserved.   Terms of Use   Privacy Statement