Skip to content

Add v3 connector board calibration#181

Closed
peteattayek wants to merge 9 commits intoPiTracLM:mainfrom
peteattayek:Add-v3-connector-board-calibration-and-setup
Closed

Add v3 connector board calibration#181
peteattayek wants to merge 9 commits intoPiTracLM:mainfrom
peteattayek:Add-v3-connector-board-calibration-and-setup

Conversation

@peteattayek
Copy link

@peteattayek peteattayek commented Mar 19, 2026

Description

Add python script for calibration of the LED strobe for V3 connector board

What does this PR do?

This PR adds a python script to the web-server folder that finds the DAC value that corresponds to the target current of the strobe LED

Why is this change needed?

The default behavior without calibration is to send the max current through the LEDS (15+ amps)

Changes Made

  • Python calibration script added to web-server folder

Testing Performed

Test Environment

  • Pi Model: Pi 5 8GB
  • Camera Type: N/A
  • OS Version: Trixie 64bit
  • Installation Method: source
  • LED variant: 100W amazon LED array and V3 LED

Test Results

Calibration script was tested on 100W amazon LED with target current of 7A and V3 LED board with target current of 10A. The output current was verified with an oscilloscope.

Test Commands Run

sudo python calibrate_strobe_output

Breaking Changes

  • This PR includes breaking changes

Dependencies

  • No new dependencies
  • [ ] New dependencies added:

  • Updated dependencies:
    • GPIO libraries need to be modified:
      sudo apt install --allow-downgrades liblgpio1=0.2.2-1~rpt1+trixie python3-lgpio python3-rpi-lgpio python3-gpiozero

Hardware Compatibility

  • Tested on Pi 5
  • Tested on Pi 4
  • Tested with single Pi setup
  • Tested with dual Pi setup

Documentation

  • No documentation needed
  • Documentation updated in this PR
  • Documentation PR to follow
  • Updated relevant sections:
    • README
    • Hardware guide
    • Software guide
    • Troubleshooting guide

AI (Vibe-Coded) Content Description

None of this code was AI generated

Checklist

Code Quality

  • Code follows existing patterns and conventions
  • No unnecessary comments added
  • Error handling implemented appropriately

Build & Test

  • Successfully builds with ./packaging/build.sh build
  • All existing tests pass
  • New tests added for new functionality
  • [ ]x] Tested on actual Raspberry Pi hardware (not just CI)

Submission Requirements

  • Commits squashed if needed (git rebase -i HEAD~n)
  • CLA signed
  • PR title follows format: [PR TYPE] Brief description
  • Branch is up-to-date with main

Additional Context

  • This script is required to run with sudo to get optimal performance
  • Must have the correct gpio dependencies: sudo apt install --allow-downgrades liblgpio1=0.2.2-1~rpt1+trixie python3-lgpio python3-rpi-lgpio python3-gpiozero
  • V3 connector board will not currently work with PiTrac: The strobe pin must be changed in a future PR

@github-actions
Copy link
Contributor

github-actions bot commented Mar 19, 2026

All contributors have signed the CLA. Thanks!
Posted by the CLA Assistant Lite bot.

@peteattayek
Copy link
Author

I have read the CLA Document and I hereby sign the CLA

@connorgallopo
Copy link
Collaborator

To match our current standards this should be converted to a ux/ui based utility before it can be merged.

@connorgallopo
Copy link
Collaborator

Also dependencies need to be managed properly - we do not manually install deps anywhere else in the repo and have put lots of effort in to get away from that.

@jamespilgrim
Copy link
Collaborator

Yeah, I had envisioned this working and being positioned similarly to the camera calibration utilities. Except, the hardware calibration tool will likely only be called once. Though you could still call it through the UI.

The idea is that when you install Pitrac, the build script will automatically call the calibration tool. (or if you try to run Pitrac with a version three board before it's been calibrated and the settings are placed in the user_settings json file, PiTrac will error out.

Agreed on the deps. I forgot we had worked with that as a workaround, and didn't expect it in the PR. The best fix is to get me to rebuild and package the 2.2.3 version of the liblgpio1 library and get Conor's help getting it positioned correctly in pour PiTrac deps area on GitHub.

@connorgallopo
Copy link
Collaborator

connorgallopo commented Mar 19, 2026

The idea is that when you install Pitrac, the build script will automatically call the calibration tool. (or if you try to run Pitrac with a version three board before it's been calibrated and the settings are placed in the user_settings json file, PiTrac will error out.

My biggest issue with that is a lot of folks get the Pi first. And will image it and be able to play in the UI and use the testing tools to check integrations and such. Or - first boot or install will happen on a bench and not with the assembled pitrac hardware.

People don't read the docs generally - so if things have an option to not be 100% reliant on order and can be done independently through the UI i think it will provide the best possible experience. Especially if we want to capture the less technical golf community

@peteattayek
Copy link
Author

I definitely installed PiTrac on my Pi before connecting everything, so people do that

The calibration would also need to be re-run any time the LED is swapped (not sure how often this will happen).

There is also a non-zero chance that the calibration will change with temperature, so there may be a slightly different calibration value on a "cold" LM vs a "warm" one. So it's possible we may want to run the calibration periodically and not just once at setup.

@peteattayek peteattayek marked this pull request as draft March 20, 2026 00:24
@peteattayek
Copy link
Author

Changing this to a draft to swap spi_0 and spi_1, this will keep the current MOSI pin for strobing

Copy link
Collaborator

@jamespilgrim jamespilgrim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Yeah, let's try to get the package updated in the repo. Working on that now... :)

@jamespilgrim
Copy link
Collaborator

And for posterity, here's the error we were getting when trying to use the newer python GPIO functions:

Unsatisfied dependencies:
 python3-lgpio : Depends: liblgpio1 (= 0.2.2-1~rpt1+trixie) but 0.2.2-1~trixie1 is to be installed
Error: Unable to correct problems, you have held broken packages.
Error: The following information from --solver 3.0 may provide additional context:
   Unable to satisfy dependencies. Reached two conflicting decisions:
   1. liblgpio1:arm64=0.2.2-1~rpt1+trixie is not selected for install
   2. liblgpio1:arm64=0.2.2-1~rpt1+trixie is selected as a downgrade because:
      1. python3-rpi-lgpio:arm64=0.6-0~rpt1+trixie is selected for install
      2. python3-rpi-lgpio:arm64 Depends python3-lgpio
      3. python3-lgpio:arm64 Depends liblgpio1 (= 0.2.2-1~rpt1+trixie)

Which is why this worked as a quick fix:

sudo apt install --allow-downgrades liblgpio1=0.2.2-1~rpt1+trixie python3-lgpio python3-rpi-lgpio python3-gpiozero

@peteattayek peteattayek force-pushed the Add-v3-connector-board-calibration-and-setup branch from 7abd454 to 7399165 Compare March 20, 2026 15:02
@peteattayek peteattayek marked this pull request as ready for review March 21, 2026 01:06
@peteattayek
Copy link
Author

Updated calibration script to use spi1 for the ADC and DAC. Updated wiring diagram and documentation. Added dtoverlay=spi1-2cs to configure-cameras.sh to enable spi1

Ready for review now

@connorgallopo
Copy link
Collaborator

Updated calibration script to use spi1 for the ADC and DAC. Updated wiring diagram and documentation. Added dtoverlay=spi1-2cs to configure-cameras.sh to enable spi1

Ready for review now

This should be put on hold until it's in the UI. Command line scripts took a lot of work to remove so adding them back is not the direction we want to go.

I can rewrite into ui if needed

@peteattayek
Copy link
Author

Updated calibration script to use spi1 for the ADC and DAC. Updated wiring diagram and documentation. Added dtoverlay=spi1-2cs to configure-cameras.sh to enable spi1
Ready for review now

This should be put on hold until it's in the UI. Command line scripts took a lot of work to remove so adding them back is not the direction we want to go.

I can rewrite into ui if needed

Do you mean adding a button to the UI to call the calibration script or re-writing it in another language? I think @jamespilgrim is working on the former but I know he'll be out for a while traveling.

@connorgallopo can you take a quick look at the changes I made to build.sh and configure_cameras.sh to see if you would implement those changes differently? I don't know anything about the packaging/build

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed 1-2 rpi and replaced with just 1 rpi

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New wiring guide for rpi5, cameras, v3 connector board, and V3 strobe led.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be copied or moved to the enclosure build documentation, but that documentation needs a significant re-write with current build info!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 changes to this file:

  1. if cameras are not found, it no longer skips the entire configuration, just the camera configuration. Other non-camera changes to config.txt are still made even if the cameras aren't found.
  2. add dtoverlay=spi1-2cs to config.txt to enable spi1 with 2 chip selects. This will be used for communicating with the DAC and ADC.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added new python runtime depencies. @connorgallopo is this the right place to add them or will these be tracked elsewhere?

@connorgallopo
Copy link
Collaborator

Do you mean adding a button to the UI to call the calibration script or re-writing it in another language?

No - I mean following the patterns used by the entire web ui python application you are adding this to. I will open a PR with the changes, the python code is not something that should be merged in its current state as it has a lot of issues.

The change to configure cameras is fine - but the build script is incorrect as that is not how python dependencies are managed

@peteattayek
Copy link
Author

Do you mean adding a button to the UI to call the calibration script or re-writing it in another language?

No - I mean following the patterns used by the entire web ui python application you are adding this to. I will open a PR with the changes, the python code is not something that should be merged in its current state as it has a lot of issues.
I just built off the script James gave me. I don't think it was originally intended to live here, but do whatever you want to at as long as it retains it's functionality

The change to configure cameras is fine - but the build script is incorrect as that is not how python dependencies are managed
Ok, I just saw other python dependencies on that line so added the new ones. Should the ones that were already there be managed a different way?

@connorgallopo
Copy link
Collaborator

I just built off the script James gave me. I don't think it was originally intended to live here, but do whatever you want to at as long as it retains it's functionality

Totally hear you - not trying to nitpick. The script proves it out well - but its just not production ready yet. Ill try to have something by end of day. It's beefy. Trying to write tests to make sure I don't break anything.

Ok, I just saw other python dependencies on that line so added the new ones. Should the ones that were already there be managed a different way?

So looking at it I think 1 or 2 might stay as apt deps (just higher up as the CLI stuff is not the web-app), and then whatever doesnt need apt will be moved to requirements.txt as it will have access the web-servers dependency chain

@connorgallopo
Copy link
Collaborator

This can be closed - i used this as the head of a new branch. all your commit are still there, just with mine after
#186

This should also be tested and verified because i do not currently have my pitrac setup - nor was i involved in this dev effort originally.

@peteattayek
Copy link
Author

Closing PR with commits integrated into #186

@github-actions github-actions bot locked and limited conversation to collaborators Mar 22, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants