From a3870cb152b8c252b7992408c0c1d1e613ef8206 Mon Sep 17 00:00:00 2001 From: bartool Date: Sun, 7 Jun 2026 17:16:29 +0200 Subject: [PATCH] dzialajaca konfiguracja --- mayo-mill-remora.hal | 6 ++-- remora_pico_config.json | 46 +++++++++++++------------- upload_config.py | 72 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 98 insertions(+), 26 deletions(-) create mode 100644 upload_config.py diff --git a/mayo-mill-remora.hal b/mayo-mill-remora.hal index 6ef3b31..58dbd21 100644 --- a/mayo-mill-remora.hal +++ b/mayo-mill-remora.hal @@ -6,7 +6,7 @@ loadrt [EMCMOT]EMCMOT base_period_nsec=[EMCMOT]BASE_PERIOD servo_period_nsec=[EM # load the Remora real-time component - loadrt remora-eth PRU_base_freq=75000 + loadrt remora-eth-3.0 PRU_base_freq=75000 loadrt estop_latch names=estop_latch loadrt and2 names=run_and,step_and @@ -43,7 +43,7 @@ loadrt [EMCMOT]EMCMOT base_period_nsec=[EMCMOT]BASE_PERIOD servo_period_nsec=[EM net user-request-enable <= iocontrol.0.user-request-enable => remora.reset estop_latch.reset #Halt is shared with motor alarms and is in the estop loop. #estop_latch returns 'ok' when fault-in is false, ok-in is true, and reset changes from false to true. - net estop-fault_in remora.input.07 => estop_latch.fault-in + net estop-fault_in remora.input.03 => estop_latch.fault-in net remora-status remora.status => estop_latch.ok-in net estop-status estop_latch.ok-out => iocontrol.0.emc-enable-in @@ -118,7 +118,7 @@ loadrt [EMCMOT]EMCMOT base_period_nsec=[EMCMOT]BASE_PERIOD servo_period_nsec=[EM # Probe - net probe-in motion.probe-input <= remora.input.08 + net probe-in motion.probe-input <= remora.input.04 # Manual toolchange diff --git a/remora_pico_config.json b/remora_pico_config.json index 0117a6a..0104ecb 100644 --- a/remora_pico_config.json +++ b/remora_pico_config.json @@ -21,58 +21,58 @@ { "Thread": "Base", "Type": "Stepgen", - "Comment": "X - Joint 0 step generator", + "Comment": "X - Joint0", "Joint Number": 0, - "Step Pin": "GP2", - "Direction Pin": "GP3" + "Step Pin": "GP02", + "Direction Pin": "GP03" }, { "Thread": "Base", "Type": "Stepgen", - "Comment": "Y - Joint 1 step generator", + "Comment": "Y - Joint1", "Joint Number": 1, - "Step Pin": "GP4", - "Direction Pin": "GP5" + "Step Pin": "GP04", + "Direction Pin": "GP05" }, { "Thread": "Base", "Type": "Stepgen", - "Comment": "Z - Joint 2 step generator", + "Comment": "Z - Joint2", "Joint Number": 2, - "Step Pin": "GP6", - "Direction Pin": "GP7" + "Step Pin": "GP06", + "Direction Pin": "GP07" }, { "Thread": "Servo", "Type": "Digital Pin", - "Comment": "X axis limit/home switch", + "Comment": "X limit", "Pin": "GP13", "Mode": "Input", "Data Bit": 0, - "Invert": "False" + "Invert": "True" }, { "Thread": "Servo", "Type": "Digital Pin", - "Comment": "Y axis limit/home switch", + "Comment": "Y limit", "Pin": "GP14", "Mode": "Input", "Data Bit": 1, - "Invert": "False" + "Invert": "True" }, { "Thread": "Servo", "Type": "Digital Pin", - "Comment": "Z axis limit/home switch", + "Comment": "Z limit", "Pin": "GP15", "Mode": "Input", "Data Bit": 2, - "Invert": "False" + "Invert": "True" }, { "Thread": "Servo", "Type": "Digital Pin", - "Comment": "Emergency Stop switch", + "Comment": "E-Stop", "Pin": "GP28", "Mode": "Input", "Data Bit": 3, @@ -81,7 +81,7 @@ { "Thread": "Servo", "Type": "Digital Pin", - "Comment": "Versaprobe tool probe input", + "Comment": "Probe", "Pin": "GP27", "Mode": "Input", "Data Bit": 4, @@ -90,8 +90,8 @@ { "Thread": "Servo", "Type": "Digital Pin", - "Comment": "X axis driver enable pin", - "Pin": "GP9", + "Comment": "X enable", + "Pin": "GP09", "Mode": "Output", "Data Bit": 0, "Invert": "False" @@ -99,7 +99,7 @@ { "Thread": "Servo", "Type": "Digital Pin", - "Comment": "Y axis driver enable pin", + "Comment": "Y enable", "Pin": "GP10", "Mode": "Output", "Data Bit": 1, @@ -108,7 +108,7 @@ { "Thread": "Servo", "Type": "Digital Pin", - "Comment": "Z axis driver enable pin", + "Comment": "Z enable", "Pin": "GP11", "Mode": "Output", "Data Bit": 2, @@ -117,8 +117,8 @@ { "Thread": "Servo", "Type": "Digital Pin", - "Comment": "Spindle On command relay", - "Pin": "GP8", + "Comment": "Spindle", + "Pin": "GP08", "Mode": "Output", "Data Bit": 3, "Invert": "True" diff --git a/upload_config.py b/upload_config.py new file mode 100644 index 0000000..1e5b19e --- /dev/null +++ b/upload_config.py @@ -0,0 +1,72 @@ +#!/usr/bin/env python3 + +import binascii +import sys +import math +import json +import tftpy +import time + + +if len(sys.argv) < 2: + print("usage: upload.py ") + exit(-1) + + +# Check for a valid JSON formatted file, if ok upload to NVEM board via TFTP +with open(sys.argv[1], 'r') as jsonFile: + try: + testForValidJson = json.load(jsonFile) + print('Valid JSON config file, uploading to NVEM board') + + except ValueError: + print('Incorrectly formatted JSON configuration file') + exit(-1) + + +# Load File +config = open(sys.argv[1], "rb").read() + +# Compute length (in bytes and words) +jsonLength = len(config) +length = math.ceil(jsonLength / 4) +mod = jsonLength % 4 +print('Config file length (words) =', length) +print('Config file length (bytes) =', jsonLength) +print('Remainder =', mod) + +# add padding at end of file to ensure length is multiple of 4 bytes (word) +# to ensure correct CRC32 calculation +if mod > 0: + padding = [0 for i in range(4 - mod)] + print('Padding added = ', padding) + config = config + bytes(padding) + +newLength = len(config) +print('Config file length with padding (bytes) =', newLength) + +# Compute crc32 +crc32 = binascii.crc32(config) +print('CRC-32 =',hex(crc32)) + +# Insert metadata +metadata = [0 for i in range(512)] +metadata[0] = crc32 & 0xff +metadata[1] = (crc32 >> 8) & 0xff +metadata[2] = (crc32 >> 16) & 0xff +metadata[3] = (crc32 >> 24) & 0xff +metadata[4] = length & 0xff +metadata[5] = (length >> 8) & 0xff +metadata[6] = (length >> 16) & 0xff +metadata[7] = (length >> 24) & 0xff +metadata[8] = jsonLength & 0xff +metadata[9] = (jsonLength >> 8) & 0xff +metadata[10] = (jsonLength >> 16) & 0xff +metadata[11] = (jsonLength >> 24) & 0xff +config = bytes(metadata) + config + +open("/tmp/config.txt", "wb").write(config) + +# Upload using TFTP, set large timeout +client = tftpy.TftpClient("10.10.10.10", 69) +client.upload("config", "/tmp/config.txt", timeout=30)