fl { HDD motor(BLDC) PropForth5.5 2015/09/07 23:26:36 HDD motor P8 ----- A P9 ----- B P10 ----- C } \ =========================================================================== \ Constants \ =========================================================================== 8 wconstant phaseA 9 wconstant phaseB d10 wconstant phaseC clkfreq d40 / constant 25msec variable phaseState -4 allot 1 c, 1 c, 1 c, 0 c, 0 c, 0 c, \ =========================================================================== \ Variables \ =========================================================================== wvariable stepA wvariable stepB wvariable stepC \ =========================================================================== \ Main \ =========================================================================== : HDDmotor \ Initialize step* 0 stepA W! 2 stepB W! 4 stepC W! \ Set pin to outport phaseA pinout phaseB pinout phaseC pinout 25msec 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 25msec waitcnt \ Output pulse to each phase stepA W@ phaseState + C@ if phaseA pinhi else phaseA pinlo then stepB W@ phaseState + C@ if phaseB pinhi else phaseB pinlo then stepC W@ phaseState + C@ if phaseC pinhi else phaseC pinlo then fkey? swap drop until drop ;