Host Engineering Forum

General Category => DirectSOFT => Topic started by: drakerebel on April 29, 2008, 10:12:18 AM

Title: How do i move bits from 2 words (minutes/hours) into 1 word?
Post by: drakerebel on April 29, 2008, 10:12:18 AM
could someone tell me how i could place the bits from 2 different words (one being minutes and the other hours from the plc time stamp) into one word  i.e.: V1200 (0039)  and  V1201 (0010)  into V1202 (1039) which would mean 10:39.  i don't want to do a shift left or right because i would like to condense bits of words into one word and i'm running into a roadblock which maybe i can't even do.  any help?  thanks.
Title: Re: How do i move bits from 2 words (minutes/hours) into 1 word?
Post by: b_carlton on April 29, 2008, 10:44:51 AM
Assuming DL06 - source PLC Real Time Clock

LD V7770 - Hours
MUL K100
ADD V7767 - Minutes
OUT V1202
Title: Re: How do i move bits from 2 words (minutes/hours) into 1 word?
Post by: drakerebel on May 12, 2008, 03:57:50 PM
thanks, that's the ticket! 8)
Title: Re: How do i move bits from 2 words (minutes/hours) into 1 word?
Post by: MikeS on May 13, 2008, 08:39:56 AM
using a SHFL K8 instead of the MUL K100 will accomplish the same thing, and use less of CPU time doing it - it's not much time, but if you've ever been in a position where you needed to minimize the PLC scan, you'll take every few ms anywhere you can get them.

I'm not sure why you didn't want to use shift left or shift right to pack the bits and/or bytes into words, but hey .... to each his own
Title: Re: How do i move bits from 2 words (minutes/hours) into 1 word?
Post by: AZRoger on June 01, 2008, 11:58:31 AM
... and ADD is 10 times slower than OR ...
So the fastest way would be LD then SHFL then OR  :)
Title: Re: How do i move bits from 2 words (minutes/hours) into 1 word?
Post by: b_carlton on June 01, 2008, 02:04:35 PM
Regarding SHFL versus MUL and OR versus ADD both MikeS and AZRoger are entirely correct. To me the MUL and ADD is more natural but the time impact of doing that way is very great. Time for an old dog to learn some new tricks.