Author Topic: 485 communication  (Read 16472 times)

ashish

  • Newbie
  • Posts: 25
    • View Profile
485 communication
« on: April 07, 2006, 04:11:05 AM »
i have a E10+ PLC.
i have a temperature controller which is having rs 232 port and sends temperature data out on this port.
i want to read  data from my temp. controller on RS 232 port of PLC (data length 52 bytes) and forward it through rs 485 port of PLC.
also i want to compare the temparature value with set value.
if 'ok' then one output should high (which is connected with green indicator) and if NotOk then another o/p should be high (which is connected with red indicator).
it needs only 2 outputs, 1 rs 232 port and 1 485 port.
how it could be done with E10+ PLC ? ( to read the data string on 232 port and out it in free dump mode to rs 485 port of plc.)

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:485 communication
« Reply #1 on: April 09, 2006, 01:03:33 AM »
E10 only has a single serial port (either RS232 or RS485 but not both) and it is a slave port only. i.e. The PLC is unable to output data through its serial port. What you want to do can only be accomplished using the T100MD888+ PLC which has two separate serial ports and the PLC has ability to respond to one port as slave and act as master on the other port.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

ashish

  • Newbie
  • Posts: 25
    • View Profile
Re:485 communication
« Reply #2 on: April 09, 2006, 07:33:53 PM »
thanks.
is it possible with T100MX+ also?

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:485 communication
« Reply #3 on: April 10, 2006, 08:31:10 AM »
Yes, T100MX will be able to do the same job. But the smallest T100MX PLC is T100MX-3224 which is much bigger than an E10.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

ashish

  • Newbie
  • Posts: 25
    • View Profile
Re:485 communication
« Reply #4 on: April 15, 2006, 11:47:25 PM »
i have a CNC controller with rs 232 port.
this controller sends data out on request.
my operational sequence is as follows :

1) send a requst string from PLC to CNC on 232.
     request string is in Hex format and string length is of  
    8 bytes. Ascii equivalent of hex should be sent
2) In responce to this string, CNC controller will reply and  
    send data of 70 bytes. Data is in BCD format.
3) PLC should read the data and pick the words from
    particular location in string i.e. seperate the string.
4)Set the digital I/O according to string value.
5) Generate next request. (repeat from step 1)

Communication boud rate is 9600 (or 38400 optional)

Is it possible to do this communication with H series PLC ?

i.e.  built a string, send on serial port, receive a string through same port, seperate and use for further process.
Also, whether transmit and  receive buffers are different? or same memory is allocated for both transmit and receive buffer ?


support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:485 communication
« Reply #5 on: April 17, 2006, 09:04:15 AM »
H-series also has a single serial port which is selectable as RS232 or RS485 via DIP switch #2. But this is a slave port only. i.e. it does not have the intelligence to send out user's program serial data to other devices to request for response. Only the M-series PLCs (T100MD+ and T100MX+) has such capabilities.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

ashish

  • Newbie
  • Posts: 25
    • View Profile
Re:485 communication
« Reply #6 on: May 02, 2006, 08:42:42 PM »

i have got T100MD88+ plc.
i am using it for receiving data from my CNC.
i send a request string from plc to CNC and in response CNC sends the data.
as mentioned in help, to read the received data from rs232 input buffer of plc i tried to used 'input#' command.
but my CNC do not send carrige return, at the end of string. hence this command does not work.
then i tried with 'incomm' command but it also does not work and do not read the data.

i tried communication of this plc with my pc with carrige return at end of string. it worked fine.
hence, if i do not have carriage return character at the end of string i receive, hoe to read this data from receive buffer?
this is very urgent. i am online waiting for reply.

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:485 communication
« Reply #7 on: May 02, 2006, 11:21:16 PM »
If your machine does not send CR, then you MUST use the INCOMM to read the characters one by one into a DM array so that you can then examine each DM register to try to find the data.

Note that INCOMM check the buffer and return the byte it sees or return a -1 if there is no data. So you have to put a loop to keep checking the buffer until you have received sufficient number of characters. For an example on how to use INCOMM, follow our example at:

http://www.tri-plc.com/trilogi/modbusFunction04.zip

The above implement a Modbus READ function in pure TBASIC and it uses the INCOMM to read the response from the MODBUS slave.


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

ashish

  • Newbie
  • Posts: 25
    • View Profile
Re:485 communication
« Reply #8 on: May 03, 2006, 09:39:39 PM »
thanks.
i tried with incomm function, but i am receiving lot of garbage data values which i am not getting able to decode.

(I AM DOING THIS COMMUNICATION THROUGH COMM1)

e.g.
1) i set up the program and i send a string "27" from my pc serial port.
i was expecting to receive these values in DM array but i receive some different numbers and values in DM array. it was not containing 27 or it's equivalent any way.

2) i switch off the plc and switch on again.
    after this action, i execute the function again without sending data from PC. still i got some data im DM array (actually nothing should be there since plc was power reset.)

3) how to clear the receive buffer of plc ? since no of time i execute the 'incomm' i get the data in DM array i am not sure that if plc input buffer is getting clear even after power reset

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:485 communication
« Reply #9 on: May 03, 2006, 10:34:12 PM »
Everytime you transfer a program or monitor through the comm port there are data stored in the serial buffer which are not deleted until they are read by INCOMM or INPUT$. So you need to clear the buffer before using it. A better solution is to use COMM3 or monitoring/programming and COMM1 for connection to other serial devices.

To clear buffer, put in a loop of INCOMM statement until you receive -1 and the buffer is cleared.

E.g.

    FOR I = 1 to 256
        IF INCOMM(1) < 0 Goto @5
    NEXT

    @5 '....... continue what you want to do.

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

ashish

  • Newbie
  • Posts: 25
    • View Profile
Re:485 communication
« Reply #10 on: May 04, 2006, 06:09:22 AM »
thanks.
i did it according to instruction.
i read the input buffer till i get -1.
even, after restarting, when i scan input buffer with incomm i found some data in dm array.

second most important thing is that, whatever data i send through external device (pc) serially, i do not found that data but lot of characters which do not have any significance with data sent.
e.g. i sent '92' from my pc.
when i scan input buffer using incomm i found following data in dm array :
48,88,62,2A,58,22,10,16...... there were 74 such numbers / characters in array. but nothing was there which shows atleast some relation with 92.

 for serial communication with pc, protocol was set  
 (by 'setprotocol' command) to NONE (10)

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:485 communication
« Reply #11 on: May 04, 2006, 09:04:35 AM »
Did you set the PLC's serial port to the same baud rate as that of the device it is attached to?

Unless your clear your DM it will still contain data from previous read.  If you are using MX-RTC with DIP switch #1 ON then the DM data are not cleared. Turn of DIP switch #1 and reset the PLC to clear the DM.

Try to use a PC program to monitor the output from the PLC to find out what data the PLC is sending. If the PLC is sending out ASCII data then you can monitor using the HyperTerminal program that comes with every Windows installation. But if the PLC is sending out non printable characters then HyperTerminal can't display them so you need a monitoring program that can display binary data in Hex format for easy ready.

You can find such program on the internet and many have free evaluation version. We also offer a version written in Java to our PLC customer if they contact us by email and furnish their purchase details.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

ashish

  • Newbie
  • Posts: 25
    • View Profile
Re:485 communication
« Reply #12 on: May 04, 2006, 09:48:52 PM »
1) plc boud rate is same as that of pc.

2) i cleared the DM completely (till -1) and then tried to
    receive the data

3) dip s/w is in off position.

 system is giving data with input command if i send data with CR. but facing this difficulty with incomm command only.

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:485 communication
« Reply #13 on: May 04, 2006, 10:14:40 PM »
INCOMM will receive data only if your device is sending data or noise to it. You will have to track down what data the device is sending to the PLC or is it noise. If it is noise where does it come from? If you remove the RS232 connection to the device and run the INCOMM you should not receive anything more after clearing the buffer. i.e. INCOMM will return -1 all the time since there is no incoming data.

We are confident that INCOMM works exactly what it is supposed to do and if you are receiving wrong data, you will have to check what's wrong with your connection.  You can check if the PLC serial port is working by using it for program transfer and online monitoring (pause the PLC program first so that it does not try to send data out of this serial port to prevent problem). If you are able to use it for communication with the PC, but hooking to your own CNC controller it receive wrong data, then the problem is likely to be your CNC controller or wrong settings.

Usually the problem of reading wrong data is caused by different baud rate, make sure that the device is not only same baud rate, but also same number of data bit, stop and parity as the PLC.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

ashish

  • Newbie
  • Posts: 25
    • View Profile
Re:485 communication
« Reply #14 on: May 08, 2006, 05:46:49 AM »
thanks for your long term reply and support.

the problem has been sorted out.

we was trying out this activity in simulation with pc brfore connecting to cnc.

activity was to send the data through on 232 port and then check the contents of dm array through on line monitoring window.

both the activities were done through same serial port.
hence the garbage data we was seeing was the instructions which plc is receiving from triology software after making the online monitoring window ON.

monitoring port and data port was same one.