mirror of
https://github.com/sinseman44/PyCNC.git
synced 2026-04-20 18:48:11 +00:00
m84 real implementation, refactoring: mostly line width
This commit is contained in:
@@ -35,10 +35,12 @@ def init():
|
||||
gpio.init(FAN_PIN, rpgpio.GPIO.MODE_OUTPUT)
|
||||
gpio.init(EXTRUDER_HEATER_PIN, rpgpio.GPIO.MODE_OUTPUT)
|
||||
gpio.init(BED_HEATER_PIN, rpgpio.GPIO.MODE_OUTPUT)
|
||||
gpio.init(STEPPERS_ENABLE_PIN, rpgpio.GPIO.MODE_OUTPUT)
|
||||
gpio.clear(SPINDLE_PWM_PIN)
|
||||
gpio.clear(FAN_PIN)
|
||||
gpio.clear(EXTRUDER_HEATER_PIN)
|
||||
gpio.clear(BED_HEATER_PIN)
|
||||
gpio.clear(STEPPERS_ENABLE_PIN)
|
||||
|
||||
|
||||
def spindle_control(percent):
|
||||
@@ -99,6 +101,13 @@ def get_bed_temperature():
|
||||
return thermistor.get_temperature(BED_TEMPERATURE_SENSOR_CHANNEL)
|
||||
|
||||
|
||||
def disable_steppers():
|
||||
""" Disable all steppers until any movement occurs.
|
||||
"""
|
||||
logging.info("disable steppers")
|
||||
gpio.set(STEPPERS_ENABLE_PIN)
|
||||
|
||||
|
||||
def __calibrate_private(x, y, z, invert):
|
||||
if invert:
|
||||
stepper_inverted_x = not STEPPER_INVERTED_X
|
||||
@@ -190,6 +199,8 @@ def calibrate(x, y, z):
|
||||
:param z: boolean, True to calibrate Z axis.
|
||||
:return: boolean, True if all specified end stops were triggered.
|
||||
"""
|
||||
# enable steppers
|
||||
gpio.clear(STEPPERS_ENABLE_PIN)
|
||||
logging.info("hal calibrate, x={}, y={}, z={}".format(x, y, z))
|
||||
if not __calibrate_private(x, y, z, True): # move from endstop switch
|
||||
return False
|
||||
@@ -206,6 +217,8 @@ def move(generator):
|
||||
# moving. In this case machine would safely paused between commands until
|
||||
# calculation is done.
|
||||
|
||||
# enable steppers
|
||||
gpio.clear(STEPPERS_ENABLE_PIN)
|
||||
# 4 control blocks per 32 bytes
|
||||
bytes_per_iter = 4 * dma.control_block_size()
|
||||
# prepare and run dma
|
||||
@@ -309,6 +322,7 @@ def deinit():
|
||||
""" De-initialize hardware.
|
||||
"""
|
||||
join()
|
||||
disable_steppers()
|
||||
pwm.remove_all()
|
||||
gpio.clear(SPINDLE_PWM_PIN)
|
||||
gpio.clear(FAN_PIN)
|
||||
|
||||
@@ -15,8 +15,8 @@ class GPIO(object):
|
||||
|
||||
def __init__(self):
|
||||
""" Create object which can control GPIO.
|
||||
This class writes directly to CPU registers and doesn't use any libs
|
||||
or kernel modules.
|
||||
This class writes directly to CPU registers and doesn't use any
|
||||
libs or kernel modules.
|
||||
"""
|
||||
self._mem = PhysicalMemory(PERI_BASE + GPIO_REGISTER_BASE)
|
||||
|
||||
@@ -191,7 +191,7 @@ class DMAGPIO(DMAProto):
|
||||
self._phys_memory.write_int(self.__current_address + 20
|
||||
- self._DMA_CONTROL_BLOCK_SIZE, 0)
|
||||
logging.info("DMA took {}MB of memory".
|
||||
format(round(self.__current_address / 1024.0 / 1024.0, 2)))
|
||||
format(round(self.__current_address / 1048576.0, 2)))
|
||||
|
||||
def run_stream(self):
|
||||
""" Run DMA module in stream mode, i.e. does'n finalize last block
|
||||
@@ -199,18 +199,19 @@ class DMAGPIO(DMAProto):
|
||||
"""
|
||||
# configure PWM hardware module which will clocks DMA
|
||||
self._pwm.write_int(PWM_CTL, 0)
|
||||
self._clock.write_int(CM_PWM_CNTL, CM_PASSWORD | CM_SRC_PLLD) # disable
|
||||
# disable
|
||||
self._clock.write_int(CM_PWM_CNTL, CM_PASSWORD | CM_SRC_PLLD)
|
||||
while (self._clock.read_int(CM_PWM_CNTL) & CM_CNTL_BUSY) != 0:
|
||||
time.sleep(0.00001) # 10 us, wait until BUSY bit is clear
|
||||
self._clock.write_int(CM_PWM_DIV,
|
||||
CM_PASSWORD | CM_DIV_VALUE(5)) # 100MHz
|
||||
# configure, 100 MHz
|
||||
self._clock.write_int(CM_PWM_DIV, CM_PASSWORD | CM_DIV_VALUE(5))
|
||||
self._clock.write_int(CM_PWM_CNTL,
|
||||
CM_PASSWORD | CM_SRC_PLLD | CM_CNTL_ENABLE)
|
||||
|
||||
self._pwm.write_int(PWM_RNG1, 100)
|
||||
self._pwm.write_int(PWM_DMAC, PWM_DMAC_ENAB
|
||||
| PWM_DMAC_PANIC(15) | PWM_DMAC_DREQ(15))
|
||||
self._pwm.write_int(PWM_DMAC, PWM_DMAC_ENAB | PWM_DMAC_PANIC(15)
|
||||
| PWM_DMAC_DREQ(15))
|
||||
self._pwm.write_int(PWM_CTL, PWM_CTL_CLRF)
|
||||
# enable
|
||||
self._pwm.write_int(PWM_CTL, PWM_CTL_USEF1 | PWM_CTL_PWEN1)
|
||||
super(DMAGPIO, self)._run_dma()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user