Sign in to follow this  
Followers 0
digispark

Using BSET instruction in FB

5 posts in this topic

I'm writing a function block to handle comms timeout based on a lifeword counter received. So if the lifeword counter stops incrementing for x amount of time, the FB will write a zero to all RX word registers. In it, I have a BSET instruction, to write a zero integer (Internal) from a start address word (IN OUT) to an end address word (IN OUT): BSET (071) Zero_Integer Start_Word End_Word Upon compiling, I get an error saying "The variable does not have enough memory size for the operand, or start/end addresses are different variables". How can I bypass this error? Is there a way to manipulate addresses using math functions? Like start address = D5000 +25 words = end address = D5024... Edited by digispark

Share this post


Link to post
Share on other sites
Why bother even farting around with an FB for such a simple thing to do. Yes, I hate FBs - cannot help you with the FB but it is so simple to do this in ladder I would not even bother confusing the issue and using an FB. Someone who uses FBs more regularly will probably be able to help you if you still wish to use an FB. Sorry about the rant but I really cannot see the sense in going to so much trouble for such a simple task.

Share this post


Link to post
Share on other sites
lol you made my day The FB does bit more than just writing zeroes into those registers, like FINS comms between the PLCs etc... I thought it would be easier to just copy paste and replace FB and parameters.

Share this post


Link to post
Share on other sites
Can you use an array as a variable instead of 2 different variables for start and end?I suspect that would solve the problem. It would ensure that the start word was a lower memory address than the end word.I suspect you could also use an IR (index register) to solve the problem, but the array would be a more strait forward solution.

Share this post


Link to post
Share on other sites
Can you post your FM, or a screen shot? I would be suspect of the 'Zero_Integer' declaration, do you need this instead of just using #0? Could be that the Start_Word, End_Word have not had there allocation done correctly, you could make them AT variables... I would go with PMCR's solution as well, he a bit of a gun! But, I do tend to agree with Bob on the FB thing. Unless you are going to have multiple instances of the FB, such as pumps/valves/scaling etc, then pure ladder is best. Something like PLC-PLC comms would be best in standard ladder. What comms media are you using, can you not use the DataLinks?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0