Author Topic: How to open serial port in basic coding  (Read 12633 times)

Tito

  • Newbie
  • Posts: 48
  • Think
    • View Profile
How to open serial port in basic coding
« on: August 09, 2012, 06:57:19 AM »
Hi I am trying to open serial port by using basic coding. I am quite new for basic coding. Please do assist me. Hardware FMD88-10

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:How to open serial port in basic coding
« Reply #1 on: August 09, 2012, 08:08:52 AM »
In TBASIC there is no need to open the serial port since it is dedicated and it is always open.

So you simply use the PRINT #n or outcomm n, x to send ASCII or binary data out of the serial port n and use INPUT$(n) or INCOMM(n) to read ASCII string or binary data from serial port #n.
 
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

Tito

  • Newbie
  • Posts: 48
  • Think
    • View Profile
Re:How to open serial port in basic coding
« Reply #2 on: August 10, 2012, 02:55:09 AM »
Hi, In my serial, i am connecting GSM modem. My GSM modem setting is the Baud rate is 115200, Databits 8, Parity None, Stop Bits 1.

How I can set this to my port before send Commands

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:How to open serial port in basic coding
« Reply #3 on: August 10, 2012, 10:23:28 AM »
Check the SETBAUD command.

To change baud rate to 115,200, 8, n, 1

SETBAUD 1,9

Email: support@triplc.com
Tel: 1-877-TRI-PLCS

Tito

  • Newbie
  • Posts: 48
  • Think
    • View Profile
Re:How to open serial port in basic coding
« Reply #4 on: August 10, 2012, 10:50:22 AM »
Hi, After go through in User Manual, I did set as :-
SETBAUD 1,&H9,
is that make different with SETBAUD 1,9
Please do advice.
Do i have to do anything with Dip switches? I am using FMD88-10 board.
« Last Edit: August 10, 2012, 10:51:35 AM by Tito »

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:How to open serial port in basic coding
« Reply #5 on: August 10, 2012, 11:11:47 AM »
&H9 is the hexadecimal representation which is the same as decimal 9.

You don't have to do anything else. You need to run the SETBAUD 1,9 once only in order to change the serial port #1 to the desired baud rate. After that you can use PRINT # command and Input$() command at the new baud rate until power is reset to the PLC.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

Tito

  • Newbie
  • Posts: 48
  • Think
    • View Profile
Re:How to open serial port in basic coding
« Reply #6 on: August 10, 2012, 11:25:04 AM »
 :) Thank you.