PDA

View Full Version : Using an Arduino to solve common interface problems


Richards
Thu 03 November 2011, 15:32
One of the problems that I've often had was justifying the expense of building a computer interface to solve some of the more simple problems that I've been asked to solve. To most people, it always seems like a simple problem when they ask, "How difficult could it be to connect some push-button switches to this controller?" or "How difficult could it be to add some indicator lights to that controller?" What looks like a simple problem to those who haven't had to deal with bouncing switch contacts or high current/high voltage lights, is that the real world and little computers don't get along very well.

Knowing that it will cost at least $200 to have a proto-type circuit board fabricated, after I've spent a week designing the schematics and another week writing and debugging code means that a simple project that only needs $10 worth of parts suddenly is a project costing hundreds and even thousands of dollars.

When I try to tactfully tell customers and friends that they can't afford to do what they want to do, unless they're planning on building a lot of those computers, many of them just think that I'm getting old and crotchety.

Yesterday, I finally found a practical solution for MANY of those types of problems. (A few of you have even mentioned that solution in some of your posts - but I never associated that solution as a general purpose solution for most I/O problems.) Someone emailed me and asked whether I thought that the Arduino Uno micro-controller board could be used to make hooking up switches and sensors easier on a CNC machine. The first thing I asked myself is, "What is an Arduino Uno?"

It turns out that an Italian company has been making simple computer boards using an inexpensive micro-processor - for years. They not only make the hardware, but they've designed some excellent software that makes it easy for non-programmers to do the kinds of things that a lot of you are trying to do.

Here in the United States, the Arduino Uno costs less than $30 from a variety of suppliers. The software is free. Tutorials, some even having videos, are available on the Internet.

The Arduino just plugs into the USB port on your Windows, Mac, or Linux computer (yes, it works with all three). It has connectors for a lot of inputs and outputs. It has two clock/timers. It does everything that you would expect a micro-controller to be able to do. As frosting on the cake, the Arduino Uno can also be used to program other Atmel AVR chips so that you can use a chip costing as little as $1.50 to solve fairly large problems.

Granted, the Arduino doesn't solve all interfacing problems (anything but a 5V device still has to have an opto-isolator or other interface chip to convert voltages and high-current/high-voltage devices still have to use an Opto-22 G4 module or other device), but the Arduino sure makes it easier to debounce switches, multiplex sensors, and turn on lights and alarms when something goes wrong.

It's something that is affordable and easy to use. It was designed to help everyone do things that only programmers and engineers have been able to do in the past.

So, the next time someone asks me if I could design a simple interface for them, my first response will be to ask, "Have you evaluated the Arduino Uno board yet?"

Surfcnc
Thu 03 November 2011, 16:38
Hi Mike

I see you have discovered the Arduino, it seems to be a real internet phenomenon at the moment.
As an additional piece of information to your post, "shields" in Arduino parlance add extra functionality to the basic board.
Here is a very long list of shields for the Arduino http://shieldlist.org/.

Regards
Ross

TechGladiator
Thu 03 November 2011, 17:39
We use them at work alllllllll the time. You are absolutelly right about being a great solution for one-off things or custom solutions. We also design our owm relay, IO, Rs232 boards at work but the arduino board sure solves a lot of problems.

bradm
Thu 03 November 2011, 19:41
Yep, Arduinos are great. Another great resource are the Microchip single chip microcontrollers. They are very supportive with samples for R&D, and the resulting boards can be even simpler and cheaper than the Arduinos. I love them both.

normand blais
Fri 04 November 2011, 08:07
Here are some link for firefly, witch is a plugin for grasshopper witch is again a plugin for rhino.
Firefly control stepper and other stuff .beyon my understanding for now. Might be usefull for you
http://www.fireflyexperiments.com/
http://www.liftarchitects.com/
http://vimeo.com/10259250

Richards
Sat 05 November 2011, 20:44
Sometimes we get so focused on solving the complex that we forget that most people only need to solve the simple.

For example, many people have posted questions about proximity sensors. They want to know how to wire a N/O set of sensors opposed to wiring a N/C set of sensors. With a micro-processor (arduino or other), it doesn't matter. N/O sensors can be mixed with N/C sensors and a simple program change (complement the bit) can accommodate either type.

An Arduino costs about $30, but an ATtiny85 chip that easily interfaces with a proximity sensor costs about $1.50. The Arduino can reprogram the ATtiny85 to work with either a N/O or a N/C proximity sensor. In a normal setting, it might take one ATtiny85 chip per sensor, but at $1.50 each, does that really matter?

Using technology properly can minimize the time it takes to solve problems. Sometimes that innovation requires an Arduino, and other times it only requires the USE of an Arduino to program other chips.

Don't overlook the FREE software, like AVR Studio 5, that allows you to program and debug programs.

The Internet has made it possible to do some great things at low or no cost. Thinking "small" is sometimes the best way to get into using micro-controllers.

smreish
Sun 06 November 2011, 07:32
Mike,
Back in early 2007 when working on the limit circuit for my MM, I actually used a Automation Direct D05 PLC to the simple (and a few other routines for me) 99.00 for all the IO I ever needed to add logic to my MM. I used the IO in the PLC to resolve the prox circuits and a few others duties related to machine interlock and vacuum system. Then just sent the resolved signal to the J block on the pmdx.

Great ideas making the machine a better place.

TechGladiator
Sun 06 November 2011, 09:44
Mike, Sean;

Of you can build your own board :). We actually build a Start/Stop circuit into a board that will activate a buzzer/horn for X amount of seconds before sending power to the starter. Over the years we found it incredible how many so called "control electricians" couldn't figure out how to wire a simple start/stop circuit :)

Richards
Sun 06 November 2011, 14:11
Some of you have modified the original design and added features and functions that best suit your needs. Sharing those ideas with everyone helps others to also extend the functionality of their machines.

That's what it's all about - making a CNC machine do what we want it to do.

Finding the Arduino was like getting a breath of fresh air. I'm used to using an old programmer that is out of production and writing code in a text program and then hand checking the code for logic errors. Because I have been doing it for so many years, it is simple for me; but when I tell others how to program a $2.00 Atmel 89C series part, they just throw up their hands saying that they can't buy an affordable programmer and they wouldn't know a logic error from anything.

The Arduino (and other similar inexpensive platforms for other brands of chips) make testing and implementation easy. Using a combination of programs, I can easily simulate the operation of a micro-controller and then "burn" that program into an Arduino or into a single chip. That's the beauty of it. If the problem warrants a $30 Arduino, I can use a dedicated Arduino. If the solution only requires a $1.36 ATtiny85 chip, I can use the Arduino to program that single chip. If the solution to the problem requires more than five I/O lines, then I can dig deeper into my pocket and us a $4.00 ATmega328 chip.

If the solution to the problem warrants the cost of a real circuit board, I can use free software from ExpressPCB to draw a schematic and layout a multi-layer circuit board. Their proto-type boards cost about $100 or $200 depending on the size and the number of layers.

If the solution to the problem allows a one-off wire-wrap board, I can use that same ExpressPCB to draw the schematic and then use it as a guide to wire-wrap the design.

Normally, I just use a little solderless breadboard to build and test the circuit. When I'm sure that I've got what I want, I layout a real circuit board and have some prototype boards made.

The point I'm trying to make is that almost anything is possible with readily available parts, parts that are available world-wide at reasonable prices.

Richards
Mon 05 December 2011, 07:48
The Arduino Uno R3 is available from Radio Shack in the United States for $35.00. Radio Shack also has a variety of prototyping boards specifically designed for the Arduino Uno. I bought two boards on Friday night. Within 15 minutes, I had prototyped and verified two designs. Normally, using the AT89Cxx microprocessors, which require assembly language instead of "C", programming those two projects would have taken several hours each.

A perfect use for an Arduino would be to interface the proximity sensors to your break-out-board. Using software, you could easily configure the Arduino to give the proper response no matter whether you use N/O or N/C sensors and it wouldn't matter whether the sensor goes active when it sees a hole or when it sees a target. Programming would compensate for all of those issues. Using a "shield" designed for quick prototyping would let you add the necessary opto-isolators without going to the expense of having boards fabricated.

quadtech
Sun 11 December 2011, 23:19
The starter pack from Adafruit is a pretty good deal too.

http://www.adafruit.com/products/68

aniljangra
Tue 13 December 2011, 07:54
I did use an AVR (atmel mega 8) to combine all proxy and buttons on my mechmate. Beware not to use weak pullups (internal pullups) if needed, when using micros, noise easily can get in and trigger EStop in Mach.

Richards
Wed 14 December 2011, 12:25
Anil makes a good point. The 20K built-in resistors allow the Atmel chip to sink/source about 0.25ma. Normally a 2.2K or a 4.5K pull-up resistor would be used giving 5X or 10X more current. I normally use 2.2K pull-up resistors in my own designs.

However, the whole design cycle needs to be explained so that no one assumes that an Arduino by itself is used.

On my test bench, I have two Arduino Uno devices. One is always set to ISP mode, meaning that it can be used to program other chips. The other one is used in its "native" mode. I start with the non-ISP device and test each part of the computer program for proper operation. When the program has been verified, then I burn an ATtiny chip which I use in the final design. The ATtiny chip is put into a wire-wrap or prototype board where I can closely examine each part of the circuit for proper electrical operation. I use a lot of opto-couplers in my designs to keep electrical noise outside, even when the outside circuits work with 5VDC. If I have a push-button switch that needs absolute error-free reading, I add a software switch debouncing routine in software or I use another ATtine85 chip that is dedicated to monitoring that single switch ($1.25 per ATtiny85). When the design checks out electrically, then I design a proper PCB board.

The Arduino makes prototyping quick and easy. It allows me to concentrate on the "what ifs" in a design rather than being bogged down in the "how tos" part of the design.

One additional piece of hardware is often required. I use an Atmel AVR Dragon ($75 with ZIF connector) when I really need to get down to the bare essentials of a microcomputer chip. The Dragon, along with AVR Studio 5 software (free), lets me do anything that the chip is capable of doing.

The Arduinos and the Dragon cost much less than the programmer that I used for the older AT89Cxxxx chips and the Arduino/Dragon design cycle is so much faster. Most of the time I can use C/C++ rather that writing in Assembler, so I don't have to worry about the intricacies of the microcomputer chip.

By working through a design systematically, I can separate the programming errors from the electrical errors, then I can test the electronics on the prototype or wire-wrap board before spending more than the cost of the chip and the other components.

aniljangra
Wed 14 December 2011, 13:02
For denouncing a single input I use even cheaper chip ($0.1) the 555 timer (CMOS version LMC 555) in mono-shot configuration :), very useful when you are trying to attach input to interrupt pin.

Although not relevant here, you can't beat a small CPLD for denouncing and combining many inputs, the only downside is these little chips are available in surface mount packages.

I never felt a need for Audrino since I got my AVR dragon :) , along with free avrstudio it make a perfect development combo. By the way Mike you may want to try R8C tiny from Renesas, cheaper than AVRs and more immune to noise, I am using more of these now than AVRs.

Richards
Wed 14 December 2011, 20:08
The beauty of microcomputers and discrete electronics is that there are endless ways to preform the same task. The "best solution" is the solution that works for you.