Page 1 of 3 123 LastLast
  1. Good Day All.

    As the title says I am looking for advice with regards to programming PIC's.

    To date the only kind of PIC's I have worked with are called PicAxe.

    Due to the design and build in software thease PIC chips are to slow for what I am after.

    I am looking at building my own PIC based stepper motor driver board.

    I am looking to use one PIC per axis total of 3 axis on my board.

    Each axis will have the following inputs and outputs.

    Inputs
    Enable.
    Step.
    Dir.
    Mode Select 1.
    Mode Select 2.

    Outputs
    Coil A.
    Coil B.
    Coil C.
    Coil D.
    Fan.
    Enable LED.
    Step LED.
    Dir LED.

    So I am going to need a PIC chip with at least 5 inputs and 8/9 outputs.

    I am only looking at driving the stepper motors as unipolar.

    The mode select switches will be for Full, Wave, and Half Mode stepping, I don't want to go down the micro stepper route yet.

    I will be using this driver board with the Mach3 software.

    Here are the two related posted on the PicAxe forum.

    [ame="http://www.picaxeforum.co.uk/showthread.php?t=11593"]3 Axis Stepper and Spindle Control Circuit Diagrams[/ame].
    and
    [ame="http://www.picaxeforum.co.uk/showthread.php?t=12324"]1-5us pulse capture[/ame].

    I have made a little box to put the driver board into.


    Thanks for your time.

    Best Regards.
    Last edited by Mad Professor; 07-06-2009 at 09:14 AM.

  2. #2
    I can't really assist you with your PIC selection (though you've not really any specific h/w needs...eg PWM, USARTS etc ....so I'd imagine most of the PIC 18 range would suffice), but just wanted to chime in as another recent PIC novice/convert.

    I'm using my PIC to control just one stepper motor - this stepper is used as a way of traversing enamelled wire onto a coil winding motor. Basically, the main DC motor has an encoder disk. The PIC counts the stripes from this disk & every x stripes (to work out how far it has travelled) it then sends out a pulse to the stepper.

    I actually went the simple/lazy way & used a dedicated IC to hadle to stepper interfacing - a UCN5804.

    You project sounds really interesting - good luck!

  3. Thanks for your reply.

    I did not want a boring front on my control box, yes it is a little over the top.

    I was looking at the F16 / F18 range of the PIC's.

    As you already said I don't need PWM, ADC, Ect.

    I will be buying the PIC's from RS.

    I am not going to buy any pic or parts to build the driver boards unto such time that I know I can build the board and program the PIC to do what I want / need, as I could safe the money to buy a prebuilt driver, but it's not liky to find a driver board with all the led and fan control I am looking for.

    The picaxe's that I have been using upto now are programed in something that is very close to Basic.

    With the picaxe chips you don't need to buy the software or magic programmer.

    I have been looking around the internet and I see there are meny languages for the pic, Basic, C, C++, Pascal, Ect.

    As the picaxe was based around the Basic language, so a quick google found "MELabs PICBASIC Compiler" but this is a paid software,
    PICBASIC Compiler - meLabs £68.94
    and
    PICBASIC Pro Compiler - melabs £195.44.

    That seems like alot of money to splash out for possibly a one time use.

  4. #4
    Quote Originally Posted by Kip View Post
    Wow....is that a psychopathic paint job or is the camera fubar? :D Watch out the video on the shelf isn't an omen ;)


    (I know about the typo lol )

    What video ? need to get these glasses sorted...........

    .
    John S -

  5. #5
    Hi

    Love the box and I think I know what you're trying to achieve with the pics, however I think you are over-complicating matters by trying to go that route. I think you may be better having a look at various stepper-drive IC datasheets eg: http://www.robotstorehk.com/5804.pdf these or others may provide the functionality you require already built-in.

    As for your progression to Pics your 3 main choices of language would be basic, assembler and 'C'.

    Regards

    Dave

  6. MP, (got a name?)

    I suggest you get a PICKIT2 and program in PIC assembler (I don't think the PIC is really suited to a HLL) with MPLAB. As to choice of PIC, there are many (too many?) that'll do the job, I suggest you pick one with more I/O and internal resources than you need (you're not buying millions, so the difference in cost between that and one that'll just do the job is pennies).

    I know you're re-inventing the wheel, but hey, we all know we could improve on round...

  7. Thanks for the info.

    I see on the Microchipdirect web site: PICkit 2 Starter Kit (DV164120) £35.45

    Is this the best / cheapest place to buy one from?

    I am just watching some PIC Programming videos on YouTube.

  8. Is this the best / cheapest place to buy one from?
    how long is a piece of string?

    I picked up a Pickit2 from Microchip with 16F887 development board in a promo last year for <£10 delivered, so keep your eyes open for promo's

    They flog the PK2 programmer on its own for £25 + carriage + VAT.
    http://www.microchipdirect.com/produ...words=pickit+2

    There are some very simple DIY PC comport programmers if you want to DIY. You can download the software (MPLAB 8.2 etc.) FOC from the Microchip web site.

    [edit]

    I think I have stepper driver code for 16 bit pics somewhere, if you want to pinch it.

  9. Ok thanks.

    how long is a piece of string?
    Thatís easy it's double half it's length.

    I am just installing the MPLAB as I type.

    I will keep my eyes open for a promo.

  10. Here you go:

    It was designed around a 16C84 to drive a L6219 bipolar driver, but since it uses a step table, all you need to do is change the bits to suit your output.

    You'll have to change the CPU type etc. to suit whatever PIC you use.

    Ignore / delete the limit switch code.

    Code:
    ;****************************************
    ;             PIC Header
    ;****************************************
    ;(c) 1994 - 2008 W.K.Todd Electronics
    ;
    ;DATE:23/08/2008 (initialised 27/09/1998)
    ;FILE:STEPPER.ASM  -  L6219 STEPPER DRIVER
    ;VERSION:1.10    - interrupt driven
    ;
    ; Target processor = 16C84 (eeprom PIC)
    ; Assembler = MPASM
    ;
        LIST P=16C84
        #INCLUDE P16C84.INC
    
    ;EQUATES    
    STPCNT        EQU    0x0C    ;STEP COUNTER
    FLAGS        EQU    0x0D    ;VARIOUS FLAG BITS
    TIMER        EQU    0x0E    ;GP TIMER USED TO SLOW LOOP
    
    ;interrupt service temps
    STATUS_TEMP    EQU    0X2E
    W_TEMP        EQU    0X2F
    
    
    ;BIT ADDRESSES
    DEBN        EQU    0x00    ;DEBOUNCE FLAG
    CLKIN        EQU    0X00    ;CLK INPUT
    DIRIN        EQU    0x01    ;DIRECTION INPUT
    XLIM        EQU    0x00    ;LIMIT SWITCH INPUTS
    YLIM        EQU    0x01    ;
    ZLIM        EQU    0x02    ;
    LIMIT        EQU    0x03    ;LIMIT OUTPUT (ACTIVE HIGH)
    BYPSWT        EQU    0X04    ;LIMIT BYPASS SWITCH
    
    ;
    
        ORG    0x000    
        GOTO    START        ;RESET VECTOR
        NOP
        NOP    
        NOP
    ;INTERRUPT VECTORS TO HERE
    ;
    PUSH    MOVWF     W_TEMP         ; Copy W to TEMP register,
        SWAPF     STATUS, W     ; Swap status to be saved into W
        MOVWF     STATUS_TEMP     ; Save status to STATUS_TEMP register
    ; Interrupt Service Routine
        ;test interrupt type
        BTFSS    INTCON,INTF    ;test int0 flag
        goto    POPW
        
        bcf    INTCON,INTF    ;clr flag
        BTFSC    PORTB,DIRIN    ;TEST DIRECTION
        GOTO    CLKWIZ        
        ;DO ANTI CLK TURN
        DECF    STPCNT,W    ;DECR AND FETCH STEP COUNT
        ANDLW    0x07        ;MODULO 7
        MOVWF    STPCNT        ;SAVE
        CALL    STPTAB        ;GET PHASE VALUES
        MOVWF    PORTB
        GOTO    POPW        ;AND FINISH
    
    ;DO CLOCKWISE TURN
    CLKWIZ    INCF    STPCNT,W    ;INCR AND FETCH STEP COUNT
        ANDLW    0x07        ;MODULO 7
        MOVWF    STPCNT        ;SAVE
        CALL    STPTAB        ;GET PHASE VALUES
        MOVWF    PORTB
    
    
    POPW     SWAPF     STATUS_TEMP, W     ; Swap nibbles in STATUS_TEMP register
                    ; and place result into W
        MOVWF     STATUS        ; Move W into STATUS register
                    ; (sets bank to original state)
        SWAPF     W_TEMP, F     ; Swap nibbles in W_TEMP and place result in W_TEMP
        SWAPF     W_TEMP, W     ; Swap nibbles in W_TEMP
        RETFIE
    ;
    ; TABLES
    ;Bits/function
    ;7   6   5   4   3   2   1   0
    ;Io1 I11 PH1 I12 I02 PH2 DIR STEP
    STPTAB    ADDWF    PCL,f
    
    ;2/3 current, half step table
    ;    RETLW    0xC8    ;STEP0
    ;    RETLW    0x88    ;1
    ;    RETLW    0x9C    ;2
    ;    RETLW    0x8C    ;3
    ;    RETLW    0xEC    ;4
    ;    RETLW    0xAC    ;5
    ;    RETLW    0xB8    ;6
    ;    RETLW    0xA8    ;7    
    
    ;full current, half step table
        RETLW    0xC0    ;STEP0
        RETLW    0x00    ;1
        RETLW    0x1C    ;2
        RETLW    0x04    ;3
        RETLW    0xE4    ;4
        RETLW    0x24    ;5
        RETLW    0x38    ;6
        RETLW    0x20    ;7
    
    
    ;
    ; START OF PROGRAM
    ;
    START    BSF    STATUS,RP0 ;select bank 1
    
        MOVLW    0x03    ;RB0 +1 TO INPUT
        MOVWF    TRISB
        MOVLW    0x17    ;RA0,1,2,4 TO INPUT
        MOVWF    TRISA
        MOVLW    0XCF
        MOVWF    OPTION_REG    ;set up interrupt
        BCF    STATUS,RP0
        
        MOVLW    0X90
        MOVWF    INTCON    ;enable int0
        CLRF    STPCNT
        CLRF    FLAGS
    
    ;MAIN LOOP    
    MAINLP
    
    ;TEST LIMIT SWITCHES
    TLBPS    BTFSS    PORTA,BYPSWT        ;TEST LIMIT BYPASS
        GOTO    BYPASS
        MOVF    PORTA,W        ;GET LIMIT SWITCHES
        ANDLW    0x07
        BTFSS    STATUS,Z
        BSF    PORTA,LIMIT    ;SET LIMIT IF X,Y OR ZLIM IS HIGH
        BTFSC    STATUS,Z
    BYPASS    BCF    PORTA,LIMIT    ;CLEAR LIMIT OUTPUT IF SWITCHES ARE ALL LOW
        GOTO    MAINLP        ;LOOP BACK    
    
    
        END

Page 1 of 3 123 LastLast

Similar Threads

  1. NEW MEMBER: Newbe on the site
    By Phillou in forum New Member Introductions
    Replies: 0
    Last Post: 14-03-2014, 05:54 PM
  2. NEW MEMBER: Newbe in France
    By dudz in forum New Member Introductions
    Replies: 1
    Last Post: 17-10-2012, 06:46 PM
  3. NEW MEMBER: Newbe
    By THE PHOENIX in forum New Member Introductions
    Replies: 2
    Last Post: 03-12-2010, 07:20 PM
  4. NEW MEMBER: Hi from newbe
    By croy in forum New Member Introductions
    Replies: 2
    Last Post: 28-01-2010, 09:22 PM
  5. NEW MEMBER: Newbe
    By cncezee in forum New Member Introductions
    Replies: 3
    Last Post: 29-08-2009, 07:40 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •