Gnomes Posted October 12, 2005 Report Posted October 12, 2005 Hello, I've been experimenting a little with using subroutines and call functions. I'm running into a problem and I don't know why it doesn't work. Below is a picture of my main code. In the first two subroutines (Hello, Clear) are just some block move instructions that set up a data block for the commreq. The last call command (dummy) has some move instructions along with the commreq. All of these commreq's are for a write bytes command. Hello prints hello to my hyperterm window while clear is a new page command (Clears my window) and dummy prints dummy. What I'm running into is after downloading my program to the plc I flip input one and hello appears on my screen. I set input two my screen clears, then I switch on input three and dummy appears on my screen. So everything seems to be working all right. So I try it again and there is hello and clear page but I get no "dummy" appearing. It looks like when I have the commreq in my call function it only seems to work on the first time after downloading the program whereas when the commreq isn't in my call function it appears to work every time. What do I have to do to be able to keep my commreq in my call function for it to work each time? Thanks for any help! Quote
Guest Guest_Russ Posted October 12, 2005 Report Posted October 12, 2005 The Hello and Clear Com_reqs are contolled by 1_Shots, is Dummy? If not that is probably the problem. Also I suggest that you arrange your logic so the Hello, Clear, and Dummy Blocks are called by the 1_Shots, you can move them to the same rung as the Com_Req. Quote
Gnomes Posted October 12, 2005 Author Report Posted October 12, 2005 Here's a picture of the Dummy subroutine. I am using a one shot for my commreq and from my knowlege I thought this would work but for some reason it only wants to work once on the intial power up of the plc and then no more. So it's also a good idea to use a one shot when using a call funtion as well? Quote
RussB Posted October 13, 2005 Report Posted October 13, 2005 No, only a Call that is used just for setting up a Comm_Req, or doing just Math, or some other functions that are better used with 1_Shots. You still need to remember that any coils turned "ON" in a Called Block will stay on if the the Block is no longer called. Quote
Steve Bailey Posted October 13, 2005 Report Posted October 13, 2005 I think the problem is due to the One-Shot inside the subroutine. Assuming that Dummy_?????? (the variable for the One-Shot coil) is non-retentive, then upon powerup, it is off. You turn on the switch that triggers the call to the Dummy block and that also fires the Dummy_????? One-Shot. The transition table remembers that the One-Shot has fired so it doesn't fire again. Now you turn off the switch that calls the Dummy block. Since the block is no longer called, the memory associated with the variable (including the transition table) doesn't get changed. Now you turn on the switch that calls the Dummy block again. The CPU starts processing the rungs inside the block. When it evaluates what to do with the One-Shot coil it checks the transition table for the last state of the address. The transition table shows the last state as on, so the One-Shot does not fire. One solution would be to put the One-Shot coil that enables the COMREQ instruction outside of the Dummy block. Quote
Gnomes Posted October 17, 2005 Author Report Posted October 17, 2005 Thanks for your help Steve and Russ. I moved the one shot coil and that seemed to solve the problem I was having now it's time to try and see if I can figure out some other troubles I'm having! Quote
Recommended Posts
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.