Read external encoder with X20DC1176

Hello,
I need to know how I could read the velocity of external encoder with X20DC1176, then this velocity will be the master for ACOPOS 1090 and will control tension web of winder.

Best Regards

Hello Fausto,

the module only provides a counter value, but no speed. You have to calculate the current speed of the encoder in your application. For example, you create a task in a 1 second task class and save the current position in a variable each time the task is called. You can then simply subtract the variable value from the current counter reading and multiply it by 60, then you have the increments per minute. If your encoder has 2000 pulses per revolution, for example, then you have to divide the measured pulses per minute by 2000 to get the revolutions per minute.

Gruß
Stephan

Hello Stephan,
Thanks for the repply, for this case what will be the function or function block for read or save the actual position of X20DC1176, what input of module I will must use for read the actual position? I have the next inputs:

  • Encoder01
  • Encoder01 Time Valid
  • Encoder01TimeChanged
  • Encoder01Latch
  • Encoder01LatchCount
  • Encoder01_A
  • Encoder01_B

Best Regards

Hello Fausto,

here is a small example:


VAR
Speed : REAL;
LastCounterValue : DINT;
Counter : DINT;
EncoderResolution : REAL;
IncrementsPerMin : DINT;
END_VAR

PROGRAM _INIT

EncoderResolution	:= 2000;

END_PROGRAM

PROGRAM _CYCLIC

IncrementsPerMin	:= (Counter - LastCounterValue) * 60;
IF EncoderResolution > 0 THEN
	Speed	:= DINT_TO_REAL(IncrementsPerMin) / EncoderResolution;
ELSE
	Speed	:= 0;
END_IF
LastCounterValue	:= Counter;

END_PROGRAM

Regards

3 Likes