Jump to content
OMRON Forums

Using the value of an absolute encoder


maartenvervelde

Recommended Posts

Hi,

 

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].

 

Maarten

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

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].servoctrl=1
motor[0].phasectrl=0
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.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

×
×
  • Create New...