Can I use an Atmega in my project

I am in the "conceptual" phase for a project and I am trying to figure out which way to go as far as controllers. I have 20+ years in Industrial PLC (Allen Bradley, Siemens, Direct Logic) programming but almost none in embedded microcontroller programming. I know exactly what I want to do and how I would do it in a PLC but how to accomplish the tasks in a microcontroller is something for another post. That said, PLC's use some sort of microcontroller... so it can be done :slight_smile:

I have no qualms with using multiple controllers. For instance, one for data handling and one for control. How to do that is another matter but I'm not at that point yet. I would not want to split IO groups. For instance, 4 analogs on one controller and 4 on another.

The project has the following requirements-

8- scaleable analog optically isolated inputs (I can get by on 4 for this particular project)
4 - scaleable analog optically isolated outputs (I can get by on 0 for this particular project)
16 - Digital inputs (I can get by on 12 for this particular project)
8 - Digital outputs (Technically I only need 1 if I can use a serial display for textual alarm display)

Project wishes (these would make the project more attractive)

(1) Serial connectivity for current data retrieval and some configuration (like scaling). This would be RS232 or RS485 using the Modbus (slave) protocol or Ethernet using the Modbus TCP protocol.

(2) Bluetooth connectivity (see item 1)

(3) 32 bit analog data. Even 16 bit would be better than 8 bit. 12 works too.

There is an Arduino modbus library: Arduino Playground - ModbusMaster Library
Only the Arduino Due (32bit Arm micro controller) has 2 analog outputs (12bit). The Due also has 12 analog inputs with 12 bit resolution. Other Arduinos (AVR based) only have pwm outputs and 10bit analog inputs. So you would need additional hardware to accomplish what you want.
Bluetooth is pretty easy to accomplish, you can buy a bluetooth shield or just connect a bluetooth module to your Arduino. Programming them is pretty straight forward as it's just serial communication.

Bajdi:
There is an Arduino modbus library: Arduino Playground - ModbusMaster Library
Only the Arduino Due (32bit Arm micro controller) has 2 analog outputs (12bit). The Due also has 12 analog inputs with 12 bit resolution. Other Arduinos (AVR based) only have pwm outputs and 10bit analog inputs. So you would need additional hardware to accomplish what you want.
Bluetooth is pretty easy to accomplish, you can buy a bluetooth shield or just connect a bluetooth module to your Arduino. Programming them is pretty straight forward as it's just serial communication.

I should have been more specific. The comm mode will be Modbus slave only. I'll edit my post. But... thanks for the link. I'll add the library to mine.

I could make 12 bit (0-4095) work. Some of the lower end PLC's are 12 bit AI.

Could I use I2C and some other hardware to expand the analog outputs if necessary? At the moment I don't "need" an analog output. My PLC experience is not helping me in that regard. Customers have VFO's installed in their brains so you never know what they are going to want. I often install IO "just in case" in PLC projects. In the case of this design, there really isn't much need for an AO since I won't be doing any PID control.

I would not want to split IO groups. For instance, 4 analogs on one controller and 4 on another.

Why is this? What if they are in different rooms or even buildings?

8- scaleable analog inputs (I can get by on 4 for this particular project)
4 - scaleable analog outputs (I can get by on 2 for this particular project)
16 - Digital inputs (I can get by on 12 for this particular project)
8 - Digital outputs (Technically I only need 4 if I can use a serial display for textual alarm display)
Serial Display

Is this all one one board?

32 bit analog data

Yikes, above my pay grade :slight_smile:

Can you give us some idea of the topology, so far it seems there's just a single board with comms to a PC or whatever, but that's a very limiting arrangement.


Rob

I would not want to split IO groups. For instance, 4 analogs on one controller and 4 on another.

Why is this? What if they are in different rooms or even buildings?

The application is stand alone. A "package" so to speak. I normally install a $10k to $15k PLC panel to do what I think can be done with a micro.

8- scaleable analog inputs (I can get by on 4 for this particular project)
4 - scaleable analog outputs (I can get by on 2 for this particular project)
16 - Digital inputs (I can get by on 12 for this particular project)
8 - Digital outputs (Technically I only need 4 if I can use a serial display for textual alarm display)
Serial Display

Is this all one one board?

I could stack boards or use some other board arrangement. The more compact it is the more attractive it might be to the end user (space is money in the industrial world) BUT ambient heat is a concern.

32 bit analog data

Yikes, above my pay grade :slight_smile:

Can you give us some idea of the topology, so far it seems there's just a single board with comms to a PC or whatever, but that's a very limiting arrangement.


Rob

Analog inputs are used to turn a pump off and on for pump protection
Digital inputs are used in the same way as the analogs as well as for function and I need to be able to give them the option of using analog or digital control. That's probably going to be a dip switch on the board but at the moment I'm just trying to determine if it's feasible.

Example: AI0 is scaled 0-100 lbs. DO0 is the control output for the device that removes weight. The source of the weight is uncontrolled. Let's say that it comes from a truck and the truck can arrive at any time.

In the PLC the logic looks like this (kind of):

If AI0 > High Setpoint
(and there are no shutdowns like an EStop or other safety related IO)
Then
DO0 : = 1;
EndIf;

If AI0 <= Low Setpoint
(and there are no shutdowns like an EStop or other safety related IO)
Then
DO0 : = 0;
EndIf;

(Yes, I know... I can use ElseIf... and make this more compact)

It's a little more complicated than that but not much. There is also a "run permissive" string so that the IF Then is really an If THEN ElseIF statement.

Sounds quite interesting.

I could stack boards or use some other board arrangement.

Myself and a colleague are developing a system that is very much like this from what I can tell. It's for use in commercial and light-industrial applications where an Arduino is not up to the job but the offerings of A&B, Honeywell et al are overkill or too expensive.

My colleague sounds like you (experienced with PLCs) and I'm experienced in embedded processors, so we're hoping that between the (so far) two of us we can make something quite nice.

If you're interested email me, it's completely open source though so if you had in mind a proprietary system it won't be suitable.


Rob

It's pretty neat how many of us are moving in this direction. Using Arduino to supplant or augment PLCs and Industrial Controllers.

Getting whatever you build to support an OPC, CANBUS or MODBUS interface really opens it up to the world of measurement, automation and controls.

I'm looking at a couple of MODBUS and OPC libraries for DUE now, hoping to get them working. Arduino makes for a very nice intelligent transmitter for sensors and analyzers.

Rob, have you looked at this? http://www.arduinoopc.com/

Hi Peter,

Rob, have you looked at this?

Not really, there is a thread running about it on the Due board but I didn't take much notice. I will now, I'll have a good read up on it.

As you know (or have guessed) the Toucan has been laid to rest, it's just too complicated for us to do, but we are about to go to PCB with another interesting project, not 32-bit yet (although it can use any CPU you like) but we plan to use it for control apps so it would be good to implement one of the standard control buses for it.

We are already talking to Mike (Mike6158) about it, and may already have our first application down in Tasmania with Paul, email me if you have an interest.


Rob

ODwyerPW:
It's pretty neat how many of us are moving in this direction. Using Arduino to supplant or augment PLCs and Industrial Controllers.

Getting whatever you build to support an OPC, CANBUS or MODBUS interface really opens it up to the world of measurement, automation and controls.

I'm looking at a couple of MODBUS and OPC libraries for DUE now, hoping to get them working. Arduino makes for a very nice intelligent transmitter for sensors and analyzers.

Rob, have you looked at this? http://www.arduinoopc.com/

OPC for Arduino. It looks promising, We have two OPC clients running on our server(s). Kepware and AES. They aren't free but they handle 10's of thousands of data points without a lot of trouble. Kepware isn't expensive at all and it supports the AB PLC, Modbus, as well as numerous other protocols that I don't use, with add on features. AES is a licensed by user and number of points client and its not cheap to own. It is robust though and it has a nice diagnostic feature.

Depending on your ambition with the project (IE do you want it to be open source, or is the plan to make a new product for you to sell?) Arduino may not be the way to go. The Due would be the best bet for getting the # of pins you want, but I also imagine you could do a lot with Atmel's Xmega series, which has most of what you want on it (12 Bit ADCs/DACs, numerous inputs and outputs). That being said, there is something to be said for a simple interface, and you would not get that with the Xmega (You could simplify it some but that would be other development). However, there may also be some legal requirements involved with an open-source based project that are non-conducive to small business models (IE, you might have to share what you do, and then why should we buy from you when we can get it for free?). I've never been quite clear on this.

You would be much better off telling us what the project really is instead of a woolly (very very woolly) set ~"requirements".

Micros have there own way of working and it far better to work with them than try to force them to be PLC or something.

Mark

mirith:
Depending on your ambition with the project (IE do you want it to be open source, or is the plan to make a new product for you to sell?) Arduino may not be the way to go. The Due would be the best bet for getting the # of pins you want, but I also imagine you could do a lot with Atmel's Xmega series, which has most of what you want on it (12 Bit ADCs/DACs, numerous inputs and outputs). That being said, there is something to be said for a simple interface, and you would not get that with the Xmega (You could simplify it some but that would be other development). However, there may also be some legal requirements involved with an open-source based project that are non-conducive to small business models (IE, you might have to share what you do, and then why should we buy from you when we can get it for free?). I've never been quite clear on this.

You make some very good points that I hadn't considered. Maybe the Arduino is a better platform for learning what can be done rather than a basis for a commercial product. .

holmes4:
You would be much better off telling us what the project really is instead of a woolly (very very woolly) set ~"requirements".

Micros have there own way of working and it far better to work with them than try to force them to be PLC or something.

Mark

The problem with explaining the project is that 99.99% of the world has no idea how they get their fuel or where the raw material for plastics comes from. I could write volumes on what it does and how it works and it would be meaningless to most people.

If a system is controlled by a very small but very expensive PLC platform ($10k - $15k) and it's controlled exactly the same way with exactly the same IO and other than modern upgrades it hasn't changed in 50 years then I think it's a good candidate for a hard coded, simple control system that cost significantly less than the current offerings.

Maybe the Arduino is a better platform for learning what can be done rather than a basis for a commercial product. .

You can do both, just don't tell people it's "Arduino inside".


Rob

Mike6158:

mirith:
Depending on your ambition with the project (IE do you want it to be open source, or is the plan to make a new product for you to sell?) Arduino may not be the way to go. The Due would be the best bet for getting the # of pins you want, but I also imagine you could do a lot with Atmel's Xmega series, which has most of what you want on it (12 Bit ADCs/DACs, numerous inputs and outputs). That being said, there is something to be said for a simple interface, and you would not get that with the Xmega (You could simplify it some but that would be other development). However, there may also be some legal requirements involved with an open-source based project that are non-conducive to small business models (IE, you might have to share what you do, and then why should we buy from you when we can get it for free?). I've never been quite clear on this.

You make some very good points that I hadn't considered. Maybe the Arduino is a better platform for learning what can be done rather than a basis for a commercial product. .

holmes4:
You would be much better off telling us what the project really is instead of a woolly (very very woolly) set ~"requirements".

Micros have there own way of working and it far better to work with them than try to force them to be PLC or something.

Mark

The problem with explaining the project is that 99.99% of the world has no idea how they get their fuel or where the raw material for plastics comes from. I could write volumes on what it does and how it works and it would be meaningless to most people.

If a system is controlled by a very small but very expensive PLC platform ($10k - $15k) and it's controlled exactly the same way with exactly the same IO and other than modern upgrades it hasn't changed in 50 years then I think it's a good candidate for a hard coded, simple control system that cost significantly less than the current offerings.

One of the biggest things about those very expensive PLC platforms comes from all of the testing and certification. That makes it remarkably difficult for large companies to change them, since they KNOW it works, and that the manufacturer will guarantee it. I agree, PLCs are silly expensive for what they do, but UL and CE testing can cost $100k (US) at least each. And manufacturers want that.

I'm not trying to talk you out of this, but it is just something to consider.

Mike6158:
(2) Bluetooth connectivity (see item 1)
(3) 32 bit analog data.

Just get a 32-bit processor like ARM or PIC32 or AVR32 or whatever you feel is best but I think that you should give some flexibility this is because:

Mike6158:
I normally install a $10k to $15k PLC panel to do what I think can be done with a micro.

If you are replacing something normally costing that much the extra $1-3 dollars is not going to be noticed and will be seen as a drop in the bucket however the performance you gain will be noticed a lot. You can use an atmega if you want and it will do it but I am just saying that there is no reason to cheap out for an 8-bit processor. Also you can buy 32-bit micro-controllers with built-in Bluetooth so you may actually save money. By googling Bluetooth Soc ARM I found this in about one minute http://www.mouser.com/ProductDetail/Nordic-Semiconductor/nRF51822-QFAA-R7/?qs=sGAEpiMZZMvQqVCO1QUkez7sIZGL4lOYjddp8D7wMfY%3D

a 32-bit processor like ARM or PIC32 or AVR32

That won't give you 32-bit analog inputs, but I think we decided that wasn't required.


Rob