Author Topic: Serial Comms with LibertyBasic ???  (Read 15696 times)

Ray386

  • Newbie
  • *
  • Posts: 5
  • I'm a llama!
    • View Profile
Serial Comms with LibertyBasic ???
« on: January 20, 2009, 07:26:24 PM »
Has any one tried LibertyBasic to communicate with any type of PLC from trilogi?
Communication seems to only work with Qbasic.
When I use the same code in LibertyBasic PLC does not respond.

Yes i do give some wait time before looking at input.
Yes there is a command send out on the comm port. This is confirmed with other laptop and serial debug software.
So whay does this PLC "T44H-pnp" does not respond to the command chr$(5) or any other? The feedback is suppose to be an echo of what is sent.

Here is the code

[opencom]
    open  "com1:9600,n,8,1,ds0,cs0,rs" for random as #1

[sendwakeup]
    print "com 1 opened."
    print #1,chr$(5)
    timer 200, [timedown]
    wait
[ri]
    a$ = input$(#1,1)
    print "Feedback is >";a$
    close #1
    print "file is closed."
    end
[timedown]
timer 0
goto [ri]

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:Serial Comms with LibertyBasic ???
« Reply #1 on: January 20, 2009, 09:43:20 PM »
We have examples of Visual Basic 6 that you can download from:

http://www.tri-plc.com/applications/VBsample.htm
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

Ray386

  • Newbie
  • *
  • Posts: 5
  • I'm a llama!
    • View Profile
Re:Serial Comms with LibertyBasic ???
« Reply #2 on: January 20, 2009, 09:54:08 PM »
Not helpful as I am using LibertyBasic.

Ray386

  • Newbie
  • *
  • Posts: 5
  • I'm a llama!
    • View Profile
Re:Serial Comms with LibertyBasic ???
« Reply #3 on: January 23, 2009, 08:51:48 PM »
I have tried VB Express 2008 and I have the same issue.
i can write but the plc does not respond or the laptop can't catch it?
Only Qbasic can do it wright. But it's obsolete for gui programming.
Anyone seen this before?

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:Serial Comms with LibertyBasic ???
« Reply #4 on: January 24, 2009, 05:01:41 PM »
I am beginning to think the issue maybe that VisualBasic (or Liberty Basic??) does not automatically enables the DTR when the COM port is opened. The RS232 interface on the T44H is opto-isolated and it requires that the DTR pin (pin 4) of the PC's RS232 port be powered to drive the opto-isolated interface. In your program you MUST enable the DTR signal on the serial port so that there is a +9V voltage appear between pin 4 and pin 5 of the DB9 interface from the PC.

In Visual Basic you can enable the DTR of the serial port object (e.g. SerialPort1 in our case) using the following command:

      SerialPort1.DtrEnable = True
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

Ray386

  • Newbie
  • *
  • Posts: 5
  • I'm a llama!
    • View Profile
Re:Serial Comms with LibertyBasic ???
« Reply #5 on: January 25, 2009, 02:01:09 AM »
We are one step closer. Turning on the DTR I can now at least receive the ready byte chr(5) back from the PLC.
However When I do a read or write command nothing happens. I do not get feedback from the PLC on a read and writing commands no longer work and they use to with DTR off.???
Also if you have a copy of that code you can send me that would be great but I think I got it with the serial1.ReadExist and putting that in string variable. It?s just that nothing comes back in the serial buffer. See here the results from serial monitor. The working qbasic application is ?ntvdm.exe? and my VBExpress2008 is ?SCADA1.exe? Notice that I am sending the exact same hex code ?in red?. PLC Answers the wakeup 05 but fails to answer the RO00* command. Notice that with the other application in Qbasic ?ntvdm.exe?. It all works. I have tried slowing down with time between write and read with no effect.  Any ideas??



Port opened by process "SCADA1.exe" (PID: 2056)
Request: 1/25/2009 04:40:42.54664 (+78.5313 seconds)
 05                                                .              

Answer: 1/25/2009 04:40:44.62464 (+2.0781 seconds)
 05                                                .              

Request: 1/25/2009 04:40:44.62464 (+0.0000 seconds)
 52 4F 30 30 2A 0D                                 RO00*.          

Port closed

Port opened by process "ntvdm.exe" (PID: 5412)
 05                                                .              

Answer: 1/25/2009 04:41:38.95264 (+0.0156 seconds)
 FF 03 AA 05                                       ?.?.            

Request: 1/25/2009 04:41:38.95264 (+0.0000 seconds)
 52 4F 30 30 2A 0D                                 RO00*.          

Answer: 1/25/2009 04:41:38.96864 (+0.0156 seconds)
 52 4F 30 39 2A 0D FF 03 0A                        RO09*.?..      

Port closed

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:Serial Comms with LibertyBasic ???
« Reply #6 on: January 25, 2009, 08:13:14 AM »
You can now download a sample program written using VB 2008 Express from the following link:

http://www.tri-plc.com/applications/VBsample.htm#VB6sample

Run the project "SerialCommTest.vbproj" and you will be able to send hostlink commands from the command prompt and get a return string from the response string. You can simply add the Serial.vb and Serial.Designer.vb to your own project and use the function "sendCommand" to send out your command string and obtain a response string.

We recommend using only multi-point command for all communication except "IR*" if you do not know the ID of the PLC. It is one less exchange and therefore works faster and better. The built-in error check also makes the communication more robust.
« Last Edit: January 25, 2009, 09:46:48 PM by support »
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

Ray386

  • Newbie
  • *
  • Posts: 5
  • I'm a llama!
    • View Profile
Re:Serial Comms with LibertyBasic ???
« Reply #7 on: January 25, 2009, 04:28:25 PM »
This code works, thanks. Now Allo I have to do is figure out why it works.