Author Topic: TOGGLEIO Tbasic instruction  (Read 10203 times)

skj1402

  • Newbie
  • Posts: 28
  • The Innovator!
    • View Profile
TOGGLEIO Tbasic instruction
« on: September 15, 2005, 03:40:57 AM »
I have noted in an earlier forum article that there is a TBasic 'TOGGLEIO' instruction for the M series that allows an output to be toggled open and closed by the alternate pushing of an input. However, despite my many endeavours to find any reference to this very useful instruction in your 'documentation', I have come to the conclusion that it doesn't exist.....or does it? Because by placing the instruction in a Cusfn it does seem to compile.....but only on its own, as I've tried all kinds of syntax arrangements with it (references to various IO), but it then fails to compile.

Could you therefore please supply some syntax information for this instruction, and also could you let me know if there are any other useful Tbasic instructions that exist, which for some reason or other are also not documented? Thanks ???

skj1402

  • Newbie
  • Posts: 28
  • The Innovator!
    • View Profile
Re:TOGGLEIO Tbasic instruction
« Reply #1 on: September 15, 2005, 04:12:28 AM »
Shortly after I posted my query I somehow stumbled on a 'toggle.pc5' sample ladder file in the usr directory that gave me some information relating to this topic i.e. TOGGLEIO out3 being the example, where out3 is the label given to O/P 3.  So, could I also assume that I can use this instruction for say 'in3' too? And can it be used for relay contacts as well i.e. 'rel5', or is it confined just to the IO ports?

skj1402

  • Newbie
  • Posts: 28
  • The Innovator!
    • View Profile
Re:TOGGLEIO Tbasic instruction
« Reply #2 on: September 15, 2005, 04:38:29 AM »
Seems that I've answered my own questions by simple trial and error (again!).

By labelling the IO references either out(n) or in(n) then it works, but they don't if you label the IO either out_(n) or in_(n). Strangely (and fortunately) this also applies to relays too, which strictly speaking aren't really IO?

Ho hum....I do wish all of this had been documented though, it would have saved me so much time!

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:TOGGLEIO Tbasic instruction
« Reply #3 on: September 15, 2005, 06:06:55 PM »
You can refer to the SETIO, CLRIO &  TOGGLEIO command in the TRiLOGI Programmer's reference guide for description and example on how to use this function. These are really meant to be straightforward operation on an I/O label name.  

These functions are meant to work on the single bit element such as input bits, output bits, relay bits, timer bits and counter bits. So yes, you can use TOGGLEIO on the input bit, but what happen is that you are only going to change the input bit momentarily for the rest of the ladder logic up to the last rung. Once the CPU scan past the last rung of the ladder program, it will update its internal input bit status from the actual physical inputs. So the input will assume whatever real physical input status.

Likewise if an output relay, timer or counter is controlled by the other part of the program, then the TOGGLEIO will only change the bit at the moment of execution until it is being changed by other parts of the program.

I don't think you can use parenthesis in a I/O label name. So you should stick to using only A to Z and underscore for the label names.
« Last Edit: September 15, 2005, 06:08:51 PM by support »
Email: support@triplc.com
Tel: 1-877-TRI-PLCS