Author Topic: use DELAY in dcusfn and cusfn  (Read 6873 times)

kenobe

  • Jr. Member
  • Posts: 66
  • I'm a llama!
    • View Profile
use DELAY in dcusfn and cusfn
« on: January 07, 2009, 04:18:50 AM »
Hi
Is it possible to use TBASIC DELAY command in dcusfn or cusfn?
I am using t100md 888 tbasic language

my dcusfn is as follow

setio out1
delay 50
clrio out1

and by cusfn is as follow

setio out2
delay 50
clrio out2

result is : non of the out1 or out2 turns on!
what should I do in the cusfn or dcusfn to turn on an IO for 5 seconds and turns it off?

Thanks ??? ??? ???

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3171
    • View Profile
    • Internet Programmable PLCs
Re:use DELAY in dcusfn and cusfn
« Reply #1 on: January 07, 2009, 09:37:11 AM »
SETIO and CLRIO only set the internal bit, the external output only get updated during I/O scan. So what you are doing only change the internal bit and not the physical output. To force a I/O refresh you can use the REFRESH command or let the function exit and at the end of the ladder scan will be followed by I/O scan.

You should use timers to achieve time delay. Using DELAY  function to delay for 5 second is a bad idea since the rest of the PLC program stops while waiting for the time to expire.

If you are not familiar with using timers in ladder logic try to consult some basic ladder logic programming books or website such as www.plcs.net  - the TRiLOGI simulator let you quickly test out your program that involves timers and it is not hard to visualize that once you have tried some examples.


« Last Edit: January 07, 2009, 09:39:39 AM by support »
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

ccdubs

  • Full Member
  • Posts: 116
    • View Profile
Re:use DELAY in dcusfn and cusfn
« Reply #2 on: January 07, 2009, 10:33:03 AM »
On a similar note regarding update of I/O. If I am communication via MODBUS at what point do the DM registers get updated. Is this also only during the I/O scan?

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3171
    • View Profile
    • Internet Programmable PLCs
Re:use DELAY in dcusfn and cusfn
« Reply #3 on: January 07, 2009, 11:32:05 AM »
DM registers have no external "physical I/O" so the DM memory location is updated immediately the moment it is written to whether it is via Modbus or host link commands.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

ccdubs

  • Full Member
  • Posts: 116
    • View Profile
Re:use DELAY in dcusfn and cusfn
« Reply #4 on: January 07, 2009, 11:46:51 AM »
OK so if I want to be sure a DM value doesn't change mid scan due to unsynchronised MODBUS comms I would need to map MODBUS DM registers to some other DM registers at the begining of the scan?

Is there any chance that the program can access a DM while MODBUS is writing to it? If so what happens then?

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3171
    • View Profile
    • Internet Programmable PLCs
Re:use DELAY in dcusfn and cusfn
« Reply #5 on: January 07, 2009, 10:12:56 PM »
The CPU processes the host link communication as a function call in between processing of TBASIC statements and not via interrupt processing. So it will not affect a TBASIC operator that is in the midst of accessing a variable.

If you want synchronous data for a DM throughout the scan then you do have to copy the data of the DM for processing from a DM that can be changed by MODBUS.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

kenobe

  • Jr. Member
  • Posts: 66
  • I'm a llama!
    • View Profile
Re:use DELAY in dcusfn and cusfn
« Reply #6 on: January 08, 2009, 05:42:59 AM »
Thanks guys