Breaking down an INT to send to a robot

dhuber

Member
Join Date
Jul 2009
Location
Ontario
Posts
49
Hi everyone.

I'm working with a Motoman robot and I have to send values ranging from 50-2500 to the robot.
The robot can only accept signed single integers so that only gives me 127. I need to break down my user entered value to send to the robot and then put it back together in the robot.
What is the best way to break down the integer to send the ones values, tens values, hundreds, and thousands to the robot with 4 data transmissions?
It's an Allen Bradley compact logic plc.
If anyone can start me in the right direction it send a sample program that would be greatly appreciated.

Thanks.
 
I'm not sure what resources that you have on the Motoman end, but why not use BCD? Or a variance of it. Since it seems that you have an eight bit path to your robot, put the digit in the lower nibble, and the multiplier (1's, 10's, 100's, etc) in the upper nibble.

So:

0000 0010 would be a decimal 2
0001 0011 would be a decimal 30
0010 0101 would be a decimal 500

Either use a predefined number of digits, or a marker to show end of transmission. Such as:

1111 1111

which wouldn't be a valid BCD value anyways.
 
One way would be as follows:

1000's: Divide by 1000, truncate the result
100's: Mod by 1000, Divide by 100, truncate the result
10's: Mod by 100, Divide by 10, truncate the result
1's: Mod by 10

So for 1056 you get:
1000's: 1056/1000 = 1.056 -> 1
100's: 1056 % 1000 = 056 -> 056/100 => 0.56 -> 0
10's: 1056 % 100 = 56 -> 56/10 = 5.6 -> 5
1's: 1056 % 10 = 6

Can't say if its the best, but it should work.
 
One way would be as follows:

1000's: Divide by 1000, truncate the result
100's: Mod by 1000, Divide by 100, truncate the result
10's: Mod by 100, Divide by 10, truncate the result
1's: Mod by 10

So for 1056 you get:
1000's: 1056/1000 = 1.056 -> 1
100's: 1056 % 1000 = 056 -> 056/100 => 0.56 -> 0
10's: 1056 % 100 = 56 -> 56/10 = 5.6 -> 5
1's: 1056 % 10 = 6

Can't say if its the best, but it should work.

The op said this was a CompactLogix.... so your method won't work as intended in all cases.

The reason is that Logix5000 systems use a different type of rounding with numbers that end in .5

Normally, this would be rounded UP, but Logix5000 rounds to the nearest EVEN number. It is one of the topics I cover that causes the most raised eyebrows.

However, all is not lost - the idea of doing division and truncation together is performed automatically in Logix5000 when ALL of the operands of the math instruction are of an integer data-type.

Consider :

DIV, 10, 6.0 : This is forced to use a f.p. calculation, (because at least one of the operands is a REAL number), to determine 1.66666, but then that is rounded when storing to an integer type, so will result in the answer 2

DIV, 10, 6 uses a faster, integer-only, calculation that truncates the result, giving the answer 1 - that's your division and truncation handled in one go !

Yes, it's a headache when what appears to be the same calculation produces different results, but the knowledge of WHY this happens will be of great benefit.
 
The reason is that Logix5000 systems use a different type of rounding with numbers that end in .5

Normally, this would be rounded UP, but Logix5000 rounds to the nearest EVEN number. It is one of the topics I cover that causes the most raised eyebrows.

That is a strange way to round. Thanks for the clarification daba!

I've got an application that I'm working on that has a similar splitting of numbers and I'm using the INT division because it was less instructions, but its good to know that it wouldn't work with the truncate instruction.

-Benaiah
 
... send values ranging from 50-2500 to the robot. The robot can only accept signed single integers so that only gives me 127...
That sounds like ASCII characters. I don't have experience with Motoman or AB, but I'm doing something similar with a KEP (Weintek) HMI.
The operator enters a value on the screen. The Macro uses a built-in function, HEX2ASCII, to break it down into the 3 or 4 individual ASCII characters for RS232.
I expect you could stay fixed at 4 characters, and send 0050 for 50.
 
Hello there,

I used to work with Motoman robots and Ive transfered data between a PLC and a robot many times.

First of all, as someone pointed out, you can get data transferd between 0-255 per byte. All you need to do is use two bytes.

I havnt touched the robots in more than a year now, so my code might be a bit rusty, but I think this should be what u need.

Move first byte into IG#(101) (0-255)
Move 2nd byte into IG#(102) (256->)


In the robot make this code:

//Move values from input group into B-variables
SET B0001 IG#(101)
SET B0002 IG#(102)
//Reset the value of a D-variable
SET D0001 0
//Move the highest value of your word into a D-variable and multiply with 256
ADD D0001 B0002
MUL D0001 256
//Add the lowest value of your word to the highest
ADD D0001 B0001
PAUSE
//Go to main menu - d-variables - and check the value of D0001. It should now contain a value between 0 and 32767.


Feel free to change the variable numbers and the input groups.
 

Similar Topics

Hello, I am working on a SCADA system using Wonderware Intouch 2014 R2 and have a small glitch with the historical trend feature. Every time I...
Replies
5
Views
2,838
I know tabview is not a PLC but I also know that some of you use LabView for a HMI and data acquisition. We have at a !@#$% if a time with...
Replies
6
Views
4,297
I was listening to the radio today and a discussion about Simulation Hypothesis came on and it was quite intriguing and actually entertaining. I...
Replies
11
Views
2,049
Since I had to relocate, I've been working in new construction as an electrician, however my boss is definitely open to letting me take on...
Replies
9
Views
2,853
Hello All, First of all I am using an AB Logix 5571 revision 30. I am trying to use a FBC to tell me which slave is unplugged in order. The...
Replies
4
Views
2,357
Back
Top Bottom