Advice selecting approporiate Microcontroller - Page 1
Forum section: electronics / general

author: Sterno
author_rank: Contributor
timestamp: December 17, 2014, 02:56:15 am
content: HI, I'm working on a very basic visual detection system for a piece of farm equipment and am looking for some input.The machine in question is a prepruner which straddles a row of grapes and cuts the long branches in preperation for pruning. At each post, the cutting heads have to move apart, this is done manually by the operator and we want to automate this process.I have built an array of 66 photodetectors (next iteration I plan to have 90 for more resolution) with matching emitters on the opposing side and have used a pile of discrete 7400 series gates (22 to be exact) to do the logic, requiring the system to only trigger when a straight line of a minimum 18mm thickness blocks the photo sensors. This is, expectedly, cumbersome and a bit of a mess, but it works reasonably well.Yes, if i grow a beard, it is gray!I would like to simplify the hardware and use a micro instead of the discrete ICs.The downside:My Microcontroller experience is limited, I last programmed 8051s in college in the early 90s with assembly, same goes for C, learned 20 yrs ago and haven't used it since. I know it's going to be a bit of a steep learning curve but I'm OK with that.The requirements aren't all that heavy, I figure if the Micro can query the array 15-20 times per second I'll be laughing.I would love to get some feedback/advice, even if you think I'm crazy.

author: Wilksey
author_rank: Super Contributor
timestamp: December 17, 2014, 03:04:27 am
content: Just a thought, if you are using so many logic chips, have you considered a CPLD or FPGA rather than just a Micro?

author: nctnico
author_rank: Super Contributor
timestamp: December 17, 2014, 08:25:50 am
content: Hiring a consultant to help creating a circuit and a basic piece of embedded firmware to kickstart the project could be a good idea. That way you could easely get started with an ARM based controller without going through a big learning curve.

author: paulie
author_rank: Frequent Contributor
timestamp: December 17, 2014, 09:55:26 am
content: In relation to learning curve I'm not sure if mention of FPGA and ARM were serious or intended as a joke. Here in the real world one option stands alone in that respect.... Arduino. Boards with mega1280 or mega2560 have more than enough I/O, are cheap, and can be programmed in ASM, C, or even BASIC.

author: Howardlong
author_rank: Super Contributor
timestamp: December 17, 2014, 09:57:34 am
content: Quote from: Wilksey on December 17, 2014, 03:04:27 amAgreed, or an I2C or SPI I/O expander or two perhaps?

author: Wilksey
author_rank: Super Contributor
timestamp: December 17, 2014, 11:27:32 am
content: Yes, an IO expander would do the job also, if the right one was chosen.No I was not joking, I wasn't talking about the "learning curve" I was talking with regards to how to replace 22 logic chips with something a little more palatable.If you want something uber simple, buy a PLC and learn Ladder Logic.....

author: dannyf
author_rank: Super Contributor
timestamp: December 17, 2014, 12:00:30 pm
content: QuoteThat's a lot of words providing little context to your readers.You should figure out if you are trying to read digital information (is it on or off?) or analog information (shades of grey). and then how you want to read it.If it is digital, shift-in registers can be used to scan them; if it is analog, you can do so with switches as well.With a modern mcu, you can easily get it down to 10 - 20us per sensor.

author: wraper
author_rank: Unknown
timestamp: December 17, 2014, 12:07:57 pm
content: Any cheap microcontroller with some sort of I/O expander would do the job. For example, you could use one of the cheapest Atmega MCU and few of such I/O expandershttp://www.farnell.com/datasheets/1090521.pdf

author: ptricks
author_rank: Frequent Contributor
timestamp: December 17, 2014, 12:15:00 pm
content: Almost any micro will work , if you want to get started fast without much learning the arduino is easiest to use. Something like the Mega2560 is more than enough and still has room to grow if you need it. About $20 if you search around. You can download the software for free and it connects to the pc via usb.

author: 22swg
author_rank: Frequent Contributor
timestamp: December 17, 2014, 12:40:35 pm
content: What a great project.. If you already can do 8051 asm , then go with that , there are up-to-date 8051 versions , if you are polling 90 sensors you will need some kind of expander or perhaps a long IC shift register . any mcu solution would be a steep-ish learning curve.

author: paulie
author_rank: Frequent Contributor
timestamp: December 17, 2014, 01:52:01 pm
content: Quote from: Wilksey on December 17, 2014, 11:27:32 amIt's true OP hinted that a steep learning curve was desirable so ARMs, PLCs, and FPGAs might be just the thing. Strangely path of least resistance does not often seem to be popular with noobs. For that minority who do need to actually get something done efficiently and economically an off the shelf easy to program $20 board will always trump a stack of I/O expander cards or other Rube Goldberg kluge.Ptricks who did an excellent job of echoing my post seems to be the only other person here with "git-er-done" and "git-er-done-cheap" attitude.

author: Wilksey
author_rank: Super Contributor
timestamp: December 17, 2014, 03:08:36 pm
content: Well, the IO expander that wraper posted would probably do the job, there are more ways that 1 to skin a cat so to speak, so I guess the best thing is for us to give the OP ideas and for them to decide the path they would like to go down.From my own personal preference, if I wanted a direct replacement for a bunch of 74 series chips I would more than likely look at using a CPLD or FPGA, but I know how to write HDL, so it might not be so desirable over writing C or assembler, which is then when you would look at using IO expanders on a I2C or SPI bus and do the logic in the micro.

author: tszaboo
author_rank: Super Contributor
timestamp: December 17, 2014, 03:27:26 pm
content: Quote from: Sterno on December 17, 2014, 02:56:15 amYes, you are crazy. I would replace a micro with a handful of logic gates whenever it is possible. You solder it together and it works. The first time you place a micro on a board, the development time expands like a balloon, and the cost expands like a bunch of it.Especially, if it is working, why would you change it? Are you planning to make hundreds of this at least?

author: paulie
author_rank: Frequent Contributor
timestamp: December 18, 2014, 12:56:06 am
content: Quote from: NANDBlog on December 17, 2014, 03:27:26 pmProbably spoken by the type who uses timers and interrupts to blink an LED. It's true there's more than one way to skin a cat. Expensive painful way, and quick and easy. That first can be useful for purposes of of education. Unfortunately the lesson is usually what NOT to do.There is always only one easiest and also only one lowest cost solution. The good news is often they are one and the same.

author: tszaboo
author_rank: Super Contributor
timestamp: December 18, 2014, 10:38:12 am
content: Quote from: paulie on December 18, 2014, 12:56:06 amNo, I'm the one tossing a finished board to the programmer, who then usually spends the rest of eternity to make firmwares and patches.

author: Jeroen3
author_rank: Super Contributor
timestamp: December 18, 2014, 03:57:56 pm
content: Go buy an arduino and get an IO Expander shield. And try something for an hour or so.If you get the IO expander working (which should be a library ready to use) you'll have your IO issue fixed.Only things left are:- Cutter position actuator/sensors.- Algorithm calculating the required cutter position.- User feedback/input.If it doesn't work out, you can always have some fun with an arduino making some blinky-led, beep-a-tron or floppy drive music in your spare time.

author: paulie
author_rank: Frequent Contributor
timestamp: December 18, 2014, 07:54:27 pm
content: Quote from: NANDBlog on December 18, 2014, 10:38:12 amAha... so your the type that CAN'T blink an LED so hires someone to do it. I decided to check out your blog. Surprise... surprise... first word "NE555". It got even more interesting when I saw you were replacing a generic penny transistor with that integrated circuit.BTW you need to fire the programmer and find one that don't spend the rest of eternity to make firmwares and patches to toggle an LED.

author: LabSpokane
author_rank: Super Contributor
timestamp: December 19, 2014, 05:47:09 am
content: Take the advice on the Arduino. There is just no need for more horsepower than that. It will take you all of 15 minutes to be executing your own code - allowing you to focus on solving the problem - not learning ARM development. The Arduino is a great, low-friction prototyping tool, and exactly what you need for this.

author: miguelvp
author_rank: Super Contributor
timestamp: December 19, 2014, 06:40:29 am
content: Since the OP is well versed with discrete logic and programming is long forgotten, there is an alternate path in the FPGA front.You don't have to do VHDL or Verilog, there is always the schematic interface, so pretty much you just place your logic gates in the FPGA fabric.It can be simulated and debugged and reconfigured, a DE-0 Nano might have enough GPIOs for the 90 sensors (88 3.3V digital and 8 analog) but there are other dev boards with the appropriate number of direct GPIOsOf course other approaches can be done with external hardware to expand the I/O capabilities.My point is that FPGAs can be programmed using logic gates in the schematic input.

author: AndyC_772
author_rank: Super Contributor
timestamp: December 19, 2014, 09:01:12 am
content: I would never recommend using a schematic interface to program an FPGA. I've seen companies do it; they rapidly end up with a total monster that's impossible to read, maintain or debug, and all because someone thought the effort was better spent joining blocks together than learning the language. Schematic entry might be OK for a two hour introductory lab session for someone who has never seen an FPGA before, but it doesn't scale.Much the same applies to boards built out of discrete logic. Yes, you've side-stepped the need for any code, but you've saddled yourself with a single-purpose lump that becomes increasingly difficult to modify and debug as time goes on.Keep the hardware as simple as you can. For a one-off project, an off-the-shelf board with "-ino" in its name somewhere is probably not a bad solution.

author: Sterno
author_rank: Contributor
timestamp: December 19, 2014, 03:40:34 pm
content: Quote from: Wilksey on December 17, 2014, 03:04:27 amI had not, but I've investigated and it sounds like the right direction to go. Looking at a couple of Dev boards, might as well start learning now.I'm leaning towards the Lattice LC4256ZE-B-EVN, 8K gates, 92 I/O and under $40. Other recommendations?Quote from: NANDBlog on December 17, 2014, 03:27:26 pmGood point, If it's not broken why fix it. As for production volume, we're talking maybe 20-30 per year.Some other good points here:1- Yes a PLC would make it real simple, Industrial controls is my main gig with this company but it would be too expensive to be worthwile.2- I have an Arduino Uno and have been playing with it, a Mega with I/O expansion would be relatively easy to set up, however I'd like to keep it a one board solution like it is now.Guess I'll stick with discrete IC logic for now, parts cost is under$10 at volume and the design is basically done already.I'll see how things go with regards to learning to apply a CPLD and may switch to it in future.

author: zapta
author_rank: Super Contributor
timestamp: December 19, 2014, 05:19:03 pm
content: Quote from: Sterno on December 19, 2014, 03:40:34 pmWith a CPLD or a MCU you will be able to tweak the detection algorithm/criteria, as opposed to hard wired discrete ICs.

author: nctnico
author_rank: Super Contributor
timestamp: December 19, 2014, 05:53:34 pm
content: Quote from: Sterno on December 19, 2014, 03:40:34 pmI like the Xilinx XC9500XL series. They are not expensive and easy to program. The smaller ones still come in a PLCC package so you could use them on a through hole board in a socket. Whether to go with schematics or VHDL is up to you. Schematics probably get you going quicker and may be a good choice if you don't want to venture much deeper into using CPLDs or FPGAs.

author: tggzzz
author_rank: Super Contributor
timestamp: December 19, 2014, 05:58:10 pm
content: There is a vast range of micros that could "do teh job", so that isn't a good discriminator.Consider instead defining what skills (e.g. languages) you already know, finding a suitable development environment, and lastly choosing a micro that works in that context.Alternatively, learn quickly and cheaply by trying an arduino and seeing what it can achieve. Thereafter you will be in a much better position to make choices.For reducing the number of TTL chips, consider using a CPLD class device.