Bobodopalus

String shift register

9 posts in this topic

Hello all

thanks to bits n bytes's date and time to string converter here https://forums.mrplc.com/index.php?/topic/31786-write-plc-time-as-text-to-memory-card/#comment-149418 i have made a nice string output function block for the PLC date and time that i will attach.

I'm now wandering how to shift this into a memory card as well as display it on a NB screen.

for the NB screen i think i can just used a text box to display the code using 8 words, i sadly dont have a CJ2M plc with me at the moment so i cannot test.

for the memory card i have not used these at all yet, is there a special shift register for strings? i cant seem to find it.

i will be using this simply for a checklist on the HMI where an operator goes through the list of tasks to perform and ticks them off on the HMI which then logs the time and date they were completed at.

do i need to create a shift register using MOV$ with a @destination and increase the count of the destination witch each input?

Thanks in advance

Date_and_time_string_convert.cxf

Edited by Bobodopalus

Share this post


Link to post
Share on other sites

It looks like you may have your answer. I don't know because I haven't explored the function block in your link.

If you decide to do the CF writing discretely, you can have a look at this example: https://forums.mrplc.com/index.php?/files/file/276-compact-flash-memory-write/

If you are required to do the shifting discretely, think about this. MOV$ will move a string, or bytes starting from your address specification up to (and including) the first null character. So the length is indeterminate until it is executed. For this reason, if you would need to know that maximum possible length of the strings you are using. Then you can shift using the Block Transfer instruction (XFER 070). The XFER will move the data byte for byte and bit for bit, so it will remain unchanged.

For example:  If your string length is less than 200 characters (100 Words), then you could do an XFER, N: &100, S: D100, D: D200. Now you would most likely require a table. To do this you would Indirectly Address D100 and D200 where you could control the locations.

If you function block doesn't work out, we could provide a simple example for this method.

Share this post


Link to post
Share on other sites

unfortunately i wont be able to test it for a while, i only have CP1L's on hand at the moment so its gonna be a while getting a cj2m now.

i think the block will do what i need it to for the writing to memory card, i am only moving 16 characters so 8 or 9 words is all i need.

i think i will need to use MOV$ for displaying the latest input into the file on the HMI, its all sounding a bit easy though lol.

bit annoying that i cant test but oh well.

Share this post


Link to post
Share on other sites
2 hours ago, Bobodopalus said:

i think i will need to use MOV$ for displaying the latest input into the file on the HMI

One of the points I was trying to make is that you can use any MOV or XFER type instruction to move your string. It doesn't have to be a "$" instruction. The special thing about the "$" instructions is that it will operate on the byte data up to and including the "00" or Null character. Using MOV or XFER, you would have to know how many to move.

The important thing is displaying. The HMI will take care of interpreting the data as String so long as it is set to read the data as "String", "ASCII" or "Text" or whatever the setting is. (I'm not that well versed on the NBs).  

Edited by IO_Rack

Share this post


Link to post
Share on other sites

Yes that should be fine for MOV$ i just need to reserve a word to be 00 or null, how do i force a null in?

Share this post


Link to post
Share on other sites

00 is Zero Zero. Just write it to the location. Keep in mind that your string may end on an Even or Odd byte. You'll have to determine which then do something like ANDW in Hex.

ANDW, #FF00 to write zeros to the lower byte and preserve the higher byte.

ANDW, #00FF to write zeros to the higher byte and preserve the lower byte.

Share this post


Link to post
Share on other sites

I strongly recommend using ANDW as described for separating the time segments - I use it all the time.It is seamless.

Share this post


Link to post
Share on other sites

Ok i got this working nicely now, thanks all.

for any1 using NB designer the text box needs to have high and low bytes swapped ticked to display correctly

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