3/22/2014 7:43 PM | |
Posts: 146 Rating: (0) |
Thank you for reply ..sir ! This is my PDF witn block creating and Insert block to OB1 ! Just one block insert..nothing happen..but both block inserted ..when press I 0.o ..both Q0.0 and Q0.1 are running ! AttachmentFC1.pdf (365 Downloads) |
3/23/2014 12:49 AM | |
Posts: 74 Rating: (31) |
Hi Xuanphu, Here is an example TIA V12 project with you pump control. It is zipped, as Siemens Forum won't allow .zap12 file types - doh! See my other post for further description. AttachmentFB_example.zip (317 Downloads) |
This contribution was helpful to1 thankful Users |
3/23/2014 1:05 AM | |
Posts: 74 Rating: (31) |
Hmm, it took me a while to understand why. But you are doint something very dangerous! You are trying to use your Temp variable TermRunto remember the state of the motor. You should NEVER use a Temp variable to remember anything from last time the block was called. Temp Variables may only be used immediately in the same scan as they are actively set to a defined state. The TEMP area is shared between all functions called. The problem is, that when a block is called (no matter if it is a FC or FB), the TEMP area is in a undefined state, as the memory might have been used by other program blocks in the meantime. You MIGHT be "lucky" that you get something to work, but suddently it will stop working or work unexpected, when the same bits has been written to from somewhere else. And that is what you are seeing here, and why you somehow can get something to work when calling the block 2 times after each other - but as you have realized, the functions are "magically" getting connected now for you. Anyway, I fall into this mistake once in a while when I'm programming as well...with a lot of headaches to follow trying to debug what's happening to my program...
Yes - see my example - I think it answers it.
See the attached PDF for a description of my sample project I have created for you. AttachmentFB_Example.pdf (330 Downloads) |
This contribution was helpful to2 thankful Users |
Follow us on