Sign in to follow this  
Followers 0
cghaba

Activate state relay using a data register

11 posts in this topic

I have the number of a state relay in a data register, say D10. How can I use D10 to make that state relay active? cghaba

Share this post


Link to post
Share on other sites
With M-bits I would use the DECO instruction. However, I am not sure this will work with state relays. But why not to try and then tell us? Edited by Sergei Troizky

Share this post


Link to post
Share on other sites
I have already taken into consideration DECO instruction. The problem with DECO instruction is its range which is limited to 128 bits. My FX1N has 1000 state relays. One solution would be to split the 1000 state relay range into areas of 128 states. Then, using the data register where the state number is stored (ex. D10), I would need to compute the base address of the 128-states-area my state belogs to (this would be the D operand of the DECO instruction) and the offset from that base address (this would be the source operand of the DECO instruction). I was wondering, isn't there a simpler way to do the job? (I have also tried with index registers but not working). cghaba

Share this post


Link to post
Share on other sites
And there is another problem with DECO instruction. When you use it to set a state relay, all other state relays in the 128-state-area are reset. In my program, I use 3 SFCs working in parallel, one that supervises the other two and the second controlling the third. At one moment there are at least 3 active states, one from each SFC. I would want to activate a state in the third SFC without resetting (stopping) the other two SFCs. cghaba

Share this post


Link to post
Share on other sites
i don't understand what you want to do clearly but, would inline comparison work ? something like this ----LD=5 D10--------------(S5)

Share this post


Link to post
Share on other sites
Jerrycat, I need to go to a state I memorized in D10. It could be any state from s0 to s999, not only s5. Sometimes D10 could be 102 so I should go to s102, sometimes D10 could be 455 so I should go to s455 and so on. It is not just one particular state (s5), but could be one among 10 or 20 states I would wish to go back to under certain conditions. cghaba

Share this post


Link to post
Share on other sites
Did you try to use pointer? If you have 1000 bits (or 1024) starting at M1000 and you want to set ONE bit addressed by D10 I would probably try to work on something like code below. I cannot test it right now but it should work. Other devices used: D12 bit address within one word (16-bit). M40-M55 : 16 bits used to set the one you want Z0 : pointer to word that has to be OR-ed D14 : temp. Let me know if this helped.

Share this post


Link to post
Share on other sites
Btw, code above was just the concept. Don't forget to check the range of D10 or you might get into trouble. The simplest protection is to insert one more instruction like WAND D10 h3FF D10 or just use two comparison blocks.

Share this post


Link to post
Share on other sites
"Inclusive relationship" table in FX manual says P-SRET and STL can not be combined. What I am trying to do is to simulate a kind of subroutine in STL and I try to implement the return from subroutine. In the data register I store the state that makes the "call" and at the end of "STL subroutine" I need to return that state. For example, I have to make a program that has among other sequences 20 stages, each stage being a sequence of commands of the form: 1) go forward/backward m slots 2) get close/go far from machine n slots 3) rise/lower body p slots 4) advance/retreat hand1 r slots 5) advance/retreat hand2 s slots where for each stage, direction of movement and parameters m, n, p, r and s take different values. As I am used with C programming, I would put all this into a function and call the function 20 times in the right sequence with corresponding parameters. cghaba

Share this post


Link to post
Share on other sites
The following will set the S(D10): MOV H1 K1M100 MOV D10 Z WOR K1S0Z K1M100 K1S0Z It will affect 4 consecutive M100 to M103 bits. Edited by Sergei Troizky

Share this post


Link to post
Share on other sites
Sergei, Thanks. It works fine. For my purpose, one RST instruction must be added in order to reset the current state. cghaba

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