Skip to content

Developing Smart Heads

Simone C edited this page Mar 7, 2017 · 4 revisions

Head Development Kit

Developing Smart Heads

Caveat: the information contained here refers to features under development. The exposed g-code usage and the features themselves may vary widely from one commit to another.

Introduction

With new versions of FABlin, and possibily with the aid of the Head Development Board, you can easily develop custom toolheads for the FABtotum Personal Fabricator that can accept input and give feedback from and to the user in the form of simple lines of text, similarily to how g-code is handled for the usual machine's operations. We call these kind of heads Smart Heads, in contrast to normal heads (...dumb heads?), in which the equipment inside the head is directly controlled with dedicated lines from the FABlin or other firmware running on the FABtotum's controller board.

Newer versions of FABlin make a bunch of new g-codes available to the user to flexibly set-up and use communication functions with smart heads.

General advice

When developing a custom head it is best to set a head ID different from those of the factory ones. You can use any value equal or greater than 100. You can do this by entering the following command inside the MDI frame of FAB-UI's Jog page:

M793 S100

This is helpful in that it can disable some default and hardcoded behaviours that are going to be configured manually for the custom head.

Tool definition

First and foremost, developing a smart head requires enabling serial communication between TOTUMduino and the head.

Newer and upcoming versions of FABlin are going to support the ability to define different tool configurations and switch them on the fly with a few commands. A particular configuration can then be recalled with the T command.

At present this feature can be used to enable or disable serial communication for the installed head.

Tools are numbered starting from 0, which is the default at the machine's startup. Supposing you want to use the default tool, to enable serial communication for it you can enter the following command:

M563 P0 S1

You can make sure that tool configuration #0 is active by issuing a

T0

(When modifying the currently active tool's configuration, the new settings are automatically applied, upon successful execution of the M563 command.)

Serial communication

To ease communication with new peripherals and toolheads, the development version of FABlin make available multiple communication interfaces, and supports configuring of communication parameters at run-time. You can fiddle with this parameters while developing a custom head without the need to hack through FABlin's source code, recompile, or reflash it.

Internal interfaces

Interface numbers 0 to 3 are reserved for TOTUMduino onboard hardware serial interfaces, 0 being the main serial interface through which TOTUMduino and the system board (Raspberry Pi) exchange data. At present this interface has a hard-wired configuration and cannot be changed by the user.

Head interface

Interface 4 is reserved for the carriage-mounted head. At present it is implemented as a serial channel for which the user can configure receiving and transmitting pins, and baudrate. These values can be set on the fly even when the interface is already active, in which case it will be reinitialized.

Interface 4 can use the following pins on the TOTUMduino as transmitting and receiving pins (shown with their HDB names):

  • Receiving: 11 (SERVO PWM), 67 (THERM +)

  • Transmitting: 11, 20 (I2C SDA), 21 (I2C SCL), 67

You can se how these pins are mapped on the Head Development Board in the HDB Cheatsheet. In general, you'll get the best performance using the couples 11/20 or 11/21.

Recognized baudrates for the interface are:

300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 31250, 38400, 57600

however, you'll get the best result with values comprised between 9600 and 38400. Moreover, due to the particular implementation of this serial interface, the higher the baudrate the better, beacuse in that way you'll minimize delays in firmware execution during receiving or transmitting. Again, refer to the cheatsheet and keep it at hand when experimenting with smart heads.

Communicating with the head

When all is set you can send lines of text to the head, where your listening firmware will possibly parse and take action accordingly. The head firmware, in turn, can respond with some output which will be reported back to the user inside FABlin's output.

Text can be sent one line at a time with a dedicated g-code command you can intermix freely with other commands sent to the machine. Alternatively, with a variant of the same command, you can enable a text forwarding mode, by which normal FABlin parsing of input is bypassed altogether and everything you enter is transmitted as-is to the smart head, again, on a line-wise base.

If you choose the first option, you want to send the characters my_cmd to the head, you'll enter the following command:

M790 P4 "my_cmd"

If you want to enable text-forwarding mode, you just specify the interface number with no text after it, e.g.: M790 P4. To exit text-forwarding, a line containing only a dot must be present in the input (sounds too much like SMTP...?). Namely:

M790 P4
first line sent
second line sent
next line will stop forwarding
.

A complete reference for this and the other commands involved in development and use of smart heads are given in the other sections of the wiki.

Happy hacking!

Clone this wiki locally