a few TinyG firmware patches you may find useful

Post Reply
WayOutWest
Posts: 198
Joined: Thu Jul 16, 2015 12:18 am
Location: Washington State, USA

a few TinyG firmware patches you may find useful

Post by WayOutWest »

The G38.3 command is used to probe by moving the machine in a certain direction until a limit switch is hit (or ceases to be hit); this lets you use the z-max switch to "feel" the height of things beneath the needle or use the x/y-max switches to automatically detect the size of the machine.

This is the ONLY time that hitting a limit switch will not crash the TinyG, so it's quite useful. Note that once the switch has been hit you must "probe" away from the switch (which will move until the switch is no longer activated) -- attempting to execute any other command from such a position will (wait for it...) crash the TinyG.

The stock TinyG firmware has two problems:

1) It will refuse to allow a probe command if the A-axis is not at position "0". The first patch removes this limitation.

2) It will kill the "spindle" when you initiate a probe command. Depending on how you've wired your liteplacer this will do various things. On my machine it kills the vacuum pump, causing the Liteplacer to drop whatever part it's holding. The second patch removes this limitation, allowing you to place a component after rotating it without having to pre-program the component thickness.

I'm slowly refactoring my customized TinyG-firmware to try to pull out the parts that may be useful to others. I'll post the bits as they work their way clear of the rest of the hairball.
Attachments
do-not-kill-vacuum-when-probing.txt
(616 Bytes) Downloaded 481 times
allow-probing-with-a-axis-nonzero.txt
(689 Bytes) Downloaded 482 times
Last edited by WayOutWest on Mon Nov 30, 2015 1:12 pm, edited 1 time in total.
- Adam
WayOutWest
Posts: 198
Joined: Thu Jul 16, 2015 12:18 am
Location: Washington State, USA

Re: a few TinyG firmware patches you may find useful

Post by WayOutWest »

Since the A-axis on the liteplacer is rotational, it has no maximum or minimum limits. Therefore there are no A-MAX or A-MIN switches, and these pins should be reused.

This patch does that.

Specifically, to change the new GPIO pins, issue a tool-change command (T). The tool number you pick will be interpreted as an 8-bit integer, and the bottom two bits of this integer will be the outputs (0=gnd, 1=vdd) of the a-min (bit 0) and a-max (bit 1) pins. Example:

Code: Select all

T0      (set a-max=GND, a-min=GND)
G04 P2  (wait two seconds)
T1      (set a-max=GND, a-min=VDD)
G04 P2  (wait two seconds)
T2      (set a-max=VDD, a-min=GND)
G04 P2  (wait two seconds)
T3      (set a-max=VDD, a-min=VDD)
G04 P2  (wait two seconds)
Notes:

1. You must remember to tell TinyG to ignore the switch inputs by issuing $asx=0 and $asn=0.
2. There is a pull-up resistor hardwired to the board on these pins, so setting them to zero will burn a small amount of power.
3. Leave bits 2..7 zeroed out. I will be posting a patch that sends these bits out of the SPI pin header on the TinyG.
4. I wanted to use M06 instead of the T-command, but there is an architectural bug in the TinyG that makes this impossible; see below [*].

I use these pins to control the extra LEDs on my system: one for the upcam and one for the plancam (wide-angle camera mounted directly below the Z-motor, facing down).

[*] The T-command is simply supposed to declare the next-tool, and the M06 command "triggers" it. Unfortunately the TinyG has a major bug, which is acknowledged in the source code comments: parsing a T-command, or a T-argument to an M06, causes it to forget all previously-parsed-but-not-yet-executed T-commands or T-arguments; this means that the program above would toggle all four changes to the pins before ANY of the two-second delays. If those two second delays were actual movements, the machine would do the totally wrong thing. Fixing this bug is not worth it. So although this patch is slightly heretical (T-commands should have no effect), it's easier than re-architecting the TinyG's flow control.
Attachments
allow-use-of-amin-and-amax-pins.txt
(2.23 KiB) Downloaded 498 times
- Adam
Post Reply