bit shifts

wjmosesjr

Guest
W
In SLC 500 language, how can I accomplish the following:

N7:0 xxxx xxxx 0101 1101 (only 8 bits will be needed for both)
N7:1 xxxx xxxx 1010 0011

n7:0 will be holding seconds (resets every 60)
n7:1 will be holding minutes (resets every 99)

I want to combine these two numbers into a BCD 16 bit words such that:

n7:1 upper byte = minutes, lower byte = seconds, for BCD conversion.

I will be outputing a 16 bit BCD number

I am confused about the bit shift left instruction, and when to convert to BCD for output. I'm thinking BCD conversion should be done before any shifting, and combing of words.

Thanks,
Bill M.
 
First off, are the upper 8 bits in N7:1 (minutes) all zeros, or is there some extraneous data in them?

To purge the extraneause data, use the MVM command, making your mask 00FFh, and put the result in, say N7:2.

Now N7:2 only contains a number from 0 to 255 (or 0 to 99 if you prefer). A MUL of N7:2 by 256 will effectively move any bit 8 places over. The reason you want no data in the upper byte is to prevent a math overflow error.

The resulting integer register will have no values in the lower byte. If the N7:0 register upper byte is empty, you can just add it to the other register. If not, do a MVM and do the add.

MVM N7:1 00FFh N7:2
MVM N7:0 00FFh N7:3
MUL N7:2 256 N7:2
ADD N7:3 N7:2 N7:3

N7:3 contains the final time signature.
 

Similar Topics

Guys, Good morning I'm drawing a blank here. I have a Studio5000 and i'm writing a program one of the Turck I/O blocks I am reading from is a...
Replies
5
Views
2,184
See the screenshot of EIP tag list. We are trying to read in a digital input that is hard-wired. It is shown here as I31.1. I believe we cannot...
Replies
7
Views
297
A couple days ago I accidentally toggled an alwasyoff bit. The issue is it was set up as a single OTU on a rung, nothing else, and used as XICs...
Replies
3
Views
231
Hi I have an old panel builder 32 that I’m replacing for a factory talk me hmi . In the plc for the old panel builder there is a coms bit for the...
Replies
0
Views
80
Hello, Haven't been on in a while. I need to generate a bit level pdf of the I/O for RSLogix 500. I can generate a report but it just shows the...
Replies
1
Views
171
Back
Top Bottom