1. 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.
    Dismiss Notice

Tutorials for PIC?

Discussion in 'Microcontrollers' started by falleafd, May 20, 2003.

  1. falleafd

    falleafd New Member

    Joined:
    May 13, 2003
    Messages:
    412
    Likes:
    0
    Location:
    Vietnam
    Do you know somewhere there are tutorials for PIC? A really good tutorials from basic to adv.

    Thanks muchie
     
  2. Skyknight

    Skyknight New Member

    Joined:
    May 1, 2003
    Messages:
    97
    Likes:
    0
    Location:
    Spain
    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.
     
  3. kinjalgp

    kinjalgp Active Member

    Joined:
    Oct 28, 2002
    Messages:
    1,851
    Likes:
    3
    Location:
    INDIA/USA
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. Scubasteve

    Scubasteve New Member

    Joined:
    Apr 6, 2003
    Messages:
    176
    Likes:
    0
    Location:
    Ontario, Canada.

    The one is also pretty good

    http://www.piclist.com/techref/microchip/intro/pic.htm
     
  6. robinvan

    robinvan New Member

    Joined:
    May 12, 2003
    Messages:
    1
    Likes:
    0
  7. falleafd

    falleafd New Member

    Joined:
    May 13, 2003
    Messages:
    412
    Likes:
    0
    Location:
    Vietnam
    Thanks for your help.

    I knew some basic concepts. Perhaps, I'll ask for your help when I finish my program.

    I'm writing a program to drive a stepping motor via ULN2003. I'm sure it'll have many mistakes, and I hope you may help.

    Thanks again for your help. It's very kind of you all.
     
  8. falleafd

    falleafd New Member

    Joined:
    May 13, 2003
    Messages:
    412
    Likes:
    0
    Location:
    Vietnam
    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|c|ddddd

    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

    Questions:
    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
     
  9. falleafd

    falleafd New Member

    Joined:
    May 13, 2003
    Messages:
    412
    Likes:
    0
    Location:
    Vietnam
  10. falleafd

    falleafd New Member

    Joined:
    May 13, 2003
    Messages:
    412
    Likes:
    0
    Location:
    Vietnam
  11. Skyknight

    Skyknight New Member

    Joined:
    May 1, 2003
    Messages:
    97
    Likes:
    0
    Location:
    Spain
    Good page, good job!
    Thank you!
     
  12. moki

    moki New Member

    Joined:
    May 28, 2003
    Messages:
    20
    Likes:
    0
    Location:
    Durban, South Africa
  13. falleafd

    falleafd New Member

    Joined:
    May 13, 2003
    Messages:
    412
    Likes:
    0
    Location:
    Vietnam
    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
     
  14. moki

    moki New Member

    Joined:
    May 28, 2003
    Messages:
    20
    Likes:
    0
    Location:
    Durban, South Africa
    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.winpicprog.co.uk
    http://www.ke4nyv.com/picprojects.htm
    http://www.mastincrosbie.com/mark/electronics/pic/stepper.html (exactly what u want!!)
    http://www.fritsche.com/dave/notebook/pic/c2c/steppermotor/stepper.html

    I hope this is of some help to you!
     
  15. olly_k

    olly_k Member

    Joined:
    Jul 5, 2003
    Messages:
    236
    Likes:
    1
    Location:
    UK
    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.
     
  16. falleafd

    falleafd New Member

    Joined:
    May 13, 2003
    Messages:
    412
    Likes:
    0
    Location:
    Vietnam
    Thanks muchie for all.

    I also have some questions bout directives that I posted on this forum, but noone answer meeh. May you help me about this?

    By the way, I'd like to ask more bout macro, may you tell me bout the basic concepts of macro when writing in MPASM?

    Deeply thanks.
     

Share This Page