Author Topic: Serial Communications Issue  (Read 12342 times)

keith

  • Newbie
  • Posts: 5
    • View Profile
Serial Communications Issue
« on: October 05, 2009, 06:23:31 AM »
Hope somebody can help me with a little serial communication problem I?m having. I wrote a simple front end to a touchscreen application in Visual Basic 2008 for interface with T100MD. Works great but now I?m trying to send the T100MD a control code in the form of simple Ascii string through the PC?s com port, per the following:


SerialPort1.Open()
SerialPort1.WriteLine(TextBox1.Text)

No difficulty getting the data out to the device ? as verified with my terminal program. My problem is that in order to correctly impement the instructions, the 888 requires a carriage return as part of the host-link command terminator. I cannot find any T100MD setting or Visual Basic reference that will add the CR after the string and I know I?m not the first to run into this. Any help that could be given would be very much appreciated.

Thanks

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:Serial Communications Issue
« Reply #1 on: October 05, 2009, 11:47:20 AM »
You may like to download the Visual Basic Express 2008 samples and see how the working code control the serial port:

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

In fact you can simply add the sample object to your program which makes a very nice serial setup interface that is ready to go.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

EDGAR

  • Jr. Member
  • Posts: 60
  • Automating concepts around the world!
    • View Profile
    • Kinemics
Re:Serial Communications Issue
« Reply #2 on: October 05, 2009, 03:28:47 PM »
In Vb did you tried constant keyword 'vbCr' or Chr$(13)? Im not sure in the TM but Chr(13) should work in the TM100MD.

check the ascii table here http://www.asciitable.com/ and tri the function CHR(decimal index from the table)

Hope this works,
Ed
Low cost Modbus OPC DA Server, supporting Modbus RTU, ASCII, and TCP. Download your demo today! Go to www.kinemics.com/modbus.

EDGAR

  • Jr. Member
  • Posts: 60
  • Automating concepts around the world!
    • View Profile
    • Kinemics
Re:Serial Communications Issue
« Reply #3 on: October 05, 2009, 03:31:23 PM »
Sorry forgot sample

in VB:
Dim x As String
x = "Hello" & VbCr
or
x = "Hello" & Chr$(13)

In TM100:
A$ = "Hello" + Chr(13)

Low cost Modbus OPC DA Server, supporting Modbus RTU, ASCII, and TCP. Download your demo today! Go to www.kinemics.com/modbus.

keith

  • Newbie
  • Posts: 5
    • View Profile
Re:Serial Communications Issue
« Reply #4 on: October 05, 2009, 05:38:11 PM »
 ;D

Edgar was right on the money! Adding the vbCr makes host link commands simple to transmit and quite reliable. Thanks to you Edgar.