PDA

View Full Version : newbe looking for PIC advice



Mad Professor
- 17th May 2009, 08:17
Good Day All.

I have been looking around the internet this morning for a PIC related forum and found this one.

I do hope you might be able to help me.

I am looking for help and advice with a current project.

Upto now I have been using PicAxe (http://www.picaxe.co.uk) PIC chips for my projects.

As the picaxe has it's own bootloader and software built into the chip, it runs much slower then a standard pic chip.

So I need to go down the route of using a true pic chip for my project.

I am trying to build my own stepper motor driver board to use with the Mach3 (http://www.machsupport.com) cnc software.

I am looking at using a pic chip something along the lines of PIC16F88 as I can pick thease up cheap atm.

I need a total of 14/15 usable io ports.

Input
Enable Pin.
Step Pin.
Dir Pin.
Mode Select Pin1.
Mode Select Pin2.

Output
Coil A.
Coil B.
Coil C.
Coil D.
Fan Control.
Enable LED.
Step LED.
Dir LED.

I want to be able to select the step modes via two side switchs, Full Step Mode, Wave Step Mode, and Half Step Mode.

The enable and dir pins are just switched high / low inputs no rapid changing.
The step pin only has a very small pulse, the Mach3 default pulse lengh is just 1us, but this can be adjust upto a max of 15us.

Here is the code that is used with the PicAxe chip.


#picaxe 28x2

setfreq em40

let dirsB = %11111111
let adcsetup = 0

let pinsB = %00000000

Main:
if pinA.0 = 0 then goto no_step
if pinA.0 = 1 and pinA.2 = 0 and pinA.1 = 1 then goto Step_CW
if pinA.0 = 1 and pinA.2 = 1 and pinA.1 = 1 then goto Step_CCW
goto main

no_step:
let pinsB = %00000000
goto main

step_CW:
let b1 = b1 + 1
goto step2

step_CCW:
let b1 = b1 - 1
goto step2

step2:
let b1 = b1 & %00000111
Read b1,b2
Eeprom 0, (%00000001,%00000011,%00000010,%00000110,%00000100 ,%00001100,%00001000,%00001001)
let pinsB = b2
do
if pinA.1 = 0 then goto main
loop


I know that true pic code looks nothing like the picaxe coding, but it might give you a better idea what I am trying to do.

Now that you might have some idea what I am trying to do here comes my questions.

(1) Am in the right forum to ask this question.
(2) What would be the best, cheapest, and smallest pin number chip that I can use.
(3) I understand that there are meny types of coding for true pic chips, whats going to be the easyest for a newbe.
(4) where do I start?

Thanks for your time.

Best Regards.

Melanie
- 17th May 2009, 09:57
"Best, Cheapest and Smallest" doesn't always come in the same package.

There's a whole heap of PICs that will do what you want, probably starting with the 16F628 (which is real easy to work with for a beginner) working up with more RAM and more features. Bare PIC chips are only a couple of $ (or less).

PICBasic Pro is easiest for a newbe - it's also the most expensive, but then again you pay for the integral features, it's stability and maturity.

If you go with PICBasic Pro (or it's cut-down little brother PICBasic which is a little more difficult to use due to it's stripped-down spartan way of doing things) then you are in the right forum.

Your existing PICAXE Basic isn't too distant from PICBasic Pro (looks like your learning curve should be about 30 Seconds), that, along with a suitable PIC programmer would probably your biggest investment. Go to the MeLabs website www.melabs.com or one of their distributors, set yourself up with what you need and we'll see you back here with either stories of success or requests for help. I'm sure if you're buying a complete outfit, any of them will throw in some PICs into the bundle to get you started for free if you asked.

Archangel
- 27th May 2009, 07:01
Good Day All.

I have been looking around the internet this morning for a PIC related forum and found this one.

I do hope you might be able to help me.

I am looking for help and advice with a current project.

Upto now I have been using PicAxe (http://www.picaxe.co.uk) PIC chips for my projects.

As the picaxe has it's own bootloader and software built into the chip, it runs much slower then a standard pic chip.

So I need to go down the route of using a true pic chip for my project.

I am trying to build my own stepper motor driver board to use with the Mach3 (http://www.machsupport.com) cnc software.

I am looking at using a pic chip something along the lines of PIC16F88 as I can pick thease up cheap atm.

I need a total of 14/15 usable io ports.

Input
Enable Pin.
Step Pin.
Dir Pin.
Mode Select Pin1.
Mode Select Pin2.

Output
Coil A.
Coil B.
Coil C.
Coil D.
Fan Control.
Enable LED.
Step LED.
Dir LED.

I want to be able to select the step modes via two side switchs, Full Step Mode, Wave Step Mode, and Half Step Mode.

The enable and dir pins are just switched high / low inputs no rapid changing.
The step pin only has a very small pulse, the Mach3 default pulse lengh is just 1us, but this can be adjust upto a max of 15us.

Here is the code that is used with the PicAxe chip.


#picaxe 28x2

setfreq em40

let dirsB = %11111111
let adcsetup = 0

let pinsB = %00000000

Main:
if pinA.0 = 0 then goto no_step
if pinA.0 = 1 and pinA.2 = 0 and pinA.1 = 1 then goto Step_CW
if pinA.0 = 1 and pinA.2 = 1 and pinA.1 = 1 then goto Step_CCW
goto main

no_step:
let pinsB = %00000000
goto main

step_CW:
let b1 = b1 + 1
goto step2

step_CCW:
let b1 = b1 - 1
goto step2

step2:
let b1 = b1 & %00000111
Read b1,b2
Eeprom 0, (%00000001,%00000011,%00000010,%00000110,%00000100 ,%00001100,%00001000,%00001001)
let pinsB = b2
do
if pinA.1 = 0 then goto main
loop


I know that true pic code looks nothing like the picaxe coding, but it might give you a better idea what I am trying to do.

Now that you might have some idea what I am trying to do here comes my questions.

(1) Am in the right forum to ask this question.
(2) What would be the best, cheapest, and smallest pin number chip that I can use.
(3) I understand that there are meny types of coding for true pic chips, whats going to be the easyest for a newbe.
(4) where do I start?

Thanks for your time.

Best Regards.
For a stepper controller that is fairly easy and low cost do a google search for Linistepper. Roman Black developed it, the code is available or you can buy kits from James Newton either through eBay or directly. These were my first PIC project. A cheap JDM programmer will run about 12 bucks eBay. Better a PICKit2 will run about $60 us with a demo board from Microchip (cheaper in some countries, I think). PICs are faster because you are loading them with actual hex file so they run directly, no interpreter. Here is a link to get you that linistepper : http://www.piclist.com/tecHREF/io/stepper/linistep/lini_wks.htm
http://www.piclist.com/tecHREF/io/stepper/linistep/index.htm

Mad Professor
- 27th May 2009, 07:56
Thanks for the info.

I will save up and buy PICBasic Pro, and a suitable PIC programmer.

I will also have a look at this linistepper you talk about.

Thanks again for your time.

Best Regards.