Below is a simplified code snippet that is driving me
crazy. Any help would be greatly appreciated.
1. The last line keeps throwing an error saying [pointer
expected].
I'm trying to set the persist value it points to to the
new value from the first structure's element
axis[0].rawEncPosition. I know that there is a valid
value as it prints fine, but why is it not allowing me to
assign it to the pointer's memory loc? Maybe I'm missing
something obvious...
2. I've somewhat remedied this second issue, but why
can't I assign values to a position in an array by using a
variable? For instance:
float normalizeScalar[6] =
{xyPitch,xyPitch,zPitch,zPitch,rotPitch,rotPitch};
Where all of the parameters were defined just above it?
Fails because all are variables. I know if I #define
them to be constants it works, but that seems rather odd.
Any ideas?
Thanks in advance!
int *x1Pos = &persist.UserData[101]; // x1 location
input
typedef struct {
int
rawEncPosition; //raw
encoder position value
float
measuredPos; //encoder
postion converted to mm or degrees
float
degrees; //rotation
normalized for coordinate system neg-0-pos
float
coordPos; //linear
normalized for coordinate system neg-0-pos
}AXIS;
AXIS axis[6];
float steps = 800;
float xyPitch = (.25 * 25.4)/steps;
float zPtich = (1.0 * 25.4)/steps;
float rotPitch = (1/20);
float normalizeScalar[6] =
{xyPitch,xyPitch,zPitch,zPitch,rotPitch,rotPitch};
float coordZero[6] =
{xCoordZero,yCoordZero,zCoordZero,zCoordZero,xRotCoordZero,yRotCoordZero};
void ready_axes(void)
{
int
i;
for(i=0;
i<6; i++)
{
axis[i].rawEncPosition
= chan[i].Position; //store raw encoder values
printf("Raw
Encoder: %i\n",axis[i].rawEncPosition);
//<<<<<<<<<<<<PRINTS
EXPECTED VALUE
axis[i].measuredPos
= axis[i].rawEncPosition * normalizeScalar[i]; //convert
encoder position to mm
axis[i].degrees
= axis[i].measuredPos - coordZero[i];
axis[i].coordPos
= axis[i].degrees;
}
}
*x1Pos = axis[0].rawEncPosition;