Author Topic: LCD and TBasic  (Read 9633 times)

CYBERTEK007

  • Newbie
  • Posts: 6
  • Cool
    • View Profile
LCD and TBasic
« on: April 24, 2006, 07:50:43 AM »
I am trying to learn the TBasic and LCD comand structure.
and am trying to use the relays() to fire off the lines of text using 1  function #255 to script all text to LCD.

If Relay (1) then setlcd 1,1, "hello"
If Relay (2) then setlcd 2,5, "hello"
If Relay (3) then setlcd 3,10, "hello"
If Relay (4) then setlcd 4,15, "hello"
If Relay (5) then setlcd 0,0, "clear screen"

Ect Ect this will let me build a library of commands,text messages, and special efects all located in one function

The problem is it does not work.
Is there a better Way?

The reason i am trying to use the Relays is there is 512 of them or so it says.

Help Please



 

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:LCD and TBasic
« Reply #1 on: April 24, 2006, 11:14:31 AM »
There is no function such as Relay(1) or Relay(2). This is an incorrect way of referencing the relay bits.

You can reference relay bits in two ways:

IF TESTBIT (RELAY[1], 0)   ' for relay bit #1
IF TESTBIT (RELAY[1], 1)   ' for relay bit #2
....


OR if you have defined a label name for a relay bit, then use TESTIO.

IF TESTIO(rlyname1)
IF TESTIO (rlyname2
....

Note that if you keep a lot of text string, your function could consume a lot of program memory very quickly.

A better way could be to first write a program to store the strings inside the EEPROM using the Save_EEP$ command,

You can then retrieve the EEPROM content using the LOAD_EEP$ and specify the location of the string.

So in all other parts of your program, you just have to supply the string location via a variable (e.g. N = 5 to retrieve the 5th string variable) to call function 255 and function 255 only need a single statement:

  SETLCD 1,1, LOAD_EEP$(N)

this is assuming that you don't need to change position. Of course you still can use the IF THEN ELSE or compute the row/column position based on the value of N.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

FQ-ONG

  • Jr. Member
  • Posts: 61
    • View Profile
Re:LCD and TBasic
« Reply #2 on: June 17, 2006, 03:15:25 AM »
Two more errors:
IF without ENDIF
setlcd 0,0, "clear screen" is wrong command, check the setlcd example program for correct clear screen command.

Please check the program size available on your PLC, you should not over the mark.

Thank you