Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Choosing a microcontroller

Status
Not open for further replies.

tyco

New Member
Hello,

I'm relatively new to microcontrollers and I have read through the "Newcomers, please read! (PIC regarded) Upd. 0xC" but I don't think it completely answers my question.

I have written some C code I would like to run on a microcontroller for a prototype. It is pretty simple code (requires floats) and the microcontroller would only need to receive input from a digital scale, a single sensor, and a few input buttons. The microcontroller also needs to output to a small LCD.

The problem is that I'm not even sure what family of microcontrollers I should be looking into (68HC11, 68HC12, PIC, 8051, etc). Any recommendations for a first-time development kit?

My computer does not have a serial port, so a USB programmer would probably be required. Also, I can rewrite the code in Assembly if necessary, although I would prefer not to.

Any help would be appreciated.
Thanks!
 
Floating point operations are slow, so you may prefer a high frequency crystal (and a micro controller that can be operated with high speed oscillators).
You can find free light versions of C compilers for micro controllers on the web, but your code may grow beyond the allowed size?
How many inputs do you need exactly?
 
At most, I should need about 10 inputs and then the LCD output.

Most of the variables in my program are floats, so it is important that the chip handle them efficiently.

I happen to stumble across the Atmel AVR, which looks very nice. It has a lot of C libraries and its bulk cost is low (if I ever go beyond the prototype phase). Any thoughts on this microcontroller, as compared to a PIC?
 
tyco said:
At most, I should need about 10 inputs and then the LCD output.

Most of the variables in my program are floats, so it is important that the chip handle them efficiently.

To handle floats 'efficiently' requires a maths co-processor, but any micro-controller will handle them well enough - particularly for a low speed application like your's. However, do you really need floats anyway?, it's usually possible to do most jobs with integers, faster, smaller, and more accurately.

I happen to stumble across the Atmel AVR, which looks very nice. It has a lot of C libraries and its bulk cost is low (if I ever go beyond the prototype phase). Any thoughts on this microcontroller, as compared to a PIC?

The AVR was Atmels attempt to steal some of the PIC's market, even to the extent of copying a three letter name - although they bear no resemblance to a PIC. They are good processors, either those or a PIC (or indeed many of the others) would be fine - your application sounds like it doesn't need much power anyway.
 
I don't need the precision of a float, but I am dealing with fractional values. Do you suggest I remove the decimal point to do the calculations and then reinsert it for display?

As for the speed needed, its hard to gauge. On my computer the program doesn't make a dent, but on a 10MHz processor I'm not sure. It does about 30 float (currently) calculations per user input. So as the user, for example, presses an up arrow, it should be able to show the result on the display in real-time. I'm not sure if thats a low-power application since I've never dealt with processor speeds so low.
 
tyco said:
I don't need the precision of a float, but I am dealing with fractional values. Do you suggest I remove the decimal point to do the calculations and then reinsert it for display?

Yes, it's far faster and more accurate - imagine you're dealing with money?, don't think of £5.29 (or $5.29), think of it as 529 pence (or 529 cents).

As for the speed needed, its hard to gauge. On my computer the program doesn't make a dent, but on a 10MHz processor I'm not sure. It does about 30 float (currently) calculations per user input. So as the user, for example, presses an up arrow, it should be able to show the result on the display in real-time. I'm not sure if thats a low-power application since I've never dealt with processor speeds so low.

You will be amazed how fast PIC's (and others) run - a 20MHz PIC only takes 200nS per instruction cycle, and almost all instructions only take one cycle (with a few taking two). So it can execute 5,000,000 instructions per second!, even at only 4MHz it does 1,000,000 per second.

As it's receiving input from a digital scale, presumably that is fairly slow?, due to the mechanical processes involved - anything in the 'real world' runs at a crawl compared to the PIC world.
 
Excellent. I feel much more comfortable with this entire project now.

I will take your advice on utilizing integer values instead of floats and I'll probably end up purchasing an AVR stater kit because of AVR-gcc (I have a Mac).

Thank you so much for all your help.
 
check out the Arduino from www.Sparkfun.com.

https://www.sparkfun.com/commerce/product_info.php?products_id=666

It uses the Atmega8 microcontroller. Its only $32, but make sure its got the necessary programming space first. If you need more inputs than it can allow, use a multiplexer for the inputs so you can use one input and use two or three output pins for changing the input address.

The programming is fairly easy with the arduino, So I would reccomend it highly. And its USB too! After you program it, you can remove the Atmega8 and build a permanent board, and buy a new controller for less than $10
 
Mind you, a 20mhz instruction cycle on an AVR is 50ns. Pic's still have an inbuilt divide by four clock on their system clock. That's a maximum of 1mips per mhz on an AVR. Depending on processing vs I/O requirements, AVR's can be 4 times faster than a similarly clocked PIC.
 
Sceadwian said:
Mind you, a 20mhz instruction cycle on an AVR is 50ns. Pic's still have an inbuilt divide by four clock on their system clock. That's a maximum of 1mips per mhz on an AVR. Depending on processing vs I/O requirements, AVR's can be 4 times faster than a similarly clocked PIC.

Unless you use an 18F or dsPIC series PIC?.
 
Sceadwian said:
Mind you, a 20mhz instruction cycle on an AVR is 50ns. Pic's still have an inbuilt divide by four clock on their system clock. That's a maximum of 1mips per mhz on an AVR. Depending on processing vs I/O requirements, AVR's can be 4 times faster than a similarly clocked PIC.

Sometimes I wonder where you pull your information from. PIC24s and dsPIC33s run up to 40MIPS (25ns instruction clock) and work on 16-bits of data making them quite a bit quicker. They also divide their clock by 2 instead of 4 which is a new approach for Microchip.

The dsPIC30s are divide by 4 but still run at 30MIPS and handle 16-bit data with true 5V signaling. You can even heat your house with them!
 
The only real reason I prefer AVR's over PIC's is there's less of a variety of them. The standard core is just that, completly standard across the entire line. Various higher end chips have hardware multipliers more I/O, timers, peripherals, memory. But the standard AVR architecture is the same across the entire product line.
 
805X's

You should still consider the 805X series of processors. Yes, there is a
huge selection of them about but a lot of the newer variations have ISP
(In System Programming) interfaces and you can build the hardware to
a finished (or almost finished) state and update the firmware at will. And
some of the newer ones from Atmel, Dallas / Maxim have serial, USB, i2C,
parallel, A/D, D/A, and keyboard interfaces built in! Now one thing kind of
on the down side is that these processors come in really tiny .5mm TQFP
packages and need adapter boards. these are easily available from places
like www.schmartboard.com (a hell of a selection of prototype boards are
available, highly recommended). Their new EZ series makes it super easy
to jump into surface mount prototyping to shrink those projects you have.
or another board supplier I found with cheap boards at https://stores.ebay.com/MeasureExplorer. Actually I've found a few
places but these have had the best quality boards. And fast shipping.
And most of these chips can be programmed using standard programmers
too if you don't want to mess with the ISP programming interface. I've used
these boards to make adapters for conventional programmers, but where they
really shine is when you get the design hardware finished and then decide
to build it with SMD's. The footprint shrinks dramatically. Yeah, you need
steady hands and if you're an old fart like me more than likely a magnifier
with a light source. But the end result is certainly worth the effort. Tiny,
rugged and a mighty feeling of accomplishment when you're done. Also, some
of those newer microcontrollers use so little power and have such a wide
power supply range that you can power them off of the serial, parallel or USB
ports eliminating the power supply portion of the show. If you do get the
adapters from one of these guys then tell them the Young Scientists Club
sent you. They've been so supportive in the past that I just want them to
know how much I appreciate them. And no, they don't pay me. Ha ha. They
just seem to be in the business for all the right reasons. To help folks learn
and get their projects going. And some of the gear they offer REALLY saves
that that most precious of commodities, TIME. Anyway, consider those
processors. There are such huge libraries of software for them. They've been
around so long that almost every problem you can think of coding them has
been addressed by someone out there. And the manufacturers have started
to supply their own code examples and development software for free. You
on have to download it and read, read, read, read.......... Then DO!

Dr. Atomic
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top