• Stars
    star
    114
  • Rank 308,031 (Top 7 %)
  • Language
    C++
  • License
    GNU General Publi...
  • Created almost 11 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

G-code interpreter and stepmotor controller for crazy fast coordinated moves of up to 8 steppers. Uses the Programmable Realtime Unit (PRU) of the Beaglebone.

BeagleG

License: GPL v3 Β  Ubuntu Build

Step-motor controller for CNC-like devices (or 3D printers) using the PRU (Programmable Realtime Unit) of the Beaglebone Black to create precisely timed and fast stepper-pulses for acceleration and travel. (And with fast, we're talking up to 1Mhz fast. For 8 motors in parallel. In a controlled move (G1). So this is not a limit in real-world applications).

Works with a cape designed by the author (the BUMPS cape), but also provides relatively easy adaption to new hardware (currently: support for CRAMPS). See hardware subdirectory.

This was one of my very early tests: First Test

The {accl-,decel-}eration and travel motion profile is entirely created within the PRU from parameters sent by the host CPU decoupled via a ring-buffer. The BeagleBone main CPU prepares the data, such as parsing the G-Code and doing travel planning, while all the real-time critical parts are done in the PRU. The host CPU typically needs less than 1% CPU-time doing everything else (and there is no need for a real-time kernel).

The main machine-control program is parsing G-Code, extracting axes moves and enqueues them to the realtime unit. It can receive G-Code from a file or socket (you can just telnet to it for an interactive session, how cool is that?).

Install

For detailed system configuration and building the machine-control binary, see INSTALL.md.

Before you can use beagleg and get meaningful outputs on the GPIO pins, two things are required on a fresh Beaglebone installation (we recommend the IoT image).

Enable PRU

To enable the PRU the way we use it, we need to /boot/uEnv.txt and enable the correct uboot_overlay_pru line.

We need to disable the line containing PRU-RPROC (add a # in front) and enable the line containing the PRU-UIO (remove # in front).

###pru_uio (4.14.x-ti, 4.19.x-ti & mainline/bone kernel)
uboot_overlay_pru=/lib/firmware/AM335X-PRU-UIO-00A0.dtbo

Reboot.

Enable Output Pins for your board

The GPIO pins used for each hardware This is how you initialize the pins if you use the BUMPS board:

/opt/source/bb.org-overlays/tools/beaglebone-universal-io/config-pin -f hardware/BUMPS/bumps.pins

See the Hardware page for more boards.

Machine control binary

To control a machine with G-Code, use the machine-control binary. This either takes a filename or a TCP port to listen on.

Usage: ./machine-control [options] [<gcode-filename>]
Options:
  -c, --config <config-file> : Configuration file. (Required)
  -p, --port <port>          : Listen on this TCP port for GCode.
  -b, --bind-addr <bind-ip>  : Bind to this IP (Default: 0.0.0.0).
  -l, --logfile <logfile>    : Logfile to use. If empty, messages go to syslog (Default: /dev/stderr).
      --param <paramfile>    : Parameter file to use.
  -d, --daemon               : Run as daemon.
      --priv <uid>[:<gid>]   : After opening GPIO: drop privileges to this (default: daemon:daemon)
      --help                 : Display this help text and exit.

Mostly for testing and debugging:
  -f <factor>                : Feedrate speed factor (Default 1.0).
  -n                         : Dryrun; don't send to motors, no GPIO or PRU needed (Default: off).
  -P                         : Verbose: Show some more debug output (Default: off).
  -S                         : Synchronous: don't queue (Default: off).
      --allow-m111           : Allow changing the debug level with M111 (Default: off).

Segment acceleration tuning:
     --threshold-angle       : Specifies the threshold angle used for segment acceleration (Default: 10 degrees).
     --speed-tune-angle      : Specifies the angle used for proportional speed-tuning. (Default: 60 degrees)

                               The --threshold-angle + --speed-tune-angle must be less than 90 degrees.

Configuration file overrides:
     --homing-required       : Require homing before any moves (require-homing = yes).
     --nohoming-required     : (Opposite of above^): Don't require homing before any moves (require-homing = no).
     --norange-check         : Disable machine limit checks. (range-check = no).

The axis configurations (max feedrate, acceleration, travel, motor mapping,...) is configured in a configuration file like in this example.

The G-Code understands logical axes X, Y, Z, E, A, B, C, U, V, and W.

More details about the G-Code code parsed and handled can be found in the G-Code documentation.

Examples

For testing your motor settings, you might initially just have a simple file:

sudo ./machine-control -c hardware/BUMPS/bumps.config -f 10 myfile.gcode

Output the file myfile.gcode in 10x the original speed (say you want to stress-test). Note, the factor will only scale feedrate, but the machine will always obey the machine constraints with maximum feed and acceleration given in the configuration file.

echo "G1 X100 F10000 G1 X0 F1000" | sudo ./machine-control /dev/stdin

This command directly executes some GCode coming from stdin. This is in particular useful when you're calibrating your machine and need to work on little tweaks.

sudo ./machine-control -c my.config --port 4444

Listen on TCP port 4444 for incoming connections and execute G-Codes over this line. So you could use telnet beaglebone-hostname 4444 to have an interactive session or send a file simple via socat from a remote machine:

 cat myfile.gcode | socat -t5 - TCP4:beaglebone-hostname:4444

Use socat, don't use the ancient nc (netcat) - its buffering seems to be broken so that it can get stuck. With socat, it should be possible to connect to a pseudo-terminal in case your printer-software only talks to a terminal (haven't tried that yet, please let me know if it works).

Note, there can only be one open TCP connection at any given time (after all, there is only one physical machine).

G-Code stats binary

There is a binary gcode-print-stats to extract information from the G-Code file e.g. accurate expected print-time, Object height (=maximum Z-axis), filament length. This is in particular useful because many GCode runtime estimators are widely off; this is accurate to the second because it takes all acceleration phases into account.

Usage: ./gcode-print-stats [options] <gcode-file> [<gcode-file> ..]
Options:
        -c <config>       : Machine config
        -f <factor>       : Speedup-factor for feedrate.
        -H                : Toggle print header line
Use filename '-' for stdin.

The output is in column form, so you can use standard tools to process them. For instance, from a bunch of gcode files, find the one that takes the longest time

./gcode-print-stats -c my.config *.gcode | sort -k2 -n

Cape

The BUMPS-cape is one of the capes to use, it was developed together with BeagleG (but it is not widely distributed yet). BeagleG also works with the CRAMPS board, which is a popular motor driver cape for the BeagleBone Black. You can easily adapt your own hardware, check the hardware sub-directory.

Bumps board

Axis to Motor mapping

Each board has a number of connectors for motors and switches to which you connect your physical motors and end-switches to.

To map these connector positions to logical axes names, the machine-control binary has a configuration file in which you can configure not only the various axis parameters (max speed, acceleration, steps/mm), but also assign these axes to motor drivers provided by the cape (motor_1, motor_2,...) and end switches (switch_1, switch_2,...) to logical functions (e.g. min_x). See the annotated config file.

Visualization

BeagleG provides a tool, gcode2ps to export the machine path and speed into a color-coded image for inspection. The color coding shows the machine speed according to the configured machine constraints.

Β  Β  Β 

Development

If you want to use the nicely seprated sub-APIs of BeagleG programmatically or want to get involved in the development, check the Development page.

License

BeagleG 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 3 of the License, or (at your option) any later version.

More Repositories

1

rpi-rgb-led-matrix

Controlling up to three chains of 64x64, 32x32, 16x32 or similar RGB LED displays using Raspberry Pi GPIO
C++
3,229
star
2

timg

A terminal image and video viewer.
C++
1,889
star
3

gmrender-resurrect

Resource efficient UPnP/DLNA renderer, optimal for Raspberry Pi, CuBox or a general MediaServer. Fork of GMediaRenderer to add some features to make it usable.
C
841
star
4

txtempus

A DCF77, WWVB, JJY and MSF clock LF-band signal transmitter using the Raspberry Pi
C++
416
star
5

ldgraphy

Simple Laser Direct Lithography / Laser Direct Imaging for PCB manufacturing
PostScript
272
star
6

rpi-gpio-dma-demo

Performance writing to GPIO with CPU and DMA on the Raspberry Pi
C
196
star
7

flaschen-taschen

Noisebridge Flaschen Taschen display
C++
193
star
8

rpi-matrix-pixelpusher

PixelPusher protocol for LED matrix.
C++
160
star
9

augenmass

Measure relative sizes on background image.
JavaScript
93
star
10

upnp-display

Display state of UPnP/DNLA renderer in the network with a 16x2 LCD display (or 24x2, 40x2 ..) connected to the Raspberry Pi. Unicode support (UTF-8).
C++
69
star
11

gcode-cli

Simple command line tool to send gcode to serial 3D printer/CNC machine.
C++
39
star
12

spixels

Spixels - 16-SPI LED Raspberry Pi adapter with library (SPI - Pixels).
C++
39
star
13

rpt2pnp

Solder paste dispensing and Pick'n Placing
C++
34
star
14

stuff-org

Organize electronic components. Or other stuff.
Go
33
star
15

postscript-hacks

A collection of some useful PostScript programs.
PostScript
31
star
16

folve

Folve - seamlessly FIR convolving audio file fuse filesystem with gapless support.
C++
30
star
17

trs80-100-schematic

A transcript of the TRS80 Model 100 schematic
Nix
28
star
18

rpt2paste

Convert KiCAD rpt files to G-Code to dispense solder paste
C++
24
star
19

bumps

BeagleBone Universal Multi Pololu Steppers
KiCad Layout
21
star
20

blisplay

A tactile display for the blind.
OpenSCAD
19
star
21

pixelpusher-server

A simple library that allows to receive pixels via the PixelPusher protocol.
C++
17
star
22

otp-image

Optical One-Time Pad XOR encoding of images
C++
17
star
23

digi-spherometer

A digital spherometer, reading data from digital dial indicator and converting it to radius, displaying on OLED display.
C++
14
star
24

RedPitaya-Case

A case for the Red Pitaya scope/function generator
OpenSCAD
12
star
25

joystick-gcode-jog

Jogging a machine such as a 3D printer or CNC machine with a gampad. Mostly proof of concept.
C
12
star
26

gds2vec

A simple program to convert gdsII files to vector output formats. Currently used to create laser-cut models of standard cells.
C++
12
star
27

openscad-things

Things made with OpenSCAD. Mostly experimental right now.
OpenSCAD
9
star
28

quadrigotion

TMC2660 Four stepper motor drivers on a stick.
Python
9
star
29

tmc2660-breakout

Little breakout board to play with the TMC2660 stepper driver
Python
9
star
30

precise-pitch

Instrument tuner app. Mostly my playground to learn Android development.
Java
8
star
31

symbiflow-simple-sample

Using Symbiflow arch defs to get BASYS3 board entertained with logic
Makefile
8
star
32

bant

Bazel/Build Analysis and Navigation Tool
C++
8
star
33

bare-lsp

A language server protocol implementation
C++
6
star
34

jcxxgen

A schema compiler generating c++ structs with boilerplate to be serialized easily with nlohmann/json
C++
6
star
35

spixels-pixelpusher

A PixelPusher implementation using the Spixels hardware to control LED strips.
C++
6
star
36

bdfont.data

Generate C-structs from BDF fonts to be compiled into embedded programs.
C++
5
star
37

sound-cam

Simulation of using Microphones to pick up sound locations.
C++
5
star
38

pi-registerplex

GPIO multiplexer for Raspberry Pi
Python
3
star
39

makerspace-tag

Simple app keeping track of makerspace users and their capabilities
Go
3
star
40

ziplain

A plain, no-frills ZIP file writer.
C++
3
star
41

hot-snipper

A Hot-Knife cutting machine
OpenSCAD
3
star
42

simple-fasm

A simple parser for the FPGA Assembly format
C++
3
star
43

DerKnopf

Simple IR remote control of a volume knob
KiCad Layout
3
star
44

eda-tools

Small useful tools I use while doing stuff with electronics.
3
star
45

pitch-hero

C++
2
star
46

simple-spherometer

A simple analog spherometer made from simple hardware-store materials, laser cut acrylic and 3D printed parts.
PostScript
2
star
47

air-filter-box

Quad AirFilter using standard box-fan and standard aircon/furnace filters
OpenSCAD
2
star
48

microorb

A USB controlled 2.5W RGB LED
C++
2
star
49

FlaschenTaschen-PixelPusher-bridge

Receives FlaschenTaschen protocol and sends to a PixelPusher installation.
C++
2
star
50

rp2040-nix-template

Minimal rp2040 c++ template
Makefile
2
star
51

gaggia-pid

PID controller, useful for e.g. coffee machines.
C++
1
star
52

golang-pgp-test

Experiments with the golang OpenPGP implementation.
Go
1
star
53

cogsworth-viz

Visualization of data generated from Project-COGSWORTH
C
1
star
54

sneeze-guard

Sneeze-guard on working tables for reduced Viral spread.
G-code
1
star
55

flaschen-taschen-avr

Quick hack to make first FlaschenTaschen crates work.
C++
1
star
56

bidi-tee

A bidrectional `tee` program that passes through stdin/stdout/stderr and copies them colored coded to a file
C++
1
star
57

ear-saver

A laser-cuttable ear-saver for face masks.
OpenSCAD
1
star
58

threadless-server

select() event API experiment with c++11 closures.
C++
1
star
59

gstreamer-gapless-test

Sample source code to demonstrate a gstreamer issue.
C
1
star
60

din-rail-clip-mount

3D printed Din-Rail mount for PCB and other components
OpenSCAD
1
star
61

glowxels

Glow-in-the-dark canvas
C++
1
star