{"id":18620497,"url":"https://github.com/simonsobs/sobonelib","last_synced_at":"2026-01-24T00:56:48.139Z","repository":{"id":166156609,"uuid":"641598407","full_name":"simonsobs/sobonelib","owner":"simonsobs","description":"Code running on BeagleBone Black microcontrollers","archived":false,"fork":false,"pushed_at":"2024-11-07T22:44:10.000Z","size":117,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-31T08:06:20.872Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/simonsobs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-16T20:10:13.000Z","updated_at":"2024-11-07T22:44:15.000Z","dependencies_parsed_at":"2024-02-07T14:27:21.115Z","dependency_job_id":"2638c2d9-3047-40bd-b8c6-b7c924946961","html_url":"https://github.com/simonsobs/sobonelib","commit_stats":{"total_commits":49,"total_committers":6,"mean_commits":8.166666666666666,"dds":0.7142857142857143,"last_synced_commit":"4ba3398045907f884324f867eba320efe06032a9"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonsobs%2Fsobonelib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonsobs%2Fsobonelib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonsobs%2Fsobonelib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonsobs%2Fsobonelib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simonsobs","download_url":"https://codeload.github.com/simonsobs/sobonelib/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252839678,"owners_count":21812148,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T04:06:36.412Z","updated_at":"2026-01-24T00:56:48.104Z","avatar_url":"https://github.com/simonsobs.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sobonelib\nThis repository contains code which runs on Beaglebone Black microcontrollers. This code is ment to interact with OCS agents but does not fit within the standard agent structure. Instead these pieces of code run as independent processes on the Beaglebone microcontrollers and interact with agents through UDP data packets.\n\n## Beaglebone Black Microcontrollers\n[Beaglebone Black's](https://beagleboard.org/black) are off the shelf microcontrollers with ~80 configurable pins (GPIO, PWM, PRU, etc) and an onboard linux kernal. Each Beaglebone has two so called \"Programmable Real time Units (PRUs)\" which are able to independently run compiled code on 200 MHz processors. These PRUs have access to shared memory addresses and can query/change the state of specific PRU pins. The 200 MHz clock speed is a significant improvement over similar microcontrollers (16 MHz for Arduino Microcontrollers) and improves accuracy when measuring the state of a rapidly changing signal. Unfortunately, programming with the PRU's is not well documented and requires additional steps beyond what a typical user might understand.\n\n## hwp_encoder\nBeaglebone code for the hwp_encoder agent. This code continually records rising/falling edges from two encoder signals (one primary one quadrature) and one IRIG-B timing signal. Encoder collection runs on PRU1 while IRIG-B collection runs on PRU0. Data is stored at shared memory addresses so it can be put into packets by the main processor.\n\n### Setup\n#### Network Setup\n- Connect to the beaglebone with the provided USB cable using the default credentials `ssh debian@192.168.7.2`, password: `temppwd`\n- (Optional) Create a new user using `sudo adduser [username]` and `sudo usermod -aG sudo [username]`\n- Make the IP of the beaglebone static, so that the board can be SSH-ed into over ethernet, by opening the file `/etc/network/interfaces` and make the following changes (Commented lines have been omitted):\n\nBefore\n```\nauto lo\niface lo inet loopback\n\nauto eth0\niface eth0 inet dhcp\n```\nAfter\n```\nauto lo\niface lo inet loopback\n\nauto eth0\niface eth0 inet static\n        address [user defined]\n        netmask [user defined]\n        network [user defined]\n        gateway [user defined]\n\niface usb0 inet static\n        address 192.168.7.2\n        netmask 255.255.255.252\n        network 192.168.7.0\n        gateway 192.168.7.1\n```\n- Reboot the beaglebone with `sudo reboot`. Connect the beaglebone to your network switch and varify that the beaglebone is accessible at the entered network configuration\n  \n#### PRU Config\n- In order to use the beaglebone PRUs for DAQ, uncomment the following lines in `/boot/uEnv.txt`\n  - `disable_uboot_overlay_video=1`\n  - `disable_uboot_overlay_audio=1`\n  - `uboot_overlay_pru=/lib/firmware/AM335X-PRU-UIO-00A0.dtbo`\n - Once the `/boot/uEnv.txt` file has been edited, reboot the beaglebone with `sudo reboot` to apply the changes\n\n#### External Package Installation\n- Clone the [am335x_pru_package](https://github.com/beagleboard/am335x_pru_package) repository onto the beaglebone\n- Navigate into the top level directory `cd am335x_pru_package` and then run `make` followed by `make install`\n- Navigate to `am335x_pru_package/pru_sw/app_loader/lib/` and copy the generated binaries `libprussdrv.a`, `libprussdrv.so`, `libprussdrvd.a`, and `libprussdrvd.so` into `/usr/lib/`\n\n#### Building sobonelib/hwp_encoder\n- Navigate into the hwp_encoder subdirectory `cd sobonelib/hwp_encoder`\n- Edit the `config.txt` file so that the `PORT` and `HOST_IP` match your agent setup\n  - By default `PORT` should be 8080 for encoder1 and 8081 for encoder2\n  - `HOST_IP` is the IP address of the node running the encoder OCS agent\n - With the configuration file set, run the command `make`.\n   - This will both compile the code and instantiate the systemctl services\n\n#### Checking Status\n- To check the status of the encoder process, use `systemctl status hwp-encoder-pru.service`\n- To stop/start the encoder process, use `sudo systemctl stop hwp-encoder-pru.service`/`sudo systemctl start hwp-encoder-pru.service`\n- To change the configuration parameters, simply update `config.txt` and run `make` again\n- To get more detailed logs from the process, use `journalctl -u hwp-encoder-pru.service -n 100`\n\n## hwp_gripper\nBeaglebone code for the hwp_gripper agent. This code is split into two independent processes. The first process runs on the PRU's and periodically records the state of six encoder signals (two for each actuator) and six limit switch signals (two for each actuator; one for the warm grip location and one for the cold grip location). Encoder collection runs on PRU1 while limit switch collection runs on PRU0. Data is stored at shared memory addresses so it can be put into packets by the main processor. The second process is a simple python script, which acts a server to process incomming control commands. This script accepts a socket connection from the agent and converts commands received into state changes of the Beaglebone's pins.\n\n### Setup\nThe hwp_gripper setup is largely similar to the hwp_encoder setup with a couple key differences. As a background it is assumed that you have read through and understood the hwp_encoder setup section.\n\n#### (New) Installing OS onto microSD\n- Typically the beaglebone OS is stored on an embedded MultiMediaCard (eMMC). For the hwp_gripper however, serveral I/O pins typically reserved for the eMMC are reappropriated to different tasks. This means that the OS needs to run from an external \u003e=32 GB microSD card instead\n- On a seperate computer, download the beaglebone OS from [here](https://www.beagleboard.org/distros). Filter for \"BeableBone Black\" and select a non-flasher debian image that runs on an SD card. Previous beablebones have used `AM3358 Debian 10.3 2020-04-06 4GB SD IoT`\n- Download [Etcher](https://etcher.balena.io/) onto the same computer, and use it to flash the OS onto the microSD card\n- Insert the microSD into the beaglebone's microSD slot and supply power\n- Uncomment the following lines in `/boot/uEnv.txt`\n  - `disable_uboot_overlay_emmc=1`\n  - `disable_uboot_overlay_wireless=1`\n  - `disable_uboot_overlay_adc=1`\n - Reboot the beaglebone with `sudo reboot`. The beaglebone OS should now be running from the microSD card\n\n#### Network Setup\n- Exactly the same as hwp_encoder's Network Setup\n\n#### PRU Config\n- Exactly the same as hwp_encoder's PRU Config\n\n#### External Package Installation\n- Exactly the same as hwp_encoder's External Package Installation\n\n#### Building sobonelibe/hwp_gripper\n- Navigate into the hwp_gripper subdirectory `cd sobonelib/hwp_gripper`\n- Edit the `config.txt` file so that the `PRU_PORT` and `CONTROL_PORT` match your agent setup\n  - By default `PRU_PORT` should be 8040 and `CONTROL_PORT` should be 8041\n- With the configuration file set, run the command `make`.\n   - This will both compile the code and instantiate the systemctl services\n\n#### Checking Status\n- To check the status of the gripper processes, use `systemctl status hwp-gripper-pru.service` and `systemctl status hwp-gripper-control.service`\n- To stop/start the gripper processes, use `sudo systemctl stop hwp-gripper-pru.service`/`sudo systemctl start hwp-gripper-pru.service` and `sudo systemctl stop hwp-gripper-control.service`/`sudo systemctl start hwp-gripper-control.service`\n- To change the configuration parameters, simply update `config.txt` and run `make` again\n- To get more detailed logs from the processes, use `journalctl -u hwp-gripper-pru.service -n 100` and `journalctl -u hwp-gripper-control.service -n 100`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonsobs%2Fsobonelib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimonsobs%2Fsobonelib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonsobs%2Fsobonelib/lists"}