Sign in to follow this  
Followers 0
mr_shadow

CJ1G-H FBS USING RSTA COMMAND

4 posts in this topic

Hi everybody; I'm a new user of FB's in plc i defined a bool array x[number of elements=15] and i want to reset all of this array with only one command like "RSTA". How can i do this? i couldn't find the syntaxes i think. when i write "set x[0]" or x[1], e.t.c. it works, but when i want to make this with multiple set-reset commands i couldn't do it. can anybody help me?

Share this post


Link to post
Share on other sites
How about MOV #0000 to the channel or the BSET command?

Share this post


Link to post
Share on other sites
Hello Mr Shadow, The problem that you are having, is due to the fact that arrays of type BOOL cannot be used in place of words (INT, UINT etc) within the instruction set. To be able to do what you are asking (using the 'RSTA' instruction), you would need to define a second variable (type UINT) using the AT Address option, which would correspond to an AT Address you would need to define for your BOOL array. E.g. MyArrayX Type = BOOL Array Size = 16 AT Address = (e.g.) W100 This defines your array, Then - MyArrayWord Type = UINT Array Size = 0 AT Address = W100 This will then allow you to reference your array as a single word, which can then be used in the RSTA instruction (or indeed as BobB points out, MOV or BSET instructions). Hope this helps Regards anonymous

Share this post


Link to post
Share on other sites
i did it by thinking each bit of the array as a word array. the bit is always the first bit of the word array's element for example if you think x[number of elements=16] and you use the first bits of the array you must write "SETA X[0], &0, &1" then if you want to reset all first bits you write "RSTA X[0], &0, &256"(16X16). In this solution you waste bits and you waste program memory for single set operation because you write SETA (NOT SET). Also For LD command you have to use BTEST command because your bits are the first elemnts of the word array. As your approach to the problem it is not useful because if you make the variable as "AT" AND you assigned w400 for example and you use two or three times these function block in different places in the program then the function block doesn't work as a function f(x) it works like a subroutine i think

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