You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

---------->>>>>Get FREE PLC Programming Tips

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

PLC training tools sale

Reply
 
Thread Tools Display Modes
Old October 23rd, 2017, 09:59 AM   #1
Bigshad24
Member
United States

Bigshad24 is offline
 
Join Date: Oct 2017
Location: Dayton, Ohio
Posts: 8
Moving Strings from AB to Mits using Crimson 3.0

Hi all,

I am new here... I am hoping someone could help me figure out how to transfer strings from Allen Bradley to Mitsubishi using Red Lion DSP and Crimson 3.0 software.

Initially, I attempted setting up a string tag then moving it via Block. I realized that the protocol can't handle strings. Then I attempted to setup a numeric tag array. This works except, AB strings are in SInt while Mits uses full words or 16 bits. Therefore, I need to somehow move 2 chars into a single Word for this to work.

Any help would be greatly appreciated.
  Reply With Quote
Old October 23rd, 2017, 02:06 PM   #2
OkiePC
Lifetime Supporting Member
United States

OkiePC is offline
 
OkiePC's Avatar
 
Join Date: Mar 2005
Location: ENE of Nowhere Oklahoma
Posts: 9,411
I am pretty sure you can bring the A/B strings into Crimson string tags. I have no string experience with Mitsubishi. In most systems, each character is one byte. In the A/B plc, the first word is the length field and the characters are stored in each following byte, so you have 2 characters per word.

If what you are saying about the Mitsubishi is correct, then you can probably use the string handling functions in the DSP in a Crimson program to get those characters' values out of the A/B string and then plop them into words in the Mitsubishi.

The bottom of the line DSP will not support the use of programs/scripts which will limit your ability to do this type of thing.

Tell us specifically which models you are dealing with please.
__________________
It's not all the variables I am most concerned with, it's the undiscovered constants.
  Reply With Quote
Old October 23rd, 2017, 02:33 PM   #3
keshik
Lifetime Supporting Member
Canada

keshik is offline
 
Join Date: Jun 2011
Location: Portland, OR
Posts: 350
This should be doable. You may have to write a small program in Crimson to move things properly. You probably won't have to convert things into strings unless it helps you visualize what you're doing.

Something along the lines of copying the AB string SINT into a 16-bit integer, bit shifting it over by 8 bits, then copying the second AB SINT into the relevant bits of the 16-bit integer.

You may have to experiment with the bit order as well. I'd recommend that when you're testing that you look at the actual binary values of what you're sending back and forth. The letters might be bit reversed or byte reversed.

Are the strings only going from AB to Mitsubishi and not both directions?
  Reply With Quote
Old October 23rd, 2017, 02:38 PM   #4
Bigshad24
Member
United States

Bigshad24 is offline
 
Join Date: Oct 2017
Location: Dayton, Ohio
Posts: 8
Quote:
Originally Posted by OkiePC View Post
I am pretty sure you can bring the A/B strings into Crimson string tags. I have no string experience with Mitsubishi. In most systems, each character is one byte. In the A/B plc, the first word is the length field and the characters are stored in each following byte, so you have 2 characters per word.

If what you are saying about the Mitsubishi is correct, then you can probably use the string handling functions in the DSP in a Crimson program to get those characters' values out of the A/B string and then plop them into words in the Mitsubishi.

The bottom of the line DSP will not support the use of programs/scripts which will limit your ability to do this type of thing.

Tell us specifically which models you are dealing with please.
I am using a DSPSX000.

I have been attempting exactly what you have suggested above. I have created an Int array to grab data from AB. I have this array mapped to the DATA part of the AB tag so that I am not getting the length just the String. When I open a watch window, I can see he data in the Int Array that I created. So, I created another Int Array, and wrote a program to Convert the first Int Array into Text (I believe that this will be treated as 16 bits so may only get first char) Then I set the second array to the Text to Int conversion. My code is below for your reference. I already know I will need to add more in order to get the additional characters but want to see basic functionality.

cstring chars1and2 := IntToText(Bore_Inspect_to_MES.PCS_Defect1_Side[0],10,1);
Defect1_Side_Int[0] := TextToInt(chars1and2,10);

Opening up the Watch window shows Data at Bore_Inspect_to_MES.PCS_Defect1_Side[0] but nothing at Defect1_Side_Int[0]

At this point, I don't even know if the program is being run. I set it up in the display pages to run On Tick.

Let me know what you think...
  Reply With Quote
Old October 23rd, 2017, 02:42 PM   #5
keshik
Lifetime Supporting Member
Canada

keshik is offline
 
Join Date: Jun 2011
Location: Portland, OR
Posts: 350
If you're not sure that the program is being run I would create a tag and do this:
Code:
testTag := testTag + 1
then put that tag on a screen or in your watch window (I'm not sure if that unit has display pages).

I would probably also make cstring chars1and2 a global tag so that you can watch that as well. It can be put back into program scope later when you're convinced that part is working.

What does "Bore_Inspect_to_MES.PCS_Defect1_Side[0]" look like in the watch window?
  Reply With Quote
Old October 23rd, 2017, 02:45 PM   #6
Bigshad24
Member
United States

Bigshad24 is offline
 
Join Date: Oct 2017
Location: Dayton, Ohio
Posts: 8
Quote:
Originally Posted by keshik View Post
This should be doable. You may have to write a small program in Crimson to move things properly. You probably won't have to convert things into strings unless it helps you visualize what you're doing.

Something along the lines of copying the AB string SINT into a 16-bit integer, bit shifting it over by 8 bits, then copying the second AB SINT into the relevant bits of the 16-bit integer.

You may have to experiment with the bit order as well. I'd recommend that when you're testing that you look at the actual binary values of what you're sending back and forth. The letters might be bit reversed or byte reversed.

Are the strings only going from AB to Mitsubishi and not both directions?
Thanks for the response. I like your ideal but don't know how I could bit shift then copy the other 8 bits without over-writing the already shifted bits. I am not a strong programmer. But I guess I could use bit-wise operators?? If I can get the bits to equal something regardless of reversed bits/bytes, that would be a step in the right direction.
  Reply With Quote
Old October 23rd, 2017, 02:56 PM   #7
Bigshad24
Member
United States

Bigshad24 is offline
 
Join Date: Oct 2017
Location: Dayton, Ohio
Posts: 8
Quote:
Originally Posted by keshik View Post
If you're not sure that the program is being run I would create a tag and do this:
Code:
testTag := testTag + 1
then put that tag on a screen or in your watch window (I'm not sure if that unit has display pages).

I would probably also make cstring chars1and2 a global tag so that you can watch that as well. It can be put back into program scope later when you're convinced that part is working.

What does "Bore_Inspect_to_MES.PCS_Defect1_Side[0]" look like in the watch window?
I have added the suggested code and see that my program doesn't appear to be getting called. I can not watch Chars1and2 because I can't put a string in the watch window... Here is what The Bore_Inspect_To_MES.PCS_Defect1_side array looks like:

PCS_Defect1_side[0] 72
PCS_Defect1_side[1] 105
PCS_Defect1_side[2] 46
PCS_Defect1_side[3] 51

Should be Hi.3 in ASCII...
  Reply With Quote
Old October 23rd, 2017, 02:59 PM   #8
keshik
Lifetime Supporting Member
Canada

keshik is offline
 
Join Date: Jun 2011
Location: Portland, OR
Posts: 350
Quote:
Originally Posted by Bigshad24 View Post
Thanks for the response. I like your ideal but don't know how I could bit shift then copy the other 8 bits without over-writing the already shifted bits. I am not a strong programmer. But I guess I could use bit-wise operators?? If I can get the bits to equal something regardless of reversed bits/bytes, that would be a step in the right direction.
Actually, I think we can accomplish this without using a masked move (bitwise AND).

You could try something like this:

Code:
int char1, char2, outputInt
char1 := Bore_Inspect_to_MES.PCS_Defect1_Side[0]
char2 := Bore_Inspect_to_MES.PCS_Defect1_Side[1]

outputInt := (char1 << 8) + char2
Sample run:
Bore_Inspect_to_MES.PCS_Defect1_Side[0] = "M" (hex: 77; binary: 01001101)
Bore_Inspect_to_MES.PCS_Defect1_Side[1] = "a" (hex: 97; binary: 01100001)

Code:
char1 => 0x0077
char2 => 0x0097

outputInt => (0x7700 + 0x0097) => 0x7797
  Reply With Quote
Old October 23rd, 2017, 03:00 PM   #9
keshik
Lifetime Supporting Member
Canada

keshik is offline
 
Join Date: Jun 2011
Location: Portland, OR
Posts: 350
Quote:
Originally Posted by Bigshad24 View Post
I have added the suggested code and see that my program doesn't appear to be getting called. I can not watch Chars1and2 because I can't put a string in the watch window... Here is what The Bore_Inspect_To_MES.PCS_Defect1_side array looks like:

PCS_Defect1_side[0] 72
PCS_Defect1_side[1] 105
PCS_Defect1_side[2] 46
PCS_Defect1_side[3] 51

Should be Hi.3 in ASCII...
Are you running your test on actual hardware or simulating?
  Reply With Quote
Old October 23rd, 2017, 03:04 PM   #10
Bigshad24
Member
United States

Bigshad24 is offline
 
Join Date: Oct 2017
Location: Dayton, Ohio
Posts: 8
Quote:
Originally Posted by keshik View Post
Actually, I think we can accomplish this without using a masked move (bitwise AND).

You could try something like this:

Code:
int char1, char2, outputInt
char1 := Bore_Inspect_to_MES.PCS_Defect1_Side[0]
char2 := Bore_Inspect_to_MES.PCS_Defect1_Side[1]

outputInt := (char1 << 8) + char2
Sample run:
Bore_Inspect_to_MES.PCS_Defect1_Side[0] = "M" (hex: 77; binary: 01001101)
Bore_Inspect_to_MES.PCS_Defect1_Side[1] = "a" (hex: 97; binary: 01100001)

Code:
char1 => 0x0077
char2 => 0x0097

outputInt => (0x7700 + 0x0097) => 0x7797
How are you calling this program?
  Reply With Quote
Old October 23rd, 2017, 03:05 PM   #11
Bigshad24
Member
United States

Bigshad24 is offline
 
Join Date: Oct 2017
Location: Dayton, Ohio
Posts: 8
Quote:
Originally Posted by keshik View Post
Are you running your test on actual hardware or simulating?
I am running this on an actual device. The device is currently moving other types of data from AB to Mits with no problem. I am only having issues with the string data.
  Reply With Quote
Old October 23rd, 2017, 03:11 PM   #12
keshik
Lifetime Supporting Member
Canada

keshik is offline
 
Join Date: Jun 2011
Location: Portland, OR
Posts: 350
The "On Tick" should work for what you're trying to do. Have you remembered to translate the program before downloading it (should be green instead of yellow)? Ctrl-T should be the shortcut.
  Reply With Quote
Old October 23rd, 2017, 03:28 PM   #13
Bigshad24
Member
United States

Bigshad24 is offline
 
Join Date: Oct 2017
Location: Dayton, Ohio
Posts: 8
Quote:
Originally Posted by keshik View Post
The "On Tick" should work for what you're trying to do. Have you remembered to translate the program before downloading it (should be green instead of yellow)? Ctrl-T should be the shortcut.
Thank you very much keshik!!

The program was translated had to be in order to download to device. However, I changed the program to remove the string calls. Used something similar to what you proposed above with the bit shifts and I am now getting the data to the output Integer as intended.

Two things to note,
1. The string calls didn't appear to work.
2. The TestTag := TestTag +1 is still not updating ???

Otherwise, I have enough to hopefully finish this project :-)
  Reply With Quote
Old October 23rd, 2017, 03:37 PM   #14
keshik
Lifetime Supporting Member
Canada

keshik is offline
 
Join Date: Jun 2011
Location: Portland, OR
Posts: 350
1. By string calls do you mean your "cstring" calls in your original example? I'd double check your syntax on your inttotext calls if you still care on that one.
2. The TestTag thing should work - did you define TestTag as a local or global variable? Should be global. Otherwise each time the program is run it will be re-created with a 0 value.

Good to hear that things are looking better now.
  Reply With Quote
Old October 23rd, 2017, 03:43 PM   #15
Bigshad24
Member
United States

Bigshad24 is offline
 
Join Date: Oct 2017
Location: Dayton, Ohio
Posts: 8
1. Thank you, I will look into the IntToText calls syntax.
2. I created the tag outside of folders, does that mean it is global?

Thanks again for your patience. I am mostly a Mitsubishi PLC guy. I have a little experience with coding a long time ago. I guess I need to brush up. :-)
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
Crimson 3.0 emulator talking to RS Logix 500 emulator radfahrer LIVE PLC Questions And Answers 0 March 23rd, 2015 02:56 PM
Crimson 3.0 - Automatic Login? Casby LIVE PLC Questions And Answers 5 March 16th, 2015 05:38 PM
Crimson 3.0 Newbie shoelesscraig LIVE PLC Questions And Answers 6 January 16th, 2015 08:27 AM
Crimson 3.0 and Filezilla, Help please!! leogar07 LIVE PLC Questions And Answers 3 May 1st, 2012 06:40 PM
Crimson 3.0 learner rta53 LIVE PLC Questions And Answers 5 April 4th, 2012 07:05 AM


All times are GMT -5. The time now is 09:28 PM.


.