Simulate encoder

Hi there,

For virtual commissioning, I wanna connect my custom conveyor to the control program. My control program in TIA Portal depends on the position of the component sent by an encoder but I don’t really know how to do so in VC. Could you guys give me a piece of advise on how to simulate it?

Thanks a lot,

Hi @avicente
This is a hard one but i think its possible.

  1. Dont think like a conveyor behaviour in VC.
  2. Create 2 component containers. 1 for moving part,1 for static holding part.
  3. Attach those dynamic components to your container.
  4. Create a real property for your encoder connection in your conveyor component.
  5. Connect your encoder value to your property.
  6. Create a script that can trigger everytime that property changes.
  7. Everytime property changes grab your parts with the move container then offset how much it needs to move.
  8. After offsetting your container. Grab parts with holding container.
  9. Move your ‘‘move container’’ to home position.
    Then repeat those proses over and over.

That might look complicated but i think it would work…
Hope it helps you

1 Like

Hi @ozan, thanks for your answer!

It looks like in the end it’s sligthly different to what I thougth. Instead of sending the position of the component, the encoder sends the distance traveled by the belt of the conveyor in mm, which is triggered by a sensor signal (at the beggining of the conveyor) and it restarts when it reaches 10000 mm.

Theoretically, this distance should be the same as the position of the component that you showed me how to calculate, but if it isn’t syncronized (or if the component slides or something), those values will be different.

I guess I’m gonna have to play with pathSpeed property of my physics conveyor to calculate the distance traveled and then send it to PLCSIM, rigth?

Calculating with speed is good idea, when i was partially making encoder for conveyor it needed to be in rotations so i was using speed to calculate distance, so your opinion make sense and in my experience it will work.

Hey @Seidel , thanks for answering, I appreciate it. Good to know that it is possible to achieve something with my speed aproximation, but I’m having some issues with it.

First of all, in python script, when I update the real signal value with the distance traveled to send it to PLCSIM, VC crashes. If I put a delay of 0.01s, which is the typical scan cycle value, the performance of VC really downgrades.
Also, my conveyor accelerates to match previous conveyor speed whenever a component is coming and then decelerates to 0 so calculating the distance is gonna be a bit tedious. Maybe could it be easier to attach a frame or something to the path and read its coordinates, similar to what @ozan said?


Yeah, that cycle time will be messing with performance. About that acceleration, You can use Transition signal on conveyors to start calculating after its triggered (True when component is on conveyor and False when it leaves).

1 Like