News:

  • June 09, 2026, 08:16:23 AM

Login with username, password and session length

Author Topic: How do i move bits from 2 words (minutes/hours) into 1 word?  (Read 13647 times)

drakerebel

  • Newbie
  • *
  • Posts: 2
How do i move bits from 2 words (minutes/hours) into 1 word?
« 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.

b_carlton

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 606
    • thePLCguy
Re: How do i move bits from 2 words (minutes/hours) into 1 word?
« Reply #1 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
An output is a PLC's way of getting its inputs to change.

drakerebel

  • Newbie
  • *
  • Posts: 2
Re: How do i move bits from 2 words (minutes/hours) into 1 word?
« Reply #2 on: May 12, 2008, 03:57:50 PM »
thanks, that's the ticket! 8)

MikeS

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 264
    • Host Engineering, Inc.
Re: How do i move bits from 2 words (minutes/hours) into 1 word?
« Reply #3 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
Good design costs a lot. Bad design costs even more.

AZRoger

  • Jr. Member
  • **
  • Posts: 18
Re: How do i move bits from 2 words (minutes/hours) into 1 word?
« Reply #4 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  :)

b_carlton

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 606
    • thePLCguy
Re: How do i move bits from 2 words (minutes/hours) into 1 word?
« Reply #5 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.
An output is a PLC's way of getting its inputs to change.