Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
LinkBack Thread Tools Display Modes
Old 2nd October 2007, 03:22 AM   (permalink)
Default

Usually programming in C will produce code that's quite a bit less efficient than if programmed carefully in assembly. However, I've found that generally it's fair, and sometimes the simplicity of C overshadows the costs, in terms of time of writing and debug, of straight assembly. Of course, stuff that's *really* critical to get right, including dealing with running out of program memory, getting every single last byte through assembly is crucial.

Because C is much easier to write and maintain, I think I'm about to GPL my really simple AVR-C tachometer (configurable to both fake-analog or 7-segment) without actually building the circuit and getting other people to fix it... Actually, I'm planning on doing this to see how many people bite and build one despite that fact of missing the hardware sample.

I think both PIC and AVR assembly have their strengths and weaknesses, both have nice features, but I personally prefer AVR as it seems more natural to me.

Quote:
Originally Posted by nunotins14
Code:
#include "16F84A.h"
#fuses XT, NOWDT, NOPROTECT
#use delay(clock=4000000)

void main()
{
	if (input(PIN_A0) == 1)
		output_high(PIN_A1);

	else if (input(PIN_A0) == 0)
		output_low(PIN_A1);
}
I'm not sure what you mean by "stable" or about PIC C compilers, but typically, at least in avr-gcc, if you want to constantly monitor a signal to change another, you'll need to make an endless loop:

Code:
#include "16F84A.h"
#fuses XT, NOWDT, NOPROTECT
#use delay(clock=4000000)

void main()
{
        while(1)
	{
		if (input(PIN_A0) == 1)
			output_high(PIN_A1);

		else if (input(PIN_A0) == 0)
			output_low(PIN_A1);
        }
}
Now you should have a $6.00 line driver
boxer4 is offline  
Old 2nd October 2007, 10:13 AM   (permalink)
Default

Quote:
Originally Posted by Sceadwian
How specifically is PIC assembler more efficient? Also what about complexity? Basic code in ASM specifically is a lot easier to understand on an AVR than it is a PIC
Presumably you mean that YOU find AVR assembler code easier to understand?, just because you do doesn't mean the rest of the world does. The far smaller instruction set means that many people find it easier to learn.

Personally I find PIC assembler far simpler, and so do many others - I think it really depends on your programming background?. I've always considered that a 6502 background means you find PIC easier, and a Z80 background means you find AVR easier.

Quote:

they both might be RISC based but the similarities stop there. A speed difference of 4 to 1 per clock is pretty big by anyones standards, which specific higher end PICS are you referring to vs which specific AVR's?
AVR's have a 4 times higher clock speed, but they don't run programmes four times faster - PIC assembler is pretty efficient, because it's very accurately targeted at doing a specific job. If you're trying to do micro-processor type applications?, then the AVR has significant advantages, as it's less specifically a micro-controller.

As always though , both will do almost all jobs, as will many other micro-controllers, it's really just down to personal choice.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 2nd October 2007, 07:58 PM   (permalink)
Default

boxer4 sorry i forgot that part...i did it too, if you notice i said the lad flashes, its impossible for it to flash without the loop



Guys what about the Intel 8051 family i read it controls over 40% of the microcontrollers market
Is it a good choice?
nunotins14 is offline  
Old 2nd October 2007, 09:17 PM   (permalink)
Default

Quote:
Originally Posted by nunotins14
Guys what about the Intel 8051 family i read it controls over 40% of the microcontrollers market
Is it a good choice?
It's a good choice if you have a job lined up programming for it - but essentially it's a very old, fairly low spec, design, a micro-processor that was modified to make it somewhat micro-controller like.

The reason it's around in large numbers is because it's made by lots of different manufacturers, and it's been about for such a long time.

If you search these forums you will notice that almost all posts regarding it come from India and the surrounding area - the rest of the world moved on from them a long time ago.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 2nd October 2007, 09:51 PM   (permalink)
Default

hmm...i just said this cuz im using them at school
Nigel what you use, what's the "best" for you, that has PWM, ADC etc?
nunotins14 is offline  
Old 2nd October 2007, 10:50 PM   (permalink)
Default

Quote:
Originally Posted by nunotins14
hmm...i just said this cuz im using them at school
Nigel what you use, what's the "best" for you, that has PWM, ADC etc?
I use PIC's which are by far the most popular amongst hobbyists, but if you are learning 8051 it would make good sense to go with that. Generally you can do what you want with almost any micro-controller.

Once you've learnt 8051 at school, and you want to move to something more modern, I would suggest the Atmel AVR - which is probably second in popularity, but more similar to the 8051 than the PIC.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 2nd October 2007, 11:14 PM   (permalink)
Default

hmm i see...but i cant find a cheap easy programming popular with PWM and ADC PIC :/, by the way...where is the radio project in your website?
nunotins14 is offline  
Old 3rd October 2007, 12:26 AM   (permalink)
Default

With PWM and ADC? Lots of pics have both of those features, lots of AVR's have those features as well. There are cheap programmers by the dozen on the net and you can home brew SPI programmers with a few discrete components plugged into a parallel port and using software such as ponyprog. You can usually home brew something for a few dollars. Try actually looking =)

http://www.lancos.com/prog.html

Supports the bulk of the PIC and AVR lines as well as eeproms and allows communication to any device that use an I2c bus. Circuit schematics provided for all interfaces.
__________________
"Because I be what I be. I would tell you what you want to know if I
could, mum, but I be a cat, and no cat anywhere ever gave anyone a
straight answer, har har."
Sceadwian is offline  
Old 3rd October 2007, 01:34 AM   (permalink)
Default

lol i know that there are many microcontrollers with these features, but my question was, cheaper with PWM, ADC, home made programmer, easy interface etc, you guys just say, there are many, you can use this you can use that, this site this this site that, but i want a reference im using PIC16F84A, so, I should upgrade to ...? :P
nunotins14 is offline  
Old 3rd October 2007, 03:11 AM   (permalink)
Default

I was using a 16C84 and 16F84 on one of my projects but quickly switched to the 16F628A as it's much cheaper and easily portable (minus a few setup, my code directly ran on the 628A). The programmer was fairly simple. I also use the AVR 90S2313 and think they're about the same in terms of dev starter costs.

As usual I'd say don't use manufacturer to choose your design, use your design to choose your manufacturer. I still prefer AVR for its general purpose instruction set rather than a fairly hackish PIC architecture, though it's absolutely unnecessary to have general purpose. I like the general purpose nature because things like gcc can have natural backend mappers that work like any other CPU.

You know things are a hack when things like PCLATH and bank switches need to be monitored carefully... And the fixed stack size (though you wouldn't want to go too deep anyway) can be quite annoying. One thing I should have done on PIC is macro btfss as naturally I'd think the next instruction _should_ be executed if true, not skipped
boxer4 is offline  
Old 3rd October 2007, 07:46 AM   (permalink)
Default

Ok, we have many opinions, damn, why they make so many PIC's lol...but looks like I have some good info for the upgrade...

Thanks alot guys
nunotins14 is offline  
Old 3rd October 2007, 09:12 AM   (permalink)
Default

Quote:
Originally Posted by nunotins14
lol i know that there are many microcontrollers with these features, but my question was, cheaper with PWM, ADC, home made programmer, easy interface etc, you guys just say, there are many, you can use this you can use that, this site this this site that, but i want a reference im using PIC16F84A, so, I should upgrade to ...? :P
As you're using the long obselete 16F84, the obvious move is to it's replacement the 16F628 - but for similar chips with ADC etc. look at the 16F88 and 16F819.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk

Last edited by Nigel Goodwin; 3rd October 2007 at 09:14 AM.
Nigel Goodwin is offline  
Old 3rd October 2007, 10:15 AM   (permalink)
Default

Trust us, starts with PIC because it is simpler to get something working with PIC first.

Then moves on to AVR, and this is what one gets.

For about the same price per chip, 32 general purpose registers(six of them can be used as three 16-bit address pointer), linear SRAM memory addressing without banks to worry about, unlimited stack level within reasons, vectored interrupt handling and free full-featured GCC C compiler.

I try not to mention the up to four time speed increases at the same crystal frequency as someone will jump in and said there is no point because most of the time the MCU is spent waiting.

The down side of AVR, unlike PIC, which is foolproof on this aspect, is in its fuses programming. Unaware learner can program an AVR into a state where he cannot access it again using more general programmer hardware. That said, the fuse information is clear and it is always the user fault not understand them or following them closely or not knowing what he would end up with a particular fuse setting.

Added: If one still wants to go ahead with AVR, the best one to try is the Tiny2313(20-pin). With 2K of flash, 128 Byte SRAM and 128 Byte EEPROM. One also gets a full 8-bit port and separate pins for serial RX/TX. Not even the bigger 28-pin brother Mega88 can beat that.
__________________
L.Chung

Last edited by eblc1388; 3rd October 2007 at 10:27 AM.
eblc1388 is offline  
Old 3rd October 2007, 09:25 PM   (permalink)
Default

eblc1388 what PIC you recomend that fits my needs?
nunotins14 is offline  
Old 4th October 2007, 08:11 AM   (permalink)
Smile

Well,

Atmel also has many varieties..

Atmel avr or 89 series

and microchip has pic and its many varieties..

Actually both are good...

1. AVR by Atmel is a fresh controller.. and you can get its easy to make programmer also very easily.. at ..

this page

and refer the websites for tutorials and projects:

www.avrfreaks.net
www.avrbeginners.net

---------------------------------------------------------------------


2. while pic has many advantages that.. you'll get a lot of material on internet to work with..

programmers are easy to be found in the market.. and easy to make at home also..

and a lot of people working with this controllers..

in other words.. lucky to start with pic..

Refer our moderators site for further clarifications:

www.winpicprog.co.uk


----------------------------

Please check my answer before taking decision..

Regards,

Simran..
__________________
Simran..
8051 Specialist..

Last edited by simrantogether; 4th October 2007 at 08:22 AM.
simrantogether is offline  
Reply

Bookmarks

Thread Tools
Display Modes



Similar Threads
Title Starter Forum Replies Latest
Why choose PIC instead of other microcontroller? StupidDum Micro Controllers 33 21st October 2007 08:28 AM
Programming the Mini-Max 8051 microcontroller blimon Micro Controllers 8 13th July 2005 03:42 AM
Answers for cisco test faiz General Electronics Chat 0 13th July 2004 04:06 PM
Connection of Siemens c167 microcontroller to peripherals. Roslan Electronic Projects Design/Ideas/Reviews 3 23rd March 2004 07:52 PM
Interfacing a microcontroller with a modem matt_d82 General Electronics Chat 3 21st March 2004 03:43 AM



All times are GMT. The time now is 08:58 PM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

eXTReMe Tracker