Replies: 1 comment 5 replies
-
*Hi Terje,*
*I am no expert, but **I am looking at using STM32 – Nucleo-144 Boards
which would **e**liminate the **n**umber of **a**vailable pins for a
particular project (CNC, Laser, PnP etc)*
*BUT how to allocate the Port/Pins is a problem.*
*Thus I think your **solution “**Claim the pin by port number:” **is a Good
Solution**, and would *
*open up grblHAL for any type of project without limitations.*
…On Fri, Nov 12, 2021 at 7:32 AM Terje Io ***@***.***> wrote:
I have been trying to find a solution to this conundrum and have come up
with two alternative solutions.
*Claim the pin by port number:*
The main issue is to convey which port is used for what without making it
complicated for the end user.
The aux pins gets a default label such as *Aux out 0*, this is bound to
the physical pin by a entry in the board map file.
For the M62-M66
<http://www.linuxcnc.org/docs/html/gcode/m-code.html#mcode:m62-m65>
commands the aux number (port) is the P parameter used to interact with the
pin. If a port is claimed explicitly by port number this no longer true
(unless it is the highest numbered port) leading to a "hole" in the P
parameters available. Handling that in the gcode parser is not
straightforward so I needed to come up with a better solution that avoids
generating "holes" and is backwards compatible with the current method1.
My solution is to add a new call to the hal.port struct
<http://svn.io-engineering.com/grblHAL/html/structio__port__t.html> for
claiming a port. This moves the port outside the available (for M-codes)
ports range via a simple remapping table. Since this breaks the mapping of
the P parameter to the Aux number I decided to add the P parameter value to
the $pins report. An example:
uint8_t port1 = 1, port2 = 3;
hal.port.claim(Port_Digital, Port_Output, &port2, "Claimed port3");
hal.port.claim(Port_Digital, Port_Output, &port1, "Claimed port1");
$pins output:
[PIN:PB15,Aux out 0,P0]
[PIN:PB2,Aux out 1,Claimed port1]
[PIN:PA5,Aux out 2,P1]
[PIN:PA6,Aux out 3,Claimed port3]
[PIN:PA7,Aux out 4,P2]
With proper PCB labeling this should make it clear which port/pin is used
for what, either available for M-commands and which P parameter value to
use or claimed by a plugin.
*Pin swapping:*
This just swaps the port to pin binding between two ports. If the ports
are inputs and a plugin has registered an interrupt handler for one of them
they cannot be swapped. An example:
hal.port.swap_pins(Port_Digital, Port_Output, 0, 1);
I am not sure this method is needed. The first method cover the needs?
------------------------------
It can be mentioned that there is an optional entry point in the hal.port
struct that can be used to request details about a given port. E.g. an
input port can be checked for interrupt capabilities.
------------------------------
1 The current method is simply claiming ports by assigning from and
decrementing number of available ports.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#83>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AC5DYJZOG2W5R7ZLGOKFGCDULQZALANCNFSM5H3MVIYA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have been trying to find a solution to this conundrum and have come up with two alternative solutions.
Claim the pin by port number:
The main issue is to convey which port is used for what without making it complicated for the end user.
The aux pins gets a default label such as Aux out 0, this is bound to the physical pin by a entry in the board map file.
For the M62-M66 commands the aux number (port) is the P parameter used to interact with the pin. If a port is claimed explicitly by port number this no longer true (unless it is the highest numbered port) leading to a "hole" in the P parameters available. Handling that in the gcode parser is not straightforward so I needed to come up with a better solution that avoids generating "holes" and is backwards compatible with the current method1.
My solution is to add a new call to the hal.port struct for claiming a port. This moves the port outside the available (for M-codes) ports range via a simple remapping table. Since this breaks the mapping of the P parameter to the Aux number I decided to add the P parameter value to the
$pins
report. An example:$pins output:
With proper PCB labeling this should make it clear which port/pin is used for what, either available for M-commands and which P parameter value to use or claimed by a plugin.
Pin swapping:
This just swaps the port to pin binding between two ports. If the ports are inputs and a plugin has registered an interrupt handler for one of them they cannot be swapped. An example:
hal.port.swap_pins(Port_Digital, Port_Output, 0, 1);
I am not sure this method is needed. The first method cover the needs?
It can be mentioned that there is an optional entry point in the hal.port struct that can be used to request details about a given port. E.g. an input port can be checked for interrupt capabilities.
1 The current method is simply claiming ports by assigning from and decrementing number of available ports.
Beta Was this translation helpful? Give feedback.
All reactions