maybe getting into PIC

Thread Starter

strantor

Joined Oct 3, 2010
6,782
Ok, so I have been using Arduino for all my μC needs until now. Now I need high speed PWM which Arduino lacks. I have been steered toward PIC but I am not looking forward to another steep learning curve. I have seen some "starter kits" out there but I don't know which way to turn. Seems the world of PIC has more options. What would be the easiet & cheapest route for someone with a little (little) bit of programming experience? It would be nice if whatever "starter kit" was capable of 20khz PWM.
 
I can't let this go by without commenting, but I would be stunned that the Arduino couldn't 20 kHz PWM. The underlying AVR mega168, or 328, has a 16 bit timer with two seperate registers, meaning two different PWM's of the same frequency.

I'm all for PIC's, but why spend the cash and time learning a new system, if the current platform is perfectly capable?
 

Thread Starter

strantor

Joined Oct 3, 2010
6,782
DOH! I love you.
I found this initially:
http://www.arduino.cc/en/Reference/AnalogWrite
After a call to analogWrite(), the pin will generate a steady square wave of the specified duty cycle until the next call to analogWrite() (or a call to digitalRead() or digitalWrite() on the same pin). The frequency of the PWM signal is approximately 490 Hz.
So I thought I was limited to ~500Hz PWM.

You prompted me to search further and I found this:
http://www.arduino.cc/playground/Code/PwmFrequency
// Set pin 9's PWM frequency to 3906 Hz (31250/8 = 3906)
// Note that the base frequency for pins 3, 9, 10, and 11 is 31250 Hz
setPwmFrequency(9, 8);

// Set pin 6's PWM frequency to 62500 Hz (62500/1 = 62500)
// Note that the base frequency for pins 5 and 6 is 62500 Hz
setPwmFrequency(6, 1);

// Set pin 10's PWM frequency to 31 Hz (31250/1024 = 31)
setPwmFrequency(10, 1024);





Please keep in mind that changing the PWM frequency changes the Atmega's timers and disrupts the normal operation of many functions that rely on time (delay(), millis(), Servo library).
So looks like I'm back to "I'll learn PIC some day"
Thanks a bunch!
 
DOH! I love you.
I found this initially:
http://www.arduino.cc/en/Reference/AnalogWrite

So I thought I was limited to ~500Hz PWM.

You prompted me to search further and I found this:
http://www.arduino.cc/playground/Code/PwmFrequency


So looks like I'm back to "I'll learn PIC some day"
Thanks a bunch!
There you go:). They must be using Timer interrupts for adding the additional PWM's.

If curiosity gets the cat, then a PICkit 3 programmer with a companion starter/debug board would be a good way to get acquainted with PIC's. I'm still with the PICkit 2, and it handles nearly everything but the most recent devices. Also, very few of the PIC32 devices are supported by the PICkit 2.
 

thatoneguy

Joined Feb 19, 2009
6,359
I'd still suggest learning PICs, you already have the concept of ports down, in addition to general code concpets.

You can put that to great use using an 8 pin PIC for a small project where an Arduino would be severe overkill and a waste of money.

Total investment to get started (PICKit, 44 pin Demo Board, BoostC or Boost BASIC): About $60 with shipping.
 

Thread Starter

strantor

Joined Oct 3, 2010
6,782
I'd still suggest learning PICs, you already have the concept of ports down, in addition to general code concpets.

You can put that to great use using an 8 pin PIC for a small project where an Arduino would be severe overkill and a waste of money.

Total investment to get started (PICKit, 44 pin Demo Board, BoostC or Boost BASIC): About $60 with shipping.
Is boostC similar to the arduino language?
My programming experience came from using MS visual Basic back in 1997-99 time frame. then I never programmed again until I picked up the arduino last year and I picked it up pretty quick. They say arduino is close to C, and I've read that the basic used to program PICs is nothing like visual basic. I would be looking for whatever is closest to Visual Basic or arduino
 

thatoneguy

Joined Feb 19, 2009
6,359
Most of the language elements are the same, such as code layout, functions, etc.

The big difference between compilers is the "Standard Library" of functions that come with the compiler, such as A-D and PWM routines to run on uCs that do not have hardware PWM.

I use BoostC for hobby stuff since it is cheap to free and easy to learn. Their version of Basic is more like Visual Basic (object oriented) than BASIC Stamp BASIC. For smaller projects, you can use both for free, and for $5, mid sized projects won't be an issue. It gives a great "bang for buck", IMO.

Also take a look at code for CCS and Hi-Tech C, those have shipped with Microchip in the past (lots of Hi-Tech), so there is a ton of code out there to use snippets of.

I love PICs, but have recently gotten an Arduino as well as a PIC Axe board too, once you learn the "new name for similar function" in each, the major difference is price. The more user friendly the programming is, the more it costs. This is true with straight PICs as well, but the compiler is a one time hit, and not something you need to buy for every single project.
 

Thread Starter

strantor

Joined Oct 3, 2010
6,782

thatoneguy

Joined Feb 19, 2009
6,359
Then you are still back to putting a large amount of money into a board for a project that only requires 2 inputs and 2 outputs. A standalone 8 pin PIC on perfboard would be under $5 and do the same task.

They are all good development platforms, and I think everybody should sample them.

I look at the Arduino and PICAxe boards as "tinker boards", something to re-use between ideas, rather than a solution for a project.

When it comes to an actual project or product, it's often easier to only include circuitry that is pertinent to the function of the project. When designing a product, even pennies matter to keep the price down when building 10,000 units.
 

Thread Starter

strantor

Joined Oct 3, 2010
6,782
Ok, now back to this PIC thing; For my motor controller and I have been recommended to use the dsPIC30F3010 as the microcontroller. I have never used a PIC device before so I am looking for a kit with all the essential stuff to get me started.

programmer cost 900$ (what is this? why is it so expensive?)

Total investment to get started (PICKit, 44 pin Demo Board, BoostC or Boost BASIC): About $60 with shipping.
will the pickit perform the function of the 900$ programmer?
will the pickit support the dsPIC30F3010? - things I've read say yes, but I want to make sure.
Dave jones said in this review that the pickit3 does not support external programmers, only MPLAB (189$). is he referring to things like boostC and boostBasic? What is mplab?
All the other things I find when I google such terms as "dsPIC30 kit" are evaluation boards and prototype boards.
I don't want a pre-made board. All I want is a kit with all the necessary bits to build a circuit on a breadboard and get the thing online and start programming it & interface with the rest of my circuit.
any recommendations? I know there has to be somebody out there throwing marked-up kits together.
 

thatoneguy

Joined Feb 19, 2009
6,359
For motor control, you only need the 8 bit PIC, the 16F or 18F line of PICs.

You are looking at the 16/32 bit line of Microchip processors. The development for those costs quite a bit.

The 16 bit dsPIC can be programmed with the PICKit 2, so the startup cost is $100 instead of $50 for the PicKit 2 + 18F45k20 44 pin demo board. The compilers mentioned will also cost more for the dsPIC family, they are meant to run very speedy for digital signal processing.

If you are getting into it at a hobby level, it will be a long time before an 8 bit controller is unable to do what you'd like it to. Arduino/AVR uCs are also 8 bit.

--ETA: dsPICs are more like a microprocessor in some aspects than a microcontroller. dsPICs have dozens of interrupts, 16 registers, a deep stack, Floating point math, hardware matrix multiply, etc built in. So a new compiler is needed for these, and they are generally spendy, as the people using these work for companies that buy the user the compiler and all tools.
 
Last edited:

Thread Starter

strantor

Joined Oct 3, 2010
6,782
For motor control, you only need the 8 bit PIC, the 16F or 18F line of PICs.

You are looking at the 32 bit line of Microchip processors. The development for those costs quite a bit.

If you are getting into it at a hobby level, it will be a long time before an 8 bit controller is unable to do what you'd like it to. Arduino/AVR uCs are also 8 bit.
The microcontroller skills I posess are hobby-level (or slighly below, limited to arduino actually) but the controller I'm building is 100V 600A, slighly above what most would consider hobby-level.
I will quote the recommendation in question (from another forum) and point out the why. first, my comments:
My simulation shows that with my motor of 45uH & .09ohms (verified measurements), my current skyrockets about 3A/uS. I'm sure it will be slower due to lead inductance and whatnot, but My instincts are telling me I need it to be lightning fast......The problem is that I don't trust a microcontroller to be fast enough to limit the current in the way I am trying. I may be wrong about that. I'm going on the assumption that microcontrollers are slow in comparison to discretes.
and his recommendation:
If you look at these two parts you will see that the IR2114S has a shut down pin that lets you kill the FET drive in 100 nano seconds, also when you search the dsPIC30F3010 (and other dsPIC series) you will see that the PWM FaultA pin operates to kill the PWM with hardware type latency of 50 nSec!! Don't think I could do it faster with discreets.
So that's all I'm basing this "need for dsPIC30F3010" on. All I need out of the PIC (or any uC) is to be very fast at detecting overcurrent. either that, or eliminate the microcontroller from the current control loop entirely, which was my original plan before this recommendation. is there a similar pic that can instantly kill the PWM output with no processing delay?
 

t06afre

Joined May 11, 2009
5,934
Ok, now back to this PIC thing; For my motor controller and I have been recommended to use the dsPIC30F3010 as the microcontroller. I have never used a PIC device before so I am looking for a kit with all the essential stuff to get me started.

programmer cost 900$ (what is this? why is it so expensive?)


will the pickit perform the function of the 900$ programmer?
will the pickit support the dsPIC30F3010? - things I've read say yes, but I want to make sure.
Dave jones said in this review that the pickit3 does not support external programmers, only MPLAB (189$). is he referring to things like boostC and boostBasic? What is mplab?
All the other things I find when I google such terms as "dsPIC30 kit" are evaluation boards and prototype boards.
I don't want a pre-made board. All I want is a kit with all the necessary bits to build a circuit on a breadboard and get the thing online and start programming it & interface with the rest of my circuit.
any recommendations? I know there has to be somebody out there throwing marked-up kits together.
What!!!! 900$....:eek: That sales person is dodgy as used car salesman. Do not ever listen to that person ever again. MPLAB is a free programming enviroment for PICs. You can do all your coding,debugging, and chip programming from that enviroment. As you are a beginner with PICs I would perhaps recommend this one http://www.microchipdirect.com/ProductSearch.aspx?Keywords=DV164131 about 70$ It comes with demo board and some lessons. Then your are done toying with the demo board. You can move to your own design. The PICkit 3 can now also reprogram any flash based PIC microcontroller. I think all PICs have flash based variant nowadays . You use the ICSP interface. That is no more than 5 pins. No problem doing your own design on bread board if that is what you want.
 

Thread Starter

strantor

Joined Oct 3, 2010
6,782
ah thanks; I didn't know mplab was free. I am downloading it now and play around with it to see what I can see. Note however that the 900$ device I linked to is not software; looks like some kind of desktop thingamajig that does something. I was unsure if that's needed hardware or maybe it's for mass production/programming of thousands of chips?

so if I get the pickit3 you linked to,play around with it, then move to my own board design, I will need to make sure I get a pic chip that is flash-based? or else I won't be able to program it with pickit3?

the pickit3 sales page says:
The PICkit 3 allows debugging and programming of PIC(R) and dsPIC(R)
and the page for MPLAB download says:
MPLAB Integrated Development Environment (IDE) is a free, integrated toolset for the development of embedded applications employing Microchip's PIC® and dsPIC® microcontrollers
does that mean I could use the pickit3 to program the dsPIC30F3010? or would I still need to buy something else?
 

John P

Joined Oct 14, 2008
2,025
is there a similar pic that can instantly kill the PWM output with no processing delay?
With a tiny amount of external hardware yes, though you might call it cheating. Many PIC processors have a built-in analog comparator, just comparing the levels of two voltages and driving an external pin (the processor has access to this output also, and can be interrupted by it). So you could use the comparator to say "Overcurrent shutdown" and override the PWM output. Of course it's doing exactly what an external comparator could do, but if you want a "pic that can instantly kill the PWM output", that would do it.
 

Markd77

Joined Sep 7, 2009
2,806
A lot of PICs have the Enhanced CCP module which has automatic shutdown based on a comparator, logic input or by the program.
Have a look at the PIC16F887 datasheet, section 11.6.4 as an example.
 

Thread Starter

strantor

Joined Oct 3, 2010
6,782
Ok, I'm getting myself more confused as I read this stuff. I though MPLAB was all I needed to program the PIC. now I'm reading that it doesn't include a "compiler" so I searched the microchip website and the C compiler is 495$!. So I guess this is where your BoostC/BoostBasic reccommendation comes into play? Are the boostbasic/boostc programs "compilers" that I need to use in conjunction with MPLAB in order to program; or are they standalone programs? how does this work if Dave Jones said that the PicKit3 only works with MPLAB?
 

John P

Joined Oct 14, 2008
2,025
That's neat, I hadn't noticed that feature. So yes, the processor can shut down the PWM output on the basis of a comparator output.

The MLAB program isn't a compiler. It's sad but true that one advantage of the AVR chips over the PIC ones is that you can get a pretty good free compiler for the AVRs. The Hi-Tech C compiler has a free version, but I don't know what it includes or leaves out.
 

t06afre

Joined May 11, 2009
5,934
http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en534868
Take a look here. All the listed compilers have a LITE mode. That is free. The Lite compilers are freeware compilers provided as a low-cost tool for all purposes. These compilers have no time or memory limitations, however most code optimizations will be restricted. You will also get a 30 or 60 days trail period with full optimizations
By the way MPLAB will allow assembler programming for all PICS with no C compiler installed
 
Top