PDA

View Full Version : PLC Interfacing with PIC



skian85
- 5th June 2008, 06:32
Hi all,

This is my first post. Thanks in advance for helping me out.

I am a user of both PLC (Ladder diagram) and PIC (PIC Basic PRO) using Keyence, IDEC PLC 24VDC and PIC16F877A. I am working on a machine process display project that monitors the process of a machine and displays the current process and errors using an LCD display. I plan to use PIC16F877A to monitor the inputs and outputs of my PLC, process the signals and display the current process at the LCD display.

By doing that, I need to tap the 24VDC signals from PLC into PIC 5VDC. The problem is how can I convert 24VDC signal into 5VDC ? I am researching on optocouplers and zener diodes. Is there any simple and effective way of doing that? Any ideas are much appreciated.

PJALM
- 5th June 2008, 10:32
You sound like your on the right track with the optos. I have made a few projects involving PLCs but I always interfaced to them using RS485 but I guess yours doesn't have that option.

You shouldn't have a problem using optos to interface to the 24VDC but I don't think you need any diodes just the optos and some matching resisters but I could be wrong.

Archangel
- 5th June 2008, 17:13
Hello skian85 and Welcome,
The opto's are a good way, a perhaps simpler and cheaper way is to use a 78L05, regulator.They are in a TO92 package 3 wires.

locko
- 5th June 2008, 18:32
Hello skian85 and Welcome,
The opto's are a good way, a perhaps simpler and cheaper way is to use a 78L05, regulator.They are in a TO92 package 3 wires.

Hah! I would never have thought about using a 7805 for that purpose..... Nice!
I will never forget this one, hehehe

tenaja
- 5th June 2008, 20:56
Hah! I would never have thought about using a 7805 for that purpose..... Nice!
I will never forget this one, hehehe

It's cute, but with a PLC, I would go with the opto isolators. PLC's often switch relays and other noisy things in noisy environments, so you are probably much better off making sure you get a clean signal to your PIC.

mackrackit
- 5th June 2008, 23:53
It's cute, but with a PLC, I would go with the opto isolators. PLC's often switch relays and other noisy things in noisy environments, so you are probably much better off making sure you get a clean signal to your PIC.
How would a 7805 be a problem? I would think it would actually clean the signal with a cap or two.

tenaja
- 6th June 2008, 00:24
How would a 7805 be a problem? I would think it would actually clean the signal with a cap or two.

It will clean up one a bit, but PLC's are typically used in the most notoriously dirty environments, from an electrical standpoint. It may work for many applications (i.e. a quick & dirty fix), but an opto-iso is a better choice.

Norbac
- 6th June 2008, 03:03
Hi, I think a 7805 could be a solution for the output from the PLC to the PIC, but what about the output from the PIC to the PLC?
I still prefer the optocoupler solution for both sides.

Alfredo

PJALM
- 6th June 2008, 18:34
Please don't go with the 7805. I tried this and was bad idea, i couldn't hunt down a counting problem i was having and it turned out to be the regulator. Regulators will only work if your inputs don't change very fast, the regulators are kinda slow. I used it to interface to a gear sensor and was losing a lot of pulses. Def stay with the optos. Good isolation and reliable.

falingtrea
- 6th June 2008, 18:35
Does your PLC have some kind of monitor function from a serial port? You could just hook up the PIC to the PLC serially then and just process the monitor codes the PLC sends out.
Or are you planning to use the PIC to watchdog the PLC?

Otherwise, using optos is the best way. All the signals to the PIC would be inputs, because you are monitoring the inputs and outputs of the PLC. So the optos would be all connected the same way, with the LED connected to the PLC signals on the anodes through a current limiting resistor, and gnd on the cathodes. Pick your resistor so you get minimum on current for the LED with about 5VDC and less than maximum with 24VDC. Remember that the LED has a forward voltage that needs to be subtracted before you calculate the current though the resistor. On the PIC side, connect the emitter to gnd and the collector to +5VDC though a 500-1k ohm resistor. Connect the PIC pin between the resistor and the opto collector. This will create an inverter, so remember to invert the signals in the PIC code.

PJALM
- 6th June 2008, 18:39
How would a 7805 be a problem? I would think it would actually clean the signal with a cap or two.

The cap is even worse. It can hold the input signal in a given state and cause false sensor readings. When it comes to PLCs, do it right and use optos for input and either optos or solid state relays for the outputs. The last thing you want is to go through the programming over and over trying to figure out why your timings are wrong.

rhino
- 7th June 2008, 00:00
If you're looking for an "off the shelf" solution (which most of us are not) look at opto22 modules or similar.

tenaja
- 7th June 2008, 00:30
I've used quite a few Opto22 modules. (Opto's plant is just across the street from me.) They work well, but check the spec sheet on timing, if you need high speed.

On my last project, I used Grayhill's Opto22 pin-compatible modules, and saved quite a bit of money. They worked just as well as Opto's.

skian85
- 12th June 2008, 17:29
Thank you so much for all your advise. I will try them. Maybe i can use zener diodes to replace LM7805. I appreciate your effort and time.

George
- 19th June 2008, 07:43
Just use a resistor! The input pin is limited to vcc so a resistor works quite well and is very cheap and simple - if the output of your PLC is left floating you may have to tie it down with another resistor. I've used a resistor straight into a PIC from 240Vac for sensing the zero crossing to synchronize firing a TRIAC (I think I used some where in the region of 200k). It seems so wrong I know, but it really works well and is simple.

George
- 19th June 2008, 23:05
Just make sure with yr resistor you don't exceed 20mA - try keep it down to 1-2mA