fl { HDD motor(BLDC) PropForth5.5 2015/09/10 14:50:41 SLA5064 HDD motor 3 ----- A 7 ----- B 10 ----- C P8 ----- Tr -- 4 P9 ----- Tr -- 2 P10 ----- Tr -- 6 P11 ----- Tr -- 8 P12 ----- Tr -- 11 P13 ----- Tr -- 9 GND ----- Tr -- 1 ---- 0V 5,12 -- 4.8V } \ =========================================================================== \ Constants \ =========================================================================== 8 wconstant phaseA d10 wconstant phaseB d12 wconstant phaseC h3F phaseA lshift invert constant phasemask clkfreq d200 / constant 5msec variable phaseState -4 allot 3 c, 3 c, 3 c, 0 c, 0 c, 0 c, \ =========================================================================== \ Variables \ =========================================================================== wvariable stepA wvariable stepB wvariable stepC \ =========================================================================== \ Main \ =========================================================================== \ Output pulse to SLA5064 \ ( -- ) : setPhase stepA W@ phaseState + C@ phaseA lshift stepB W@ phaseState + C@ phaseB lshift or stepC W@ phaseState + C@ phaseC lshift or outa COG@ phasemask and or outa COG! ; : demo \ Initialize step* 0 stepA W! 2 stepB W! 4 stepC W! \ Set pin to outport phasemask invert dira COG! 5msec cnt COG@ + begin \ phaseA 1 stepA W+! stepA W@ 5 > if 0 stepA W! then \ phaseB 1 stepB W+! stepB W@ 5 > if 0 stepB W! then \ phaseC 1 stepC W+! stepC W@ 5 > if 0 stepC W! then 5msec waitcnt \ Output pulse to each phase setPhase fkey? swap drop until drop ;