News:

  • August 27, 2026, 05:23:42 PM

Login with username, password and session length

Author Topic: Best way to write bits to DL  (Read 21338 times)

CReese

  • Hero Member
  • *****
  • Posts: 184
Best way to write bits to DL
« on: March 26, 2014, 02:36:24 PM »
Hello,

While I appear to be able to write TO a DL series PLC bit address or addresses from a DoMore using DLWX, I don't seem to be able to write FROM anything but word addresses. Does this mean I need to take my bits and put them into words on the DoMore side, or is there something I am missing?

Thanks,
Colin

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3843
    • Host Engineering
Re: Best way to write bits to DL
« Reply #1 on: March 26, 2014, 02:44:50 PM »
The DL protocol is a BYTE oriented protocol, hence you must specify a starting bit for the Source Do-more element that is on a BYTE boundary, and you must send a multiple of 8 bits (i.e. the instructions ask you for number of BYTEs, so 1 BYTE would be 8 bits).

That means using a numeric register OR a BYTE CAST on a BIT that is BYTE aligned, e.g. C0:UB, C8:UB, X32:UB, etc.

CReese

  • Hero Member
  • *****
  • Posts: 184
Re: Best way to write bits to DL
« Reply #2 on: March 26, 2014, 02:51:41 PM »
That's fine. What's the easiest way to cast 8 bits into a byte? Say they are non-contiguous, like one bit from a position in an array, one from a variable etc. If I choose to send a couple bytes of bits starting at, say, V2000, can I cast a bit into a specified position within the byte? That would be ideal. I can obviously hack a bit to word, send a word, and then convert back to bit, but then I'm sending 8x the data I need to.

Thanks,
Colin

CReese

  • Hero Member
  • *****
  • Posts: 184
Re: Best way to write bits to DL
« Reply #3 on: March 26, 2014, 02:54:14 PM »
I see. I can copy them to a contiguous memory location and then cast from the location using UB. That will work.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3843
    • Host Engineering
Re: Best way to write bits to DL
« Reply #4 on: March 26, 2014, 03:03:06 PM »
That's fine. What's the easiest way to cast 8 bits into a byte? Say they are non-contiguous
The most compact in terms of screen real estate: MAPIO.  The fastest execution: CONTACT/OUT COIL, CONTACT/OUT COIL, ...
« Last Edit: March 26, 2014, 03:04:48 PM by franji1 »

CReese

  • Hero Member
  • *****
  • Posts: 184
Re: Best way to write bits to DL
« Reply #5 on: March 26, 2014, 03:07:30 PM »
I went for contact/out.

Funny thing -- how do I get a DLWX to run every cycle? I have it in a program that exits after each completion, and it's set to run in main.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3843
    • Host Engineering
Re: Best way to write bits to DL
« Reply #6 on: March 26, 2014, 03:08:58 PM »
I went for contact/out.

Funny thing -- how do I get a DLWX to run every cycle? I have it in a program that exits after each completion, and it's set to run in main.
Is it using Stage?

CReese

  • Hero Member
  • *****
  • Posts: 184
Re: Best way to write bits to DL
« Reply #7 on: March 26, 2014, 03:16:16 PM »
Yes.

S0 : poke values, DLWX, S1/S2 Success/Fail
S1 : Success, JMP S3
S2 : Fail, JMP S3
S3 : EXIT

Runs once on switch to RUN, then not again.

CReese

  • Hero Member
  • *****
  • Posts: 184
Re: Best way to write bits to DL
« Reply #8 on: March 26, 2014, 03:23:55 PM »
I got it. JMP to S0 with timer. STILL wrapping my head around program execution.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3843
    • Host Engineering
Re: Best way to write bits to DL
« Reply #9 on: March 26, 2014, 03:24:27 PM »
If the "normal" behavior is to "poll", I would make S3 have a condition with a "keep polling" bit (say C100)

SG S3

STR C100  // if C100 is on, do it again
JMP S0

STRN C100 // if C100 is OFF, exit the program
EXIT


Then, $Main (or whoever) can STOP the polling by RESETTING C100.  Although to restart, you gotta SET C100 then RE-FIRE the RUN MyDLWXProgram (make the input into the RUN instruction go LOW then HIGH - it's LEADING EDGE triggered).

OR, if you want COMPLETE control in $Main (i.e. you aren't polling, but want to do it on an "event"), refire the "event" logic driving the RUN MyDLWXProgram.

CReese

  • Hero Member
  • *****
  • Posts: 184
Re: Best way to write bits to DL
« Reply #10 on: March 26, 2014, 03:29:06 PM »
Yes, typically what I do is have a <<routine>>Enabled bit, and in the last stage, a NC contact with EXIT. In MAIN then have a <<routine>>Enabled to RUN routine.

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6174
  • Yes Pinky, Do-more will control the world!
Re: Best way to write bits to DL
« Reply #11 on: March 26, 2014, 06:51:45 PM »
If you just want it to run continuously, just enable a box from $Main using interval mode set to 0ms.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

CReese

  • Hero Member
  • *****
  • Posts: 184
Re: Best way to write bits to DL
« Reply #12 on: March 26, 2014, 09:23:52 PM »
I'll have to revisit this again, but for some reason this did not work when I was performing network operations.

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6174
  • Yes Pinky, Do-more will control the world!
Re: Best way to write bits to DL
« Reply #13 on: March 26, 2014, 11:39:07 PM »
Unless the instruction is broken, there is no easier way to continuously write values. When in interval mode, the input leg is level triggered...runs while on.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO