Jump to content
OMRON Forums

Encoder Conversion table from Acc-28E


kmonroe023

Recommended Posts

I've got an application where I'm trying to slave a motor to an analog sensor connected to an ACC28E card. I'm processing the input from the ACC28E through the ECT. The input is 0-10V (0-3000microns), so I want an ECT output of 0-3000.

 

The data from the 28E card shows up in the PrevEnc Register in the high 16 bits as expected, so I set index2 to 16 to shift it all down to the lower 16 bits. Then I set the ScaleFactor to scale the output of the ECT in my user units (microns). All works great until the input from the 28E is greater than 32767, at which point the ECT output goes immediately negative.

 

I assumed that if I got the MSB out of bit 32 that it would no longer be used as a sign bit and the data from the 28E would show up in PrevEnc as an unsigned integer. However, as soon as bit 16 goes high in the PrevEnc register (with index2=16), the register still goes negative.

 

I'm missing something here. How can I take the 0-65535 counts raw data from the 28E and scale it to 0-3000 so I can use it to slave the motor.

 

//ECT setup

EncTable[25].type=1

EncTable[25].index1=0

EncTable[25].index2=16

EncTable[25].index3=0

EncTable[25].index4=0

EncTable[25].index5=0

EncTable[25].pEnc1=Sys.pushm

EncTable[25].pEnc=Acc28E[8].AdcUdata[0].a

EncTable[25].MaxDelta=0

EncTable[25].ScaleFactor=3000/65535;

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Regarding my OP.

 

I think I may have fixed this.

 

I used a double register read, type 2. Pointed pEnc2 at a shared user memory register that I will set to zero in a BgPLC. So I end up with the ADC data in bits 8 to 23, and the 'zeroed' data from shared memory in bits 24-32. Shift everything down 8 bits with index2=8 and voilà, unsigned integer result in PrevEnc.

 

I find it weird that the single register read with a 16-bit right shift didn't work though. Shouldn't the MSB of the original source data not cause the register to roll over once it's been shifted right?

Link to comment
Share on other sites

The ECT's "right shift" operation uses C's built-in right-shift operation, which "sign extends" the value as it shifts. That is, if the MSB of the source value is 0, all of the high bits of the right-shifted value will be 0; if the MSB of the source value is 1, all of the high bits will be 1.

 

By adding 8 high bits of 0 to your source data, you are ensuring that the right shifted value will have a 0 as its high bit, and so when interpreted as a signed value (which PrevEnc is) will report as positive.

 

If you are happy with your solution, by all means keep it. But it is not necessary to do this for successful use as a master.

 

Because the actual output of the ECT entry is the differential "DeltaPos" value, which will have the proper difference even when the source value "rolls over", and the master following function also handles rollover properly, you could use the standard method successfully. The way PrevEnc reports the value -- signed instead of unsigned -- is not relevant to the success of the operation.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

×
×
  • Create New...