Evo i malog programa za kontrolu motora za fokusiranje.
Sad samo treba vremena i noc bez mjesecine...
Ima li netko ideju, kako tu dodati akceleraciju?
Na primjer, dok se drzi tipka, da se timer skracuje?
Mislio sam nakon svakog ciklusa dekrementirati timer konstante (a kad je tipka otpustena opet sve ide u default..)
;*************************************************
;* Stepper motor driver for focuser *
;* Single motor CZ 2801 *
;* Based on control program v.1.5 *
;* *
;* (c) Bojan Stajcar 06-04-2012 *
;*************************************************
; Program generates output on port A
; Control (UP/DWN) comes from Port B
$include "INIT.ASM"
org ram ; $e0
timer0 ds 1
timer1 ds 1
timer2 ds 1
scratch ds 1
org rom ; $200
AR_phase db $11,$00,$22,$00,$44,$00,$88,$00 ; AZ / Hour Motor, Full steps, 50% duty cycle
time db !1,!3,!227,!26 ; Soft timer
time_fast db !1,!1,!1 ; second timer
start org $20f ; Program start
CLI
CLRX
LDA #18
STA $17 ; MOR byte, Disable COP
LDA #02 ;
STA COPR ; Stuff that watchdog timer, just in case
LDA #$ff
STA DDRA ; PORTA direction: OUT
LDA #$00
STA DDRB ; PORTB direction: IN
LDA time ; init counter/timer
STA timer0
LDA time+1
STA timer1
LDA time+2
STA timer2
LDX #$08 ; Table length
loop LDA #$00
STA PORTA ; disable motor(s)
test BRSET 0,PORTB,Step_DWN ; Test... if backwards button pressed then bit 1 will be HIGH
BRSET 1,PORTB,Step_UP ; Test for forward button
JMP loop
Step_DWN DECX ; 3; pointer down one line
BMI table_top ; 3; negative? if yes, it was bottom of the table, so back to top
JMP next ; still in table, continue
Step_UP INCX ; 3; pointer UP one line
STX scratch
LDA #$08
SBC scratch
BPL next
LDX #$00 ; Back to te bottom of the table
JMP next ; 3;
table_top LDX #$07 ; 2; back to top of table
next LDA AR_phase,X ; 5;
STA PORTA ; 4;
time0 DEC timer0 ; 5; Internal timer loop
BNE time0 ; 3; If not zero, once more
time1 LDA time ; 4; If yes then
STA timer0 ; 4; Timer0 to init value
DEC timer1 ; 5; decrement timer1 loop
BNE time0 ; 3; If not zero, back into fast loop
time2 LDA time+1 ; 4; If yes then
STA timer1 ; 4; timer1 to start value. (timer0 is reset earlier)
DEC timer2 ; 5; decrement outer timer2 loop
BNE time0 ; 3; If not zero, back into fast loop
LDA time+2 ; 4; If yes then
STA timer2 ; 4; timer2 reset (timer0 and timer1 already reset earlier).
JMP loop