Jump to content

Access PLC memory by using AVR microcontroller


Recommended Posts

Posted
Hi everyone: My hardware : AVR(Atmega16A) + Maxim 485 IC ------------RS-485-BD + FX 1N. I have a problem when I use AVR microcontroller to communicate with PLC. When the protocol is computer link, they work perfectly, AVR can read or write data from/to PLC. But when I use RS instruction(non-protocol) to communicate, things become wrong, PLC can't receive data from AVR and the RD+ LED on RS-485-BD dosen't flash at all. When PLC sent data to AVR, the SD+ LED flash, but AVR receive no data. I am sure the character format and baudrate are right, my PLC ladder show below. Can anyone tell me why PLC go wrong when using RS instruction. I suppose my PLC got some problems , after all , it is second-hand. But I don't have another one in hand to check that . thanks in advance.

Posted
I must admit I haven't studied your ladder pictures, but did you remember to power-cycle the PLC after changing from ComputerLink to NoProtocol so that the BD card is initialized with the new, correct parameters?
Posted
OK, by the pictures it looks like everything is in order so to start debugging we should skip as many possible "problems" as we can. If you connect the PLC to a RS485 converter or similar to your computer can you receive any data using a standard serial console? In essence I would like you to connect the PLC to a computer running a terminal without any response code so that we can see if the PLC actually sends any data at all.... Is that possible?
Posted
Sorry,Mr Kaare_t, for replying to you so late. Today?I do what you advice. I connect PLC to my computer through a RS485-USB converter, my software on computer is VB6. The program(shows below) written in VB6 will display "ok" characters on testbox when it receives any data from PLC . Unfortunately, it doesn't work, when PLC sends data to computer, nothing is displayed on the textbox. but oddly, PLC can receive data send from computer, and its register value can be changed, that is what I have observed. It is the RS instruction(none protocol) been used on the PLC side, when I change it to computer link protocol, the communication works normally again. I am going to be mad about the RS instruction... ...
Posted
Don't give up, it can be done. I did it with a Microchip controller many years agoo. The PLC was (if I remember correctly) a FX1S with a 485 BD card. PLC was master and a couple of external Microchip controller where slave units. Communication settings: 9600, 8, N, 1 Don't think the PLC software is on my computer today, but it was done with GX IEC Dev. 7.x What PLC software are you using ?
Posted (edited)
I use GX Works2 1.77F. Now, I am going to find another PLC to try it. By the way, what protocol did you use? Modbus? Edited by M1923
Posted
No, it wasn't Modbus, it was a "home made" protocol. I'm currently working on a protocol called Excom (very old) to transfer data to a bunch of ancient cooling compressors. It will be done with RS instructions. I use GX IEC Developer 7.04 today, I have GX Works 2 on the computer too. But everything I do is quicker and easier with GX IEC Dev. Are you going to use Modbus RTU to your AVR?
Posted
I opened the communication manual today to check some things. Then did I think about your communication problem. What value do you have in D8400 and D8401 ?? Can't find them in your ladder.
Posted
I set the communication format by using parameters, instead of writing data to the register.These two way which I have already tried, unfortunately, don't work at all. Actually, it is the D8120, not D8400 or D8401, I should deal with when use RS(not RS2) instruction. Yes, I am going to use Modbus RTU, it seems to be used widely in inverter, printer,and so on.
Posted (edited)
Then try this for master communication Or this one for slave communication There are some program examples that are easy to use for your communication. It's for GX Works II Edit: Corrected Links Edited by Bryll
Posted
Thanks, Mr Bryll, it will be very helpful. I find the problem at last, my PLC goes wrong. I try another one, then the communication back to normal. There is no surprise, this sort of things happen in China. Thank you for all your concern, guys.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...