Author Topic: RS 485 Modbus programming  (Read 12218 times)

DLUN

  • Newbie
  • Posts: 18
    • View Profile
RS 485 Modbus programming
« on: January 21, 2010, 11:06:03 AM »
Hello Again.

I am trying to program my F1616 to  read the registers of my DC100 data collector trough an RS485 modbus connection on COMM2.

The register that I need to be read is 39002 of the data collector. The modbus protocol is RTU protocol. The data collectors address has been set using dip switches to 2 and has been tested with the original data collector program.

1st question. What am I missing in this code.
(initial scan I run this code)
SetBAUD 2, 3
(every second I use this code)
A = READMODBUS (12, 2,9001) ' this register is the seconds clock of the data logger
SetLCD 2,1, STR$(A)

2nd question.

Is their an LED that will tell me if I am transmitting and recieving over COMM2.

Thank you.


DLUN

  • Newbie
  • Posts: 18
    • View Profile
Re:RS 485 Modbus programming
« Reply #1 on: January 21, 2010, 12:38:20 PM »
I have continued to attempt to connect the the data logger. I now have LED LC2 and LC5 blinking on the board. I believe this means that I am both sending and recieving information from the data logger. However, I am trying to store those values in variable DM[1] and I am seeing now change to that memory location. Any ideas?

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:RS 485 Modbus programming
« Reply #2 on: January 21, 2010, 02:17:47 PM »
Yes, it seems like you have gotten a communication since you see both the Tx and Rx LED for COMM2 blinking on the F1616 PLC.

The data from location 39002 is read into variable A every second. If you want to store the data in DM[1], then just write:

DM[1] = A

If you want to store a number of data in DMs, use an index:

E.g. initialize I = 1 in 1st.Scan.

DM = A
I = I+1
IF I > 1000 THEN I = 1 : ENDIF  ' store 1000 values of A into DM[1] to DM[1000]
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

DLUN

  • Newbie
  • Posts: 18
    • View Profile
Re:RS 485 Modbus programming
« Reply #3 on: January 22, 2010, 10:38:50 AM »
For anyone following this thread.

I have found out why I was unable to get the input registers of the data logger (39007) even though I was sucessfully communicating (according to the indicator lights).

I needed to use the setsystem command so that I could set the default modbus command to function 4. This allows me to use the zero biase address off 30000 instead of 40000.

The command was entered on first scan is Setsytem 6,4

Well, off to the next problem.