From: Joseph Coffland Date: Wed, 14 Nov 2018 11:18:53 +0000 (-0800) Subject: Added dev docs X-Git-Url: https://git.buildbotics.com/?a=commitdiff_plain;h=1e2dbd6e83cfa3e72415b47f4c4b0c93715d4dcc;p=bbctrl-firmware Added dev docs --- diff --git a/README.md b/README.md index cd3fad8..226e882 100644 --- a/README.md +++ b/README.md @@ -1,149 +1,60 @@ -# Buildbotics Machine Controller Setup +# Buildbotics CNC Controller Firmware +This repository contains the source code for the Buildbotics CNC Controller. +See [buildbotics.com](https://buildbotics.com/) for more information. -These instructions are for a Debian *testing* development system targeting the RaspberryPi. +## Overview +![Buildbotics architecture overview](docs/buildbotics_architecture_overview.png) -## Download & install the base RPi system +The main parts of the Buildbotics CNC Controller software and the technologies +they are built with are as follows: -``` -https://downloads.raspberrypi.org/raspbian/images/raspbian-2015-09-28/2015-09-24-raspbian-jessie.zip -unzip 2015-09-24-raspbian-jessie.zip -``` + * Web App - Frontend user interface + * [Javascript](https://www.w3schools.com/js/) + * [HTML5](https://www.w3schools.com/html/) + * [Stylus](http://stylus-lang.com/) + * [Pug.js](https://pugjs.org/) + * [Vue.js](https://vuejs.org/) -or + * Controller OS - RaspberryPi Operating System + * [Raspbian](https://www.raspbian.org/) -``` -wget https://downloads.raspberrypi.org/raspbian/images/raspbian-2015-05-07/2015-05-05-raspbian-wheezy.zip -unzip 2015-05-05-raspbian-wheezy.zip -``` + * BBCtrl - Python App + * [Python 3](https://www.python.org/) + * [Tornado Web](https://www.tornadoweb.org/) -Now copy the base system to an SD card. You need a card with at least 4GiB. After installing the RPi system all data on the SD card will be lost. So make sure you back up the SD card if there's anything important on it -In the command below, make sure you have the correct device or you can **destroy your Linux system** by overwriting the disk. One way to do this is to run ``sudo tail -f /var/log/syslog`` before inserting the SD card. After inserting the card look for log messages containing ``/dev/sdx`` where ``x`` is a letter. This should be the device name of the SD card. Hit ``CTRL-C`` to stop following the system log. + * GPlan - Path Planner Python Module + * [C++](http://www.cplusplus.com/) + * [CAMotics](https://camotics.org/) -``` -sudo dd bs=4M if=2015-05-05-raspbian-wheezy.img of=/dev/sde -sudo sync -``` + * Main AVR Firmware + Bootloader - Real-time step generation, etc. + * [ATxmega192a3u](https://www.microchip.com/wwwproducts/ATxmega192A3U) + * [C](https://en.wikipedia.org/wiki/C_(programming_language)) -The first command takes awhile and does not produce any output until it's done. + * Pwr AVR Firmware - Power safety + * [ATtiny1634](https://www.microchip.com/wwwproducts/ATtiny1634) + * [C](https://en.wikipedia.org/wiki/C_(programming_language)) -Insert the SD card into your RPi and power it on. Plug in the network connection, wired or wireless. +## Quickstart Guide -## Login to the RPi +Be sure to read the [development guide](docs/development.md) for more detailed +instructions. -[Determine the IP address of your RPi](https://www.raspberrypi.org/documentation/troubleshooting/hardware/networking/ip-address.md). +On a Debian Linux (9.6.0 stable) system: -Login: + # Install the required packages + sudo apt-get update + sudo apt-get install -y build-essential git wget binfmt-support qemu \ + parted gcc-avr avr-libc avrdude pylint3 python3 python3-tornado curl \ + unzip python3-setuptools + curl -sL https://deb.nodesource.com/setup_11.x | sudo -E bash - + sudo apt-get install -y nodejs -``` -ssh pi@ -``` + # Get the source + git clone https://github.com/buildbotics/bbctrl-firmware -Substitute ```` with the correct IP address. The default password is ``raspberry``. You should see a prompt like this: ``pi@raspberrypi ~ $``, but in color. + # Build the Firmware + cd bbctrl-firmware + make pkg -## Configure the RPi -Copy the ``scripts/setup_rpi.sh`` script to the RPi and run it as root: - -``` -scp scripts/setup_rpi.sh pi@: -ssh pi@ sudo ./setup_rpi.sh -``` - -This will take some time and will end by rebooting the RPi. After this script has run you can log in to the RPi with out typing the IP addrerss like this: - -``` -ssh bbmc@bbctrl.local -``` - -## Install the RPi toolchain -On the development system (i.e. not on the RPi): - -``` -sudo apt-get update -sudo apt-get install -y gcc-arm-linux-gnueabihf -``` - -## Compile and run a test program - -On the development system, create a file ``hello.c`` with these contents: - -``` -#include - -int main(int argc, char *argv[]) { - printf("Hello World!\n"); - return 0; -} -``` - -Compile it like this: - -``` -arm-linux-gnueabihf-gcc hello.c -o hello -``` - -Copy ``hello`` to the RPi: - -``` -scp hello pi@bbctrl.local: -``` - -Login to the system and run ``hello`` like this: - -``` -ssh bbmc@bbctrl.local -./hello -``` - -You should see the output ``Hello World!``. - -## Install the AVR toolchain -Install the following tools for programming the AVR: - -``` -sudo apt-get install -y avrdude gcc-avr -``` - -## Program Motion Controller - -``` -make program -``` - - -## Setup Python Development - - -# Huanyang Spindle Setup - -Connections: - - * pin 13 -> Rs+ - * pin 14 -> Rs- - -Program the following settings: - - * PD013 = 8 (reset to factory settings) - * PD005 = 400 (max frequency 400Hz) - * PD004 = 400 (base frequency 400Hz) - * PD003 = 400 (main frequency 400Hz) - * PD001 = 2 (set communication port as source of run commands) - * PD002 = 2 (set communication port as source of operating frequency) - * PD163 = 1 (slave address 1) - * PD164 = 1 (baud rate 9600 bps) - * PD165 = 3 (8N1 for RTU mode) - -For a 1.5KW spindle: - - * PD006 = 2.5 (intermediate frequency 2.5Hz) - * PD008 = 220 (max voltage 220V) - * PD009 = 15 (intermediate voltage 15V) - * PD010 = 8 (min voltage 8V) - * PD011 = 120 (frequency lower limit 120Hz, to limit lower RPM settings) - * PD014 = 5.0 (acceleration time, 5 seconds) - * PD015 = 0.8 (deceleration time; any more trips the VFD) - * PD025 = 1 (starting mode: frequency track) - * PD142 = 7 (max current 7 A) - * PD143 = 2 (specific to my 1.5 KW spindle: number of poles - 2) - * PD144 = 3000 (multiplied by PD010 = 3000 * 8 = 24,000 RPM) - -See manual for settings for other spindles. +The resulting package will be a ``.tar.bz2`` file in ``dist``. See the +[development guide](docs/development.md) for more information. diff --git a/docs/buildbotics_architecture_overview.png b/docs/buildbotics_architecture_overview.png new file mode 100644 index 0000000..960307d Binary files /dev/null and b/docs/buildbotics_architecture_overview.png differ diff --git a/docs/development.md b/docs/development.md new file mode 100644 index 0000000..51647dc --- /dev/null +++ b/docs/development.md @@ -0,0 +1,106 @@ +# Buildbotics CNC Controller Development Guide + +This document describes how to setup your environment for Buildbotics CNC +controller development on Debian Linux. Development on systems other than +Debian Linux are not supported. + +## Installing the Development Prerequisites + +On a Debian Linux (9.6.0 stable) system install the required packages: + + sudo apt-get update + sudo apt-get install -y build-essential git wget binfmt-support qemu \ + parted gcc-avr avr-libc avrdude pylint3 python3 python3-tornado curl \ + unzip python3-setuptools + curl -sL https://deb.nodesource.com/setup_11.x | sudo -E bash - + sudo apt-get install -y nodejs + +## Getting the Source Code + + git clone https://github.com/buildbotics/bbctrl-firmware + +## Build the Firmware + + cd bbctrl-firmware + make + +## Build GPlan Module + +GPlan is a Python module written in C++. It must be compiled for ARM so that +it can be used on the Raspberry Pi. This is accomplished using a chroot, qemu +and binfmt to create an emulated ARM build environment. This is faster and +more convenient than building on the RPi itself. All of this is automated. + + make gplan + +The first time this is run it will take quite awhile as it setups up the build +environment. You can run the above command again later to build the latest +version. + +## Build the Firmware Package + + make pkg + +The resulting package will be a ``.tar.bz2`` file in ``dist``. + +## Upload the Firmware Package to a Buildbotics CNC Controller +If you have a Buildbotics CNC controller at ``bbctrl.local``, the default +address, you can upgrade it with the new package like this: + + make update HOST=bbctrl.local PASSWORD= + +Where ```` is the controller's admin password. + +## Updating the Pwr Firmware + +The Pwr firmware must be uploaded manually using an ISP programmer. With the +programmer attached to the pwr chip ISP port on the Builbotics controller's +main board run the following: + + make -C src/pwr program + +## Initializing the main AVR firmware + +The main AVR must also be programmed manually the first time. Later it will be +automatically programmed by the RPi as part of the firmware install. To perform +the initial AVR programming connec the ISP programmer to the main AVR's ISP port +on the Buildbotics controller's main board and run the following: + + make -C src/avr init + +This will set the fuses, install the bootloader and program the firmware. + +## Installing the RaspberryPi base system + +Download the latest Buildbotics CNC controller base image and decompress it: + + wget \ + https://buildbotics.com/upload/2018-05-15-raspbian-stretch-bbctrl.img.xz + xz -d 2018-05-15-raspbian-stretch-bbctrl.img.xz + +Now copy the base system to an SD card. You need a card with at least 8GiB. +After installing the RPi system all data on the SD card will be lost. So make +sure you back up the SD card if there's anything important on it. + +In the command below, make sure you have the correct device or you can +**destroy your Linux system** by overwriting the disk. One way to do this is +to run ``sudo tail -f /var/log/syslog`` before inserting the SD card. After +inserting the card look for log messages containing ``/dev/sdx`` where ``x`` is +a letter. This should be the device name of the SD card. Hit ``CTRL-C`` to +stop following the system log. + + sudo dd bs=4M if=2015-05-05-raspbian-wheezy.img of=/dev/sde + sudo sync + +The first command takes awhile and does not produce any output until it's done. + +Insert the SD card into your RPi and power it on. Plug in the network +connection, wired or wireless. + +## Logging into the Buildbotics Controller + +You can ssh in to the Buildbotics Controller like so: + + ssh bbmc@bbctrl.local + +The default password is ``buildbotics``. It's best if you change this.