Arduino as a PLC

Hello everyone,

I am new to this forum and to electronics in general, so please be warned that you may encounter some rather stupid questions or comments in my postings. :slight_smile:

I am trying to build a machine that requires high-amp AC motors (15 amp) and temperature control. I was on the verge of buying a PLC for this purpose when I, quite accidentally, came across the Arduino project.

My first question is this, is it possible to control a something like this with an Arduino board?

I understand that I will need to use transistors to run 24v circuitry from the 5v pins, but I need to run up to ten different motors/solenoids, with an equal number of inputs (position sensors, RTD's, push buttons, etc.), simultaneously.

Will the Arduino (Mega?) be able to handle all of this?

Thanks for reading through this.

Pokey

It sounds like you've come to the right place.

I am pretty confident what you wanted to do can be achieved using either an Arduino or ArduinoMega (with Arduino, you will just have to add an IO expander so that you have enough pins).

My first question is this, is it possible to control a something like this with an Arduino board?

Well certainly an Arduno could be used with suitable external I/O components to handle the higher voltage/current devices. However an Arduino and a PLC are quite different in how you program them. An Arduino program is written in the C/C++ language while a PLC is normally programmed in a visual language called ladder logic. If you have no experience with industrial controls and programming in general I would recommend the PLC path, especially if this is a commercial for profit project. PLC usually come with industrial certifications and have lots of safety features suited for industrial applications.

If however it's just a hobby project for yourself then the Arduino platform can be a lot of fun and probably cheaper to get started.

Lefty

Thanks for the replies.

It sounds as though the Arduino has enough oomph to get the job done. I actually prefer a real programming language over ladder logic or function block diagrams—it is much easier to specify exactly what one needs.

My next question is more explicitly technical (and reveals my lack of expertise); what transistor should I use to control circuits with a spec of 24v 2amp? And how do I wire them?

P.S. This is not a for-profit project. My main reason for pursuing the Arduino course is cost.

Thanks.

A simple transistor (or MOSFET) switch would not be able to serve as a switch in your scenario since 5V is likely to be too low of a voltage to fully turn the transistor on.

A simple solution is to use an optocoupler (like 4N25, etc.), the emitting diode can be connected to the 5V logic and the other side can be used to turn on a more powerful transistor (like TIP35C) can be used as the switch.

I personally prefers MOSFETs for their low on-resistance. If you are using MOSFET (IRFZ20 can handle your load easily), you can refer to (http://www.kerrywong.com/blog/wp-content/uploads/2010/02/serialportctrl.png) as an example for how to hook it up (just replace the relay with your motor).

A simple transistor (or MOSFET) switch would not be able to serve as a switch in your scenario since 5V is likely to be too low of a voltage to fully turn the transistor on.

I thought that's what logic-level MOSFETs were for, to allow you to use a TTL signal (instead of larger voltage levels like many MOSFETs need)?

:-?

Hmm cr0sh, do you have a particular model number in mind?

IRL520 for example is a logical level MOSFET, but if you look at its operation curves (IRL520 Datasheet pdf - 100V Single N-Channel HEXFET Power MOSFET in a TO-220AB package - International Rectifier) you'd see that 5V is not enough to maintain a fully on state, at least not when there's significant drain to source current....

Hmm cr0sh, do you have a particular model number in mind?

No, I don't - but the one you provide below will do for the discussion...

IRL520 for example is a logical level MOSFET, but if you look at its operation curves (IRL520 Datasheet pdf - 100V Single N-Channel HEXFET Power MOSFET in a TO-220AB package - International Rectifier) you'd see that 5V is not enough to maintain a fully on state, at least not when there's significant drain to source current....

Ok - I will fully admit that I probably am not understanding things...

With that said, looking at Figs 1 & 2 seems to indicate that the curve for 5V gate voltage (second curve from top), will allow for a current flow from the drain of a little over 10A, if the drain-source voltage is 10 volts or more (roughly).

Fig 3 seems to show the same (@5V gate voltage, and 50V drain-source voltage, current handling is about 10A.

So...my question is...what am I reading wrong here?

Furthermore, if I am reading it wrong - how the heck do I read it "right" - do you (or anyone else for that matter) know of a tutorial on how to read these spec sheets for MOSFETs, because from what I have been able to gather online and from people here, is that the way I am reading them (as above) is how they should be read (???)...

Now you're telling me something else...

:-/

I just want a tutorial or something (hell, give me the name of a book - maybe I should re-read my Grob?) - that says exactly how to pick the right MOSFET (and as a bonus, any current limit resistors and such) for a given use/need. I mean, I can find tons of things online about BJTs, but seemingly nothing for MOSFETs.

Also - if this particular MOSFET is "logic-level", but won't "fully turn on with logic-level" signals - then why is it called "logic-level"? For instance (and I don't have model numbers handy here), I have plenty of N-channel MOSFETs that -aren't- "logic-level"; their curves show that at certain voltages (typically below 10 volts, usually), the drain-source amperage is really low (generally no more than an amp, even if the FET allows for 50-100 amps drain-source current) - but at 10V it jumps up to "maximum" drain-source current. To me, these would be "non logic-level" - right?

What am I reading wrong? How do I read this right? This is important to me, mainly because I want to base future h-bridge designs for motor control on large MOSFETs capable of handling the current. Should I just give up and stick with h-bridge ICs or something? I really want to understand this!

:slight_smile:

The first line in first table of the datasheet states the maximum current available at 25C is 9.2 A if you have 5V Gate to Source.

In the second table it states the "Gate Threshhold Voltage" is between 1V (min) and 2V (max), meaning it will start to be ON once more than 2V is applied G to S.

If you look closely at Fig 1 there's a little table in top left that shows each line in the graph is for a different VGS from 2.25 to 7.5V. So picking the line VGS = 3.5V it says that if Drain to Source volts is 10V (10 with power 1) the current will be about 10 to the power 0.2 or about 1.6 Amps.

(it's bit hard to read the logarithmic graph, but just remember 10 to the power 0.1=1/10, 10 to the power 0 = 1, power 1 i= 10, power 2 = 100. For fractions between use your calculator or the POWER function in Excel)

But notice if VGS is 4V this rises to nearly 10A (which seems to contradict the 9.2A max!)

Anyway I'd say there's little doubt the Arduino output could drive this, it just comes down to setting your circuit up correctly.

I find Wikipedia expains things really well ... have a look at MOSFET - Wikipedia

Hi cr0sh,

What I was trying to say was that 5V gate voltage would not fully put the MOSFET in the switching mode. As ninja2 pointed out, the output of an Arduino may well be able to be high enough to be able to drive the motor, but it is not high enough to put the MOSFET in the saturation region (the flat top region). The saturation region shifts to the right as Vds goes up.

For small signal applications, this is not an issue but to drive a motor you really want to get the point of operation to as far right as possible (i.e. higher Vgs) in order to obtain the lowest on-resistance and thus reduce the power dissipation of the MOSFET.

The main difference between Logic MOSFET and normal MOSFET is that, for any given Vds the Vgs required to drive the device into the saturation region is lower. And particularly, if you are using a TTL device, it is guaranteed to turn on when Vgs is greater than 2.2V (which is the minimum TTL high for 5V supply), but like all the MOSFET, the required gate voltage goes up as the drain-to-source voltage goes up so for the operations Pokey desired (24V motor), a separate amplification state would be required (or using an optocoupler as I suggested before).

This is turning into a fascinating thread (...well I have to admit that a lot of this is still over my head), thank you all for a really helpful discussion.

If I am understanding correctly a MOSFET transistor may suffice on its own but adding an optocoupler will remove any possibility of doubt (I do like to play things safe). Correct?

I found this MOSFET transistor:

http://www.alliedelec.com/search/productdetail.aspx?SKU=3070341

The details claim that it is designed for "Direct Logic-Level Interface: TTL/CMOS"

What do you think?

Thanks.

I found this MOSFET transistor:

Yes, it's a logic level mosfet that can be driven directly from an Arduino digital output pin. However it's a pretty low current device, around 500ma or so at 5vdc gate drive.

Choosing the proper switching transistor is all about the load specifications of voltage and current required.

Lefty

ninja2:

The first line in first table of the datasheet states the maximum current available at 25C is 9.2 A if you have 5V Gate to Source.

In the second table it states the "Gate Threshhold Voltage" is between 1V (min) and 2V (max), meaning it will start to be ON once more than 2V is applied G to S.

OK - that much I understand.

If you look closely at Fig 1 there's a little table in top left that shows each line in the graph is for a different VGS from 2.25 to 7.5V. So picking the line VGS = 3.5V it says that if Drain to Source volts is 10V (10 with power 1) the current will be about 10 to the power 0.2 or about 1.6 Amps.

This I don't. If I look at Fig 1, for Vgs of 3.5V (fourth line from the top), Drain to Source voltage of 10V (10^1), I see 10^? - ok, I understand that the exponent is between 0 and 1; that line sits almost on top of the 5th line above the 10^0 line; the 10^1 line is the 9th line (why not 10 divisions?) - what is the amount of the divisions spacing? How do you know this? How do you know that the line that it is sitting on is "0.2"? What value is the line above it? Below it? I can read this graph, but it seems like information is missing - or has to be inferred in some manner? So how?

Let's start at 10^0; ok - next line up from that (closer to 10^1) is...? There are 9 subdivisions, so it should be 10^0.11, and the next 10^0.22...until 10^0.99999 (ie, for all intents, 10^1)...right? So, that line is actually sitting on the 10^0.5555 line, or about 3.6 amps...not 1.6 amps...???

(it's bit hard to read the logarithmic graph, but just remember 10 to the power 0.1=1/10, 10 to the power 0 = 1, power 1 i= 10, power 2 = 100. For fractions between use your calculator or the POWER function in Excel)

I'm 37 years old - I understand exponents. :slight_smile:

But notice if VGS is 4V this rises to nearly 10A (which seems to contradict the 9.2A max!)

Anyway I'd say there's little doubt the Arduino output could drive this, it just comes down to setting your circuit up correctly.

Ok. Well, it seems aside from the above confusion I have on the graph, that I -am- understanding things somewhat properly...?

I find Wikipedia expains things really well ... have a look at MOSFET - Wikipedia

I'll do that...thank you. :slight_smile:

AlphaZeta:

What I was trying to say was that 5V gate voltage would not fully put the MOSFET in the switching mode. As ninja2 pointed out, the output of an Arduino may well be able to be high enough to be able to drive the motor, but it is not high enough to put the MOSFET in the saturation region (the flat top region). The saturation region shifts to the right as Vds goes up.

Ok - I can see that; and kinda implied I understood that for what I was writing about - but perhaps not for the OP's application...

For small signal applications, this is not an issue but to drive a motor you really want to get the point of operation to as far right as possible (i.e. higher Vgs) in order to obtain the lowest on-resistance and thus reduce the power dissipation of the MOSFET.

Right - and as I was stating before, the graphs seemed to indicate that anything greater than approximately 10V drain-to-source (to an extent) would work OK @ 5V Vgs...

The main difference between Logic MOSFET and normal MOSFET is that, for any given Vds the Vgs required to drive the device into the saturation region is lower. And particularly, if you are using a TTL device, it is guaranteed to turn on when Vgs is greater than 2.2V (which is the minimum TTL high for 5V supply), but like all the MOSFET, the required gate voltage goes up as the drain-to-source voltage goes up so for the operations Pokey desired (24V motor), a separate amplification state would be required (or using an optocoupler as I suggested before).

I think I see what you are saying; because both figure 1 and 2 show that in order to stay in the "flat region" as your Vds goes up, you have to keep increasing your Vgs - which is something I didn't realize before. However, it doesn't seem like I was too far off the mark for the voltages I was talking about (ie, 5V Vgs, 10V Vds @ approx 10A drain current - for the IRL520).

Would you agree with ninja2 that wikipedia is the best source for "information" in a general manner on MOSFETs, or do you have another source you would like to recommend?

Thank you. :slight_smile:

soryy cr0sh, I'm getting a bit cr0sh-eyed in my old age and picked the 5th line from the top in error.

I'm almost certain there are actually 10 logarithmic divisions, it's just that the ninth one is so close to 10th it looks like a thicker line due to the rather poor graphics. So each line upwards represents a power increase of 0.1, so the WGS of 3.5V gives a current of 10^^0.5 = 3.16A ...

soryy cr0sh, I'm getting a bit cr0sh-eyed in my old age and picked the 5th line from the top in error.

Ok - that explains it...no problem.

I'm almost certain there are actually 10 logarithmic divisions, it's just that the ninth one is so close to 10th it looks like a thicker line due to the rather poor graphics. So each line upwards represents a power increase of 0.1, so the WGS of 3.5V gives a current of 10^^0.5 = 3.16A ...

Hmm - and that explains that!

Based on this, it seems to me that I was understanding things correctly; with the exception of Vgs going up as Vds goes up (and likely, for the OPs purposes, this logic-level MOSFET would not be suitable for a Vds of 24 volts, since Vgs would likely need to be higher than 5 volts TTL - thus the need for either an optocoupler as suggested, or another transistor or FET to switch on the main one).

Does that sound right?

:slight_smile:

just as a side-note about PLC
I have been observing electricians and a PLC guy at my place of work trying to control a unusual multiple chainblock system (it can rotate and move in a sort of H pattern and they want it to go to a certain spot in a single keypress with no operator training)

and it's been absolutely painful to watch them work
they're almost done and the system's interface is a huge 8 button remote that you have to press button in sequence to switch between system of change the destination, clearly artifacts of the PLC way of doing things

also it's very unreliable, it goes into fault mode and stops moving and the only external communication is a blue and a green light that are on off or blinking (no one knows what they mean) it goes into fault the lights are seemingly random and there's no way to know why without calling the guy and he hook his laptop

in all I think the arduino would have been a much better option for this even though it's not "industrial"

I'm going to program my arduino with lcd to output relevant messages by keypress and show it to the guy next time he comes
really that remote should at least have a LCD display !!

but there's no denying there's a lot PLC installs out there and PLC is a lot like how an electrician would make a computer, it's like a thousand relays !!!

I think there is a lot of money in this and some PLC to arduino interaction would make a very good project that would certainly boost the reputation of the arduino as an industrial solution

(seriously, ladder programming ? it's all graphical and stuff, it's like programming with lego mindstorm, it doesn't strike me as professionnal !)

Mordern plc's use structured text a pascal like language which is a lot more modern than ladder. Also ladder is almost never used in europe. The last time I saw it was ehm.. yesterday. I have to convert a program from an old plc to a DCS system (proces control system for large factories) but before that the last time I used it was when I learned it at school more then 10 years ago. For user input there are nice operator panels availlable which range from a simple lcd display with a few buttons to full colour windows ce touch screen devices.

So, allthough I like arduinos a lot I don't think they can replace a modern plc.

If you want more technical details on MOSFET than Wikipedia provides, you can probably get a book on semiconductor devices from a university library. That said, if you just want a little more detail, here's a PDF from IRF: http://www.irf.com/technical-info/appnotes/mosfet.pdf

---8<---8<---8<---

So, allthough I like arduinos a lot I don't think they can replace a modern plc.

---8<---8<---8<---

I agree, the "PLC" I am replacing for this project is an ultra low-end TECO SG2. The Arduino simply blows this unit out of the water in terms of flexibility.