encoder simulator

vitviggs

Member
Join Date
Aug 2021
Location
roma
Posts
3
Hi, does anyone know how to write an encoder simulator program in ST? The point is that I have an axis(Elau MC4) which rotates using a multipoint cam function and following the speed of a physical master encoder. I want to be able to rotate this axis without the masteer encoder active(rotating), So I am thinking to write a pulse generator with frequency variable which to replace the physical encoder



Thanks if you have any idea
 
The answer to the query in Post #1 is yes.


The first questions I can think of to pass back to the OP are

  • Is this a homework problem?
  • What frequency(-ies) of pulses is(are) desired?
    • Is the frequency constant?
    • What is the duty cycle of the pulses?
  • What PLC is running the ST program?
    • Does that PLC run scans frequently enough to do this?
    • More specifically, how accurately do the frequency and duty cycle have to meet the specifications for this to work?
  • What device will be used to make the pulses physical?
    • Does that device run fast enough to do this?
  • Does it have to be ST in a PLC
    • E.g. could this be done more easily with a 555 timer circuit or some other alternative?
    • Or is it that the PLC is what is available?
 
Hi, Thanks for the answer, it is not a homework, it is a real situation in the plant which I am facing. There is a machine which takes containers at input, applies labels and they are going out. Customer wants to bypass the machine and to pass the containers through without labeling and he wants to stop the machine letting only the conveyor and the wormscrew running. The problem is that the wormscrew is an axis which rotates from the machine physically master encoder with multipoint cam function but if the machine will stop then the wormscrew will stop. I try to figure out how to have the wormscrew axis rotating without physically encoder(while the machine carousel is stopped).

Not necessary in ST.
 
I programmed a complete machine simulator which included incremental encoder outputs. Those were done using the Motion Control facilities in the PLC, particularly the PTO (pulse train output) function. The Motion Control even has options for using two outputs to give A/B phase shifted outputs as you get with some incremental encoders. PLC was/is the Siemens S7-1200.
 
As ever with TIA Portal, Siemens made it complicated to try to make it simple, so just seeing my program would probably raise more questions than it answers. Searching for 'siemens s7-1200 PTO' finds various videos on how to set up the PTO. As for controlling the speed you can just enter how many pulses per second you want on an input to the Velocity function block.
 
The answer to the query in Post #1 is yes.


The first questions I can think of to pass back to the OP are

  • Is this a homework problem?
  • What frequency(-ies) of pulses is(are) desired?
    • Is the frequency constant?
    • What is the duty cycle of the pulses?
  • What PLC is running the ST program?
    • Does that PLC run scans frequently enough to do this?
    • More specifically, how accurately do the frequency and duty cycle have to meet the specifications for this to work?
  • What device will be used to make the pulses physical?
    • Does that device run fast enough to do this?
  • Does it have to be ST in a PLC
    • E.g. could this be done more easily with a 555 timer circuit or some other alternative?
    • Or is it that the PLC is what is available?
The OP didn't answer your very good questions.


I have done something like this only I was generating pulses for a stepper motor but the differences are small. It is doubtful a PLC can do this on its own. I think the best chance is to obtain a stepper motor controller that can also generate quadrature encoder outputs.
 
[Update:

P.S. PTO is better choice, per @BryanG, if PLC has PTO

P.P.S. https://www.google.com/search?q=555+timer+pulse+generator&tbm=isch&sa=X&biw=1865&bih=865
]

Code:
 VAR
  la_ton : TON;
  not_q : BOOL;
  acc_dint : DINT;
  virtual_master_encoder : BOOL;
END_VAR

la_ton(IN:=not_q,PRE:=t#128ms);  [COLOR=blue][B] (* Timer at ~8Hz *)[/B][/COLOR]
not_q := NOT la_ton.Q;            [COLOR=blue][B](* Make timer repeat *)[/B][/COLOR]

[COLOR=Blue][B](* [/B][/COLOR][COLOR=Blue][B][COLOR=blue][B]Generate [/B][/COLOR]~8Hz signal at 50% duty cycle: *)[/B][/COLOR]
 virtual_master_encoder := (TIME_TO_DINT(la_ton.ACC) AND 64) > 0;

[B][COLOR=blue](* OR, if ST syntax implementation allows, *)
[/COLOR][/B]virtual_master_encoder := TIME_TO_DINT(la_ton.ACC).6;[B][COLOR=blue]

(* OR *)[/COLOR][/B]

 virtual_master_encoder := TIME_TO_DINT(la_ton.ACC) > 63;

[COLOR=blue][B](* OR Generate ~8Hz signal at 25% duty cycle *)[/B][/COLOR]
virtual_master_encoder := TIME_TO_DINT(la_ton.ACC) > 31;

[COLOR=blue][B](* OR Generate ~16Hz signal at 50% duty cycle *)[/B][/COLOR]
 virtual_master_encoder := (TIME_TO_DINT(la_ton.ACC) AND 32) > 0;

[COLOR=blue][B](* OR, if ST syntax implementation allows,  *)[/B][/COLOR]
virtual_master_encoder := TIME_TO_DINT(la_ton.ACC).5;
 
Last edited:
@BryanG, that is pretty good. How does it manage ramping up or ramping down? Are there functions for that? If so, the S7-1200 is suitable for stepper motor control.


@drbitboy, hopefully the OP is using a PLC with a PTO function that maintains a 90 degree difference between the A and B phases even while changing rates/speeds.
 
Simplest Mitsubishi iQF PLChas 4 PTO 200KHz outputs, with built in commands for simple linear interpolation (2 axis simultaneous start). In your country it costs little bit less than 400 Eur.
 
@drbitboy, hopefully the OP is using a PLC with a PTO function that maintains a 90 degree difference between the A and B phases even while changing rates/speeds.


Oooh right, OP did not mention quadrature, but that would make it more complicated. But only slightly: use two adjacent bits instead of one, along with XOR, AND, etc., to define encoder signals.
 
Apologies to the OP, am slightly hijacking the thread. In answer to Ken questions, as ever I learned enough to do the stuff I needed and didn't worry about the rest. Attached are some more of the setting screens that show Acceleration/Deceleration and Homing. I think they answer the question.

Motion Control Dynamics.JPG Motion Control Homing 1.JPG Motion Control Homing 2.JPG
 

Similar Topics

Hello guys, I’m looking for a solution how to simulate 2 phase encoder in GX Works2. In the real world when the encoder is connected to the PLC...
Replies
2
Views
1,862
Hello ALL, I read motor speed rmp from driver by profibus.(connected resolver to motor) I need convert rpm to encoder simulator(count puls) on...
Replies
17
Views
6,821
I have an absolute encoder that is connected via SSI to a computer. Has anyone seen a PC card that transmits SSI so that I can create an...
Replies
1
Views
3,389
Sorry in advance for the long post, but this requires a little back story. I work in a facility with a couple hundred VFDs Most are in a web...
Replies
14
Views
310
I have an application using an incremental encoder and then I convert it to degree (0-360) using calculation program. For a while, the calculation...
Replies
8
Views
374
Back
Top Bottom