From 29341ef002f74e600e56ebaf7c4cae02e18bfcd0 Mon Sep 17 00:00:00 2001 From: Carl Philipp Klemm Date: Wed, 23 Jul 2025 17:53:33 +0200 Subject: [PATCH] inial commit --- dsmono.comp | 43 +++++++++++++++++++++++++++++++++++++++++++ install.sh | 4 ++++ 2 files changed, 47 insertions(+) create mode 100644 dsmono.comp create mode 100755 install.sh diff --git a/dsmono.comp b/dsmono.comp new file mode 100644 index 0000000..fe6095d --- /dev/null +++ b/dsmono.comp @@ -0,0 +1,43 @@ +// This is a component for LinuxCNC HAL +// Copyright 2023 The LinuxCNC Project +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +component dsmono "Double-sided monoflop"; + +// Credits: This is very loosely based on edge.comp by Jeff Epler + +pin in bit in "Input signal"; +pin out bit out "Filtered output signal, tracking 'in' with a deadtime component"; +pin out bit out_invert "Negative of 'out'"; + +param rw signed deadtime_ns = 0 "Time to be insensitive after an edge on 'in'."; +param r signed time_left_ns = 0 "Time left in this output pulse"; + +function _ nofp "Filter input with a deadtime component"; +license "GPL"; +author "ok"; +;; + +FUNCTION(_){ + static char old_in; + if (time_left_ns > 0) { + time_left_ns -= period; + } else if (old_in != in) { + time_left_ns = deadtime_ns; + old_in = in; + out = in; + out_invert = !in; + } +} diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..88d2be6 --- /dev/null +++ b/install.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +halcompile --install dsmono.comp +