The Vibra-trickler 2 is an affordable DIY auto-trickler with a mobile/web GUI for handloaders. This is achieved by...
- weighing gunpowder with a load cell
- converting the weight to numbers using HX711,
- setting up a Raspberry Pi (Zero) to
- read weight input,
- handle logic and web GUI with Node-Red,
- control output power with GPIO PWM, thus
- trickling gunpowder at varying speed with a vibrator motor.
This project is an improvement on my old Vibra-trickler 1 project. It's main feature was turning any balance scale into an auto-trickler. It's main drawbacks were
- having to trickle slooowly due to physical latency of the scale,
- a lot of job hours and fiddling to reproduce the kit.
As far as my personal interest goes, the project is "done". All the drawings, circuits, mobile web app and software works fine. But the time gained is only about 5s compared to my old Vibra-trickler 1. Hence, I wont't spend more time polishing or packaging the design further.
I thought I was the only person foolish enough to combine gunpowder and electronics. Now you have read this far, so I hope you know what you are doing. Use everything described below is at your own risk. Proceed with caution!
- a known weight
- powder hopper, preferrably with baffle for consistant flow
- RPi
- HX711
- load cell - the smaller the range, the more accurate!
- Power supply. About 10...24V, so 12V should be easily scavenged.
- 78L05 or similar 5V linear voltage regulator
- LM2596 or similar high current voltage regulator
- Small DC vibrator motor
- Solderless breadboard or Breadboard pattern PCB
- 2 x 100mA PTC fuse (for convenience)
- 350...500mA glass fuse or similar + holder (for lowest voltage drop)
- BC547C
- Any 1NXXXX diode
- 220uF capacitor
- 100nF capacitor
- 2,2kohm resistor
- Optional: push button for RPi safe off/on
Below, i will
- describe the steps to build and configure a vibra-trickler 2.
- use
192.168.0.66
as the IP address of the RPi. Your's will differ, so replace with your own RPi IP accordingly. - use pin numbers 1...40 when describing physical GPIO pins.
Note that...
- the HX711 needs a separate high precision voltage regulator, hence a 78L05 or similar.
- the RPi and vibrator draws more current, hence an LM2596 regulator or similar.
- the load cell and 78L05 should be close to the HX711, preferably like this
More nerding about hardware design considerations later. For now 'just'...
- Mount vibrator motor on the powder hopper's feeding tube.
- Connect power supply and LM2596 regulator on a breadboard > Adjust the regulated voltage to 5,1V > Disconnect power supply.
- Connect all other components according to the circuit design below.
Vibra-trickler uses Raspberry Pi Lite - i.e. SSH/CLI only. It might work on desktop Linux flavours as well, but no Linux GUI is needed. (We will install Node-Red with it's web-GUI later.)
- On a PC, use Raspberry Pi Imager to
- configure user
pi
and set a password, - set Wifi connection to your home network,
- enable SSH and
- write Raspberry OS Lite on an SD card
- configure user
- Insert SD card in RPi.
- Start up the RPi (breadboard power supply).
- Find the RPi's IP adress on a monitor or in your home DHCP server. My RPi IP addres was
192.168.0.66
. Replace with your own accordingly in the rest of this document. ssh pi@192.168.0.66
You should now be logged in to your RPi. The commands below are for the RPi SSH console.sudo apt-get update
Update APTsudo apt-get upgrade
Upgrade Linuxsudo raspi-config
> System > Network at boot > No Speeds up boot by not waiting for network.
WiringPi is used for controlling GPIO pins, e.g. HX711 input from load cell and PWM output to vibrator. More info at http://wiringpi.com/.
wget https://project-downloads.drogon.net/wiringpi-latest.deb
sudo dpkg -i wiringpi-latest.deb
gpio -v
Should show version 2.52 or later.
This is not required, but you might go crazy without it. It's also a sanity check for WiringPi. Shorting pin 5 to GND is the default start-trigger for RPi. Let's make it STOP the RPi as well...
- Connect pin 5 --> standard (n/o) push-button --> GND. See circuit design.
sudo nano /usr/local/bin/safeshutdown.sh
> Insert the script block below > Save and exit Nano (Ctrl X > Y > Enter)#!/bin/bash gpio -g mode 3 up #Pull-up pin 5 (GPIO #3) to 1 gpio -g wfi 3 falling #Wait For falling to 0 sudo poweroff
sudo chmod a+x /usr/local/bin/safeshutdown.sh
Make it executable.sudo nano /etc/rc.local
> Insert/usr/local/bin/safeshutdown.sh &
just above the line "exit 0" > Save and exit Nano. This will start safeshutdown.sh in the background, after rebootsudo reboot
- Test shutdown by pressing the button once. Wait until the green LED is completely off.
- Start the RPi again by pressing the button once more. Wait until the green LED is completely on.
Pin 12 corresponds to gpio #18, which supports PWM (Pulse Width Modification) of output. The 2k2 resistor restricts the output current to a GPIO-safe level (3,3V / 2200ohm = 1,5mA). The BC547C transistor amplifies it to 630mA (1,5mA x 420hfe = 630mA) - over six times the vibrator current draw. The 220uF capacitor smooths out PWM spikes. The diode shorts out any flyback current TO the RPi from the vibrator motor. Now let's figure out the max and min PWM levels.
- Connect a volt meter over the vibrator motor.
- Get specified max voltage from data sheet of virator motor.
gpio -g mode 18 pwm
Set pin 12 to PWM mode.gpio -g pwm 18 512 && sleep 1 && gpio -g pwm 18 0
Run for one second at 50% duty cycle.- Adjust the
512
part of the command down and repeat it until the motor no longer vibrates. Then up a bit until it starts again. This is your minimum PWM duty cycle. - Adjust the
512
part of the command up and repeat it until the volt meter hits vibrator max voltage. This is your maximum PWM duty cycle.
- Adjust the
For reference, min and max duty cycle for my kit is
- min:
gpio -g pwm 18 200
--> 1,1V --> Powder flow 1,5gr/s. - max:
gpio -g pwm 18 800
--> 3,8V --> Powder flow 8,5gr/s.
The HX711 excites the load cell's Wheatstone bridge with 5V and measures it's output voltage. The voltage is converted to numbers and sent to RPi pin 29, using pin 31 for clock/trigger. The HX711 library from Gandalf15 is used to receive the readings in RPi. .\scripts\hx-start.py
will be used
sudo apt-get install git -y
Install Gitpip3 install 'git+https://github.com/gandalf15/HX711.git#egg=HX711&subdirectory=HX711_Python3'
Pip-install from Gandalf15's Git- First, try some readings from the HX711 manually:
python3
to open a Python console. In it, run these commands:import RPi.GPIO as gpio gpio.setmode(gpio.BOARD) #Use physical pin numbers from hx711 import HX711 hx = HX711(dout_pin=29, pd_sck_pin=31) hx.reset() #This, and some other commands, returns FALSE if successful hx._read() #Get one raw reading hx.get_data_mean(5) #Get average from 5 readings gpio.cleanup() #Reset GPIO pins
- Press
Ctrl C
to exit the Python console.
- Make sure you are in the home directory i.e. default path for Node-RED:
cd ~/
- Download python script from GitHub to get continuous HX711 readings:
curl -O https://raw.githubusercontent.com/Arve2/Vibra-trickler-2/main/scripts/hx-start.py
This will be used below, and also by Node-RED later. - Run the script:
python3 hx-start.py
This should produce a continous flow of readings. - Note the values and approximate a rough median (in my case 1278000). This will be your start payload for Node-RED deviation filter later.
- Place some weight on the scale. The readings should increase following the weight. If the readings decrease: Reverse the load cell by switching A+/A- terminals, or simply turn it upside down.
- Press
Ctrl C
to exit the Python console.
Node-RED is a great graphic automation tool in Node-JS server. It's Dashboard makes for a stylish mobile web GUI. The steps below are based on this guide for Node-RED on RPi, including some tweaks.
- Download and install:
curl https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered --output noderedinstaller.sh bash noderedinstaller.sh --confirm-pi --allow-low-ports --confirm-install
- Be patient. Especially over SSH - connection might drop while install is actually going just fine.
- Answer No to "customize settings now".
- Start Node-RED manually first time to try it:
node-red-pi --max-old-space-size=256
- On PC, browse to http://192.168.0.66:1880. You should now see the Node-red flow editor. This is the "admin" part.
- Stop Node-RED with
Ctrl C
- Use Nano to tweak the settings a bit:
nano ~/.node-red/settings.js
> Change/set the following properties...flowFilePretty: true
Good for export/editing.uiPort: process.env.PORT || 80
Use default HTTP port.httpAdminRoot: '/admin'
More intuitive, since the frontend isui
by defaultdebugUseColors: true
Helpful for troubleshooting.
- Save and exit Nano (Ctrl X > Y > Enter)
- Autostart Node-red on boot:
sudo systemctl enable nodered.service
Note:max-old-space-size=256
seems to be default for nodered.service, at least after usin noderedinstaller.sh as above. - Reboot RPi using fancy button or
sudo reboot
- You should now be able to browse from PC to the Node-RED admin GUI at http://192.168.0.66/admin
Now that Node-RED is installed, it will be used to handle the flow of HX711 input, filtering, logics, PWM output and web GUI. In the admin GUI...
- Click the pancake-stack at the top right >
Import
>Select a file to import
> Browse to.\flows.json
>Import
> Finnish import process. You should now see a flow like this: - Double-click the node
Reset variables
. AfterSet / msg.payload / to the value
> Replace the default (127800) to the start payload noted earlier > ClickDone
. Two nodes down the flow, large deviations from this value will be blocked, so it needs to be adjusted to each indivitual kit. - Double-click the node
Weight in. PWM out
and...- At line 24 replace the payload
650
with your PWM max duty cycle noted earlier - max speed. - At line 34 replace the payload
325
with your PWM min duty cycle noted earlier, or a bit higher - slow and intermittant speed.
- At line 24 replace the payload
- Click
Deploy
at the top right to deploy the imported flow to the server.
- Fill the powder hopper. I suggest chia- or poppy-seeds or alike - NOT gunpowder this first try.
- Browse to the Node-RED GUI at http://192.168.0.66/ui, from PC or smartphone.
- Tare and Calibrate just like a normal digital powder scale.
- Set target weight and Throw.
The above will probably not work right out of the box.
- If the powder flow during first phase is too fast, the target weight will be overshot before the vibrator has time to slow down from max speed. Edit the node
Weight in. PWM out
> line 22 >10.5
grains margin to a higher margin. - The reverse applies if the vibrator slows down waaaay before the target weight - try a lower margin.
- If the vibrator runs too slow or too fast during the second phase, edit the slow vib setting at line 34.
- Remember to
Deploy
again after each change. The scale will re-zero itself 10s after deploy.
@ToDo:
- Powder pan / stirrup with pictures
- 3D prints
- Accuracy improvements
- Powder hopper, vibrations, feeding tube, holes, angle
- Details/description of flow