Jump to content

TE timer fails to run in my visilogic Ladder...


Recommended Posts

Hi all,

Context : I quickly created a VisiLogic file this morning, which is dedicated to control two brushless motors  (axis entitled Y1 & Y2 in the ladder) run into position & torque mode. The communication is established via CANopen protocol.

Issue : I have troubles with my program execution at the very beginning, in my main routine 😭 after the CAN bus configuration is achieved.

My program launches correctly, but the execution fails when i want to send an NMT command to my two VFDs ==> The timer "TE 0" does not launch when the PLC scans the net. Logically, it should work, but technically, it does not... What am i doing wrong  ? 🤔

I share the code with you so that you can visualize the issue. I know my topic is not really clear so i can give you further informations if needed.

 

Cheers,

Sideway.

 

P.S. : Oh and by the way, i am new to ladder programming... and programming in general actually... So if you find something weird or poorly written in my code, i would be really thankful if you can give me a feedback about it ;)

pilotage_moteurs_Y.vlp

Link to comment
Share on other sites

  • MVP 2023
2 minutes ago, Flex727 said:

Either change MB 1 to a Direct Coil instead of Reset Coil, or place a Reset Coil at the end of Rung 4.

I see now that MB 1 is being used elsewhere also and needs to remain on. You'll need to add a power-up property to Reset the bit so that it can transition to positive in rung 2.

Link to comment
Share on other sites

Hi Flex,

Thank you for your reply. I have tried to reset my MB1 coil on power-up, within a net before the CAN configuration. However, it did not change anything :(

And i can not use XB since the bit is used within the CANopen configuration function, and the only option i have in this function is "MB".

I will try again to reset this MB1, maybe i missed something ;)

Cheers,

Sideway.

Link to comment
Share on other sites

You are using a positive transition contact before the coil of the timer.

a positive transition contact will only go high for one scan once activated (this may be only for a few Milli-seconds)

The contact to start a timer needs to be maintained for the timer to stay running and time out.

your timer never gets a chance to time out.

You need to set a coil with your positive transition contact and use a contact of this coil to start the timer.

once the timer has timed you can reset the timer and the set coil you created.

 

 

Link to comment
Share on other sites

I managed to get the program work by doing the MB11 direct coil technique... It worked properly. 

Although i cant figure out why it was not working with a rising edge of MB1 🤔 

EDIT : @sgull i used a "TE" instead of a "TD", so that the timer goes HIGH when it receives a pulse. Am i wrong ? 🤔

Thanks a lot for your help !

Cheers, 

Sideway.

Edited by Sideway
Link to comment
Share on other sites

  • MVP 2023
1 hour ago, Sideway said:

EDIT : @sgull i used a "TE" instead of a "TD", so that the timer goes HIGH when it receives a pulse. Am i wrong ? 

You are correct. I'm sure sgull was just stuck on TD in his mind since that's basically the default. It happens to us all.

 

1 hour ago, Sideway said:

Although i cant figure out why it was not working with a rising edge of MB1

First scans can be a bit tricky when using transition contacts.

 

1 hour ago, Sideway said:

I managed to get the program work by doing the MB11 direct coil technique... It worked properly.

Great!

Link to comment
Share on other sites

  • MVP 2023
22 hours ago, Flex727 said:

First scans can be a bit tricky when using transition contacts.

By the way, if I can expand on this a bit. How do transition contacts work? Well, the PLC sets aside a special memory bit location for every transition contact. The value of the bit is stored there and compared to the new value whenever it is encountered. If different, the transition is triggered (if in the correct direction). On the first scan what is the current value being compared to? Is the previous value held over from prior to the PLC reset? I'm frankly not sure, but I doubt it. This is where your first scan problems occur, in my opinion. Perhaps a developer or more experienced programmer might have more to add here.

Link to comment
Share on other sites

  • MVP 2023

Flex asks an intriguing question about transitions, that really needs to be answered by the creators. (Or Joe T or Kratmel!!)  🙂   Do they transition sequentially as you step through your program?  Or is it all done at the end of the scan like other operands, going on the first change encountered?  I don't know because I always have them separated out.  Only one transition is associated with a particular other operand.

FWIW, in nearly all the programs I do, I don't have the plc do any operations at all on boot apart from first scan settings.  I build in appropriate delays, which inherently does required grid over-loading avoidance on power failure resumption.  A host of MBs are always done with a power-up setting that might be totally contrary to what they are mostly set at during actual running, with that running then switching them as required.  Nearly all the various sensors I use take time to stabilise to correct readings.  Some of them can take a few minutes.  Indeed, with my averaging, some readings can take many minutes to get to a correct reading if my restart includes an Init & Reset.  If the system runs beforehand, it can actually do a totally incorrect sequence due to the erroneous readings.

The essence of what I'm saying is that building in certain sets/resets on power up, and delays before the plc actually does anything is, in my opinion, a must for both safety and correct operation.  Depending on your needs and devices, the delay has to be made to match the job.  If it's a simple machine the delay can be minimal.  More complex might mean longer.

cheers, Aus

 

Link to comment
Share on other sites

  • MVP 2023
33 minutes ago, Ausman said:

Do they transition sequentially as you step through your program?  Or is it all done at the end of the scan like other operands, going on the first change encountered?

I feel confident that it all happens in real time, rung-by-rung. I never separate out transition contacts and they always work perfectly, even when the bit changes value more than once during a single scan (this would be easy to test definitively - I'll see if I can gin something up).

 

37 minutes ago, Ausman said:

The essence of what I'm saying is that building in certain sets/resets on power up, and delays before the plc actually does anything is, in my opinion, a must for both safety and correct operation.

And this is why you're one of the smartest people on this board. I'm not sure this is common practice except in very specific situations.

Link to comment
Share on other sites

  • MVP 2023

I'm a big fan of using counters based on SB13 or 15 to do such things.  Regular users of the forum know that I say that counters are often a much better way of doing timed operations.  SB2 shifts 0 into the counter, which then can enable progressive implementation of operations based on how much it has increased, by using compares.  Once it reaches the "end point" amount, it exceeds the final compare which disables the counter increase/addition.  On boot it then automatically restarts due to the compare saying it's ok to increase the count, due to it being at 0 again. 

The count can be temporarily stopped etc if needed as the machine carefully initialises mechanisms to start points.

And thanks Flex, flattery will get you everywhere!

cheers, Aus

 

Link to comment
Share on other sites

  • MVP 2023

Sideway, I'm a bit busy at present but will get you a scrnshot of a quick puttogetherjustforyouexample soon!

Also, think along the lines of there are two ways to start things. As well as SB2, the other one can be a power-up value of 0 in the counter MI.   That might help your thoughts in the meantime!

cheers, Aus

Link to comment
Share on other sites

  • MVP 2023

Sideway, have a look at the following.  I only quickly knocked this together, haven't actually run it, but it is the essence of what I'm talking about.  My usual methods were too hard to whittle down to show what I meant.

Explanation.

21)  On boot MI1200 returns to 0 because of a power up value of 0.  Because it is now less than 300, SB13 starts incrementing the count every second.  If the count exceeds 299 it stops increasing and will thus sit on 300.

22 to 24 are pretty self-explanatory.  Simple ideas to show the concept.  eg at 51 seconds MB1000 turns on and signals motors to run slowly, perhaps initialising to start points. You can use any of the various compares to achieve what's needed.  I've got the MBs as power up resets, but this technically isn't necessary.  I just do it in case of a single scan balls-up that might upset things.

cheers, Aus

BootDelays.jpg.f64480f026a7ee223df093d2a02c5f82.jpg

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...