Continue to Site

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.

  • 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.

Motor controller

Status
Not open for further replies.

Totally blank

New Member
Hi Guys

Firstly, if this isn't the place to post this question please advise.

OK

I need to be able to move an object about 1 kg in weight, up and down over 2 - 4 inches at an adjustable speed. I have been told that a stepper motor & PIC16F84A will be able to do the job.

The unit will need to be programmed and standalone (hence the PIC) and plugged into a UK wall socket via a power supply, have 3 push buttons to set 2inch/3inch/4inch strokes with a speed adjuster from approx 50 strokes per minute (slowest) to 100 strokes per minute (max) the duration could be anywhere from 10 minutes to an hour.

The motor (just for your info) will have a crank arm on it approximatly 2 inches in length, the motion should be as smooth as possible in the transition between back and forth.

I need to know

A) If it's at all possible, if not, then suggestions/advice on how to accomplish it
B) Is there something already available that would accomplish this
C) Someone in the UK (preferably North West,ish) able to design the above item

I do not intend to build it myself as I have no idea, just looking for someone with enough knowledge to design it and supply the finished working item, I am located in Cumbria.

Thanks for reading my post
 
For a start don't use the 16F84 (unless you have an old box full of them), it was replaced last century by the cheaper, faster, higher spec 16F628 - and you wouldn't need a crystal with that either.

As for your project, you need to check the mechanical side first, ensure a stepper motor has the power you require - a servo motor might be more suited?, or even just a DC motor and H-Bridge?.
 
Thanks for your reply Nigel

As I stated in my initial post, I have no idea how to get to what I need, I take your point on the mechanical side and am totally open to suggestions.

Do you know of anything that would do what I want? could it be built?
 
Yes it could be built, perhaps you could post a drawing of the sort of thing you're anticipating?. I find it difficult to imagine, and from what you've said it sounds like a hoist or crane would do the job?.
 
What you are describing can be designed and built. As suggested, you need to work out the mechanics of it first.

The lift of the 1 kg weight over 4 inches at 100 strokes per minute will likely define the absolute minimum power required of the motor - then you need to add for the inefficiency of your system (probably determined experimentally). The motor must be able to deliver the power/torque required at all speeds within your design range.

One engineering term used to define the smoothness between "back and forth" is jerk - the change in acceleration. The mechanical system and the behavior of your motor will determine this. With careful programming you might be able to overcome some limitations of your mechanism.

While this isn't a huge project it's certainly going to take some work.
 
Thanks Nigel & stevez

OK, before I made this thread, I had already been given a driver board kit and programmer kit, they came with the PIC16F84A, a friend got them from Magenta here in the UK. I have never built anything before like circuit boards but after your comments decided to atleast try so I can see for myself how it all works, then maybe stop asking dumb questions here, they both went together and seem to work correctly, its taken 2 days.

I have downloaded ic-prog and installed it on XP Pro, it works WITHOUT the errors (yes I got them and had to install the dll). I have since been able to read and write to the chip with the sample files Magenta provided, then stumbled after realising I needed to import .HEX files only, then came MPLAB, more learning, OK to date (in 2 days) I have built a board that runs the motor and a board to programme the chip.

I cannot work out 'where' to change the .asm file to change speed, direction, etc, I also can't understand what NEEDS to be in the file and what doesnt.

Their example does what appears to be 3 things, when powered, rotates the motor in steps for 3 full revs then reverses the same process but a touch quicker, then gives about 25 full revs at a faster speed, the driver board has a reset on it and when pushed it starts the whole sequence over.

I have searched the web for .asm example files, tried some and the motor does nothing, I can't tell if they are supposed to be used with my chip or not.

Does anyone have a simple .asm for this chip that will simply rotate the motor left then right 180deg in a loop? or a sample of code that would do just that, it would be much appreciated if the file had understandable comments too.

ps, Nigel, you must be famous as every file I have seen has your name on it, if it is you please accept my bows
 
Totally blank said:
Does anyone have a simple .asm for this chip that will simply rotate the motor left then right 180deg in a loop? or a sample of code that would do just that, it would be much appreciated if the file had understandable comments too.

Post the code you have, so people can suggest what you need to do to change it.

ps, Nigel, you must be famous as every file I have seen has your name on it, if it is you please accept my bows

I wrote the first PIC dis-assembler, so anything dis-assembled with it has my name at the top - perhaps you're looking at dis-assembled listings?.

IC-Prog even incorporated an early version of my dis-assembler, but never asked permission, or even notified me he had done so - but he did leave my copyright notice in place!.
 
Heres the example asm file I have

Code:
                PROCESSOR       16F84A
;
        TITLE  "STP12.ASM - PIC 16F84A STEPPING MOTOR DRIVER"

        RADIX           HEX
        LIST
;
;
        #DEFINE INDF    0000                    ;PAGE 0 & 1 INDIRECT ADDRESS
        #DEFINE RTCC    0001                    ;PAGE 0
        #DEFINE OPTN    0001                    ;PAGE 1 (0081)
        #DEFINE PCL     0002                    ;PAGE 0 & 1 PC LOW BYTE
        #DEFINE STATUS  0003                    ;PAGE 0 & 1
        #DEFINE FSR     0004                    ;PAGE 0 & 1
        #DEFINE PORTA   0005                    ;PAGE 0
        #DEFINE TRISA   0005                    ;PAGE 1 (0085)
        #DEFINE PORTB   0006                    ;PAGE 0
        #DEFINE TRISB   0006                    ;PAGE 1 (0086)
        #DEFINE EEDATA  0008                    ;PAGE 0
        #DEFINE EECON1  0008                    ;PAGE 1 (0088)
        #DEFINE EEADR   0009                    ;PAGE 0
        #DEFINE EECON2  0009                    ;PAGE 1 (0089)
        #DEFINE PCLATH  000A                    ;PAGE 0 & 1
        #DEFINE INTCON  000B                    ;PAGE 0 & 1
;
        #DEFINE DELAY0  000C                    ;PAGE 0  DELAY LOOP COUNTER
        #DEFINE DELAY1  000D                    ;PAGE 0  DELAY LOOP COUNTER
        #DEFINE DELAY2  000E                    ;PAGE 0  DELAY LOOP COUNTER
        #DEFINE UPBYT   000F                    ;PAGE 0  STEP PAGE ADDRESS
        #DEFINE INDEX   0010                    ;PAGE 0  STEP NUMBER 
        #DEFINE FLAGS1  0011                    ;PAGE 0  SYSTEM FLAGS 1
        #DEFINE SPEED   0012                    ;PAGE 0  SPEED  VALUE STORE
        #DEFINE SPEED1  0013                    ;PAGE 0  SPEED1
        #DEFINE SPEED2  0014                    ;PAGE 0  SPEED2
        #DEFINE STPSL   0015                    ;PAGE 0  LSD OF STEP COUNTER
        #DEFINE STPSM   0016                    ;PAGE 0  USD OF STEP COUNTER
;
;       STATUS REGISTER BITS
        #DEFINE CARRY   0X03,0                   ;CARRY FLAG
        #DEFINE DCARRY  0X03,1                   ;DECIMAL CARRY FLAG
        #DEFINE ZERO    0X03,2                   ;ZERO FLAG
        #DEFINE RPAGE   0X03,5                   ;REGISTER PAGE SELECT
;
;       OPTION REGISTER BITS
        #DEFINE PS0     0X01,0                  ;P1 - PRESCALER SELECT VALUES
        #DEFINE PS1     0X01,1                  ;      ''
        #DEFINE PS2     0X01,2                  ;      ''
        #DEFINE PSA     0X01,3                  ;P1 - PRESCALER ASSIGNMENT 
        #DEFINE RTE     0X01,4                  ;P1 - TMR0 EDGE (WHEN EXTERNL)
        #DEFINE RTS     0X01,5                  ;P1 - TMR0 SOURCE
        #DEFINE INTEDG  0X01,6                  ;P1 - B0 INTERRUPT EDGE  
        #DEFINE RBPU    0X01,7                  ;P1 - PORTB WEAK PULL UPS
;
;       INTCON REGISTER BITS
        #DEFINE RBIF    0X0B,0                  ;PORTB CHANGE FLAG
        #DEFINE INTF    0X0B,1                  ;B0 INT FLAG
        #DEFINE T01F    0X0B,2                  ;TIMER 1 INTERRUPT FLAG 
        #DEFINE RBIE    0X0B,3                  ;PORTB CHANGE INTERRUPT ENABLE
        #DEFINE INTE    0X0B,4                  ;B0 INTERRUPT ENABLE
        #DEFINE T01E    0X0B,5                  ;TIMER 1 INTERRUPT ENABLE
        #DEFINE EEIE    0X0B,6                  ;EEPROM WRITE INT           
        #DEFINE GIE     0X0B,7                  ;GLOBAL INTERRUPT ENABLE
;
;       PORTA BITS
        #DEFINE SWA1    0X05,0                  ;P0 - A SWITCH INPUT 1
        #DEFINE SWA2    0X05,1                  ;P0 -                2
        #DEFINE SWA3    0X05,2                  ;P0 -                3
        #DEFINE SWA4    0X05,3                  ;P0 -                4
        #DEFINE SWA5    0X05,4                  ;P0 -                5
;
;       PORTB BITS
        #DEFINE PHASE3  0X06,0                  ;P0 - MOTOR DRIVE PHASES 3
        #DEFINE PHASE4  0X06,1                  ;P0 -                    4
        #DEFINE PHASE2  0X06,2                  ;P0 -                    2
        #DEFINE PHASE1  0X06,3                  ;P0 -                    1
        #DEFINE SWB1    0X06,4                  ;P0 - B SWITCH INPUT 1
        #DEFINE SWB2    0X06,5                  ;P0 -                2
;       #DEFINE         0X06,6                  ;P0 - PROGRAMMING INPUTS
;       #DEFINE         0X06,7                  ;P0 - PROGRAMMING INPUTS
;  
;       FLAGS1 BITS
        #DEFINE FWDFLG  0X11,0                  ;P0 - FORWARD RUN FLAG
        #DEFINE RUNFLG  0X11,1                  ;P0 - RUN FLAG
        #DEFINE STEPF   0X11,2                  ;P0 - FULL STEP FLAG
        #DEFINE STEPC   0X11,3                  ;P0 - STEPS DONE FLAG
;
;
        ORG     0x000                           ;RESET VECTOR
        GOTO    FIRST                           ;
;
        ORG     0X004                           ;INTERRUPT VECTOR
        GOTO    SERVE1                          ;INTERRUPT SERVICE ROUTINE
;
FIRST   ORG     0x005                           ;FIRST INSTRUCTION
        NOP
        NOP
        NOP
        GOTO    START                           ;
;
        ORG     0X10
START   BCF     RPAGE                           ;MAKE SURE PAGE 0
        CLRWDT                                  ;CLEAR WATCHDOG TIMER 
;
;*                          CLEAR REGISTERS                                 *
;CLEAR OPERATING REGISTERS LOWER BANK
        MOVLW   0X0C                            ;LOAD FIRST REGISTER ADDRESS
        MOVWF   FSR                             ;TO FILE SELECT REGISTER
NXREG   CLRF    INDF                            ;CLEAR SELECTED REGISTER
        INCF    FSR,1                           ;INCREMENT POINTER
        MOVLW   0X30                            ;LOAD TOP LOCATION +1 TO W
        SUBWF   FSR, 0                          ;SUBTRACT FROM CURRENT ONE
        BTFSS   ZERO                            ;CHECK TO SEE IF EQUAL
        GOTO    NXREG                           ;IF NOT - LOOP
;

;SET UP INITIAL PORT DATA
        MOVLW   B'00010000'                     ;MOVE DATA FOR PORTA
                                                ;Note that A4 MUST be high if
                                                ;it is to be used as an input
                                                ;otherwise open collector will
                                                ;pull it down.
        MOVWF   PORTA                           ;LOAD TO PORTA REGISTER
        MOVLW   B'00000000'                     ;MOVE DATA FOR PORTB
        MOVWF   PORTB                           ;LOAD TO PORTB REGISTER
;
;                            PAGE 1
;SET UP PORT I/O AND OPTION REGISTER CONTENTS
        BSF     RPAGE                           ;SET PAGE 1
;
        MOVLW   B'00011100'                     ;SET A0&1 TO OUTPUT, 
        MOVWF   TRISA                           ;LOAD TO I/O CONTROL REG A
        MOVLW   B'11110000'                     ;SET B0-3 TO OUTPUT
        MOVWF   TRISB                           ;LOAD TO I/O CONTROL REG B
        NOP
        NOP
;
        BCF     RBPU                            ;ENABLE PORTB PULL UPS
        BSF     INTEDG                          ;SET B0 INT ON RISING EDGE
        BCF     RTS                             ;TIMER COUNTS INT CLOCK    
        BCF     RTE                             ;LOW-HIGH INT EDGE (UNUSED)
        BCF     PSA                             ;ASSIGN PRESCALER TO TIMER
        BSF     PS0                             ;SET UP PRESCALER TO /256
        BSF     PS1                             ;           ''
        BSF     PS2                             ;           ''
;
        BCF     RPAGE                           ;BACK TO PAGE 0
;                            PAGE 1

        CLRF    INTCON                          ;CLEAR ALL INTERRUPTS & FLAGS
;
 
        MOVLW   0X02                            ;LOAD DATA STRING POINTER
        MOVWF   UPBYT                           ;FOR UPPER ADDRESS BYTE
        CLRF    INDEX                           ;ZERO LOWER ADDRESS POINTER
;
;PROGRAM OPTION 1) SQRUN RUNS DEMO AND THEN READS DIRECT DRIVE SWITCHES                             ;select required option
;
		BTFSC	SWB1							;TEST PORT B4
        GOTO 	SQRUN							;B4 IS HIGH OR OPEN - DO DEMO RUN FIRST
        GOTO 	DDRIVE                          ;B4 IS LOW - LINKED TO 0V
;
;PROGRAM OPTION 2) DDRIVE SKIPS DEMO RUN AND READS DIRECT DRIVE SWITCHES IMMEDIATELY.                           ;

;
;DDRIVE - OPTION 1 DIRECT DRIVE
                                                ;select full or half step mode
                                                ;
                                                ;
DDRIVE  BCF     STEPF                           ;SET FOR FULL STEP, 
                                                ;CLEAR FOR HALF STEP
;
;                                               ;select speed counter value
                                                ;
        MOVLW   0X80                            ;LOAD VALUE FOR SPEED COUNTER
        MOVWF   SPEED                           ;INTO SPEED REGISTER
        MOVWF   RTCC                            ;AND INITIALISE RTCC REGISTER
;
        BSF     T01E                            ;TURN ON TIMER INTERRUPT
        BSF     GIE                             ;AND ENABLE GLOBAL INTERRUPTS
;
;
;Run loop - tests push switches and runs forward or reverse in response
;
RUNING	BTFSS	SWA4
		GOTO	FRUN		
        MOVLW   0X80                            ;LOAD VALUE FOR SPEED COUNTER
        MOVWF   SPEED                           ;INTO SPEED REGISTER
		GOTO	ADRUN		



FRUN    MOVLW   0XF4                            ;LOAD VALUE FOR SPEED COUNTER
        MOVWF   SPEED                           ;INTO SPEED REGISTER
		GOTO	ADRUN

ADRUN   BTFSS   SWA3                            ;TEST 'FORWARD' SWITCH
        GOTO    FWDRUN
        BTFSS   SWA5                            ;TEST 'REVERSE' SWITCH
        GOTO    REVRUN
;
        BCF     RUNFLG                          ;CLEAR RUN FLAG 'STOP'
        GOTO    RUNING                          ;LOOP FOREVER
;
FWDRUN  BSF     FWDFLG                          ;SET DIRECTION
        BSF     RUNFLG                          ;SET TO RUN
        GOTO    RUNING                          ;LOOP FOREVER
;
REVRUN  BCF     FWDFLG
        BSF     RUNFLG                          ;SET TO RUN
        GOTO    RUNING                          ;LOOP FOREVER
;
;               SERVE1  INTERRUPT SERVICE ROUTINE
;
SERVE1  MOVF    SPEED,0                         ;RELOAD SPEED COUNTER VALUE
        MOVWF   RTCC                            ;INTO TIMER COUNT UP REGISTER
;
        BTFSS   RUNFLG                          ;TEST RUN FLAG
        GOTO    ENDSTP                          ;IF NOT SET, EXIT
;
        BTFSC   STEPF                           ;TEST FLAG FOR FULL STEP 
        CALL    DRIVE                           ;FULL STEP CALL 'DRIVE'TWICE
                                                ;TO JUMP OVER HALF STEPS
        CALL    DRIVE                           ;WORK OUT FOLLOWING STEP
;
        CALL    STEP                            ;EXECUTE STEP
;
        CALL    STPCNT                          ;DECREMENT POSITION COUNTERS
;
ENDSTP  BCF     T01F                            ;CLEAR INTERRUPT FLAG
        RETFIE                                  ;RETURN FROM INTERRUPT
;
;               DRIVE CALCULATES STEP NUMBER & LOADS INTO INDEX
;
DRIVE   BTFSS   FWDFLG                          ;TEST DIRECTION FLAG
        GOTO    REVSE                           ;IF CLEAR REVERSE
;
;                                               ;FORWARD 
        INCF    INDEX,1                         ;INCREMENT STEP COUNTER
        BTFSC   INDEX,3                         ;8 HALF STEPS?
        CLRF    INDEX                           ;IF 8 RESET TO ZERO
        RETURN
;
;                                               ;REVERSE
REVSE   MOVF    INDEX,1                         ;TEST VALUE OF STEP COUNTER
        BTFSC   ZERO                            ;
        BSF     INDEX,3                         ;IF ZERO RELOAD
        DECF    INDEX,1                         ;AND DECREMENT
        RETURN
;
;SQRUN   OPTION2 MOTOR SEQUENCE DRIVE
;
SQRUN
;                                               ;first run:
;
        MOVLW   0X02                            ;SET NUMBER OF STEPS
        MOVWF   STPSM                           ;MSD
        MOVLW   0XA0                            ;
        MOVWF   STPSL                           ;LSD
        BSF     FWDFLG                          ;SET DIRECTION
        BSF     RUNFLG                          ;SET TO RUN
        MOVLW   0X80                            ;LOAD VALUE FOR SPEED COUNTER
        MOVWF   SPEED                           ;INTO SPEED REGISTER
        CALL    RUNSTP
;
;                                               ;second run:
;
        MOVLW   0X02                            ;SET NUMBER OF STEPS
        MOVWF   STPSM                           ;MSD
        MOVLW   0XA0                            ;
        MOVWF   STPSL                           ;LSD
        BCF     FWDFLG                          ;SET DIRECTION
        BSF     RUNFLG                          ;SET TO RUN
        MOVLW   0XA0                            ;LOAD VALUE FOR SPEED COUNTER
        MOVWF   SPEED                           ;INTO SPEED REGISTER
        CALL    RUNSTP
;
;                                               ;third run:
;                                               ;same speed so leave previous
;                                               ;values
        MOVLW   0X02                            ;SET NUMBER OF STEPS
        MOVWF   STPSM                           ;MSD
        MOVLW   0XA0                            ;
        MOVWF   STPSL                           ;LSD
        BSF     FWDFLG                          ;SET DIRECTION
        CALL    RUNSTP                          ;
;
;                                               ;forth run:
;
        MOVLW   0X10                            ;SET NUMBER OF STEPS
        MOVWF   STPSM                           ;MSD
        MOVLW   0XA0                            ;
        MOVWF   STPSL                           ;LSD
        BCF     FWDFLG                          ;SET DIRECTION
        BSF     RUNFLG                          ;SET TO RUN
        MOVLW   0XF4                            ;LOAD VALUE FOR SPEED COUNTER
        MOVWF   SPEED                           ;INTO SPEED REGISTER
        CALL    RUNSTP                          ;
		BCF 	RUNFLG							;CLEAR FLAG
		CALL	PAUSE2
		CLRF	PORTB
LAST    GOTO    DDRIVE                          ;LAST MOVE COMPLETED 
;
;
RUNSTP  BCF     STEPC                           ;CLEAR FLAG
        MOVF    SPEED,0                         ;LOAD SPEED REGISTER INTO W
        MOVWF   RTCC                            ;AND INITIALISE RTCC REGISTER
;
        BSF     T01E                            ;TURN ON TIMER INTERRUPT
        BSF     GIE                             ;AND ENABLE GLOBAL INTERRUPTS
;
RUNIN   BTFSS   STEPC                           ;LOOP WAITING FOR INTERRUPTS
        GOTO    RUNIN                           ;UNTIL FLAG IS SET
        BCF     GIE                             ;THEN DISABLE INTERRUPTS 
        RETURN                                  ;AND RETURN
;
;STPCNT - STEP COUNTING ROUTINE
;
STPCNT  MOVF    STPSM,1                         ;IS MSD ZERO
        BTFSC   ZERO                            ;TEST ZERO FLAG IF ZERO - JUMP
        GOTO    JUSTL                           ;ZERO FLAG SET, SO JUMP

                                                ;MSD IS NOT ZERO 
        MOVF    STPSL,1                         ;IS LSD ZERO
        BTFSC   ZERO                            ;
        DECF    STPSM,1                         ;LSD IS ZERO SO DEC MSD
        DECF    STPSL,1                         ;DEC LSD (ROLLS OVER TO FF)
        RETURN                                  ;AND RETURN

                                                ;MSD IS ZERO
JUSTL   DECFSZ  STPSL,1                         ;DECREMENT LSD
        RETURN                                  ;
        BSF     STEPC                           ;IF ZERO ALL DONE - SET FLAG
        RETURN
;
;PAUSE2 GIVES LONG DELAY BY LOOPING 10 TIMES CALLING PAUSE1 EACH TIME
;
PAUSE2  MOVLW   0x40                            ;MOVE SET UP PAUSE DELAY
        MOVWF   DELAY2                          ;TO DELAY2 REGISTER
DEL2LP  CALL    PAUSE1                          ;CALL SECOND LOOP
        DECFSZ  DELAY2, 1                       ;DECREMENT SAMPLE PULSE COUNT
        GOTO    DEL2LP                          ;AND LOOP UNTIL IT IS ZERO
        RETURN
;
;PAUSE1 GIVES MEDIUM DELAY BY LOOPING 10 TIMES CALLING PAUSE EACH TIME
;
PAUSE1  MOVLW   0x80                            ;MOVE SET UP PAUSE DELAY
        MOVWF   DELAY1                          ;TO DELAY1 REGISTER
DEL1LP  CALL    PAUSE                           ;CALL SECOND LOOP
        DECFSZ  DELAY1, 1                       ;DECREMENT SAMPLE PULSE COUNT
        GOTO    DEL1LP                          ;AND LOOP UNTIL IT IS ZERO
        RETURN
;
;PAUSE GIVES SHORT DELAY BY LOOPING FF TIMES
;
PAUSE   MOVLW   0x08                            ;MOVE SET UP PAUSE DELAY
        MOVWF   DELAY0                          ;TO DELAY0 REGISTER
DELLP   DECFSZ  DELAY0, 1                       ;DECREMENT SAMPLE PULSE COUNT
        GOTO    DELLP                           ;AND LOOP UNTIL IT IS ZERO
        RETURN             
;
;*                        MOTOR DRIVE BLOCK                                 *
;
;This routine takes the start addresses from UPBYTE and INDEX and collects 
;the motor drive pattern from ROM. 
;
;
        ORG     01F9                            ;
;
STEP    CALL    STEPCO                          ;GET DIGIT FROM TABLE INTO W
        MOVWF   PORTB                           ;SWITCH DRIVE OUTPUTS
        RETURN                                  ;RETURN
;
STEPCO  MOVF    UPBYT, 0                        ;LOAD UPPER BYTE ADDRESS
        MOVWF   PCLATH                          ;TO PC UPPER BYTE REGISTER
        MOVF    INDEX, 0                        ;GET TABLE OFFSET INDEX
        ADDWF   PCL,1                           ;AND ADD TO PC LOWER 8 BITS
;
;       THE SUBROUTINE 'STEPCO' MUST BE LOCATED AS SHOWN
;       IN ORDER TO ALLOW THE 'TABLE LOOK UP' FUNCTION TO TAKE PLACE
;       THIS HAS BEEN ENSURED IN THIS EXAMPLE BY THE 'ORG' 01F6 
;       WHICH HAS FIXED THE 'MESGE' LINE AND ALL SUBSEQUENT CODE 
;       THIS IS ONE OF MANY POSSIBLE WAYS OF FIXING THE CODE.
;       TAKE CARE NOT TO CROSS PAGE BOUNDARIES AS 'UPBYT' REFERS TO  
;       A SINGLE PAGE ONLY - 0200 TO 0300 IN THIS CASE. 
;
;The PC (program counter) is loaded with the table address from UBBYT and 
;INDEX and so jumps to that address, and returns with the data following
;the RETLW instruction. 
;
;                                               ;UPBYT 02, INDEX 00
        RETLW   B'00001010'                     ;STEP0 -'HOME' POSITION
        RETLW   B'00000010'                     ;STEP0.5
        RETLW   B'00000110'                     ;STEP1
        RETLW   B'00000100'                     ;STEP1.5
        RETLW   B'00000101'                     ;STEP2
        RETLW   B'00000001'                     ;STEP2.5
        RETLW   B'00001001'                     ;STEP3
        RETLW   B'00001000'                     ;STEP3.5
;
;
		END
 
I have posted the code as suggested but had no response, can anybody help me cut out what I don't need in it, I would like to make a simple file to run the motor back and forth and be able to set the speed/degrees of movement to atleast start to understand how to programme the PIC.
 
This is still ongoing, Eric Gibbs (a member) has been helping me with this project for a while now but has gone on holiday for a few months, heres my question

Basically I have everything I need BUT at the slow speed the motor is resonating horribly, which I can understand as it echos the steps.

The motor supplier has said the motor can run at 2000 rpm so I would just need to increase the speed and gear it back down at the output shaft, my code

loop:
StepCCW 220, 1300
WaitUs 1000
StepCW 220, 1300
WaitUs 1000
Goto loop

As I understand it, the 1300 is the time between steps, when reduced the revs will be increased, 1300 seems to be the best I can get, anything lower just makes the motor buzz.

What else is limiting the speed?
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top