Thanks, I found an old printout of a web page amongst my general bric-a-brac, while having a clearout, and found a program for using a small pic to drive a stepper motor with a ULN2803.
I thought it would be an interesting small project to begin learning about PICs.
I worked in Avionics all my life before retirement, and have no fears about electronics, but have slight knowledge of coding.
I thought I could port the program to a 12F509, and managed to get MPLAB 8.92 to compile the program as a 12F509, with some warnings.(which I do not understand)
I want to breadboard it (I have a Pickit3) but before that, I had thought to simulate the program using LEDs to monitor the motor drive outputs from the PIC, and have tried the demo of Real Pic Simulator, but although it has the 12F509 in it when I tried to run it I got an error message "Error out of code". An email to Digital Electo Soft evinced no reply, and as I don't know if it is a limitation of the demo version or something else, I am reluctant to spend any dosh yet.
I cannot understand the MPLAB simulator (especially the MPLABX version, I find MPLAB X very difficult to understand).
I have all the Oshonsoft compilers and simulators, but here is no 12C/F50x pic support.
I had hoped the Misim DE, being older might support them, but it seems unobtainable.
The Proteus simulator does support them, but is very expensive for the hobbyist.
Is it very difficult to port to a supported 8 pin PIC, say a 12F629? though they seem much more complicated.
here is the code from the (no longer available) website.
I also don't understand what
DELAY1 EQU 0C
DELAY2 EQU 0D
INDEX EQU 0E
mean, are they registers? or variables?
Code:
; 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
I will have to reinstall MPLAB 8.92 as it now longer runs since MPLAB-X updated itself to 5.10
Sorry for the long post, any help/comments will be appreciated.