Author Topic: recieving ASCII charcters  (Read 5784 times)

scottsaunders

  • Guest
recieving ASCII charcters
« on: April 20, 2003, 03:36:48 AM »
I have a T100MD888 PLC and with a Motorola 68HC12 microprocessor connected to it through the RS232 connection.

I would like to recieve an 8 bit value from the microprocessor but after looking at the help file I don't think this PLC has the capabilites to do it.

Therefore I would like to set the PLC up to recieve an ASCII character just to demonstaete that communication is possible, this is for the final part of my uni degree project as I have to prove that the PLC will read information from the microcontroller.

I've asked this question before and this was the answer you gave me:

 
Quote
You can use the ?
 
A$ = INPUT$(1) ?
 
command to receive ASCII string inputs that are terminated with CR (ASCII 13, carriage return). This function returns an empty string if there isn't a completed string in the buffer. You need to execute this command periodically until you don't see a empty string.
.

I tried this but nothing happens. I'm telling the microprocessor to send ASCII character $35 (decimal 5) then to send ASCII 13. I tried to program the PLC to read the value. I set up one line of ladder logic saying if switch one is on run dCusF. The custom function said "A$ = INPUT$(1)". I am assuming this means read input and store in variable A.

I don't have the hardware on my PC to use the RS485 connection on the PLC so I'm having to swap the RS232 cable between the PC and the microcontroller. Will this be affecting it?

I quick response would be grateful because my project is due to be finished by Thursday. ?:-/

Thank you

Scott
 ;D
« Last Edit: December 31, 1969, 04:00:04 PM by -1 »

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3171
    • View Profile
    • Internet Programmable PLCs
Re: recieving ASCII charcters
« Reply #1 on: April 21, 2003, 09:42:10 AM »
Contrary to your statement, the T100MD888+ PLC is fully capable of receiving binary data using the INCOMM command. It will return whatever binary data it receive one character at a time until buffer is empty and then it will return -1.

Do you have an LCD display? If not, how are you going to show the characters received by the PLC? You can't use the same COMM port for receiving character from the 68HC12 and use it for on-line monitoring because the TRiLOGI software online monitoring sends commands continuously to the PLC and will fill up the buffer quickly.

For what you tried to do (i.e. to have the PLC received the ASCII character for "5" followed by a CR), you can use a clock pulse to periodically check the serial port input and find out if you receive the string "5". If so, turn on an output:
   Clk:1.0s                     Fn_#1
|--||----------{dCusf}

within Fn_#1:

A$ = INPUT$(1)
IF LEN(A$)<> 0
   IF VAL(A$)=5  
        SETIO  OUT1
   ENDIF
ENDIF

If the PLC receive the string "5" it will convert it into integer if it finds that the value received is indeed equals 5 it will turn on the output with label name "OUT1". (You need to define an output with the label name "OUT1" for the program to compile properly.)

There are also many factors to consider for a successful communication. The baud rate and communication format settings must be the same for both the PLC and your 68HC12 board.  You have to make sure that everything are set up properly before trying to verify the communication result.

« Last Edit: December 31, 1969, 04:00:00 PM by 1076562000 »
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

scottsaunders

  • Guest
Re: recieving ASCII charcters
« Reply #2 on: April 22, 2003, 12:56:26 AM »
Thank you, much appreciated! I'll go try it.
« Last Edit: December 31, 1969, 04:00:00 PM by 1076562000 »