Sign in to follow this  
Followers 0
BITS N BYTES

OMRON CJ1 Structured Text FB

7 posts in this topic

Trying to figure out how to write Stuctured Text code to do the same thing as the BSET ladder instruction. Have a single internal variable in the ST function block with an AT address of D500. I need to set D500 through D520 to a value of 0. The ladder instruction BSET would use a source of #0 a starting word of D500 and end word D520. Any ideas how to do this within a Structured Text Function Block would be most appreciated.

Share this post


Link to post
Share on other sites
With FB there are endless ways to achieve what you want.... I have attached one version... i am sure others will come up with other ways...

Share this post


Link to post
Share on other sites
Thanx Sleepy. Did not realize you could use array as an offset in structured text from the original single word input D500 to address other words, without having to declare the variables D500 thru D520 as function block variables. Structured text FB documentation from Omron is fairly rudimentary/cryptic, so I am learning the capabilities as I go. BTW I have started using the V4.0 processors that include internal STRING variables within ST Function Blocks. What a fabulous improvement over some of the [less than obvious] CX-Protocol conversions. Hooray!!! Will try your suggestion tomorrow.

Share this post


Link to post
Share on other sites
I am wondering why you wish to use ST in FBs to do BSET? It does not appear to save any time - probably takes longer in fact.

Share this post


Link to post
Share on other sites
Possible he was doing some data manipulation, and maybe wanting to clear the data in that area first? I am using a bit of ST, I prefer it for most math calcs, makes it mroe readable sometimes, also commenting code can be a bit tidier. Ladder is, sometimes, more often in fact, easier to follow, but then, so can ST be as well. I think it all comes down to personal preference, and what is the best tool for the job. Even still, the Omron instruction set is quite large, so I guess there may not be the need for ST?

Share this post


Link to post
Share on other sites
My application has 4 Serial Ports connecting to 4 different devices each with sa different communications protocol. To say the least, handling all of these through Ladder and Protocol Macros has been quite a challenge. The V4.0 processors allow string manipulation within the Structured Text function blocks. This is a vast improvement in that the cryptic nature of the standard Ladder instrutions for manipulating/ converting/writing/reading ASCII data and the awkard configaration of the Read/Write messages in Protocol Macros was becoming very cumbersome. Personally I have found that doing this within a ST enviroment is far easier to troubleshoot, monitor and modify [online if necessary]. I need to mimic the BSET command within the ST Function Block to initialize and or clear data. The last post solved this perfectly. BTW The ST Functions blocks are also absolutely great at handling math. 1. Gets rid of the cumbersome setup for the APR [069] instructions with simple ST code.. 2. Able to generate a useable Average function based on my own time base rather than the lousy and [as far as I am concerned the utterly useless] AVG [195] ladder instruction which uses scan based averaging. Say no more!!

Share this post


Link to post
Share on other sites
Just done one with 6 x CJ1M. 2 of them only had a BMS interface and setting up Modbus slave was easy in the card without an FB or anything else and it just works. The other 4 had 2 SCU's on each PLC - 1 port was BMS interface as before, 1 port was high speed NT link to a touch screen, the other 2 ports - 1 port dragging info from Si-TEC CGC generator controllers, GE-Multilin SR489 relays (bot easy - 1 block read from each on the same loop), 1 port dragging info fron CAT EMCPIII genartor control panels - the data was all over the place - ther were 5 reads from there. I just used Protocol Macro with the PMCR function and counters to regulate 1 block read at a time. The input to the counter was the port "done" bit. It was pretty easy really. Manipulating the data from the CAT was not so easy - had to do a pile of floating point maths on each point. I found ladder easy as I could change a parameter on the fly and monitor it in the rung. Got all my calibrating done in one place. That really woulc have been a good place for an FB - probably just ladder - but I was being given different information all the time - they really did not know what they were doing - and ladder default was OK. Next time I do one of these I will put the calcs in an FB but will probably still use ladder and PMCR for the comms. Easy to change. It is quite often horses for courses really. One of the other problems I have is that the consultant engineers often specify ladder and will accept nothing else. A lot of people trouble shooting systems can barelt understand ladder let alone FB and ST. It is pretty hard on the phone from, quite often, thousands of kilometres away trying to explain to someone on the phone how to trouble shoot ladder let alone FB - ST would be 10 times worse. We often have to do things to suit other people and not the way we would like.

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