adding files
This commit is contained in:
58
my-3d/3d_print_filter.py
Normal file
58
my-3d/3d_print_filter.py
Normal file
@@ -0,0 +1,58 @@
|
||||
#! /usr/bin/python3
|
||||
"""changes all words for controlling filament advancment 'E' to
|
||||
more appropriet LinuxCNC join 'U' words
|
||||
also changes argument names for the user defined M-codes"""
|
||||
import sys
|
||||
|
||||
def main(argv):
|
||||
|
||||
openfile = open(argv, 'r')
|
||||
file_in = openfile.readlines()
|
||||
openfile.close()
|
||||
|
||||
file_out = []
|
||||
for l in file_in:
|
||||
line = l.rstrip('\n')
|
||||
#print(line)
|
||||
#if line[0] == ';':
|
||||
# print('hej')
|
||||
if line.find('E') != -1:
|
||||
words = line.split(' ')
|
||||
|
||||
newArray = []
|
||||
for i in words:
|
||||
if i != '':
|
||||
if i[0] == 'E':
|
||||
i = i.replace('E', 'U', 1)
|
||||
|
||||
if len(i) > 0:
|
||||
newArray.append(i)
|
||||
|
||||
line = ' '.join(newArray)
|
||||
|
||||
elif line.find('M104 S') != -1:
|
||||
line = line.replace('M104 S', 'M104 P', 1)
|
||||
|
||||
elif line.find('M106 S') != -1:
|
||||
line = line.replace('M106 S', 'M106 P', 1)
|
||||
|
||||
elif line.find('M109 S') != -1:
|
||||
line = line.replace('M109 S', 'M109 P', 1)
|
||||
|
||||
elif line.find('M140 S') != -1:
|
||||
line = line.replace('M140 S', 'M140 P', 1)
|
||||
|
||||
# Cura seems to forget to divide the wait-value (Pxyz) with 1000
|
||||
# giving really long dwell-times
|
||||
elif line.find('G4') != -1:
|
||||
words = line.split('P')
|
||||
words[1] = str(float(words[1])/1000)
|
||||
line = 'P'.join(words)
|
||||
|
||||
file_out.append(line)
|
||||
|
||||
for item in file_out:
|
||||
print(item)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main(sys.argv[1])
|
||||
140
my-3d/comms.py
Normal file
140
my-3d/comms.py
Normal file
@@ -0,0 +1,140 @@
|
||||
#!/usr/bin/python3
|
||||
# list available ports with 'python -m serial.tools.list_ports'
|
||||
import serial
|
||||
import watchdog
|
||||
|
||||
## Default values ##
|
||||
BAUDRATE = 38400
|
||||
"""Default value for the baudrate in Baud (int)."""
|
||||
|
||||
PARITY = 'N' #serial.PARITY_NONE
|
||||
"""Default value for the parity. See the pySerial module for documentation. Defaults to serial.PARITY_NONE"""
|
||||
|
||||
BYTESIZE = 8
|
||||
"""Default value for the bytesize (int)."""
|
||||
|
||||
STOPBITS = 1
|
||||
"""Default value for the number of stopbits (int)."""
|
||||
|
||||
TIMEOUT = 0.05
|
||||
"""Default value for the timeout value in seconds (float)."""
|
||||
|
||||
CLOSE_PORT_AFTER_EACH_CALL = False
|
||||
"""Default value for port closure setting."""
|
||||
|
||||
|
||||
class Message:
|
||||
"""'container for messages. keeps two strings <message> and <value>"""
|
||||
def __init__(self, name = '', data = ''):
|
||||
self.name = name
|
||||
self.data = data
|
||||
|
||||
def __repr__(self):
|
||||
return 'msg: ' + self.name + ' val: ' + self.data
|
||||
|
||||
def copy(self, msg):
|
||||
self.name = msg.name
|
||||
self.data = msg.data
|
||||
|
||||
class instrument:
|
||||
"""rs232 port"""
|
||||
|
||||
def __init__(self,
|
||||
port,
|
||||
msg_handler,
|
||||
watchdog_enabled = False,
|
||||
watchdog_timeout = 2,
|
||||
watchdog_periodicity = 0.5):
|
||||
self.serial = serial.Serial()
|
||||
self.serial.port = port
|
||||
self.serial.baudrate = BAUDRATE
|
||||
self.serial.parity = PARITY
|
||||
self.serial.bytesize = BYTESIZE
|
||||
self.serial.stopbits = STOPBITS
|
||||
self.serial.xonxoff = False # disable software flow control
|
||||
self.serial.timeout = TIMEOUT
|
||||
self.portOpened = False
|
||||
self.msg_hdlr = msg_handler
|
||||
|
||||
self.watchdog_daemon = watchdog.WatchDogDaemon(watchdog_timeout,
|
||||
watchdog_timeout,
|
||||
watchdog_enabled)
|
||||
self.watchdog_daemon.reset = self._watchdogClose #register watchdog reset function
|
||||
self.closed_by_watchdog = False
|
||||
|
||||
self.open()
|
||||
|
||||
def open(self):
|
||||
try:
|
||||
self.serial.open()
|
||||
self.portOpened = True
|
||||
print('comms::opening port')
|
||||
except serial.SerialException:
|
||||
self.portOpened = False
|
||||
print('unable to open port...')
|
||||
|
||||
def close(self):
|
||||
self.serial.close()
|
||||
self.portOpened = False
|
||||
print('comms::closeing port')
|
||||
|
||||
def dataReady(self):
|
||||
if self.portOpened:
|
||||
return self.serial.in_waiting
|
||||
else:
|
||||
return False
|
||||
|
||||
def readMessages(self):
|
||||
"""reads serial port. creates an array of events
|
||||
output: array of events:
|
||||
"""
|
||||
if self.closed_by_watchdog:
|
||||
self.closed_by_watchdog = False
|
||||
self.open()
|
||||
|
||||
while self.dataReady():
|
||||
msg_str = self._read().split('_', 1)
|
||||
|
||||
if msg_str[0] != '':
|
||||
self.msg_hdlr(Message(*msg_str))
|
||||
self.watchdog_daemon.ping()
|
||||
|
||||
def generateEvent(self, name, data = ''):
|
||||
self.writeMessage(Message(name, data))
|
||||
|
||||
def writeMessage(self, m):
|
||||
self._write(m.name)
|
||||
if m.data != '':
|
||||
#self._write(m.data)
|
||||
self._write('_' + str(m.data))
|
||||
|
||||
self._write('\n')
|
||||
|
||||
def enableWatchdog(self, enable):
|
||||
self.watchdog_daemon.setEnabled(enable)
|
||||
|
||||
def _write(self, str):
|
||||
if self.portOpened == True:
|
||||
#serial expects a byte-array and not a string
|
||||
self.serial.write(''.join(str).encode('utf-8', 'ignore'))
|
||||
|
||||
def _read(self):
|
||||
""" returns string read from serial port """
|
||||
b = ''
|
||||
if self.portOpened == True:
|
||||
b = self.serial.read_until() #blocks until '\n' received or timeout
|
||||
|
||||
return b.decode('utf-8', 'ignore') #convert byte array to string
|
||||
|
||||
def _watchdogClose(self):
|
||||
self.closed_by_watchdog = True
|
||||
self.close()
|
||||
|
||||
def _is_number(self, s):
|
||||
""" helper function to evaluate if input text represents an integer or not """
|
||||
try:
|
||||
int(s)
|
||||
return True
|
||||
except ValueError:
|
||||
return False
|
||||
|
||||
4
my-3d/custom-m-codes/M102
Normal file
4
my-3d/custom-m-codes/M102
Normal file
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
# file to turn on parport pin XX to close the IO break out bord relay
|
||||
halcmd setp and2.0.in1 1
|
||||
exit 0
|
||||
4
my-3d/custom-m-codes/M103
Normal file
4
my-3d/custom-m-codes/M103
Normal file
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
# file to turn on parport pin XX to close the IO break out bord relay
|
||||
halcmd setp and2.0.in1 0
|
||||
exit 0
|
||||
12
my-3d/custom-m-codes/M104
Normal file
12
my-3d/custom-m-codes/M104
Normal file
@@ -0,0 +1,12 @@
|
||||
#!/usr/bin/python3
|
||||
# M104: Set Extruder Temperature
|
||||
import sys
|
||||
import hal
|
||||
|
||||
_dummy = hal.component("dummy")
|
||||
|
||||
P = sys.argv[1]
|
||||
setVal = str(int(float(P))) #convert from float-in-a-string to int-in-a-string
|
||||
hal.set_p("my-temp-ctrl.ref-temp", setVal)
|
||||
|
||||
print("M104 P" + setVal)
|
||||
3
my-3d/custom-m-codes/M105
Normal file
3
my-3d/custom-m-codes/M105
Normal file
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
#do nothing
|
||||
exit 0
|
||||
6
my-3d/custom-m-codes/M106
Normal file
6
my-3d/custom-m-codes/M106
Normal file
@@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
# M106: Set Extruder fan PWM
|
||||
temp=$1
|
||||
echo fan-pwm $temp
|
||||
halcmd sets fan-pwm-value $temp
|
||||
exit 0
|
||||
4
my-3d/custom-m-codes/M107
Normal file
4
my-3d/custom-m-codes/M107
Normal file
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
# M107: Fan Off
|
||||
halcmd sets fan-pwm-value 0.0
|
||||
exit 0
|
||||
28
my-3d/custom-m-codes/M109
Normal file
28
my-3d/custom-m-codes/M109
Normal file
@@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
# M109: Set Extruder Temperature and Wait
|
||||
float_ref=$1
|
||||
printf -v int_ref %.0f "$float_ref"
|
||||
curr=$(halcmd getp my-temp-ctrl.curr-temp)
|
||||
|
||||
halcmd setp my-temp-ctrl.ref-temp $int_ref
|
||||
echo curr $curr
|
||||
echo ref $int_ref
|
||||
|
||||
CNT=0
|
||||
let ref=int_ref-2
|
||||
# do until reference temp is greater or equal to current temp
|
||||
echo curr $curr, ref $ref
|
||||
until [ $curr -ge $ref ]
|
||||
do
|
||||
sleep 1
|
||||
curr=$(halcmd getp my-temp-ctrl.curr-temp)
|
||||
echo curr $curr, ref $ref
|
||||
echo cnt $CNT
|
||||
let CNT=CNT+1
|
||||
if [ "$CNT" = 60 ]; then
|
||||
echo timeout
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
echo M109 P$int_ref
|
||||
exit 0
|
||||
6
my-3d/custom-m-codes/M140
Normal file
6
my-3d/custom-m-codes/M140
Normal file
@@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
# M140: Set Bed Temperature (Fast)
|
||||
v=$1
|
||||
echo bed-pwm $v
|
||||
halcmd sets bed-pwm-value $v
|
||||
exit 0
|
||||
3
my-3d/custom-m-codes/M190
Normal file
3
my-3d/custom-m-codes/M190
Normal file
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
#do nothing
|
||||
exit 0
|
||||
4
my-3d/custom-m-codes/M84
Normal file
4
my-3d/custom-m-codes/M84
Normal file
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
# file to turn on parport pin XX to close the IO break out bord relay
|
||||
halcmd setp and2.0.in1 0
|
||||
exit 0
|
||||
4
my-3d/custom-m-codes/disable_steppers.ngc
Normal file
4
my-3d/custom-m-codes/disable_steppers.ngc
Normal file
@@ -0,0 +1,4 @@
|
||||
o<stop_idle_hold> sub
|
||||
M103
|
||||
o<stop_idle_hold> endsub
|
||||
M2
|
||||
3
my-3d/custom-m-codes/do_nothing.ngc
Normal file
3
my-3d/custom-m-codes/do_nothing.ngc
Normal file
@@ -0,0 +1,3 @@
|
||||
o<do_nothing> sub
|
||||
o<do_nothing> endsub
|
||||
M2
|
||||
4
my-3d/custom-m-codes/enable_steppers.ngc
Normal file
4
my-3d/custom-m-codes/enable_steppers.ngc
Normal file
@@ -0,0 +1,4 @@
|
||||
o<stop_idle_hold> sub
|
||||
M102
|
||||
o<stop_idle_hold> endsub
|
||||
M2
|
||||
4
my-3d/custom-m-codes/stop_idle_hold.ngc
Normal file
4
my-3d/custom-m-codes/stop_idle_hold.ngc
Normal file
@@ -0,0 +1,4 @@
|
||||
o<stop_idle_hold> sub
|
||||
M103
|
||||
o<stop_idle_hold> endsub
|
||||
M2
|
||||
40
my-3d/custom.hal
Normal file
40
my-3d/custom.hal
Normal file
@@ -0,0 +1,40 @@
|
||||
loadusr -Wn my-temp-ctrl python3 hal_extruder_temp_ctrl.py --port=/dev/ttyACM0 -c my-temp-ctrl
|
||||
loadrt pwmgen output_type=0,0
|
||||
loadrt conv_float_u32 count=2
|
||||
loadrt and2 count=2 #enabling steppers, enabling extruder
|
||||
|
||||
addf conv-float-u32.0 servo-thread
|
||||
addf conv-float-u32.1 servo-thread
|
||||
addf pwmgen.make-pulses base-thread
|
||||
addf pwmgen.update servo-thread
|
||||
addf and2.0 servo-thread
|
||||
addf and2.1 servo-thread
|
||||
|
||||
sets spindle-at-speed true
|
||||
|
||||
### PWM for hot bed
|
||||
# pwmgen.0.value connected and controlled in M140
|
||||
net bed-pwm-value => conv-float-u32.0.in
|
||||
net bed-pwm-value => pwmgen.0.value
|
||||
setp pwmgen.0.pwm-freq 100.0
|
||||
setp pwmgen.0.scale 512 #duty_cycle = (value/scale) + offset, with 1.0 meaning 100%, now with scale 1020 max duty is 25%
|
||||
setp pwmgen.0.offset 0
|
||||
setp pwmgen.0.enable 1
|
||||
setp pwmgen.0.dither-pwm true
|
||||
net bed-pwm-out pwmgen.0.pwm => parport.0.pin-14-out
|
||||
|
||||
### PWM for extruder fan
|
||||
# pwmgen.1.value connected and controlled in M106, M107
|
||||
net fan-pwm-value conv-float-u32.1.in
|
||||
net fan-pwm-value pwmgen.1.value
|
||||
setp pwmgen.1.pwm-freq 100.0
|
||||
setp pwmgen.1.scale 255 #duty_cycle = (value/scale) + offset, with 1.0 meaning 100%
|
||||
setp pwmgen.1.offset 0
|
||||
setp pwmgen.1.enable 1
|
||||
setp pwmgen.1.dither-pwm true
|
||||
net fan-pwm-out pwmgen.1.pwm => parport.0.pin-16-out
|
||||
|
||||
### enable steppers
|
||||
net machine-is-on halui.machine.is-on => and2.0.in0
|
||||
net and-out and2.0.out => parport.0.pin-17-out
|
||||
setp and2.0.in1 1 # start enabled, in1 is written by M102(enable) and M103(disable)
|
||||
13
my-3d/custom_postgui.hal
Normal file
13
my-3d/custom_postgui.hal
Normal file
@@ -0,0 +1,13 @@
|
||||
# Include your customized HAL commands here
|
||||
# The commands in this file are run after the AXIS GUI (including PyVCP panel) starts
|
||||
### enable extruder
|
||||
net machine-is-on => and2.1.in0
|
||||
net enable-chkbtn and2.1.in1 <= pyvcp.enable-chkbtn
|
||||
net temp-ctrl-enable and2.1.out => my-temp-ctrl.enable
|
||||
|
||||
net temp-ctrl-ref my-temp-ctrl.ref-temp-out => pyvcp.ref-temp
|
||||
net temp-ctrl-curr my-temp-ctrl.curr-temp => pyvcp.curr-temp
|
||||
|
||||
net bed-pwm-u32value conv-float-u32.0.out => pyvcp.bed-pwm
|
||||
net fan-pwm-u32value conv-float-u32.1.out => pyvcp.fan-pwm
|
||||
|
||||
126
my-3d/custompanel.xml
Normal file
126
my-3d/custompanel.xml
Normal file
@@ -0,0 +1,126 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<pyvcp>
|
||||
<labelframe text="Extruder">
|
||||
<font>("Helvetica",12)</font>
|
||||
<!-- Enabled -->
|
||||
<hbox>
|
||||
<relief>RIDGE</relief>
|
||||
<bd>2</bd>
|
||||
<checkbutton>
|
||||
<halpin>"enable-chkbtn"</halpin>
|
||||
<text>" Enable Extruder Temp Ctrl"</text>
|
||||
<font>("Helvetica",10)</font>
|
||||
<initval>1</initval>
|
||||
</checkbutton>
|
||||
</hbox>
|
||||
<!-- Ref Temp -->
|
||||
<hbox>
|
||||
<relief>RIDGE</relief>
|
||||
<bd>2</bd>
|
||||
<label>
|
||||
<text>"Ref Temp "</text>
|
||||
<font>("Helvetica",10)</font>
|
||||
</label>
|
||||
<u32>
|
||||
<halpin>"ref-temp"</halpin>
|
||||
<font>("Helvetica",10)</font>
|
||||
<format>"6d"</format>
|
||||
<width>6</width>
|
||||
</u32>
|
||||
</hbox>
|
||||
<!-- Curr Temp -->
|
||||
<hbox>
|
||||
<relief>RIDGE</relief>
|
||||
<bd>2</bd>
|
||||
<label>
|
||||
<text>"Curr Temp"</text>
|
||||
<font>("Helvetica",10)</font>
|
||||
</label>
|
||||
<u32>
|
||||
<halpin>"curr-temp"</halpin>
|
||||
<font>("Helvetica",10)</font>
|
||||
<format>"6d"</format>
|
||||
<width>6</width>
|
||||
</u32>
|
||||
</hbox>
|
||||
<hbox>
|
||||
<relief>RIDGE</relief>
|
||||
<bd>2</bd>
|
||||
<label>
|
||||
<text>"Extruder Fan PWM"</text>
|
||||
<font>("Helvetica",10)</font>
|
||||
</label>
|
||||
<u32>
|
||||
<halpin>"fan-pwm"</halpin>
|
||||
<font>("Helvetica",10)</font>
|
||||
<format>"6d"</format>
|
||||
<width>6</width>
|
||||
</u32>
|
||||
</hbox>
|
||||
</labelframe>
|
||||
<labelframe text="Bed">
|
||||
<font>("Helvetica",12)</font>
|
||||
<hbox>
|
||||
<relief>RIDGE</relief>
|
||||
<bd>2</bd>
|
||||
<label>
|
||||
<text>"Bed PWM"</text>
|
||||
<font>("Helvetica",10)</font>
|
||||
</label>
|
||||
<u32>
|
||||
<halpin>"bed-pwm"</halpin>
|
||||
<font>("Helvetica",10)</font>
|
||||
<format>"6d"</format>
|
||||
<width>6</width>
|
||||
</u32>
|
||||
</hbox>
|
||||
</labelframe>
|
||||
<labelframe text="Info">
|
||||
<font>("Helvetica",12)</font>
|
||||
<relief>RIDGE</relief>
|
||||
<bd>2</bd>
|
||||
<hbox>
|
||||
<label>
|
||||
<text>"M102 - Enable steppers"</text>
|
||||
<font>("Helvetica",8)</font>
|
||||
</label>
|
||||
</hbox>
|
||||
<hbox>
|
||||
<label>
|
||||
<text>"M103 - Disable steppers"</text>
|
||||
<font>("Helvetica",8)</font>
|
||||
</label>
|
||||
</hbox>
|
||||
<hbox>
|
||||
<label>
|
||||
<text>"M104 - Set Extruder Temperature"</text>
|
||||
<font>("Helvetica",8)</font>
|
||||
</label>
|
||||
</hbox>
|
||||
<hbox>
|
||||
<label>
|
||||
<text>"M106 - Set Extruder fan PWM"</text>
|
||||
<font>("Helvetica",8)</font>
|
||||
</label>
|
||||
</hbox>
|
||||
<hbox>
|
||||
<label>
|
||||
<text>"M107 - Turn off Extruder fan"</text>
|
||||
<font>("Helvetica",8)</font>
|
||||
</label>
|
||||
</hbox>
|
||||
<hbox>
|
||||
<label>
|
||||
<text>"M109 - Set Extruder Temperature and Wait"</text>
|
||||
<font>("Helvetica",8)</font>
|
||||
</label>
|
||||
</hbox>
|
||||
<hbox>
|
||||
<label>
|
||||
<text>"M140 - Set Bed Temperature"</text>
|
||||
<font>("Helvetica",8)</font>
|
||||
</label>
|
||||
</hbox>
|
||||
</labelframe>
|
||||
</pyvcp>
|
||||
|
||||
120
my-3d/hal_extruder_temp_ctrl.py
Normal file
120
my-3d/hal_extruder_temp_ctrl.py
Normal file
@@ -0,0 +1,120 @@
|
||||
#!/usr/bin/python3
|
||||
import getopt
|
||||
import hal
|
||||
import sys
|
||||
import comms
|
||||
import time
|
||||
|
||||
class HalAdapter:
|
||||
def __init__(self, name):
|
||||
self.hal = hal.component(name) # instanciate the HAL-component
|
||||
self.hal.newpin("ref-temp", hal.HAL_U32, hal.HAL_IN)
|
||||
self.hal.newpin("enable", hal.HAL_BIT, hal.HAL_IN)
|
||||
self.hal.newpin("curr-temp", hal.HAL_U32, hal.HAL_OUT)
|
||||
self.hal.newpin("ref-temp-out", hal.HAL_U32, hal.HAL_OUT)
|
||||
|
||||
self.hal.ready()
|
||||
|
||||
def setReady(self):
|
||||
self.hal.ready()
|
||||
|
||||
def readHAL_refTemp(self):
|
||||
"""read values from LinuxCNC HAL"""
|
||||
return self.hal['ref-temp']
|
||||
|
||||
def readHAL_enable(self):
|
||||
"""read values from LinuxCNC HAL"""
|
||||
return self.hal['enable']
|
||||
|
||||
def writeHAL_currTemp(self, val):
|
||||
""" write internal wrapper pin values to LinuxCNC HAL """
|
||||
self.hal['curr-temp'] = val
|
||||
|
||||
def writeHAL_refTemp(self, val):
|
||||
""" write internal wrapper pin values to LinuxCNC HAL """
|
||||
self.hal['ref-temp-out'] = val
|
||||
|
||||
class TempControllerFacade:
|
||||
def __init__(self, port):
|
||||
self.tempController = comms.instrument(port, self.msgHandler) #serial adaptor
|
||||
self.currTemp = 100
|
||||
self.refTemp = 100
|
||||
self.enable = False
|
||||
|
||||
def __repr__(self):
|
||||
return 'curr temp: ' + str(self.currTemp) + ', ref temp: ' + str(self.refTemp) + ' , enabled; ' + str(self.enable) + '\n'
|
||||
|
||||
def msgHandler(self, m):
|
||||
if (m.name == 'mv'):
|
||||
self.currTemp = int(m.data)
|
||||
|
||||
def setEnable(self, en):
|
||||
self.enable = en
|
||||
print('extruder temp controller enable: ' + str(self.enable))
|
||||
|
||||
if en == True:
|
||||
self.tempController.writeMessage(comms.Message('en' , '1'))
|
||||
else:
|
||||
self.tempController.writeMessage(comms.Message('en' , '0'))
|
||||
|
||||
|
||||
def setRefTemp(self, refT):
|
||||
if self.enable == True:
|
||||
if self.refTemp != refT:
|
||||
self.tempController.writeMessage(comms.Message('sp' , str(refT)))
|
||||
self.refTemp = refT
|
||||
|
||||
|
||||
def main():
|
||||
name = 'my-extruder'
|
||||
port = '/dev/ttyUSB0' # default serial port to use
|
||||
|
||||
try:
|
||||
opts, args = getopt.getopt(sys.argv[1:], "hp:c:", ["port="])
|
||||
except getopt.GetoptError as err:
|
||||
# print help information and exit:
|
||||
print(err) # will print something like "option -a not recognized"
|
||||
sys.exit(2)
|
||||
|
||||
for o, a in opts:
|
||||
if o == "-h":
|
||||
sys.exit()
|
||||
if o == "-c":
|
||||
name = a
|
||||
elif o in ("-p", "--port"):
|
||||
port = a
|
||||
else:
|
||||
print(o)
|
||||
assert False, "unhandled option"
|
||||
|
||||
h = HalAdapter(name)
|
||||
tc = TempControllerFacade(port)
|
||||
#tc.setEnable(True)
|
||||
|
||||
print(tc)
|
||||
|
||||
try:
|
||||
while 1:
|
||||
tc.tempController.readMessages()
|
||||
|
||||
if h.readHAL_enable() == 1:
|
||||
if tc.enable == False:
|
||||
tc.setEnable(True)
|
||||
else:
|
||||
if tc.enable == True:
|
||||
tc.setEnable(False)
|
||||
|
||||
if tc.enable == True:
|
||||
refTemp = h.readHAL_refTemp()
|
||||
tc.setRefTemp(refTemp)
|
||||
|
||||
h.writeHAL_currTemp(tc.currTemp)
|
||||
h.writeHAL_refTemp(tc.refTemp)
|
||||
#
|
||||
time.sleep(1)
|
||||
|
||||
except KeyboardInterrupt:
|
||||
raise SystemExit
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
119
my-3d/linuxcnc.var
Normal file
119
my-3d/linuxcnc.var
Normal file
@@ -0,0 +1,119 @@
|
||||
5161 0.000000
|
||||
5162 0.000000
|
||||
5163 0.000000
|
||||
5164 0.000000
|
||||
5165 0.000000
|
||||
5166 0.000000
|
||||
5167 0.000000
|
||||
5168 0.000000
|
||||
5169 0.000000
|
||||
5181 0.000000
|
||||
5182 0.000000
|
||||
5183 0.000000
|
||||
5184 0.000000
|
||||
5185 0.000000
|
||||
5186 0.000000
|
||||
5187 0.000000
|
||||
5188 0.000000
|
||||
5189 0.000000
|
||||
5210 1.000000
|
||||
5211 0.000000
|
||||
5212 0.000000
|
||||
5213 0.000000
|
||||
5214 0.000000
|
||||
5215 0.000000
|
||||
5216 0.000000
|
||||
5217 270.164780
|
||||
5218 0.000000
|
||||
5219 0.000000
|
||||
5220 1.000000
|
||||
5221 7.154117
|
||||
5222 -1.718917
|
||||
5223 0.627583
|
||||
5224 0.000000
|
||||
5225 0.000000
|
||||
5226 0.000000
|
||||
5227 0.000000
|
||||
5228 0.000000
|
||||
5229 0.000000
|
||||
5230 0.000000
|
||||
5241 0.000000
|
||||
5242 0.000000
|
||||
5243 0.000000
|
||||
5244 0.000000
|
||||
5245 0.000000
|
||||
5246 0.000000
|
||||
5247 0.000000
|
||||
5248 0.000000
|
||||
5249 0.000000
|
||||
5250 0.000000
|
||||
5261 0.000000
|
||||
5262 0.000000
|
||||
5263 0.000000
|
||||
5264 0.000000
|
||||
5265 0.000000
|
||||
5266 0.000000
|
||||
5267 0.000000
|
||||
5268 0.000000
|
||||
5269 0.000000
|
||||
5270 0.000000
|
||||
5281 0.000000
|
||||
5282 0.000000
|
||||
5283 0.000000
|
||||
5284 0.000000
|
||||
5285 0.000000
|
||||
5286 0.000000
|
||||
5287 0.000000
|
||||
5288 0.000000
|
||||
5289 0.000000
|
||||
5290 0.000000
|
||||
5301 0.000000
|
||||
5302 0.000000
|
||||
5303 0.000000
|
||||
5304 0.000000
|
||||
5305 0.000000
|
||||
5306 0.000000
|
||||
5307 0.000000
|
||||
5308 0.000000
|
||||
5309 0.000000
|
||||
5310 0.000000
|
||||
5321 0.000000
|
||||
5322 0.000000
|
||||
5323 0.000000
|
||||
5324 0.000000
|
||||
5325 0.000000
|
||||
5326 0.000000
|
||||
5327 0.000000
|
||||
5328 0.000000
|
||||
5329 0.000000
|
||||
5330 0.000000
|
||||
5341 0.000000
|
||||
5342 0.000000
|
||||
5343 0.000000
|
||||
5344 0.000000
|
||||
5345 0.000000
|
||||
5346 0.000000
|
||||
5347 0.000000
|
||||
5348 0.000000
|
||||
5349 0.000000
|
||||
5350 0.000000
|
||||
5361 0.000000
|
||||
5362 0.000000
|
||||
5363 0.000000
|
||||
5364 0.000000
|
||||
5365 0.000000
|
||||
5366 0.000000
|
||||
5367 0.000000
|
||||
5368 0.000000
|
||||
5369 0.000000
|
||||
5370 0.000000
|
||||
5381 0.000000
|
||||
5382 0.000000
|
||||
5383 0.000000
|
||||
5384 0.000000
|
||||
5385 0.000000
|
||||
5386 0.000000
|
||||
5387 0.000000
|
||||
5388 0.000000
|
||||
5389 0.000000
|
||||
5390 0.000000
|
||||
121
my-3d/my-3d.hal
Normal file
121
my-3d/my-3d.hal
Normal file
@@ -0,0 +1,121 @@
|
||||
# Generated by stepconf 1.1 at Fri May 1 19:07:04 2020
|
||||
# If you make changes to this file, they will be
|
||||
# overwritten when you run stepconf again
|
||||
loadrt [KINS]KINEMATICS
|
||||
#autoconverted trivkins
|
||||
loadrt [EMCMOT]EMCMOT base_period_nsec=[EMCMOT]BASE_PERIOD servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[KINS]JOINTS
|
||||
loadrt hal_parport cfg="0 out"
|
||||
setp parport.0.reset-time 5000
|
||||
loadrt stepgen step_type=0,0,0,0
|
||||
#loadrt pwmgen output_type=0
|
||||
|
||||
addf parport.0.read base-thread
|
||||
addf stepgen.make-pulses base-thread
|
||||
#addf pwmgen.make-pulses base-thread
|
||||
addf parport.0.write base-thread
|
||||
addf parport.0.reset base-thread
|
||||
|
||||
addf stepgen.capture-position servo-thread
|
||||
addf motion-command-handler servo-thread
|
||||
addf motion-controller servo-thread
|
||||
addf stepgen.update-freq servo-thread
|
||||
#addf pwmgen.update servo-thread
|
||||
|
||||
#net spindle-cmd-rpm => pwmgen.0.value
|
||||
#net spindle-on <= spindle.0.on => pwmgen.0.enable
|
||||
#net spindle-pwm <= pwmgen.0.pwm
|
||||
#setp pwmgen.0.pwm-freq 100.0
|
||||
#setp pwmgen.0.scale 9333.33333333
|
||||
#setp pwmgen.0.offset 0.0928571428571
|
||||
#setp pwmgen.0.dither-pwm true
|
||||
#net spindle-cmd-rpm <= spindle.0.speed-out
|
||||
#net spindle-cmd-rpm-abs <= spindle.0.speed-out-abs
|
||||
#net spindle-cmd-rps <= spindle.0.speed-out-rps
|
||||
#net spindle-cmd-rps-abs <= spindle.0.speed-out-rps-abs
|
||||
net spindle-at-speed => spindle.0.at-speed
|
||||
#net spindle-cw <= spindle.0.forward
|
||||
|
||||
net xdir => parport.0.pin-02-out
|
||||
net xstep => parport.0.pin-03-out
|
||||
setp parport.0.pin-03-out-reset 1
|
||||
net ydir => parport.0.pin-04-out
|
||||
net ystep => parport.0.pin-05-out
|
||||
setp parport.0.pin-05-out-reset 1
|
||||
setp parport.0.pin-06-out-invert 1
|
||||
net zdir => parport.0.pin-06-out
|
||||
net zstep => parport.0.pin-07-out
|
||||
setp parport.0.pin-07-out-reset 1
|
||||
setp parport.0.pin-08-out-invert 1
|
||||
net udir => parport.0.pin-08-out
|
||||
net ustep => parport.0.pin-09-out
|
||||
setp parport.0.pin-09-out-reset 1
|
||||
|
||||
|
||||
#net spindle-pwm => parport.0.pin-08-out
|
||||
#net spindle-cw => parport.0.pin-17-out
|
||||
net min-home-x <= parport.0.pin-11-in
|
||||
net max-home-y <= parport.0.pin-10-in
|
||||
net max-home-z <= parport.0.pin-12-in
|
||||
|
||||
setp stepgen.0.position-scale [JOINT_0]SCALE
|
||||
setp stepgen.0.steplen 1
|
||||
setp stepgen.0.stepspace 0
|
||||
setp stepgen.0.dirhold 35000
|
||||
setp stepgen.0.dirsetup 35000
|
||||
setp stepgen.0.maxaccel [JOINT_0]STEPGEN_MAXACCEL
|
||||
net xpos-cmd joint.0.motor-pos-cmd => stepgen.0.position-cmd
|
||||
net xpos-fb stepgen.0.position-fb => joint.0.motor-pos-fb
|
||||
net xstep <= stepgen.0.step
|
||||
net xdir <= stepgen.0.dir
|
||||
net xenable joint.0.amp-enable-out => stepgen.0.enable
|
||||
net min-home-x => joint.0.home-sw-in
|
||||
net min-home-x => joint.0.neg-lim-sw-in
|
||||
|
||||
setp stepgen.1.position-scale [JOINT_1]SCALE
|
||||
setp stepgen.1.steplen 1
|
||||
setp stepgen.1.stepspace 0
|
||||
setp stepgen.1.dirhold 35000
|
||||
setp stepgen.1.dirsetup 35000
|
||||
setp stepgen.1.maxaccel [JOINT_1]STEPGEN_MAXACCEL
|
||||
net ypos-cmd joint.1.motor-pos-cmd => stepgen.1.position-cmd
|
||||
net ypos-fb stepgen.1.position-fb => joint.1.motor-pos-fb
|
||||
net ystep <= stepgen.1.step
|
||||
net ydir <= stepgen.1.dir
|
||||
net yenable joint.1.amp-enable-out => stepgen.1.enable
|
||||
net max-home-y => joint.1.home-sw-in
|
||||
net max-home-y => joint.1.pos-lim-sw-in
|
||||
|
||||
setp stepgen.2.position-scale [JOINT_2]SCALE
|
||||
setp stepgen.2.steplen 1
|
||||
setp stepgen.2.stepspace 0
|
||||
setp stepgen.2.dirhold 35000
|
||||
setp stepgen.2.dirsetup 35000
|
||||
setp stepgen.2.maxaccel [JOINT_2]STEPGEN_MAXACCEL
|
||||
net zpos-cmd joint.2.motor-pos-cmd => stepgen.2.position-cmd
|
||||
net zpos-fb stepgen.2.position-fb => joint.2.motor-pos-fb
|
||||
net zstep <= stepgen.2.step
|
||||
net zdir <= stepgen.2.dir
|
||||
net zenable joint.2.amp-enable-out => stepgen.2.enable
|
||||
net max-home-z => joint.2.home-sw-in
|
||||
net max-home-z => joint.2.pos-lim-sw-in
|
||||
|
||||
setp stepgen.3.position-scale [JOINT_3]SCALE
|
||||
setp stepgen.3.steplen 1
|
||||
setp stepgen.3.stepspace 0
|
||||
setp stepgen.3.dirhold 35000
|
||||
setp stepgen.3.dirsetup 35000
|
||||
setp stepgen.3.maxaccel [JOINT_3]STEPGEN_MAXACCEL
|
||||
net upos-cmd joint.3.motor-pos-cmd => stepgen.3.position-cmd
|
||||
net upos-fb stepgen.3.position-fb => joint.3.motor-pos-fb
|
||||
net ustep <= stepgen.3.step
|
||||
net udir <= stepgen.3.dir
|
||||
net uenable joint.3.amp-enable-out => stepgen.3.enable
|
||||
|
||||
net estop-out <= iocontrol.0.user-enable-out
|
||||
net estop-out => iocontrol.0.emc-enable-in
|
||||
|
||||
loadusr -W hal_manualtoolchange
|
||||
net tool-change iocontrol.0.tool-change => hal_manualtoolchange.change
|
||||
net tool-changed iocontrol.0.tool-changed <= hal_manualtoolchange.changed
|
||||
net tool-number iocontrol.0.tool-prep-number => hal_manualtoolchange.number
|
||||
net tool-prepare-loopback iocontrol.0.tool-prepare => iocontrol.0.tool-prepared
|
||||
204
my-3d/my-3d.ini
Normal file
204
my-3d/my-3d.ini
Normal file
@@ -0,0 +1,204 @@
|
||||
# This config file was created 2021-02-04 16:39:45.407451 by the update_ini script
|
||||
# The original config files may be found in the /home/johan/linuxcnc/configs/test/test.old directory
|
||||
|
||||
# Generated by stepconf 1.1 at Fri May 1 19:07:04 2020
|
||||
# If you make changes to this file, they will be
|
||||
# overwritten when you run stepconf again
|
||||
|
||||
[EMC]
|
||||
# The version string for this INI file.
|
||||
VERSION = 1.1
|
||||
|
||||
MACHINE = my-3d
|
||||
DEBUG = 0
|
||||
|
||||
[DISPLAY]
|
||||
DISPLAY = axis
|
||||
EDITOR = gedit
|
||||
POSITION_OFFSET = RELATIVE
|
||||
POSITION_FEEDBACK = ACTUAL
|
||||
ARCDIVISION = 64
|
||||
GRIDS = 10mm 20mm 50mm 100mm 1in 2in 5in 10in
|
||||
MAX_FEED_OVERRIDE = 1.2
|
||||
MIN_SPINDLE_OVERRIDE = 0.5
|
||||
MAX_SPINDLE_OVERRIDE = 1.2
|
||||
DEFAULT_LINEAR_VELOCITY = 2.50
|
||||
MIN_LINEAR_VELOCITY = 0
|
||||
MAX_LINEAR_VELOCITY = 25.00
|
||||
DEFAULT_ANGULAR_VELOCITY = 36.00
|
||||
MIN_ANGULAR_VELOCITY = 0
|
||||
MAX_ANGULAR_VELOCITY = 360.00
|
||||
INTRO_GRAPHIC = linuxcnc.gif
|
||||
INTRO_TIME = 5
|
||||
PROGRAM_PREFIX = /home/johan/linuxcnc/nc_files
|
||||
INCREMENTS = 5mm 1mm .5mm .1mm .05mm .01mm .005mm
|
||||
PYVCP = custompanel.xml
|
||||
GEOMETRY = XYZ
|
||||
|
||||
[FILTER]
|
||||
PROGRAM_EXTENSION = .png,.gif,.jpg Greyscale Depth Image
|
||||
PROGRAM_EXTENSION = .py Python Script
|
||||
PROGRAM_EXTENSION = .gcode 3D Printer
|
||||
|
||||
png = image-to-gcode
|
||||
gif = image-to-gcode
|
||||
jpg = image-to-gcode
|
||||
py = python
|
||||
gcode = python /home/johan/linuxcnc/configs/my-3d/3d_print_filter.py
|
||||
|
||||
[RS274NGC]
|
||||
PARAMETER_FILE = linuxcnc.var
|
||||
SUBROUTINE_PATH=/home/johan/linuxcnc/configs/my-3d/custom-m-codes
|
||||
USER_M_PATH=/home/johan/linuxcnc/configs/my-3d/custom-m-codes
|
||||
REMAP=M17 modalgroup=10 ngc=enable_steppers
|
||||
REMAP=M18 modalgroup=10 ngc=disable_steppers
|
||||
REMAP=M84 modalgroup=10 ngc=stop_idle_hold
|
||||
REMAP=M82 modalgroup=10 ngc=do_nothing
|
||||
|
||||
[EMCMOT]
|
||||
EMCMOT = motmod
|
||||
COMM_TIMEOUT = 1.0
|
||||
BASE_PERIOD = 100000
|
||||
SERVO_PERIOD = 1000000
|
||||
|
||||
[TASK]
|
||||
TASK = milltask
|
||||
CYCLE_TIME = 0.010
|
||||
|
||||
[HAL]
|
||||
HALUI = halui
|
||||
HALFILE = my-3d.hal
|
||||
HALFILE = custom.hal
|
||||
POSTGUI_HALFILE = custom_postgui.hal
|
||||
|
||||
[HALUI]
|
||||
|
||||
[TRAJ]
|
||||
COORDINATES = XYZU
|
||||
JOINTS = 3
|
||||
HOME = 0 0 0 0
|
||||
LINEAR_UNITS = mm
|
||||
ANGULAR_UNITS = degree
|
||||
DEFAULT_LINEAR_VELOCITY = 25.0
|
||||
MAX_LINEAR_VELOCITY = 25.0
|
||||
DEFAULT_LINEAR_ACCELERATION = 50.0
|
||||
MAX_LINEAR_ACCELERATION = 50.0
|
||||
|
||||
[EMCIO]
|
||||
EMCIO = io
|
||||
CYCLE_TIME = 0.100
|
||||
TOOL_TABLE = tool.tbl
|
||||
|
||||
|
||||
[KINS]
|
||||
KINEMATICS = trivkins coordinates=XYZU
|
||||
#This is a best-guess at the number of joints, it should be checked
|
||||
JOINTS = 4
|
||||
|
||||
# X axis
|
||||
#prescale = 2, steps/rev = 200, 2 mm/rev
|
||||
#scale = 200*2/2 steps/mm
|
||||
[AXIS_X]
|
||||
MIN_LIMIT = -90.0
|
||||
MAX_LIMIT = 90.0
|
||||
MAX_VELOCITY = 25.0
|
||||
MAX_ACCELERATION = 50.0
|
||||
|
||||
[JOINT_0]
|
||||
TYPE = LINEAR
|
||||
HOME = 0.0
|
||||
MAX_VELOCITY = 25.0
|
||||
MAX_ACCELERATION = 50.0
|
||||
STEPGEN_MAXACCEL = 62.5
|
||||
SCALE = 200.0
|
||||
FERROR = 1
|
||||
MIN_FERROR = .25
|
||||
MIN_LIMIT = -90.0
|
||||
MAX_LIMIT = 90.0
|
||||
HOME_OFFSET = -91.400000
|
||||
HOME_SEARCH_VEL = -10.0
|
||||
HOME_LATCH_VEL = -1.50
|
||||
HOME_IGNORE_LIMITS = YES
|
||||
HOME_SEQUENCE = 0
|
||||
|
||||
# Y axis
|
||||
#prescale = 2, steps/rev = 200, 2 mm/rev
|
||||
#scale = 200*2/2 steps/mm
|
||||
[AXIS_Y]
|
||||
MIN_LIMIT = -90.0
|
||||
MAX_LIMIT = 90.0
|
||||
MAX_VELOCITY = 25.0
|
||||
MAX_ACCELERATION = 50.0
|
||||
|
||||
[JOINT_1]
|
||||
TYPE = LINEAR
|
||||
HOME = 0.0
|
||||
MAX_VELOCITY = 25.0
|
||||
MAX_ACCELERATION = 50.0
|
||||
STEPGEN_MAXACCEL = 62.5
|
||||
SCALE = 200.0
|
||||
FERROR = 1
|
||||
MIN_FERROR = .25
|
||||
MIN_LIMIT = -90.0
|
||||
MAX_LIMIT = 90.0
|
||||
HOME_OFFSET = 66.00000
|
||||
HOME_SEARCH_VEL = 10.0
|
||||
HOME_LATCH_VEL = 2.5
|
||||
HOME_IGNORE_LIMITS = YES
|
||||
HOME_SEQUENCE = 0
|
||||
|
||||
# Z axis
|
||||
#prescale = 8, steps/rev = 200, 1 mm/rev
|
||||
#scale = 200*8/1 = 1600 steps/mm
|
||||
[AXIS_Z]
|
||||
MIN_LIMIT = -10.0
|
||||
MAX_LIMIT = 51.7
|
||||
MAX_VELOCITY = 6.0
|
||||
MAX_ACCELERATION = 50.0
|
||||
|
||||
[JOINT_2]
|
||||
TYPE = LINEAR
|
||||
HOME = 48.0
|
||||
MAX_VELOCITY = 6.0
|
||||
MAX_ACCELERATION = 50.0
|
||||
STEPGEN_MAXACCEL = 62.5
|
||||
SCALE = 1600.0
|
||||
FERROR = 1
|
||||
MIN_FERROR = .25
|
||||
MIN_LIMIT = -10.0
|
||||
MAX_LIMIT = 51.7
|
||||
HOME_OFFSET = 51.7
|
||||
HOME_SEARCH_VEL = 7.500000
|
||||
HOME_LATCH_VEL = 0.312500
|
||||
HOME_IGNORE_LIMITS = YES
|
||||
HOME_SEQUENCE = 0
|
||||
|
||||
# U axis
|
||||
#prescale = 4, steps/rev = 200, 34.069 mm/rev (D=10.85, pi*10.85=34.069)
|
||||
#scale = 200*4/34.069 steps/mm
|
||||
[AXIS_U]
|
||||
MIN_LIMIT = -1e99
|
||||
MAX_LIMIT = 1e99
|
||||
MAX_VELOCITY = 30
|
||||
MAX_ACCELERATION = 50.0
|
||||
|
||||
[JOINT_3]
|
||||
TYPE = LINEAR
|
||||
HOME = 0.000
|
||||
MAX_VELOCITY = 30
|
||||
MAX_ACCELERATION = 50.0
|
||||
STEPGEN_MAXACCEL = 62.5
|
||||
SCALE = 23.5
|
||||
BACKLASH = 0.000
|
||||
OUTPUT_SCALE = 1.000
|
||||
MIN_LIMIT = -1e99
|
||||
MAX_LIMIT = 1e99
|
||||
FERROR = 1
|
||||
MIN_FERROR = .25
|
||||
HOME_OFFSET = 0.0
|
||||
HOME_SEARCH_VEL = 0
|
||||
HOME_LATCH_VEL = 0
|
||||
HOME_USE_INDEX = NO
|
||||
HOME_IGNORE_LIMITS = YES
|
||||
HOME_SEQUENCE = 0
|
||||
HOME_IS_SHARED = NO
|
||||
101
my-3d/my-draw.hal
Normal file
101
my-3d/my-draw.hal
Normal file
@@ -0,0 +1,101 @@
|
||||
# Generated by stepconf 1.1 at Fri May 1 19:07:04 2020
|
||||
# If you make changes to this file, they will be
|
||||
# overwritten when you run stepconf again
|
||||
loadrt [KINS]KINEMATICS
|
||||
#autoconverted trivkins
|
||||
loadrt [EMCMOT]EMCMOT base_period_nsec=[EMCMOT]BASE_PERIOD servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[KINS]JOINTS
|
||||
loadrt hal_parport cfg="0 out"
|
||||
setp parport.0.reset-time 5000
|
||||
loadrt stepgen step_type=0,0,0
|
||||
#loadrt pwmgen output_type=0
|
||||
|
||||
addf parport.0.read base-thread
|
||||
addf stepgen.make-pulses base-thread
|
||||
#addf pwmgen.make-pulses base-thread
|
||||
addf parport.0.write base-thread
|
||||
addf parport.0.reset base-thread
|
||||
|
||||
addf stepgen.capture-position servo-thread
|
||||
addf motion-command-handler servo-thread
|
||||
addf motion-controller servo-thread
|
||||
addf stepgen.update-freq servo-thread
|
||||
|
||||
net spindle-at-speed => spindle.0.at-speed
|
||||
|
||||
net xdir => parport.0.pin-02-out
|
||||
net xstep => parport.0.pin-03-out
|
||||
setp parport.0.pin-03-out-reset 1
|
||||
net ydir => parport.0.pin-04-out
|
||||
net ystep => parport.0.pin-05-out
|
||||
setp parport.0.pin-05-out-reset 1
|
||||
setp parport.0.pin-06-out-invert 1
|
||||
net zdir => parport.0.pin-06-out
|
||||
net zstep => parport.0.pin-07-out
|
||||
setp parport.0.pin-07-out-reset 1
|
||||
setp parport.0.pin-08-out-invert 1
|
||||
|
||||
net min-home-x <= parport.0.pin-11-in
|
||||
net max-home-y <= parport.0.pin-10-in
|
||||
net max-home-z <= parport.0.pin-12-in
|
||||
|
||||
setp stepgen.0.position-scale [JOINT_0]SCALE
|
||||
setp stepgen.0.steplen 1
|
||||
setp stepgen.0.stepspace 0
|
||||
setp stepgen.0.dirhold 35000
|
||||
setp stepgen.0.dirsetup 35000
|
||||
setp stepgen.0.maxaccel [JOINT_0]STEPGEN_MAXACCEL
|
||||
net xpos-cmd joint.0.motor-pos-cmd => stepgen.0.position-cmd
|
||||
net xpos-fb stepgen.0.position-fb => joint.0.motor-pos-fb
|
||||
net xstep <= stepgen.0.step
|
||||
net xdir <= stepgen.0.dir
|
||||
net xenable joint.0.amp-enable-out => stepgen.0.enable
|
||||
net min-home-x => joint.0.home-sw-in
|
||||
net min-home-x => joint.0.neg-lim-sw-in
|
||||
|
||||
setp stepgen.1.position-scale [JOINT_1]SCALE
|
||||
setp stepgen.1.steplen 1
|
||||
setp stepgen.1.stepspace 0
|
||||
setp stepgen.1.dirhold 35000
|
||||
setp stepgen.1.dirsetup 35000
|
||||
setp stepgen.1.maxaccel [JOINT_1]STEPGEN_MAXACCEL
|
||||
net ypos-cmd joint.1.motor-pos-cmd => stepgen.1.position-cmd
|
||||
net ypos-fb stepgen.1.position-fb => joint.1.motor-pos-fb
|
||||
net ystep <= stepgen.1.step
|
||||
net ydir <= stepgen.1.dir
|
||||
net yenable joint.1.amp-enable-out => stepgen.1.enable
|
||||
net max-home-y => joint.1.home-sw-in
|
||||
net max-home-y => joint.1.pos-lim-sw-in
|
||||
|
||||
setp stepgen.2.position-scale [JOINT_2]SCALE
|
||||
setp stepgen.2.steplen 1
|
||||
setp stepgen.2.stepspace 0
|
||||
setp stepgen.2.dirhold 35000
|
||||
setp stepgen.2.dirsetup 35000
|
||||
setp stepgen.2.maxaccel [JOINT_2]STEPGEN_MAXACCEL
|
||||
net zpos-cmd joint.2.motor-pos-cmd => stepgen.2.position-cmd
|
||||
net zpos-fb stepgen.2.position-fb => joint.2.motor-pos-fb
|
||||
net zstep <= stepgen.2.step
|
||||
net zdir <= stepgen.2.dir
|
||||
net zenable joint.2.amp-enable-out => stepgen.2.enable
|
||||
net max-home-z => joint.2.home-sw-in
|
||||
net max-home-z => joint.2.pos-lim-sw-in
|
||||
|
||||
net estop-out <= iocontrol.0.user-enable-out
|
||||
net estop-out => iocontrol.0.emc-enable-in
|
||||
|
||||
sets spindle-at-speed true
|
||||
|
||||
loadusr -W hal_manualtoolchange
|
||||
net tool-change iocontrol.0.tool-change => hal_manualtoolchange.change
|
||||
net tool-changed iocontrol.0.tool-changed <= hal_manualtoolchange.changed
|
||||
net tool-number iocontrol.0.tool-prep-number => hal_manualtoolchange.number
|
||||
net tool-prepare-loopback iocontrol.0.tool-prepare => iocontrol.0.tool-prepared
|
||||
|
||||
### enable steppers
|
||||
net and-in1 halui.machine.is-on => parport.0.pin-17-out
|
||||
|
||||
#disable hot bed
|
||||
setp parport.0.pin-14-out 0
|
||||
|
||||
#disable extruderfan
|
||||
setp parport.0.pin-16-out 0
|
||||
167
my-3d/my-draw.ini
Normal file
167
my-3d/my-draw.ini
Normal file
@@ -0,0 +1,167 @@
|
||||
# This config file was created 2021-02-04 16:39:45.407451 by the update_ini script
|
||||
# The original config files may be found in the /home/johan/linuxcnc/configs/test/test.old directory
|
||||
|
||||
# Generated by stepconf 1.1 at Fri May 1 19:07:04 2020
|
||||
# If you make changes to this file, they will be
|
||||
# overwritten when you run stepconf again
|
||||
|
||||
[EMC]
|
||||
# The version string for this INI file.
|
||||
VERSION = 1.1
|
||||
|
||||
MACHINE = my-draw
|
||||
DEBUG = 0
|
||||
|
||||
[DISPLAY]
|
||||
DISPLAY = axis
|
||||
EDITOR = gedit
|
||||
POSITION_OFFSET = RELATIVE
|
||||
POSITION_FEEDBACK = ACTUAL
|
||||
ARCDIVISION = 64
|
||||
GRIDS = 10mm 20mm 50mm 100mm 1in 2in 5in 10in
|
||||
MAX_FEED_OVERRIDE = 1.2
|
||||
MIN_SPINDLE_OVERRIDE = 0.5
|
||||
MAX_SPINDLE_OVERRIDE = 1.2
|
||||
DEFAULT_LINEAR_VELOCITY = 2.50
|
||||
MIN_LINEAR_VELOCITY = 0
|
||||
MAX_LINEAR_VELOCITY = 25.00
|
||||
DEFAULT_ANGULAR_VELOCITY = 36.00
|
||||
MIN_ANGULAR_VELOCITY = 0
|
||||
MAX_ANGULAR_VELOCITY = 360.00
|
||||
INTRO_GRAPHIC = linuxcnc.gif
|
||||
INTRO_TIME = 5
|
||||
PROGRAM_PREFIX = /home/johan/linuxcnc/nc_files
|
||||
INCREMENTS = 5mm 1mm .5mm .1mm .05mm .01mm .005mm
|
||||
GEOMETRY = XYZ
|
||||
|
||||
[FILTER]
|
||||
PROGRAM_EXTENSION = .png,.gif,.jpg Greyscale Depth Image
|
||||
PROGRAM_EXTENSION = .py Python Script
|
||||
PROGRAM_EXTENSION = .gcode 3D Printer
|
||||
|
||||
png = image-to-gcode
|
||||
gif = image-to-gcode
|
||||
jpg = image-to-gcode
|
||||
py = python
|
||||
|
||||
|
||||
[RS274NGC]
|
||||
PARAMETER_FILE = linuxcnc.var
|
||||
SUBROUTINE_PATH=/home/johan/linuxcnc/configs/my-3d/custom-m-codes
|
||||
USER_M_PATH=/home/johan/linuxcnc/configs/my-3d/custom-m-codes
|
||||
|
||||
|
||||
[EMCMOT]
|
||||
EMCMOT = motmod
|
||||
COMM_TIMEOUT = 1.0
|
||||
BASE_PERIOD = 100000
|
||||
SERVO_PERIOD = 1000000
|
||||
|
||||
[TASK]
|
||||
TASK = milltask
|
||||
CYCLE_TIME = 0.010
|
||||
|
||||
[HAL]
|
||||
HALUI = halui
|
||||
HALFILE = my-draw.hal
|
||||
|
||||
[HALUI]
|
||||
|
||||
[TRAJ]
|
||||
COORDINATES = XYZ
|
||||
JOINTS = 3
|
||||
HOME = 0 0 0
|
||||
LINEAR_UNITS = mm
|
||||
ANGULAR_UNITS = degree
|
||||
DEFAULT_LINEAR_VELOCITY = 25.0
|
||||
MAX_LINEAR_VELOCITY = 25.0
|
||||
MAX_LINEAR_ACCELERATION = 50.0
|
||||
DEFAULT_LINEAR_ACCELERATION = 50.0
|
||||
|
||||
[EMCIO]
|
||||
EMCIO = io
|
||||
CYCLE_TIME = 0.100
|
||||
TOOL_TABLE = tool.tbl
|
||||
|
||||
|
||||
[KINS]
|
||||
KINEMATICS = trivkins coordinates=XYZ
|
||||
JOINTS = 3
|
||||
|
||||
# X axis
|
||||
#prescale = 2, steps/rev = 200, 2 mm/rev
|
||||
#scale = 200*2/2 steps/mm
|
||||
[AXIS_X]
|
||||
MIN_LIMIT = -90.0
|
||||
MAX_LIMIT = 90.0
|
||||
MAX_VELOCITY = 25.0
|
||||
MAX_ACCELERATION = 50.0
|
||||
|
||||
[JOINT_0]
|
||||
TYPE = LINEAR
|
||||
HOME = 0.0
|
||||
MAX_VELOCITY = 25.0
|
||||
MAX_ACCELERATION = 50.0
|
||||
STEPGEN_MAXACCEL = 62.5
|
||||
SCALE = 200.0
|
||||
FERROR = 1
|
||||
MIN_FERROR = .25
|
||||
MIN_LIMIT = -90.0
|
||||
MAX_LIMIT = 90.0
|
||||
HOME_OFFSET = -91.400000
|
||||
HOME_SEARCH_VEL = -10.0
|
||||
HOME_LATCH_VEL = -1.50
|
||||
HOME_IGNORE_LIMITS = YES
|
||||
HOME_SEQUENCE = 0
|
||||
|
||||
# Y axis
|
||||
#prescale = 2, steps/rev = 200, 2 mm/rev
|
||||
#scale = 200*2/2 steps/mm
|
||||
[AXIS_Y]
|
||||
MIN_LIMIT = -90.0
|
||||
MAX_LIMIT = 90.0
|
||||
MAX_VELOCITY = 25.0
|
||||
MAX_ACCELERATION = 50.0
|
||||
|
||||
[JOINT_1]
|
||||
TYPE = LINEAR
|
||||
HOME = 0.0
|
||||
MAX_VELOCITY = 25.0
|
||||
MAX_ACCELERATION = 50.0
|
||||
STEPGEN_MAXACCEL = 62.5
|
||||
SCALE = 200.0
|
||||
FERROR = 1
|
||||
MIN_FERROR = .25
|
||||
MIN_LIMIT = -90.0
|
||||
MAX_LIMIT = 90.0
|
||||
HOME_OFFSET = 66.00000
|
||||
HOME_SEARCH_VEL = 10.0
|
||||
HOME_LATCH_VEL = 2.5
|
||||
HOME_IGNORE_LIMITS = YES
|
||||
HOME_SEQUENCE = 0
|
||||
|
||||
# Z axis
|
||||
#prescale = 8, steps/rev = 200, 1 mm/rev
|
||||
#scale = 200*8/1 = 1600 steps/mm
|
||||
[AXIS_Z]
|
||||
MIN_LIMIT = -10.0
|
||||
MAX_LIMIT = 51.7
|
||||
MAX_VELOCITY = 6.0
|
||||
MAX_ACCELERATION = 50.0
|
||||
|
||||
[JOINT_2]
|
||||
TYPE = LINEAR
|
||||
HOME = 48.0
|
||||
MAX_VELOCITY = 6.0
|
||||
MAX_ACCELERATION = 50.0
|
||||
STEPGEN_MAXACCEL = 62.5
|
||||
SCALE = 1600.0
|
||||
FERROR = 1
|
||||
MIN_FERROR = .25
|
||||
MIN_LIMIT = -10.0
|
||||
MAX_LIMIT = 51.7
|
||||
HOME_OFFSET = 51.7
|
||||
HOME_SEARCH_VEL = 7.500000
|
||||
HOME_LATCH_VEL = 0.312500
|
||||
HOME_IGNORE_LIMITS = YES
|
||||
HOME_SEQUENCE = 0
|
||||
4
my-3d/tool.tbl
Normal file
4
my-3d/tool.tbl
Normal file
@@ -0,0 +1,4 @@
|
||||
T1 P1 Z50 D12.0 ;12mm end mill
|
||||
T2 P2 Z24.1 D8.0 ;8mm end mill
|
||||
T3 P3 Z26 D4.2 ;m5 tap drill
|
||||
T99999 P99999 Z0.1 ;big tool number
|
||||
93
my-3d/watchdog.py
Normal file
93
my-3d/watchdog.py
Normal file
@@ -0,0 +1,93 @@
|
||||
#! /usr/bin/python3
|
||||
import time
|
||||
import threading
|
||||
import sys
|
||||
|
||||
class WatchDog():
|
||||
def __init__(self, timeout):
|
||||
self.timeout = timeout
|
||||
self.last_ping_time = time.time()
|
||||
|
||||
def ping(self):
|
||||
self.last_ping_time = time.time()
|
||||
|
||||
def check(self):
|
||||
if time.time() - self.last_ping_time > self.timeout:
|
||||
self.last_ping_time = time.time() #reset tick time
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def insideMargin(self):
|
||||
if time.time() - self.last_ping_time <= self.timeout:
|
||||
return True
|
||||
else:
|
||||
self.last_ping_time = time.time() #reset tick time
|
||||
return False
|
||||
|
||||
|
||||
class WatchDogDaemon(threading.Thread):
|
||||
def __init__(self, timeout, periodicity, enable = True):
|
||||
self.wd = WatchDog(timeout)
|
||||
self.periodicity = periodicity
|
||||
self.enabled = enable
|
||||
self._start()
|
||||
|
||||
def _start(self):
|
||||
threading.Thread.__init__(self)
|
||||
self.daemon = True
|
||||
self.start()
|
||||
|
||||
def ping(self):
|
||||
self.wd.ping()
|
||||
|
||||
def run(self):
|
||||
print("Starting watchdog deamon...")
|
||||
while(self.enabled):
|
||||
time.sleep(self.periodicity)
|
||||
|
||||
if not self.wd.insideMargin():
|
||||
self.reset()
|
||||
|
||||
print("stopping watchdog deamon...")
|
||||
|
||||
def setEnabled(self, enabled):
|
||||
if self.enabled == False and enabled == True:
|
||||
self.enabled = True
|
||||
self.wd.ping() # reset tick time
|
||||
self._start()
|
||||
|
||||
if enabled == False:
|
||||
self.enabled = False
|
||||
|
||||
def reset(self):
|
||||
"""to be overriden by client"""
|
||||
pass
|
||||
|
||||
|
||||
def reset():
|
||||
print('reset')
|
||||
|
||||
def main():
|
||||
i = 0
|
||||
wdd = WatchDogDaemon(2, 0.5, False)
|
||||
wdd.reset = reset
|
||||
try:
|
||||
while 1:
|
||||
time.sleep(1)
|
||||
print('main_' + str(i))
|
||||
print(wdd.is_alive())
|
||||
i = i+1
|
||||
|
||||
if i == 5 or i == 15:
|
||||
wdd.setEnabled(True)
|
||||
if i == 10:
|
||||
wdd.setEnabled(False)
|
||||
|
||||
wdd.ping()
|
||||
|
||||
except KeyboardInterrupt:
|
||||
raise SystemExit
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user