PXL_20220831_171948354.TS.mp4
This is the backend of the Racepak/Holley Auto Digital Dash. This pairs with the AutoDashFrontEnd
WARNING - BUILDING THIS WHILE WE ARE FLYING - EXPECT MASSIVE STUPID CHANGES ON A WHIM
- https://github.com/Mathews2115/AutoDashFrontEndBoilerPlate - Feel free to clone this and make your own - it is a simple Tach display with no more bells or whistles
My personal Digital Dash project for a heavily modified 1972 Ford LTD - communicating via CAN with a Holley EFI ECU and other goodies my car needs such as GPS speedo, fuel tank remaining estimation and whatever the heck else I'm gonna start throwing at it in the future.
This is the compnent that gets installed on the raspberry Pi. It will run a Node server that will:
- Will host HTML/JS web content for chromium browser, (AutoDashFrontEnd)
- Parse CAN messages via a CAN hat from the Holley ECU
- Communicate with the dash via a websocket
- Parse GPS messages from a GPS chip via USB serial
- ...more to be added in the future!
- 64bit Bullseye OS
- Node16 - 64 bit (just get ARMv8)
- waveshare monitor (when on separate power source from pi) is not getting signal on initial power on
- While I am building this specifically to fit on my project; I'm trying to make this modular enough for other people to pick and choose for their own needs if necessary. Feel free to fork this repo and go hog wild - just be sure to share some photos of your project because I love this stuff.
- waveshare 7.9 monitor
- 3.0+ USB flash drive (optional)
- Waveshare dual CAN hat - CAN data from Holley ECU
- Geekworm x715 Power/Fan - for 12-40v input to 5v output conversion
- SparkFun GPS - NEO-M8U - Speedo and odometer
- Buttons / LEDS (optional)
- A momentary switch to reset the fuel readings (because my fuel sender is non functional) (optional obviously)
- Adafruit i2c LED/Switch board (to handle buttons/leds)
- i2c hat from sparkfun
- Check this out for safe shutdown stuff - it uses a timed relay to stop parasitic draw
if you dont care about booting from USB, just skip to Setting up Image.
- Download RPI's official Imager
- Follow the steps for setting up your initial pi image from Setup Pi Image below
- SSH in and lets have some fun
- (update bootloader stuff: watch this https://www.youtube.com/watch?v=8tTFgrOCsig)
- Download RPI's official Imager
- Image USB (or SD if you dont want usb) card with a rasp lite image
- We are going to add SSH/Wifi so we can just ssh straight into it without needing a monitor (if desired)
- Go into volume Boot of the card:
- enable SSH:
sudo touch ssh
- WiFi network
sudo touch wpa_supplicant.conf
- add the contents to that file:
country=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="NETWORK-NAME"
psk="NETWORK-PASSWORD"
}
- Edit the
/boot/config.txt
- add
# waveshare 7.9 screen - https://www.waveshare.com/wiki/7.9inch_HDMI_LCD
hdmi_group=2
hdmi_mode=87
hdmi_timings=400 0 100 10 140 1280 10 20 20 2 0 0 0 60 0 43000000 3
bootcode_delay=1
The boot code delay is so the monitor has time to fully power on (if powered by a separate power supply - otherwise feel free to omit that line)
- Pop the USB/SD in the pi and boot up
- login pi/raspberry
- (note: at some point set auto login to true, I still dont know how to do that without going to raspi-config)
- ssh from your computer:
ssh-keygen -R raspberrypi.local
ssh [email protected]
- (default password is raspberry)
- Update everything:
sudo apt -y update && sudo apt -y upgrade ; sudo apt autoremove ; sudo apt dist-upgrade -y ; sudo reboot
sudo raspi-config
- turn on auto login
Don't bother doing any of this if you dont have the hat hooked up - it will cause issues on bootup - like no wifi
sudo nano /boot/config.txt
- uncomment
dtparam=spi=on
- add below:
dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=25
dtoverlay=spi-bcm2835-overlay
https://www.waveshare.com/wiki/2-CH_CAN_HAT
dtoverlay=mcp2515-can1,oscillator=16000000,interrupt=25
dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=23
sudo apt -y install can-utils libsocketcan2 libsocketcan-dev
sudo nano /etc/network/interfaces
- THIS IS IMPORTANT - FOUND OUT THE REQUIRE BITSPEED - THIS ONE IS SETTING IT TO 1000k: - paste the below
auto can0
iface can0 inet manual
pre-up /sbin/ip link set can0 type can bitrate 1000000
up /sbin/ifconfig can0 up
up /sbin/ifconfig can0 txqueuelen 65536
down /sbin/ifconfig can0 down
sudo reboot
IMPORTANT - implement a way for your pi to shutdown safely - else make sure you put it in read only mode
sudo apt install --no-install-recommends xserver-xorg x11-xserver-utils xinit openbox --assume-yes
sudo apt install --no-install-recommends chromium-browser --assume-yes
- Now setup chromium with all the hardware enabled crap
sudo nano /etc/xdg/openbox/autostart
- Note: Waveshare settings; uncomment that line (turning on the accelerated video driver will cause it to ignore the display-rotate - so we need to use xrander to rotate it in xserver)
# Disable any form of screen saver / screen blanking / power management
xset s off
xset s noblank
xset -dpms
xrandr --output HDMI-1 --rotate right
#xrandr --output HDMI-2 --rotate right
#xrandr --output HDMI-2 --same-as HDMI-1
#xrandr --output HDMI-1 --panning 1280x1280+0+0/0x0+0+0/0/0/0/0
#xrandr --output HDMI-1 --fb 1280x800
#xrandr --output HDMI-2 --pos 0x400
# Allow quitting the X server with CTRL-ATL-Backspace
setxkbmap -option terminate:ctrl_alt_bksp
# Start Chromium in kiosk mode
sed -i 's/"exited_cleanly":false/"exited_cleanly":true/' ~/.config/chromium/'Local State'
sed -i 's/"exited_cleanly":false/"exited_cleanly":true/; s/"exit_type":"[^"]\+"/"exit_type":"Normal"/' ~/.config/chromium/Default/Preferences
# IF THE WEBGL DISPLAY IS FLIPPED: use this line (from here https://forums.raspberrypi.com/viewtopic.php?f=91&t=274315 )
#MESA_EXTENSION_OVERRIDE=-GL_MESA_framebuffer_flip_y chromium-browser --noerrdialogs --disable-infobars --disable-full-history-sync \
chromium-browser --window-position=0,0 --user-data-dir="/home/pi/Documents/Profiles/0" --noerrdialogs --disable-infobars --disable-full-history-sync \
--kiosk http:\\localhost:3000
Add this when/if you want chromium to start upon boot
sudo nano /home/pi/.bash_profile
- Add this:
[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && startx -- -nocursor
- Reboot
- Instructions from: https://www.officialrajdeepsingh.dev/install-node-js-and-npm-latest-version-on-raspberry-pi-4/
wget https://nodejs.org/dist/v16.14.0/node-v16.14.0-linux-arm64.tar.xz
tar -xf node-v16.14.0-linux-arm64.tar.xz
rm node-v16.14.0-linux-arm64.tar.xz
cd node-v16.14.0-linux-arm64
sudo cp -R * /usr/local/
sudo reboot
node -v
- install yarn
curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null
echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt update && sudo apt install yarn
- From your Local Computer, copy the Dash BackEnd software over. (sans the node_modules)
cd AutoDashBackEnd/
rm yarn.lock
cp yarn.lock.rpi_64 yarn.lock
yarn
- yarn.lock - Linux desktop file
- yarn.lock.rpi - 32 Bit version of raspi
- yarn.lock.rpi_64 - x64 version of raspi <- current for raspberry pi 4
- Setup the PI to automatically start server (read from CAN, not VCAN)
RPI_system/prepare_preduction.sh
- Start Dev CAN service
RPI_system/prepare_dev.sh
- see that file to configure what canfile to run
- If you haven't ran the production version, you'll see a lot of Cannot do this/that - feel free to ignore them, it is just trying to undo the things
prepare_production
did.
- reboot, it will automatically run the node test_server command
- ssh in and play a canfile
canplayer vcan0=can0 -I ./can_dumps/candump-racepack-running.log -li
- For Development mode:
RPI_system/start_vcan.sh
- Start the virtual CAN interface:
.RPI_system/start_vcan.sh
- Start playing CAN messages from a captured can log:
canplayer vcan0=can0 -I ./can_dumps/candump-racepack-running.log -li
- Run the server:
npm run test_server
- can util stuff
- NodeCan
- uWebSockets
- https://desertbot.io/blog/headless-raspberry-pi-4-ssh-wifi-setup
- https://www.makeuseof.com/raspberry-pi-set-static-ip/
- https://roboticsbackend.com/raspberry-pi-3-pins/
- https://desertbot.io/blog/headless-raspberry-pi-4-ssh-wifi-setup
Consider disabling services to make boot time faster (if you dont need them) - havent curated the list below, disable at your own risk
sudo systemctl disable raspi-config.service
sudo systemctl disable apt-daily-upgrade.service
sudo systemctl disable rpi-eeprom-update.service
sudo systemctl disable keyboard-setup.service
sudo systemctl disable hciuart.service
sudo systemctl disable bluealsa.service
sudo systemctl disable bluetooth.service
- disable wifi/touch?
sudo nano /boot/config.txt
- add
#Disable Bluetooth
dtoverlay=disable-bt
#dtparam=audio=on
# Disable Wifi (disable this when the dash is ready to go in; eliminate time waiting for Wifi to raise)
dtoverlay=disable-wifi
disable_touchscreen=1
- Only supports two protocols currently, Racepak and PE3
- make sure to specify the protocol in the settings.yaml file
- Protocol
- CAN data rate is 250kbps
- Found here towards the bottom
- The CAN data rate: 1 Mbit/sec
- Holley uses the ID as bit-wise structure:
- Bits 31:29 – CAN flags (normally filtered out and read as 0)
- Bits 28 – command bit (=1)
- Bits 27:25 – Target ID (= 111, broadcast)
- Bits 24:14 – Target Serial (used as a channel # index)
- Bits 13:11 – source ID (= 010, hefi)
- Bits 10:0 – source serial (the lower 11 bits of the serial # of the device as printed on the back of the ECU)
- using extended identifier (CANID) format.
- To decode data: mask out the lower 11 bits of the CANID
- (i.e., logical AND with 0xFFFFF800)
Monitor data is continuously broadcast by the HEFI.
- The monitor packets contain an index in their CAN id and values in the data field.
- rate: approximately 10mS intervals.
- All monitor packets have a DLC of 8 bytes.
- payload contains two values.
- Each set of 4 bytes (with the exception of RTC) is in a signed “fixed 24.8” format (essentially fixed 24.8 = float *256)
- The RTC is sent as an u32 showing milliseconds since power on, or if the RTC was set will it will be the current time of
If you can, try to configure your GPS chip to only send the required messages. In my instance, since I am using USB, I turned off all messages for other protocols (I2C, SPI, etc). I also only enabled NAV-ODO
, and HNR-PVT
messages.
- make sure settings.yaml, GPS settings are turned on if you require GPS functionality
- log file of service
journalctl
Logs:
dmesg
systemd-analyze
systemd-analyze critical-chain
lsmod
- list of loaded modules
Monitoring
- Monitor CPU Clock Speed -
watch -n1 vcgencmd measure_clock arm
- Measure Temperature -
watch -n1 vcgencmd measure_temp
- making quick src updates:
scp -r ../AutoDashBackEnd/src [email protected]:/home/pi/AutoDashBackEnd/src
- copy dist
scp -r ../AutoDashFrontEnd/dist [email protected]:/home/pi/AutoDashBackEnd/dist/
~ cd development/AutoDashBackEnd
➜ AutoDashBackEnd git:(main) ✗ canplayer vcan0=can0 -I ./can_dumps/candump-racepack-running.log -li
To run device related commands via SSH:
DISPLAY=:0 <command like xandr or wmctrl>
- two separate windows
chromium-browser --window-position=0,0 --user-data-dir="/home/pi/Documents/Profiles/0" --noerrdialogs --disable-infobars --disable-full-history-sync --kiosk http:\\localhost:3000 --enable-features=CanvasOop>
51 chromium-browser --window-position=0,400 --user-data-dir="/home/pi/Documents/Profiles/1" --noerrdialogs --disable-infobars --disable-full-history-sync --kiosk http:\\localhost:3000 --enable-features=CanvasO>
52
#dtoverlay=gpio-shutdown
#dtoverlay=gpio-shutdown,debounce=5000
#dtoverlay=gpio-shutdown,gpio_pin=3,active_low=1,gpio_pull=up,debounce=5000