Switchin from Picaxe to PICMicrochips?

Homebrew Talk - Beer, Wine, Mead, & Cider Brewing Discussion Forum

Help Support Homebrew Talk - Beer, Wine, Mead, & Cider Brewing Discussion Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.

Rbeckett

Well-Known Member
Joined
Dec 23, 2011
Messages
993
Reaction score
72
Location
Bronson
I'm switching to PIC Microchip 16F877A from Picaxe and was interested in discussing the different programmers and developement languages. I dont Know C or C+ , but will have to learn something new so I guess I should try to learn C+ to keep up. Any recomendations on prefered software. I have downloaded the MPLAB IDE so what else should I need to be able to wirte to a 16f series chip? I'm sort of looking for an integrated app to write, compile and debug all in one program. Something well supported and with a large help or forum for support would also be good too. Suggestions, Ideas, Recomendations? Microchip is all new to me so I would also like something a little less esoteric and difficult to learn too. Thanks in advance for the help and motivation.
WCB
 
Take two courses at your local college or tech school. 1st, take a C class. If you do embedded firmware, you need to learn C. You might be able to figure this out on your own, but the class is better for a bunch of reasons.

Second, you probably would benefit from a microcontroller class. They typically involve learning assembly language for some processor. This class will teach you how the hardware of the processor works.

MPLAB is a pretty crappy IDE, but it is free and I think there is a free C compiler for it. If you want to spend money, IAR makes a great IDE (I use this for other processors).
 
I agree with passedpawn, C is the best language to learn for PICs and micros in general. It might be worth buying a cheap development board (Sparkfun comes to mind). The dev boards will do most of the heavy lifting for you with power regulation, I/O, and some basic peripherals.
 
Kladue, Passed,
I have not looked at ARM because I figured I would eventually get to C++ and I was also trying to get into the mainstream chip population rather than the different variations that are available in Arduino, ARM and PicBasic. Its kinda like I might as well go to the mountain instead of climbing several small hills. So I ordered a couple of recent text books for a C++ class and Bjarnes C++ treatise. (why he built it and whats in the package, commands, and structure). I found a couple of good C++ programs to look at instead of MPLAB and I found a compiler that will do a direct to machine languge compilation. I ordered a couple of Sparkfuns 16f877A evaluation and project boards. The LED's will be a nice indicator of pin status while simulating the chip running I guess that means I have commited to eventually learning machine code in the distant future. I may not live that long, but it still a possibility. I live in a college community so tutoring or a class may be pretty easy to locate and attend. Our local community college has a pretty big electronics lab and program. Thanks for the differint ideas and approaches, it's always good to look at a few alternatives before setting sail on a new plan.
Thanks!!!!
WCB
 
Rbeckett,

What do you mean exactly by "trying to get into the mainstream chip population"? Arduino, ARM and PicBasic aren't "variations" they're completely different product classes.

Arduino and PICs are similar in that they are microcontrollers (Arduino is just an atmel AVR)
ARM is a core design platform for SoCs (System on chip), more powerful, than microcontrollers, not always as good for hardware interfacing
PicBasic is a terrible programming language for PICs (My first embedded language too)

for working with any microcontroller you'll want to learn C, if you wish to progress to C++ then C is a good starting point, as the name suggests, C is the base of the developed C++. I work in embedded development for a company which makes industrial networking products using quite powerful SoCs, We develop in C. for embedded purposes, C++ is overkill.
 
Rbeckett,

What do you mean exactly by "trying to get into the mainstream chip population"?

for working with any microcontroller you'll want to learn C, if you wish to progress to C++ then C is a good starting point, as the name suggests, C is the base of the developed C++.

Snood,
What I meant was having to learn different systems like changing from Arduino, and Picaxe to some othe chip with a different language or connection method (system). I figure if I have to learn something I might as well go to the top and learn the real deal rather than another intermediate language/system along the way. I was also told that learning C++ would encompas C since the + version has all of the basic C stuff plus all of the enhancements too. Now I'm really confused. So do I need to learn C before I go to C++ or just continue to work on C++ as I had planned? I know C++ is overkill for a brew troller, but I would like to learn enough to create other items of interest too, I never know where my mind is going next so I was preemptively preparing for the inevitable
WCB
 
I was also told that learning C++ would encompas C since the + version has all of the basic C stuff plus all of the enhancements too.

I don't know who you're talking to, but this is terrible advice.

C is a very simple, self-contained, straightforward, bare-bones language. C++ tries to fill every possible programming niche while remaining "C-like" to the point that it is so filled with gotchas that there are several books written for the sole purpose of helping people not screw up their C++ code.

Learning C++ will not help you learn C. While it is true that valid C code is normally also valid C++ code, the "same code" does vastly different things under the hood depending on whether it was compiled as C or C++.
 
Last edited by a moderator:
Berner,
Thanks for the get right!!! I was reading Bjarne Stroudstrups book on using C++ and the intro on Amazon said that learning C++ was an automatic extension of the C language and would cover all of it at the same time. I already have a couple of C++ texts coming, but I will probably revert to C and conquer that first. Then I will evaluate if I need to go further into C++ then. Since there is little guidance in the electronics field it does make it difficult to get a good bearing on how to get from A to B without going off on a tangent and getting uneeded or uneccesary stuff along the way. Thanks a ton!!!
WCB
 
If your sole purpose is to write your own brewing system, why not just use arduino? It would get you up and running a lot faster and likely have a much quicker learning curve. Another option is BASCOM AVR for the Atmel AVR micros. It is a "Basic" type language, but does native code compiling (not interpreted like arduino). It has a great IDE with built in compiler, debugger and programmer. I've done several complex programs with Bascom including some automotive interfaces using CAN and it handles everything I throw at it. On occassion, I'll use some inline assembly with it, but mostly it is all done in basic.

Nothing wrong with going the C/C++ route, but if your purpose is just a few small projects, I'd go with something that will get you running quicker.
 
If your sole purpose is to write your own brewing system, why not just use arduino? It would get you up and running a lot faster and likely have a much quicker learning curve. Another option is BASCOM AVR for the Atmel AVR micros. It is a "Basic" type language, but does native code compiling (not interpreted like arduino).

Fairly certain that Arduino is not interpreted, it is compiled. The Arduino language may be interpreted to C/C++, but then it is compiled. There is not an interpreter program running on the Arduino.

I do agree that Arduino is a better option than learning C/C++ and programming a PIC. The Arduino language is C-like and is very simple to get up and running. In my opinion, the only two reasons to not use an Arduino would be if 1) the Arduino micocontrollers do not have the features you need or 2) you're trying to squeeze every ounce of performance out of your microcontroller.
 
I have been programming the Picaxe line of chips successfully for about a year now in BASIC. The system is great for learning to think in an orderly manner and to address issues and bugs since it is very literal. The problem with the Picaxe system is it's lack of speed. I have run several sims on my Picaxe IDE and they all seem to run way slow. This causes issues with timing and polling that must be addressed with wait and pause commands to allow the data to get collected and written before it can be used to manipulate the outcome. DS18B20's are even too fast for Picaxe, so I figured sine I had to learn another language I might try to get a bit further up the ladder before I start trying to write in Machine language. Since I am wheelchair bound and have an enormous amount of spare time to study while I am at dialysis (12 hours in three days), I figured I might apply myself to a tougher task than BASIC. I am not really interested in how fast I can learn to do it, just that I can eventually do it right and have the knowledge to use it on other projects that may eventually pique my interest too. I appreciate all the different ideas and suggestion though and have a fall back plan if the PIC route fails with Arduino since there is so much available in sheilds, boards and code already available. Thanks a ton.
WCB
 
I would learn C and stick with that. You can develop on most micros with C. I have never heard of anybody developing firmware in C++. You should also never need to touch assembly ( machine code) unless you need to tweak a boot loader or optimize code. The point of using a language over assembly is develop code more efficiently. It is good to understand assembly and how C translates into assembly but it isn't necessary. I work for a wireless sensor company and we develop all of our FW in C. It is the industry standard.
 
Thanks Crane.
I ordered the C text books and have been studying the You Tube vids by Learnorama and doing the basic experiments like "hello world" along with them. So far it's been pretty good. And if I ever decide to go beyond C, I will have the text books for that too. Kinda sucks I wasted the money on C++, but I just got bad advice so it's not the end of the world.
Wheelchair Bob
 
Hi

Just to be different - MPLAB is fine for doing the PIC 16's in assembly language. The 16 series is pretty simple stuff. Not many instructions or variations on them. Depending on what you are really trying to do, assembly might be the better choice.

Bob
 
I would forget the PICs and go AVR. The avr-gcc/avrdude toolchain is very mature, they are blazing fast, and there's always Arduino if you are into that kind of thing. I use ATMEGA's for all my hobby stuff.
 
I would forget the PICs and go AVR. The avr-gcc/avrdude toolchain is very mature, they are blazing fast, and there's always Arduino if you are into that kind of thing. I use ATMEGA's for all my hobby stuff.

Hi

For that matter dump all this silly 8 and 16 bit stuff and go to a real CPU that runs 32 bits. The cost penalty isn't all that great anymore.

There are at least three dozen outfits that would *love* to change your mind about which cpu to use. Pick one and run with it ....

Bob
 
Built a couple of negative side transistor switches for pin outs on the 16f877A. Did a breadboard first then a couple of point to points and they tripped the SSR's and the lower amp relays perfectly every time. I guess I should look and see if they are switching on the leading or trailing edge of the volts. .012 uA to trip a 250 VAC 10A relay, or the 20 and 40 amp SSR's. Well below the sink/source of the chips pin output. I'm happy... Just gotta keep chuggin along now. The home stretch is coming...
Bob
 
Built a couple of negative side transistor switches for pin outs on the 16f877A. Did a breadboard first then a couple of point to points and they tripped the SSR's and the lower amp relays perfectly every time. I guess I should look and see if they are switching on the leading or trailing edge of the volts. .012 uA to trip a 250 VAC 10A relay, or the 20 and 40 amp SSR's. Well below the sink/source of the chips pin output. I'm happy... Just gotta keep chuggin along now. The home stretch is coming...
Bob

So you are saying you tied a IO pin from the processor to a npn (or n-ch fet) transistor, then switched the negative side of the SSRs control side (and tied the + side of the SSR input to the positive rail (though a resistor hopefully)?

The control side of the SSR is an optocoupler and should draw at least a few milliamps. Maybe the current you are talking about is from the processor to the base of the transistor?
 
Yes it was from the processor through the NPN, two resistors and an led. It calculated out to .012 uA switchin a much larger 12 VDC up to 380VAC circuit. I was only using 5 volts during the initial tests to keep the magic smoke in as much as possible, I leak it out quite a bit still.
Bob
 
Yes it was from the processor through the NPN, two resistors and an led. It calculated out to .012 uA switchin a much larger 12 VDC up to 380VAC circuit. I was only using 5 volts during the initial tests to keep the magic smoke in as much as possible, I leak it out quite a bit still.
Bob

Hi

You probably want to run a bit more bias current on the transistor. The gotcha is reverse leakage as the part ages or as temperature goes up. Roughly a 10 to 1 ratio between bias and switch current is a good target.

Bob
 
Don't forget to place a diode across the coil on the relays to prevent your I/O pins from frying when the coil turns off and needs a place to stash some energy quickly.
 
I'm using 1N4007 1000V, 1 amp. Should be big enough to reroute back emf with little delay. The resistors are a 560 Ohm on the high side of the 2N3906 with a 3mm green LED, the 100K is on the center or control pin. 12 VDC max 1.5 A on my bench top adjustable Power supply. The 1n4007 should be fine for a motor like a march pump or an SSR or a relay.
Thanks for the tip though.
Bob
 

Latest posts

Back
Top