Moving Strings from AB to Mits using Crimson 3.0

Bigshad24

Member
Join Date
Oct 2017
Location
Dayton, Ohio
Posts
8
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.
 
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.
 
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?
 
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...
 
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?
 
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.
 
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...
 
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
 
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?
 
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?
 
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.
 
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 :)
 
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.
 
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. :)
 

Similar Topics

I am trying to move a string data type (ST12:0) to (ST12:9) and other strings (1-8) into (ST12:9) depending on the state of a device. When I try...
Replies
5
Views
2,595
Hey there I am using rslogix5000 and I am trying to create a lookup table to convert decimal to hex. I am trying to copy a letter into a string...
Replies
1
Views
1,297
I'm a Siemens person, and this is one of my first AB programs. The customer wants everything programmed in Ladder. I have a lot of data (3...
Replies
14
Views
153
Hello, I have a compact Logix plc and I have been task with configuring alarms into our SCADA when an Analog signal stops moving. The analog...
Replies
6
Views
222
Hello, i am a beginner with a Siemens Logo 8 PLC. I would determine the direction of an object if it passes a whole cycle of 2 input sensors. See...
Replies
2
Views
164
Back
Top Bottom