Micro-controllers

Mtns2Skies

Final Approach
Joined
Jul 12, 2008
Messages
5,618
Display Name

Display name:
Mtns2Skies
As a mechanical engineering student, my school requires us to take a mechatronics class. Prior to this class I have used Arduino's, PSoC's, and Raspberry Pi's in both industry and in other class projects. This particular professor I have reason to believe is stuck in the 90's and is wildly out of touch with industry. That being said, he requires us to use PIC controllers and PicBasicPro as a programming language for it.

Am I wrong? Are there any advantages at all to a PIC over the aforementioned micro-controllers?
 
Last edited:
I thought you meant the people at uncontrolled airports that act like they are controllers
 
The 90s. That's when he went from the real world into college. He is there for a reason.

I learned programming in Fortran when the world used C++. It's college, not real life.
 
Besides the fact that there are 10s of billions of PIC microcontrollers in use globally, and they're still selling a billion a year or so?

Arduinos and Pis are great if you want to build a one-off automatic cat feeder + webcam as a DIY hobbyist. If you want to mass-market a home appliance, you're probably going to use something like a PIC.
 
This particular professor I have reason to believe is stuck in the 90's and is wildly out of touch with industry. That being said, he requires us to use PIC controllers and PicBasicPro as a programming language for it.

Am I wrong? Are there any advantages at all to a PIC over the aforementioned micro-controllers?

The advantage is, the professor doesn't have to write any new course material or learn anything new. You have to do all the work.
 
Believe it or not, FORTRAN is still needed in certain applications. Abaqus (a very popular FEA solver) requires custom routines to be compiled in FORTRAN and linked in. Those PIC controllers he uses, while not terribly modern, are still important and would still seem to be adequate tools to teach the basics. But I do agree with you that the modern stuff is more interesting.
 
Last edited:
I have my students build micro controller boards using AVR chips. Program with C.

And, then, there is ladder logic...o_O
 
Oh boy... Why don't you just ask something less controversial like "My instructor said low-wing but I say high-wing, AMIRITE?" :D And I think you meant PSoC, not PISOC...

Before people start talking about crap they don't understand, I think it's worth pointing out the difference between microcontrollers (PIC, AVR, ARM Cortex-M, MSP430), SoC's (ARM7, ARM9, ARM11, MIPS, etc), and development boards (Arduino, BBB, RPi, etc). I already see these terms being used interchangeably when they are not the same thing...

The AVR at the heart of most Arduinos is exactly "something like a PIC" and is just as viable for large-scale commercial use. SoCs like that used in RPi are widely deployed in consumer electronics as well, but for a different problem domain than microcontrollers.

Going back to the OP's PIC question: The PIC, with its 4 cycles per instruction, banked memory, single working register architecture is inferior to just about every other offering out there. PIC toolchains are also inferior to the competition by a wide margin. Virtually every modern microcontroller has hardware debug capability whereas, for the most part, PICs do not. PIC has market momentum, however, with a huge install base. The very term PIC was synonymous with "affordable, powerful microcontroller" for a decade and a half. Inferior as it may be, it is still relevant. PICBASIC.... ugh. Less relevant.

It's not completely backasswards to be teaching a course based on the PIC today, but it is quickly becoming obsolete. PIC toolchains are among the worst I have ever used, the hardware architecture is quirky and confusing to students, and 8-bit uC's are rapidly being displaced by much faster, more versatile, and cost-competitive ARM Cortex microcontrollers. And if you want to be taken seriously in the embedded development world, you must put away that BASIC crap and make friends with C.

Even if PIC is worthwhile to know and still a market force, OP is not wrong and the professor is a dinosaur for using a development environment whose writing is on the wall.
 
Oh boy... Why don't you just ask something less controversial like "My instructor said low-wing but I say high-wing, AMIRITE?" :D And I think you meant PSoC, not PISOC...

Before people start talking about crap they don't understand, I think it's worth pointing out the difference between microcontrollers (PIC, AVR, ARM Cortex-M, MSP430), SoC's (ARM7, ARM9, ARM11, MIPS, etc), and development boards (Arduino, BBB, RPi, etc). I already see these terms being used interchangeably when they are not the same thing...

The AVR at the heart of most Arduinos is exactly "something like a PIC" and is just as viable for large-scale commercial use. SoCs like that used in RPi are widely deployed in consumer electronics as well, but for a different problem domain than microcontrollers.

Going back to the OP's PIC question: The PIC, with its 4 cycles per instruction, banked memory, single working register architecture is inferior to just about every other offering out there. PIC toolchains are also inferior to the competition by a wide margin. Virtually every modern microcontroller has hardware debug capability whereas, for the most part, PICs do not. PIC has market momentum, however, with a huge install base. The very term PIC was synonymous with "affordable, powerful microcontroller" for a decade and a half. Inferior as it may be, it is still relevant. PICBASIC.... ugh. Less relevant.

It's not completely backasswards to be teaching a course based on the PIC today, but it is quickly becoming obsolete. PIC toolchains are among the worst I have ever used, the hardware architecture is quirky and confusing to students, and 8-bit uC's are rapidly being displaced by much faster, more versatile, and cost-competitive ARM Cortex microcontrollers. And if you want to be taken seriously in the embedded development world, you must put away that BASIC crap and make friends with C.

Even if PIC is worthwhile to know and still a market force, OP is not wrong and the professor is a dinosaur for using a development environment whose writing is on the wall.
Thank you very much for that post.

What annoys me is that pbp is useless outside of PICs AFAIK whereas C or similar is immensely useful beyond one application.
 
As a mechanical engineering student, my school requires us to take a mechatronics class. Prior to this class I have used Arduino's, PSoC's, and Raspberry Pi's in both industry and in other class projects. This particular professor I have reason to believe is stuck in the 90's and is wildly out of touch with industry. That being said, he requires us to use PIC controllers and PicBasicPro as a programming language for it.

Am I wrong? Are there any advantages at all to a PIC over the aforementioned micro-controllers?
It doesn't matter a bit. If he has his course designed around the PIC then that's what you'll use. This is the first of probably hundreds of tools, languages, and gadgets that you will learn, use, and forget during your career. I have no idea how many programming languages I have forgotten, for example. The point of the course is to learn by using a particular tool, not to learn a tool that is particularly likely to be one that you'll use in the future. Sure, expertise with a Raspberry PI might be slightly more useful in the very near future but the RP will fade into obsolescence soon enough. In the 10-year rear view mirror you will see little difference between the PIC and the RP. As a learning exercise, the PIC may be more difficult to use and hence even be the better choice. Relax and enjoy the ride.
 
I think the prof should make the noob do his PIC project in Assembly just for whining. PBP has always been stupid and often wrote hideous binary code when you looked at what it was actually doing, taking bejillions more cycles to accomplish what a tiny bit of properly written assembly could accomplish.

AVR's C compiler always did a better job, but C was always a better language to get binary output from compared to any form of BASIC.

I agree with the student in that PIC is a bit outdated at this point, but that's not the point of the class. The point of the class is to teach you how to apply something new to you to a problem, something you'll do over and over and over and over, as well as get handed stuff that's WAY OLDER than a PIC and told "fix this or redesign it, oh and stay within this budget... Which approaches zero."

Learning PIC won't kill anybody at this point and won't hurt in the job world either. Sometimes in a HUGE VOLUME project, PIC is going to beat Atmel by a whole lot of pennies per device, and the project may be a lot more profitable when you save the company hundreds of thousands of dollars by using a fully capable older micro vs getting to play with the latest and greatest whiz bang gadget.

Plus... Pi and some of those systems you mentioned are fully integrated whole board computers. Small PIC and AVR (and God forbid even that awful Motorola thing -- what was it called?) are about making the entire circuit, including designing the board.

If the prof isn't doing THAT, shame on him. You're supposed to be learning to pick a part from the available parts from the data sheets and making a whole board around that part to do a task at the lowest possible per unit cost when you're playing with the smaller PIC and AVR devices.
 
In case anyone is remotely interested here's the course syllabus:

https://www.engr.colostate.edu/~dga/mech307/syllabus.html

For our project we're building an automatic paper airplane folder and launcher. Basically put a ream of paper at one end, flip a switch and it'll keep building and shooting them until you turn it off or it runs out of paper. We have more built in features to satisfy project requirements but that's the gist of it.

EDIT: if the course or project seems basic (which it is) keep in mind we're mechanical engineers, not electrical.
 
Last edited:
EDIT: if the course or project seems basic (which it is) keep in mind we're mechanical engineers, not electrical.
For "Mechatronics for Mechanical Engineers" it looks like a pretty decent set of topics to have covered. The big problem is that there is just too much stuff to cover in one semester or so.
 
The big problem is that there is just too much stuff to cover in one semester or so.
We have a lot of cross-over with other classes. We have a class more or less focused on data acquisition, physics electromagnetism, and introduction to electrical engineering are all pre-requisites to the class. I admit the electronics classes are where I'm weakest.

We also take a significant amount of civil engineering classes where I generally excel, as well as most of the mechanical engineering courses.
 
Agree the PIC is probably fine and as mentioned has it uses. The PBP will be simple and adequate for the project you are doing, but agree C would have been better.

I occasionally do projects using Picaxe, just because they are easy and cheap for one off projects. However an Altimeter I was building need a higher sample rate so I ordered the PIC version of a PICAXE chip and wrote the Altimeter sampling routine in Assembly Code. Even I was surprised when the Assembly code ran 1000+ times faster than the Basic Code.

I once did the same with a C compiler (old one), needed a routine that did a simple AND or OR on two 1KB strings. The assembly version of the function ran something like 100 times faster than the C version.

I have determined that 99% of time you are waiting on a computer it is simply because it has been determined it isn't cost effective to make/program it to be faster.

Brian

Engineering isn't about making the best, it is about making it just good enough.
 
PIC is an established platform with a great processor and compiler. And that matters, believe me. Arduino is just a toy for hobbyists, it is not approved for industrial applications because the C++ compiler is a joke and cannot produce reliable and repeatable code.
I have used PIC, Arduino, Motorolla with CodeWarrior etc .... and while Arduino is attractive for the new crowd because it is FREE and relatively simple to sh*t some code in, it is not a reliable professional platform.
For a one-off toy project for an on-the-side customer who wants to program something simple for his car, Arduino is not the worst choice (certainly better than Motorolla). But for a marketable product, I'll go with a PIC.
Take this with a grain of salt from a professional programmer.
 
[snip]
I once did the same with a C compiler (old one), needed a routine that did a simple AND or OR on two 1KB strings. The assembly version of the function ran something like 100 times faster than the C version.
[snip]

Engineering isn't about making the best, it is about making it just good enough.

This result surprises me. I spent a number of years writing both C and Assembler (on 80x86 devices). I was deeply enough into it that I identified bugs in mismatched compiler settings by viewing disassembled code and could tell which C compiler and which switches were set by viewing disassembled code (early to mid 1990's). It got to the point where the compilers optimizations were so good I couldn't often beat them. This is assuming the C code was properly written. (I took a set of parallel programing classes during the same time period. In Parallel Programming the big metric was speedup ratios. Take your serial implementation time and compare to the parallel/number of processors. At the end of 3 semesters and 6 classes the graduate teaching assistant who had done all the lab grading told me I had the fastest serial implementations of every exercise we'd done. I was GOOD at optimizing C code.)

As for Engineering being about making it good enough, it's true. Timeliness and Cost are both aspects of quality. Sometimes they are the dominant ones. Sometimes they're not.

John
 
PIC is an established platform with a great processor and compiler. And that matters, believe me. Arduino is just a toy for hobbyists, it is not approved for industrial applications because the C++ compiler is a joke and cannot produce reliable and repeatable code.
I have used PIC, Arduino, Motorolla with CodeWarrior etc .... and while Arduino is attractive for the new crowd because it is FREE and relatively simple to sh*t some code in, it is not a reliable professional platform.
For a one-off toy project for an on-the-side customer who wants to program something simple for his car, Arduino is not the worst choice (certainly better than Motorolla). But for a marketable product, I'll go with a PIC.
Take this with a grain of salt from a professional programmer.
Well, given that the whole Arduino concept was to create a device that could be used by artists/ hobbyists / kids / people who did not know how to write C...
On the other hand, there is no reason that you have to use the Arduino development environment even if you use the Arduino hardware platform - it uses standard AVR micro's that can be programmed in straight up C or assembly.
 
This result surprises me. I spent a number of years writing both C and Assembler (on 80x86 devices). I was deeply enough into it that I identified bugs in mismatched compiler settings by viewing disassembled code and could tell which C compiler and which switches were set by viewing disassembled code (early to mid 1990's). It got to the point where the compilers optimizations were so good I couldn't often beat them. This is assuming the C code was properly written. (I took a set of parallel programing classes during the same time period. In Parallel Programming the big metric was speedup ratios. Take your serial implementation time and compare to the parallel/number of processors. At the end of 3 semesters and 6 classes the graduate teaching assistant who had done all the lab grading told me I had the fastest serial implementations of every exercise we'd done. I was GOOD at optimizing C code.)

As for Engineering being about making it good enough, it's true. Timeliness and Cost are both aspects of quality. Sometimes they are the dominant ones. Sometimes they're not.

John

I am sure C compilers have gotten a lot better since then, especially at simple but data intensive operations. I still have my Microsoft C book on the shelf from that project, If I recall correctly I think I was writing on a 286 machine at the time.

Brian
 
You can't get some of the ivy-covered professors to budge. There used to be a course at the University of Maryland required for computer science majors. It was a course in operating systems where you had to write your own simple OS. This had to be done on one of two PDP-11 clunkers upstairs left for the purpose. Microcomputers were right out.

The department got several IBM Mainframes running VM/CMS (this was about 1983 or so). Now VM would be a perfect platform to teach OS on as essentially it gave you a real nice environment for development (assuming you don't think the pain of dealing with a PDP-11 front panel is part of the "learning experience."). Couple this with the fact that the mainframes could support just about everybody in the class as a concurrent user, each in their own virtual environment.
The guy who ran the IBM mainframes and I even offered to rewrite the curriculum from the PDP-11-centric stuff to the 370 but we couldn't even get the prof to consider it.
 
EDIT: if the course or project seems basic (which it is) keep in mind we're mechanical engineers, not electrical.

In chemical engineering, we would have made certain that there is a 'kaboom' wherever the paper airplane comes down ;-)
 
Some schools are more flexible than others. Any chance that the professor might accept documentation of completed relevant projects in industry as a substitute for the course? For example, I was allowed to make a presentation on several patents for which I was named as inventor as a substitute for performing a senior design project.
 
Arduino is just a toy for hobbyists
Now you've gone and made a comparison between a PIC and the Arduino hardware and development environment. A valid comparison would be something like BASIC Stamp and Arduino or PIC and AVR.

it is not approved for industrial applications

That's a funny statement. There is no law regulating what microcontrollers can be used in indistrial applications, so who does it need to be approved by? AVR parts come in packaging and temperature ranges intended for automotive and industrial applications, just like every other semiconductor device.

In fact you can find AVRs similar to what's used in Arduino in all the places you also find PICs: set-top boxes, RC transmitters, oscilloscope front panels, battery chargers, Honeywell thermostats, glucose meters for diabetics, motor controllers, some Logitech devices, KVM switches, consumer RADAR gun, that stupid Roomba robot vacuum cleaner, some of those trailerable RADAR speed signs that show your speed as you drive by...

Hell there's even a blog dedicated to showcasing consumer and industrial products that have AVRs inside. Passive infrared motion sensor, satellite broadcast LNB, Sirius Satellite radio receiver, industrial water flow meter, an industrial fan controller...

Sure, the Arduino software development environment is hobbyist, with its lack of debugging and serial bootloader, but so are a lot of PIC development environments. GCC does a fine job of compiling C/C++ for AVR, and there's also the old AVR Studio 4, CodeVision, CrossWorks, IAR, Imagecraft. The hardware debugging (PDI, debugWire, or JTAG) beats the pants off Microchip's ICD2/3 solution and doesn't require a software blob to be installed into the uC.

PIC was a great thing for its time, but architecturally it is quirky, power-hungry, and inefficient. It may still be perfectly great and viable, but neither the architecture nor the toolchain have a leg up on AVR and ARM.

because the C++ compiler is a joke and cannot produce reliable and repeatable code.
You said C++ so I assume you're talking about GCC. This is a rather bold claim that runs counter to all the evidence I have seen. I have to assume that this was a case of garbage-in/garbage-out until you can demonstrate otherwise--I have written a lot of perfectly reliable and repeatable code on AVR with GCC. Atmel no longer maintains their own C compiler and now use GCC exclusively for their ARM and AVR parts. Freescale, TI, NXP, and ST parts are all supported by GCC as well. Maybe the last time you looked into it was 15 years ago?

I have used PIC, Arduino, Motorolla with CodeWarrior etc .... and while Arduino is attractive for the new crowd because it is FREE and relatively simple to sh*t some code in, it is not a reliable professional platform.
I agree with you that Arduino doesn't have any place on the production line, but neither does PICBASIC or BASCOM for that matter. Arduino is, however, much more relevant to the world right now, the hardware is based on a production-ready microcontroller and the software is C at its core. One could dip his feet into the embedded world with Arduino and eventually graduate from their horrible, low-quality libraries and development environment more smoothly than a transition from BASIC.

For a one-off toy project for an on-the-side customer who wants to program something simple for his car, Arduino is not the worst choice (certainly better than Motorolla). But for a marketable product, I'll go with a PIC.
Take this with a grain of salt from a professional programmer.
You keep putting too many l's in Motorola, by the way. Sorry, it's just a pet peeve like those guys who keep getting new breaks for their cameros.

Respectfully, I think you keep going back to PIC out of habit and familiarity. I normally write C++ firmware and drivers for products running VxWorks and WinCE7, but I also get paid to write PIC and AVR firmware and the occasional VHDL for FPGAs. I've done projects with soft-core CPUs like MicroBlaze and PicoBlaze, I've done a project with FreeRTOS on a Cortex-M4, I have development boards for most major embedded technologies like Freescale i.MX, Kinetis, ARM9, AVR, PIC, OMAP, MSP430, AVR32, PSoC, Xilinx, STM32, QorIQ. I've written assembly for PIC, AVR, Motorola 68HC, x86. I've worked with embedded Linux on ARM9 and MIPS, FreeBSD on the BBB. I wrote DOS programs in PowerBASIC and TurboPASCAL and I've used all kinds of quirky stupid C compilers on a variety of architectures.

I used to be a PIC fanboy until a trusted friend convinced me to try AVR, and this was long before Arduino existed. I despise Arduino, though lately I am willing to turn a blind-eye to hobbyists who choose to partake. Why the FAA lets these guys fly, I just can't understand :D

I have seen the future, though, and it is ARM. Why would anyone spend $4 on an 8-bit uC that is slower, has fewer peripherals, and less RAM and program space than a $3 ARM? It's easier to port between STM and NXP ARMs than AVR and PIC, and you can scale your project up from M0 to M3 and M4 as your requirements change without losing so much invested. The debugging capabilities are excellent and the extra available processing power lets you easily run an RTOS and/or spend less time hand-optimizing for that last ounce of performance.

I'm not saying that PIC is worthless, but the only people I see consistently getting excited about it where I work are over 50 and can't stop comparing it to the 8051. Their skills are not fresh and their programs are never more than 500 lines long. They don't want to hang up their Nuvistors and put their tunnel diodes away. They just built another really cool TNC for their C64 packet radio setup. Meanwhile the world is moving onward and forwards, except maybe for OP's mechatronics class. :D

But a message to the OP:
Look around your school and you will see two types of engineering students: Those who are learning everything they know in school and those who are going above and beyond and taking their projects home. This class and this PIC experience is just another tool in your bag and in no way subtracts from the sum total of your experience. It only adds to your perspective and in that regard is a positive and edifying experience. You can do it with the PIC in class and spend your own time to do it with the RPi or Arduino. You'll just have more experience to compare and you'll be able to make a more compelling and informed argument in favor of your favorite technology when that day comes later.

I started programming in BASIC and I started microcontrollers on the PIC and I have no regrets.
 
OP, look at the nerd-fight you have set off here!
 
Loved the summary @ollopa. You got most of it nailed other that that bias against old guys. I've seen old guys who could code in all of them, and old guys who were like yours who hadn't written much useful in a long-assed time. The ones who can code in anything would not care if you handed them a PIC or an AVR or told them to do it all in an FPGA. The two micros are such similar tools to reach an end that it almost doesn't matter which one you use unless certain needs pop up.

The comment about the typical micro compiler generating "1000 X" slower code was interesting. I never found the compiled code to be THAT bad, but some LIBRARIES certainly were close to that bad at certain things.

Back to those old guys. Many of them would have a directory full of stuff they wrote and optimized themselves over the years and if someone handed them a design that had to be ultra cheap and use a tiny PIC with no UART and bit-banged serial, they'd just copy their assembly file into the Dev directory and slap the control code around it and have it done in minutes. They knew there was no point in reinventing the wheel if the project called for a specific device. They usually had code for the device or something close enough to modify slightly, sitting there in their Dev tree on their workstation and making a copy and integrating it, took them no time at all.

In fact they'd usually find it boring. But also knew it paid the bills.

All that rot about the AVR not being used in industrial applications was utter garbage. They're used all the time.

I have a similarly meh attitude about Arduino. Never bought one, even to play with. I'd just grab the appropriate AVR and make my own board drawing and have one of the cheap prototype board places make me a board and have it at the house in two days.

When I was hot and heavy into hobby stuff with both chip manufacturer's chipsets, I'd say it took about two small projects to understand each's architecture and instruction set, and while I thought the Atmel docs were more readable, the Microchip docs were more detailed. Atmel at the time was pushing the use of their C complier and Microchip was still really targeting someone writing in assembler.

For simple stuff the AVR was faster to write for. But one never wanted to open up their standard libs and read them too carefully. They were badly bloated back then.

Motorola stuff was kinda a general disaster overall. They were constantly offering free Dev kits and I had a couple lying around collecting dust. Never really found a need for them.
 
Interesting discussion. I don't understand 90%, so I feel justified in chiming in.

Mechanical engineer? Python, arduino, C.

Enjoy it now. You're going to spend 90% of your time in meetings or doing PowerPoint presentations regardless. :)
 
I love it when these guys talk dirty! :)

Jim
 
Enjoy it now. You're going to spend 90% of your time in meetings or doing PowerPoint presentations regardless. :)
Wow.

Talk about a buzz kill.

Why ruin his fun now? Let him enjoy school. He will be finding out soon enough what it's really like.
 
Wow.

Talk about a buzz kill.

Why ruin his fun now? Let him enjoy school. He will be finding out soon enough what it's really like.
I'm not so sure engineering school was meant to be "fun". If it is, I think you're doing it wrong. :)

My first co-op I did plant support which was some solid work designing components then milling them out. My next co-op will be with a bush aircraft manufacturer in eastern washington... so hopefully more fun stuff!

In my limited experience industry has been the fun part, not school.
 
You could build a robot that pushes the mouse buttons to advance the powerpoint.
 
Enjoy it now. You're going to spend 90% of your time in meetings or doing PowerPoint presentations regardless. :)

You could build a robot that pushes the mouse buttons to advance the powerpoint.

Oh man, I laughed out loud... at both.

Don't forget the ever-popular spoken-by-some-Project-Manager who had a month to prepare: "Oh, you're a Linux Engineer, so you know COMPUTERS... and I can't get the projector/room HDMI to the Wall-O-Vision TV thingy, to work on my Windows machine for the PowerPoint presentation in ten minutes that I made about your project that needs a massive budget and will take a year to implement... so you'll take care of that, right?" :) :) :)
 
Hey I'm not biased against old guys, I'm just saying that when a guy gets hung up on the way things used to be done, he's usually an old guy. "All 'A' are 'B'" doesn't mean that all "B" are "A"!
 
Wow.

Talk about a buzz kill.

Why ruin his fun now? Let him enjoy school. He will be finding out soon enough what it's really like.

I kid, I kid. It's what you make it, and I'm on the less design-focused side, though have had some great design gigs.

You could build a robot that pushes the mouse buttons to advance the powerpoint.

That's what PM's are for. ;)
 
Back
Top