Host Engineering Forum

General Category => Do-more CPUs and Do-more Designer Software => Topic started by: CReese on March 26, 2014, 02:36:24 PM

Title: Best way to write bits to DL
Post by: CReese 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
Title: Re: Best way to write bits to DL
Post by: franji1 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.
Title: Re: Best way to write bits to DL
Post by: CReese 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
Title: Re: Best way to write bits to DL
Post by: CReese 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.
Title: Re: Best way to write bits to DL
Post by: franji1 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, ...
Title: Re: Best way to write bits to DL
Post by: CReese 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.
Title: Re: Best way to write bits to DL
Post by: franji1 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?
Title: Re: Best way to write bits to DL
Post by: CReese 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.
Title: Re: Best way to write bits to DL
Post by: CReese on March 26, 2014, 03:23:55 PM
I got it. JMP to S0 with timer. STILL wrapping my head around program execution.
Title: Re: Best way to write bits to DL
Post by: franji1 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.
Title: Re: Best way to write bits to DL
Post by: CReese 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.
Title: Re: Best way to write bits to DL
Post by: BobO 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.
Title: Re: Best way to write bits to DL
Post by: CReese 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.
Title: Re: Best way to write bits to DL
Post by: BobO 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.