Octal to Decimal

Oceansoul

Member
Join Date
Apr 2010
Location
England
Posts
307
Hi,
I have a system with 24 filters each with its own PLC5 on a DH+ network (actually 2 networks of 12). The filters are numbered 1 to 24 and the DH+ node address increment from 1 (1,2,3,4,5,6,7,10,11,12,13,14,15,16,17,20 etc).

I need to write some logic to convert the octal address (s2/0 to s2/5) to decimal. Ive found the formula on Wikipedia but thats a little bit beyond me. I kind of understand how to convert oct to dec, but im not sure how to do it in code. Can anyone offer assistance :)
 
Off the top of my head:
Couldn't you just move the S2/0 and S2/5 into their own N (N7:1 & N7:2) file. Then you could address the N word to the bit level (N7:1/0-N7:1/15 & N7:2/0-N7:2/15)

What do you need the Decimal for?
 
Brute force...

You would first have to move word S:2 thru a mask only allowing the first 6 bits thru, this gives you the octal address (N7:0)

Then using 4 limit instructions or one of the 4 depending on that PLC's node address. First one is octal address number (N7:0) between 0 and 7 if so move to decimal address (N7:1).
Next limit instruction. Is octal number (N7:0) between 10 and 17, subtract 2 destination decimal address (N7:1).
Next limit instruction. Is octal address (N7:0) between 20 and 27, subtract 4
destination decimal address (N7:1)
Next limit instruction. Is octal address (N7:0)between 30 and 37, subtract 6
destination decimal address ( N7:1)
 
Last edited:
(Warning: I haven't used a PLC5 for a couple of decades - so you may want to take this with a grain of salt.)

Using Mickey's first move which isolates the lower 6 bits -
then use TOD to convert to BCD.
Isolate the Upper digit using an AND (0x00F0)
Isolate the lower digit using another AND (0x000F)

[Edit - delete these lines
Divide the isolated upper bits by 10. (20 -> 2 etc)
Then Multiply by 8.]

Divide the isolated upper bits by 2 (Since the BCD form is a hex type value it is the 'tens' place times 16. So let's just divide it by 2.)

Finally add the lower digit (4 bits.)

It's probably even longer than the 'brute force' method, but it is my way of thinking.
 
Last edited:
Actually its even simpler then what I posted above.

After the move with mask of the S:2 word.

In nodes 0-7 do nothing the octal value is the decimal value.

In nodes 10-17 (octal) just subtract 2.

In nodes 20-27 (octal) just subtract 4

In nodes 30-37 (octal) just subtract 6
 
Last edited:
Thanks for the replies guys.
I've just been looking into implemting this and have drawn up a table in excel with the Decimal filter number, octal DH+ address and the first 6 bits of S2.

Take for example filter 22. I know it has a DH+ address of 26 (I know Dec 22 = Oct 26). Looking at bits 0-5 of the S2 word i have; S2 First 6 Bits 010110


If this part of the word was moved into an interger would that not read 22??
 
Last edited:
If this part of the word was moved into an interger would that not read 22??
That should work. Just masked move the 7 first bits into an integer, and display it as decimal and you are done.

NB. My PLC5 is a bit rusty. But I think the above is OK.

What Bullzi means is that maybe you should dsiplay as octal, since that is the standard everybody uses with DH+.
 
What Bullzi means is that maybe you should dsiplay as octal, since that is the standard everybody uses with DH+.

Yes octal is the standard for DH+ but i am trying to find out the "Filter number" from the DH+ address. As the DH+ address is the only thing unique to each filters PLC code.

Thanks for everyones help. I'll update with how i get on.
 
I am trying to find out the "Filter number" from the DH+ address
You could just go to your PLC5 Data Table (say the B3 table), switch the Radix to "Octal", type in each DH+ address in a unused memory word, then switch the Radix to "Decimal" to view the addresses.

Here are the the first 0-to-61 octal equivalent numbers for the first 0-to-49 decimal numbers.

Decimal 0-49 to Octal 0-61.jpg
 
Last edited:
Thanks for the replies guys.
I've just been looking into implemting this and have drawn up a table in excel with the Decimal filter number, octal DH+ address and the first 6 bits of S2.

Take for example filter 22. I know it has a DH+ address of 26 (I know Dec 22 = Oct 26). Looking at bits 0-5 of the S2 word i have; S2 First 6 Bits 010110


If this part of the word was moved into an interger would that not read 22??


It appears that in RSLogix5's processor status the DH+ address is displayed in octal. But when you do the "MVM" of S:2 the value is displayed in decimal as you have discovered.
I did not know that. See picture

nodeaddress.png
 
Last edited:
Thanks mickey that's exactly what I'm after. I've done my code off line, but before I had a chance to make the edits online I was called away to a failed HMI. Hopefully I'll be able to do this soon.

The reasoning behind this is for a HMI. Every filter is to have an HMI fitted, but we want just 1 apa/mer file for all the filters HMI. By reading the filter number from the DH+ address I can have the filter number read from the code.
 

Similar Topics

Partial disclaimer: I'm not the one programming the radios so everything is suspect. But I need to get the CLX eliminated as a problem. I will...
Replies
3
Views
3,417
why are octal and hexidecimal numbers used in the implementation of plc and microcomputer systems?
Replies
2
Views
5,973
I have a PLC 5 that I believe is networked through DH+ to the factories main network. I need to know the octal node so I can message the PLC 5...
Replies
15
Views
4,607
Quick question. When using the CLX PLC/SLC Message Mapping to map files 0 (Output) and 1 (Input) to CLX Integer registers is it smart enough to...
Replies
2
Views
2,091
Im busy building some test rigs for work. Learning SLC500 at the same time. Ive many I/O cards/racks/cpu's to test. See attached .doc file...
Replies
5
Views
2,488
Back
Top Bottom