PDA

View Full Version : PIC16f84A as stepper controller



rich200313
03-03-2008, 02:07 PM
I have been googling this for a while and trying to come up with a solution but so far no luck :(

I am trying to program a 16F84 to take stp pulses and dir inputs and then cycle through the correct outputs in the right order. I am using MikroC but so far i have been unable to find if a pin has been pulsed (instead of just being pulled high, so that i do not just repeat the port change every time that the code cycles).

Has anybody done this and if so could you show/explain some code so i can find out how to do this as it is driving me slowly insane (i plan to use a ULN 2804 connected to the output port BTW, and please do not use ASM, i really cant understand any of it, hope to learn it someday but havnt got the patients ATM)

Thanks,
Richard

BkYrdMachine
03-09-2008, 06:31 PM
Hello rich
I have done this by calling a table, containing the correct sequence of 1's / 0's
the table is then transfered to the output port of the pic.
for direction change, add or subtract from the table pointer
I also used one of the ports to drop the holding current after a short time, to stop over shoot but keep the average current level low... and the motor cool.
I use another port to spike the motor, to increase the speed & torque.
for testing the code, I used LEDs on a bread board.

I hope this helps you out.

pminmo
03-10-2008, 09:09 AM
Is you problem needing the C code or a translator table or?

posix
03-10-2008, 05:15 PM
I don't see how you hope to be able to play around with PICs without even trying to understand some of the assembler. There is one excellent tutorial out there that guides you through a few simple steps and by the end shows you basically how to build your own stepper controller in assembly on a 16f84. Then you can go and play with C on a PIC but you definitely want to learn at least some concepts (registers and pin assignments at least) if you want to be able to understand what's going on in your PIC. Assembler isn't THAT bad you know...trust me ;)

rich200313
03-12-2008, 04:28 AM
Thanks for the replies, i am going to try to learn pic assembly because so far i have only tried for a snes and so pic will probably be easier. I will try to find the guide that posix mentioned and see what i can learn. I have decided to use a different design altogether however, but asm could be handy later, if i try robots etc.

Thanks again,
Rich

pminmo
03-12-2008, 11:56 AM
Actyally I would disagree on learning assembler. Unless you want to do some critical timing, or push the processors limits, or get a more fundamental idea of how processors work, it's not necessary these days. The C compliers have become so good, that most of them are very efficient. PIC Basic is a really good tool also for the beginning programmer. I suspect if you did a google search on PIC, C and stepper you would get a lot of hits and compressed learning. I learned programming starting with assembler, it does give you a perspective on processor internals, but beyond that it has valid but limited usage these days.

rich200313
03-18-2008, 04:39 PM
I agree about how good some C/BASIC etc languages are these days but i would still like to learn ASM (i like to know how things work in detail), but i have had no luck in finding the tutorial that you refer to posix, do you remember the name of the author or have a link to the site?

Thanks,
Rich

keebler303
03-20-2008, 01:41 PM
Here is a really high quality course in assembly programming. I have gotten through about half of it in full depth and it really is very good.
Enjoy!

http://www.amqrp.org/elmer160/lessons/

Matt

Also there is a forum for pics in particular on the zone, FYI.

http://www.cnczone.com/forums/forumdisplay.php?f=281

rich200313
03-20-2008, 03:46 PM
Thanks for the link, i knew about the PIC zone but i wasnt sure where to put the thread when it started, as it was origionally for a stepper controller, so here seemed more appropriate.

Thanks again,
Rich