Sign in to follow this  
Followers 0
mr_electrician

RS 232 Channel 2 on a Micro 1400

27 posts in this topic

Hi there. I have a micrologix 1400 that currently uses the ethernet port for PC and PanelView 1000 communication. I have a Keyence LJ G5001 controller that has an RS 232C port on it that I would like to use for data exchange to and from the plc. I tried to set up channel 2 on the plc and have DCOMM enabled but for what ever reason it doesn't seem to communicate. All the settings match such as baud rate and parity. Any ideas???? Edited by mr_electrician

Share this post


Link to post
Share on other sites
The Keyence controller speaks DF1 Full Duplex?

Share this post


Link to post
Share on other sites
Yes it does. See screen shot. My settings match on both PLC and Keyence. The only time I see any activity is when I set channel 2 to ASCII????

Share this post


Link to post
Share on other sites
This is where I see activity with communication, however I do not see the LED lit up for channel 2 on the micro1400.

Share this post


Link to post
Share on other sites
I must be missing it. I don't see the DF1 protocol listed on those two pages. Maybe you can point it out?

Share this post


Link to post
Share on other sites
The Keyence controller does Full Duplex RS232 ASCII not DF1. If you look on the screenshot of the first page under transmission code, you will see ASCII. Change your driver to ASCII and it should be good to go. The data exchage is not automatic! You will have to write logic to ask for the data, read the reply, and then parse it into something you can use in your program. In my experience with Keyence controllers, you will have to do a ASCII WRITE (AWT) of a string command that asks for specific data. Then you will need logic to read the serial buffers for return charactors (ASCII READ). The return data is in string format, so you will need logic to manipulate it into something usable. Hope this helps..

Share this post


Link to post
Share on other sites
I was looking on first screen shot-Communication Method:Full duplex, Transmission Code:ASCII

Share this post


Link to post
Share on other sites
Um????Oh Boy! That sounds complicated. Well wish me luck!!! Think you can get me in the right direction? I just want to tell it which of the 2 programs that reside in it to run, and to get a go/no go signal from it. The reason I am not able to use the actual outputs from the controller is because they sent an NPN instead of PNP controller. Edited by mr_electrician

Share this post


Link to post
Share on other sites
I would get a couple relays and call it a day.. I wouldn't go through the pain of writing the logic for the serial port to exchange discrete values. I had to get the measured value from the controller, so the serial port was the only option. It wasn't easy to get it working..

Share this post


Link to post
Share on other sites
I agree, use relays. I've used non-mechanical signal conditioners (opto-couplers) from Woertz (Phoenix Contact, Weidmuller, etc. should have them to) to change NPN to PNP. If you are intent on using ASCII, it's painful but doable. Just not really worth it for low-count digital information, especially since it's much more difficult to troubleshoot years down the road. I recently had to modify someone else's ASCII logic in a SLC 5/02 because the piece of equipment that it was talking to went bad. When the equipment was replaced, the ASCII protocols had changed, breaking the comms. To make matters worse, the "new" protocols were correct according to the 18-year-old manual I was sent! From what I could tell, the old equipment was sending extra characters that weren't in the manual!

Share this post


Link to post
Share on other sites
So, see picture below. But I to like the relay idea.

Share this post


Link to post
Share on other sites
Thank you. This is helpful and will keep this in mind for next time. This time is too late. I would have to rewire some of the PLC, change my program addressing, and CAD drawings. I will probably use opto's for now but am determined for my own self teaching skills to program with the ASCII commands. Edited by mr_electrician

Share this post


Link to post
Share on other sites
I had to communicate to a Keyence camera system using ascii to a PLC-5. It did work but was quite a bit of logic, and occasionally the serial connectino would stop working. I had to power cycle the vision system in order to get the serial port to work again whenever if locked up. This would happen about once a week if I recall correctly. I was working in "development mode", so it was not keeping the rest of the machine from running. This is something to keep in mind, if you have similar troubles with your serial connection, using digital inputs...even with interposing relays...might be much more reliable. Edited by OkiePC

Share this post


Link to post
Share on other sites
Thanks, I am just trying to learn what is needed to do a simple command. The book says to change program numbers write the command PWxxCR. (xx being the program #) So if I wanted to run program 6 for example I should write PW06CR. If I convert this ASCII in the plc to an integer it will show it as 6 but nothing happens to the controller. I know I am communicating because I can read the measured values in my ST bits using the ARD instruction. I know there is an easier way but I would still like to learn this type of communication and programming.

Share this post


Link to post
Share on other sites
Missing formatting characters, maybe, at the beginning or end of the string?

Share this post


Link to post
Share on other sites
I agree with JRoss. Are you sure the CR at the end of that string is literally those characters "CR"? Look again in your reference material to make sure they didn't say <CR> or [CR] as in "carriage return", ascii code 13 (decimal). Every ascii device I have talked to has expected some sort of termination character to identify the end of a packet, carriage return being the most common, sometimes LF (line feed ascii 10) is used...sometimes they get creative and want something totally odd-ball. Edited by OkiePC

Share this post


Link to post
Share on other sites
The keyence Laser Micrometer that I had to communicate with used a carriage return at the end of the command. Instead of the generic ASCII Write, try using the ASCII Write Append. This instruction appends (adds) a termination charater to the end of whatever you have in your string file. Go to your port communication settings and you will see a field for termination characters. Place the CR charater here and delete the default for the Termination Charator 2. This will add the CR to the end of every command sent using a ASCII Write Append instruction. Also, since keyence ends it's response with a CR you can use ASCII READ LINE instruction instead of ASCII Read. This will read everthing in the serial buffer up to the CR charater. I had the same issue as OkiePC though. It would stop communicating after a week or two. I added logic to clear everthing out and try to establish comms again. If that failed I opened a relay on the power to the Keyence controller. Since this is a in-process on machine quality check, the machine would be down until comms was restored. I'm looking into replacing the controller with a new version that has BCD outputs. Edited by noxcuses

Share this post


Link to post
Share on other sites
Thats excactly what i needed to know. I changed the settings and whala, it changes programs the way I want to!! Thanks a million for the info. Yes relays would be the simple way but that is no fun for me! I like a challange. Now I just have to figure out how to snag the go/no go signal!!!

Share this post


Link to post
Share on other sites
I am having trouble trying to figure out how to grab the values I need from the Keyence controller. I know I am going in the right direction though. If you you look at the screen shot you will see 2 values in ST9:0. One is 2.44 and the other is 2.45. How do I get those numbers into a real number that the PLC can see? I would like to do a compare on each so that if those numbers fall out of a range that I set then my logic is false.

Share this post


Link to post
Share on other sites
You'll have to parse it out using the various string commands and math commands. ASC to search the string for the position of the data (look for the plus sign, perhaps? unless the string is always the same format). AEX to pull the correct portion of the string (one for the integer part, one for the fractional part). ACI to convert each part of the number to integers. MOV to turn them into floats. DIV to turn the fractional portion to fractional. ADD to put the two parts together. We told this was painful! Edited by JRoss

Share this post


Link to post
Share on other sites
Thanks! As far as painfull??? I look at this a a challenge, new experience, and not choosing the easy way out.

Share this post


Link to post
Share on other sites
That's a really good attitude. Despite all my comments I agree with you. As tough as these nuts can be, there is nothing more satisfying than wrapping your brain around something new and making it work! That why I like what I do!

Share this post


Link to post
Share on other sites
Hi there, If I have a value of 2.55 in ST9:1, how do I go about making this a real number that can be used in a compare function?

Share this post


Link to post
Share on other sites
Actually I just figured it out. Crude programming but I am starting to understand and learn this method.

Share this post


Link to post
Share on other sites
Ok, I am at a total loss. I have tried and tried to make this work. I have no problems sending a command to the Keyence, but trying to read the responce seems to take a long time and the Keyence sends back a time out error. If I try it with hypertext then it works great. What would I be missing with the AB?????? I even tried clearing buffers before sending a comand and reading what came back. Also when I expand the ST file it really seems to lag down the computer speed??????

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0