Host Engineering Forum
General Category => DirectSOFT => Topic started 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.
-
Assuming DL06 - source PLC Real Time Clock
LD V7770 - Hours
MUL K100
ADD V7767 - Minutes
OUT V1202
-
thanks, that's the ticket! 8)
-
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
-
... and ADD is 10 times slower than OR ...
So the fastest way would be LD then SHFL then OR :)
-
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.