Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using the value of an absolute encoder

I'm trying to change the encoders of my motor while running my system.
Changing the encoder works now with the following code:

pshm->Motor[1].pEnc = (void *) ((int)(&pshm->EncTable[41]) - (OffsetSHM << 2));
pshm->Motor[1].pEnc2 = (void *) ((int)(&pshm->EncTable[41]) - (OffsetSHM << 2));

But the problem is that the abolute encoder continues on the value the incremental encoder left it. So if the encoders are changed when the incremental encoder is at position 1000, the absolute encoder will register the position between 500 and 1500. I want to use the value that the encoder directly gives.

When I try to change the position to the position of motor[0] (because that has the same encoder to check where it should be) like this:

pshm->Motor[1].Pos = pshm->Motor[0].ActPos;

i get a following error. What would be the correct way to change the position of the motor to the position of motor[0].

I do not understand your question. Do you just need to update the absolute encoder? This can be done with an HMZ command online, or HOMEZ in a program.
What I want is to use the analog sensor data with the same offset as preferably motor[0], or the same offset everytime I use it. This is not possible now because Motor[1] uses the position it had before changing the encoders as an offset for the analog encoder.

In pp_startup.txt this happens.

EncTable[41].type = 1
EncTable[41].pEnc = PowerBrick[0].Chan[0].AdcAmp[2].a
EncTable[41].pEnc1 = PowerBrick[0].Chan[0].AdcAmp[2].a
EncTable[41].Index1 = 64
EncTable[41].Index2 = 166
EncTable[41].Index4 = 2
EncTable[41].ScaleFactor = 1/2097152

motor[0].penc = encTable[41].a
motor[0].penc2 = encTable[41].a

This makes sure that the the encoder is set up properly and that it is being used by motor[0]. I use Motor[0].ActPos to calculate some things and when I change the encoder, I would like to use the same values for Motor[1].

What would help is the possibility to just use the analog value the encoder returns and work with that, or a way to change the current position.

I tried the hmz approach and that might be usefull, but the problem I have with that, is that the value in the position window changes, but the value of Motor[1].ActPos doesn't. This results in not being able to use the sensor because I use the Motor[1].ActPos value to calculate the movements.
If the position in the position window is right, you can use it for calculations directly. The formula for it is as follows:

Motor[x].NetPos = Motor[x].ActPos - Motor[x].HomePos - Motor[x].MasterPos*((Motor[x].MasterCtrl & 2) >> 1)

NetPos does not exist in PPMAC inherently, but you can compute it in a program/online.

Forum Jump:

Users browsing this thread: 1 Guest(s)