newpicuser
New Member
Hi, does anyone know where to obtain the MiSim DE 2.1 Pic simulator by Feersum? I believe it was made freeware before being abandoned. As a newcomer to PICs I find MPLAB somewhat overwhelming.
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
; control a small stepper motor with a 12C509
; There are two controls, run/stop and direction
; The motor steps when the run button is depressed
; If the direction button is pressed
; the direction is reversed
;
; Peter Lynch, 13 May 1998
; pic@beowulf.demon.co.uk (THIS SITE NO LONGER EXISTS newpicuser)
; (this code is NOT certified Year 2000 compliant)
LIST P=12C509 ; (deleted by newpicuser)
include "\picde\12c509.inc" ; (changed to #include <p12c508.inc> newpicuser)
OPMASK EQU B'11000000'
BMASK EQU B'00101000' ; all bits output (except GP3 and GP5)
; GP3 controls run/stop
; GP5 controls direction
RUN_BTN EQU 3
DIR_BTN EQU 5
DELAY1 EQU 0C
DELAY2 EQU 0D
INDEX EQU 0E ; step index
ORG 0
; start of main code
MOVWF OSCCAL
MOVLW OPMASK
OPTION
MOVLW BMASK
TRIS GPIO
; now go into a loop, output the next bit pattern on
; GP0 - GP4 (GP3 is input only)
CLRF INDEX
NEXT
; check for run/stop button
BTFSS GPIO, RUN_BTN
GOTO NEXT
BTFSS GPIO, DIR_BTN
GOTO CWISE
INCF INDEX, W
GOTO NEW_IDX
CWISE
DECF INDEX, W
NEW_IDX
ANDLW .7
MOVFW INDEX
; here W contains the index (either incremented or decremented, depending
; on the direction switch) into the array for the new stepper actuations
CALL STEP ; convert the index into a bit pattern
MOVWF GPIO
CALL DELAY
GOTO NEXT
; routine to get step index
STEP
ADDWF PCL, F
RETLW B'00000001'
RETLW B'00000101'
RETLW B'00000100'
RETLW B'00000110'
RETLW B'00000010'
RETLW B'00010010'
RETLW B'00010000'
RETLW B'00010001'
; routine to delay between steps
DELAY
MOVLW .10 ; 10 milliseconds per step
MOVWF DELAY1
DEL_0
MOVLW .250 ; 1 millisecond delay
MOVWF DELAY2
DEL_1
NOP
DECFSZ DELAY2, F
GOTO DEL_1
DECFSZ DELAY1, F
GOTO DEL_0
RETURN ; (changed by MPLAB to RETLW 0 newpicuser)
END
Just noticed a typo in my last post.
Should be #include <p12c509.inc>
So the 0C,0D are hex starting values?
And Index 0E is an address in a register?
Index is added to the program counter in the "Step:" routine, to basically create a jump offset to the PCL. Index is a value that is incremented or decremented based on previous value. The returned value from the "Step" routine give the different pin outputs to step the motor.Just noticed a typo in my last post.
Should be #include <p12c509.inc>
So the 0C,0D are hex starting values?
And Index 0E is an address in a register?
AC162050 is used for the pic12f675... There is one for each chip... These are still available https://uk.rs-online.com/web/p/chip...31363230353026&searchHistory={"enabled":true}(There was at one time a special PIC12 IDC device, a 14 pin MCU with eight pins matching the standard PIC12 layout and extras to support simultaneous debug connections - but I cannot find any reference to those now, it looks like they are no longer made..)
; control a small stepper motor with a 12F509
; There are two controls, run/stop and direction
; The motor steps when the run button is depressed
; If the direction button is pressed
; the direction is reversed
;
#include <p12f509.inc>
__CONFIG _MCLRE_OFF & _CP_OFF & _WDT_OFF & _IntRC_OSC
OPMASK EQU B'11000000'
BMASK EQU B'00101000' ; all bits output (except GP3 and GP5)
; GP3 controls run/stop
; GP5 controls direction
RUN_BTN EQU 3
DIR_BTN EQU 5
DELAY1 EQU 0C
DELAY2 EQU 0D
INDEX EQU 0E ; step index
ORG 0x3FF ; processor reset vector
ORG 0
; start of main code
MOVWF OSCCAL
MOVLW OPMASK
OPTION
MOVLW BMASK
TRIS GPIO
; now go into a loop, output the next bit pattern on
; GP0 - GP4 (GP3 is input only)
CLRF INDEX
NEXT
; check for run/stop button
BTFSS GPIO, RUN_BTN
GOTO STEP
BTFSS GPIO, DIR_BTN
GOTO CWISE
INCF INDEX, W
GOTO NEW_IDX
CWISE
DECF INDEX, W
NEW_IDX
ANDLW .7
MOVFW INDEX
; here W contains the index (either incremented or decremented, depending
; on the direction switch) into the array for the new stepper actuations
CALL STEP ; convert the index into a bit pattern
MOVWF GPIO
CALL DELAY
GOTO NEXT
; routine to get step index
STEP
ADDWF PCL, F
RETLW B'00000001'
RETLW B'00000101'
RETLW B'00000100'
RETLW B'00000110'
RETLW B'00000010'
RETLW B'00010010'
RETLW B'00010000'
RETLW B'00010001'
; routine to delay between steps
DELAY
MOVLW .10 ; 10 milliseconds per step
MOVWF DELAY1
DEL_0
MOVLW .250 ; 1 millisecond delay
MOVWF DELAY2
DEL_1
NOP
DECFSZ DELAY2, F
GOTO DEL_1
DECFSZ DELAY1, F
GOTO DEL_0
RETLW 0
END