In other words, our goal was for axes to change their motions in response to user inputs dynamically, rather for axes to ignore user inputs while executing toolpaths statically. We aimed to use the dynamic control to make a profilometer. In particular, we connected button to the computer via a serial port. a machine that moves a button along a Z axis until it touchs
Used the programfabnet_xyaxes.py
to ran 2 axes, from the Terminal with the command python fabnet_xyaxes.py [[[X1,Y1],[X2,Y2],...]]
.
Copied the programs term.py
, hello.light.45.py
, and hello.reflect.45.py
to the folder that contains the mods examples.
Attached the button via FTDI cable, and checked its device name /dev/tty.usbserial-FT9L3BOZ
. Confirmed that the button works, can see fabnet_xyaxes.py
and renamed to fabnet_xyaxes_button.py
. Looked at term.py
to figure out which parts to integrate into fabnet_xyaxes.py
.
Within mods, can detect the button press using the WebSocket serial module using Neil's program serialserver.js
by running from the Terminal node serialserver.js 127.0.0.1 1234
. He has a line mod.socket.onmessage = function(event) {mod.status.value = event.data ...}
Decided to adjust term.py
to output a different value when d and u pressed. Changed line 76 from widget_text.insert(INSERT,byte)
to widget_text.insert(INSERT,byte+1)
and got the error widget_text.insert(INSERT,byte+"1")
This gave the result widget_text.insert(INSERT,byte)
to
if (byte == "d"):
widget_text.insert(INSERT,"Button down\n")
elif (byte == "u"):
widget_text.insert(INSERT,"Button up\n")
else:
widget_text.insert(INSERT,byte)
Now, I need to change the "Button down" etc commands to fabnet commands.
So added this code to each block
widget_text.insert(INSERT,"Button down\n")
for move in moves_down:
stages.move(move, 0)
status = stages.xAxisNode.spinStatusRequest()
# This checks to see if the move is done.
while status['stepsRemaining'] > 0:
time.sleep(0.001)
status = stages.xAxisNode.spinStatusRequest
Got another indentation error. This was from the bottom bit! Which is no longer relevant.