BDT in a SLC

JeffB

Lifetime Supporting Member
Join Date
Apr 2002
Location
NW Arkansas
Posts
79
Hello,

Can anyone tell me how I can get the decimal value of the highest 8 bits in a word, and move that value into another word. I have been able to do this by using an MVM with a mask value of 7F00 and then dividing the result by 256.

Just curious, does anyone know a different way to do this.

Thanks,
Jeff
 
Strange you should ask as I posted this just a few hours ago.
The DIV by 256 method is perfectly ok and I've often used it. But just for fun here is another way using the FRD/TOD pair.

Say for example you want to extract from a decimal number, for example: 23.53, the two parts of the number into 2300 and 53.

(In this case I was entering time of day data via a PanelView )

Like all programming there must be more than one way to skin cat, but this is the scheme I came up with late one night:

1. Convert the Decimal source value to BCD using the FRD.

2. Now the BCD result of 2353 in binary above will be:

0010 0011 0101 0011

3. Put this through a MVM of:

1111 1111 0000 0000 ( or FF00h)

4. The result now is:

0010 0011 0000 0000

5. Put this through a TOD to convert back to decimal and the result is 2300.

6. The rest of the job to extract the 53 is trivial, just subtract 2353 from 2300.

Using BCD like this is a handy trick to extract the exact digits you want from any decimal number
 
I would use a BSR to shift your bits to the low end of the byte.

I know it doesn't make much of a differance in this case, but BSR takes up a lot less processing time than a divide instruction.

It might be a little easier to read and follow too.
 

Similar Topics

I’m attempting to send a temperature from a SLC-5/02 to an EZiMarquee display. The vendor said to use a MSG instruction to send the data to the...
Replies
1
Views
81
Hello all. I have a few SLCs in my plant and of late we've seen a weird issue: The system will be running normally and then randomly the outputs...
Replies
2
Views
93
I am working on setting up a Prosoft Datalogger model PLX51-DLplus-232. This unit will be collecting data from a SLC 5/05 on the DB9 port set to...
Replies
3
Views
103
I have a redundant ControlLogix being set up. This program reads a value from a remote site which happens to be SLC PLC. Rockwell mentions SLC...
Replies
2
Views
95
Hello, I have a ControlLogix redundant controller being set up. The program reads a value from a remote site which hosts a SLC PLC. Rockwell...
Replies
0
Views
77
Back
Top Bottom