bit shifts

W

Thread Starter

wjmosesjr

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...
5
Replies
2,685
Views
I recently changed my laptop battery and it seemed to trigger bit locker. I never turned on bit locker, because I would have saved the keys when...
3
Replies
212
Views
I just tried to update a L61-v20 program to an L81-v34 and I found that addressing a REAL to the bit level is no longer allowed? Can any one...
11
Replies
247
Views
I’d like to hear from others about their experience with the GE MDS Orbit ECRL9, particularly compared with the older MDS 9710. Of the 18 GE MDS...
0
Replies
95
Views
Hello. I am currently working on recreating a FactoryTalk Optix project as a FactoryTalk View SE project (customer request). The PLC code should...
0
Replies
159
Views
Top