• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Tutorials for PIC?

Not open for further replies.


New Member
I think the best tutorial is the datasheet itself. I haven't found any tutorial about PICs that finally result usfull. There are several on Internet, but mainly for begginers. I think the best you can do is to cut the program in many short tasks, procedures or routines, just as a diagram. After that, writing the code gets much easier. If you have any trouble ask us.


Active Member


New Member
I wanna use 5 registers to save value of velocity, accelerate and numberof steps.
And I only use 5 low bits of each register to save data.
one register for velocity
one for accelerate
and 3 for number of steps, so I'll have 15 bits for number of steps
the highest bit of velocity register will show the direction that the stepper should turn

My command should come as

mm is select the PIC (I have 2 PIC to drive 2 motor- left and rite)

if c = 0 then select the register with ddddd
if c = 1 then send data ddddd to the active register

I use parallel port to send commands.
data 0 to data 7 of parallel port is connected to rb0 to rb7 of PIC16F628

1) How do I select register using my command?
For example I choose 5 register addressed at... in bank 0

2) How do I count number of steps if it is saved in 3 different registers?

3) I wanna send data to 4 pins RA0 to RA3 of PIC to ULN2003, for example sending 9 (1001)
how should i write?
bsf porta,ra3
bcf porta,ra2
bcf porta,ra1
bsf porta,ra0

but if I wanna send all 4 bits at a time, how should i write?

4) assuming that the velocity register is at 0xMM
so when i check for direction, I should write:

btfss 0xMM, 04 (the highest bit of 5 bits data of this register will show direction)
goto turnleft (if direction = 0 then turn left)
goto turn right (if direction=1 then turn right)

is this rite?

5) this will be similar to accelerate register,
if the highest bit is 0 then accelerate
if it is 1 then decelerate.

Deeply thanks


New Member
Thanks indeed

However, I'm in Vietnam and I cannot pay via internet.

I tried to program with asm on PIC, and it worked quite good. It's oki to me now.

But these near days, I got a problem on driving stepping motor with various number of steps, velocity and acceleration. I solved this problem on paper, but to compute the delay time after each step, it needs a complex mathematical formula with *, /, ^ (+,- is easy to do in asm). I don't know how to do.

I thought I should write in C then compile it.

However, I'm a newcomer in microcontroller field, Pls show me step by step how to program with C?

Which programs I need to use? Is there any tutorials on PIC C?

What is the difference between C17 and C18 compiler of microchip?

I'd like to program for 16f628.

Deeply thanks


New Member
Hi Falleafd :)

Sorry for replying so late! I am not very familiar with C. Check out the following sites for some other useful info.

http://www.piclist.com/techref/piclist/codegen/delay.htm (this one automatically produces code for time delays)

http://www.mastincrosbie.com/mark/electronics/pic/stepper.html (exactly what u want!!)

I hope this is of some help to you!


I think the EPE V2 cd is available with COMPRAHENSIVE C course (see links posted above) I prefer assembler personally I think you get to know the micro slightly better and make tighter code. I sound a bit of an expert lol but I AM NOT!
I used pictutor 'assembler' v1. That was good V2 should be much better.
Not open for further replies.

Latest threads

EE World Online Articles