Sign in to follow this  
Followers 0
ParaffinPower

Indexing an Array of BOOLs

9 posts in this topic

Hi I have an Array of 32 BOOL - MyBOOL[0] to MyBOOL[31] What I'd like to do is index this array with another tag i.e. MyBOOL[MyINT]. CXP will accept MyBOOL[20], but not MyBOOL[MyINT] Am I asking too much of CXP? I'm thinking about a method of writing sequences where extra steps can be added without shuffling all subsequent addresses Cheers

Share this post


Link to post
Share on other sites
Hmmm, well just tried this in a FB: FOR MyInt := 0 TO 31 DO MyBool[MyInt] := TRUE; END_FOR; I set both MyBool and MyInt to be internal and also MyBool to be 'AT' data memory D0. When the code is run, all 32 bits of D0 and D1 are turned on, so it appears to work for me. Is that what you meant? Andy.

Share this post


Link to post
Share on other sites
Hi Andy Thanks for the reply. I probably should've been more specific, but I'm trying to do this in ladder. As I say, I want a tidy way of coding sequences. I know I should use SFC these days but: 1. Not supported in CP1H/CP1L 2. After a quick look at it, I find it baffling... Pp

Share this post


Link to post
Share on other sites
Not too sure how to do what you ask, but one method I have used in the past when I was using Siemens is to have a step value word, for example D0. Set this to a value of &10 (for example) initially and then compare it in a 'Step 10' rung. If the value equals &10 , then step 10 is active and you can perform actions, i.e. energise solenoids etc. Also using this comparison, have a 'Transition 10' rung. When it is active, and the conditions are met to go to the next step, simply move the next step value you wish to run into the step word. eg &20. It is then easy to add intermediate steps, or indeed make the sequence run whatever step you like. Just move the step words' value you wish to run next at the completion of each transition. I hope that makes some sort of sense! Andy.

Share this post


Link to post
Share on other sites
SHIFT N-BIT DATA LEFT: NSFL(578) Should work just fine!!

Share this post


Link to post
Share on other sites
Yes, agree, but I'm after a way to seamlessly insert steps. A bitshift still required a re-jig of all subsequent steps. Thanks all, Pp

Share this post


Link to post
Share on other sites
Hello All, The main Ladder editor of CX-P (as Pp indicates), will not allow indexing using another variable. This was the specification when adding array support for the ladder editor, due I believe to the fact that the CX-P Ladder editor is primarily address based, and therefore will have no knowledge of the address at "MyBool[MyInt]", which will (obviously) cause a compile error. It is possible however to do this within either a Structured Text Program, or a Ladder / Structured Text function block. Hope this helps to clarify the situation!

Share this post


Link to post
Share on other sites
I'm not really sure about what you want to achieve.... are you trying to jump to a certain step in you program? Why do you want to be able to insert steps dynamically in a program, or is it just while programming? Beegee

Share this post


Link to post
Share on other sites
for programming sequences i've always used the MLPX function. Basically you define your sequence as a packet of DMs let's say, DMx: command code + as many other DMs as "datas" associated to your command code, then process your command through MLPX executing the function you want to perform with your command. I've done a lot of sequences some also fairly complex, in this way.

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