A cncjs pendant, using Playstation 3 Dualshock Controller / SIXAXIS Controller.
npm install cncjs-pendant-ps3Use Playstation 3 Controller wirelessly over bluetooth to control CNC from the host device (raspberry pi). PS3 CNC Control Button Map
Remote Pendant (Playstation 3 Dualshock Controller / SIXAXIS Controller)
Using a wireless game controller (like a PS3 controller) seems to be one of the lowest cost & simplest solution method. See related issue #103
Here is what I have figured out so far for PS3 on Raspberry PI 3 w/ integrated bluetooth.
The bellow just shows how to get PS3 controller connected.
Install & Enable Bluetooth Tools
sudo apt-get install -y bluetooth libbluetooth3 libusb-dev
sudo systemctl enable bluetooth.serviceAdd pi user to bluetooth group
sudo usermod -G bluetooth -a pi
`$3
`
Get and build the command line pairing tool (sixpair)
wget http://www.pabr.org/sixlinux/sixpair.c
gcc -o sixpair sixpair.c -lusb$3
Get PS3 DS
sudo ./sixpair
`$3
`
$3
Start bluetoothctl:
bluetoothctlEnable the agent and set it as default:
agent on
default-agentPower on the Bluetooth controller, and set it as discoverable and pairable:
power on
discoverable on
pairable on$3
Discover the DualShock 3 MAC address:
devices$3
#Allow the service authorization request:
#[agent]Authorize service service_uuid (yes/no): yes
#Trust the DualShock 3:
#trust device_mac_address # Replace "MAC" with MAC of "Device 64:D4:BD:B3:9E:66 PLAYSTATION(R)3 Controller"
trust 64:D4:BD:B3:9E:66
The DualShock 3 is now paired:
quitTurn the DualShock 3 off when it's no longer in use by pressing and holding the PlayStation button for 10 seconds.
Press the PlayStation button to use the DualShock 3 again.
`$3
`
$3
List Devices
ls /dev/input
`$3
cat "/sys/class/power_supply/sony_controller_battery_64:d4:bd:b3:9e:66/capacity"
$3
`
Install
sudo apt-get -y install joystickUsage / Test
jstest /dev/input/js0
`----------------------------------------
Install NodeJS Libraries
- https://www.npmjs.com/package/node-hid
- https://www.npmjs.com/package/dualshock-controller$3
`
Install Tools
sudo apt-get install -y libudev-dev libusb-1.0-0 libusb-1.0-0-dev build-essential git
sudo apt-get install -y gcc-4.8 g++-4.8 && export CXX=g++-4.8
#npm install node-gyp node-pre-gypInstall node-hid with hidraw support
#npm install node-hid --driver=hidraw --build-from-source --unsafe-permInstall Pendant Package
sudo npm install -g cncjs-pendant-ps3 --unsafe-perm # Install GloballyIf NOT installed globally, Install node-hid with hidraw support (https://github.com/rdepena/node-dualshock-controller)
`$3
`
Run as Root
sudo suYou will need to create a udev rule to be able to access the hid stream as a non root user.
sudo touch /etc/udev/rules.d/61-dualshock.rules
sudo cat <> /etc/udev/rules.d/61-dualshock.rules
SUBSYSTEM=="input", GROUP="input", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="054c", ATTRS{idProduct}=="0268", MODE:="666", GROUP="plugdev"
KERNEL=="hidraw*", SUBSYSTEM=="hidraw", MODE="0664", GROUP="plugdev"SUBSYSTEM=="input", GROUP="input", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="054c", ATTRS{idProduct}=="05c4", MODE:="666", GROUP="plugdev"
KERNEL=="hidraw*", SUBSYSTEM=="hidraw", MODE="0664", GROUP="plugdev"
EOT
Reload the rules, then disconnect/connect the controller.
sudo udevadm control --reload-rulesexit
`QUICK FIX for node-hid hidraw... PLEASE HELP IF YOU KNOW FIX
`
I am having issues with node-hid --driver=hidraw not seeming to work... quickest fix is to reinstall, node-hid --driver=hidraw
Reinstall (node-hid --driver=hidraw) on cncjs-pendant-ps3
cd /usr/lib/node_modules/cncjs-pendant-ps3/
sudo npm install node-hid --driver=hidraw --build-from-source --unsafe-perm
`I recommend rebooting now.
After reboot you can test pendant by running
cncjs-pendant-ps3 -p "/dev/ttyUSB0".----------------------------------------
Auto Start
$3
`
Install Production Process Manager [PM2]
npm install pm2 -gSetup PM2 Startup Script
pm2 startup debian
#[PM2] You have to run this command as root. Execute the following command:
sudo su -c "env PATH=$PATH:/home/pi/.nvm/versions/node/v4.5.0/bin pm2 startup debian -u pi --hp /home/pi"Start Dual Shock / PS3 Bluetooth Remote Pendant for CNCjs (conected to serail device @ /dev/ttyUSB0) with PM2
pm2 start $(which cncjs-pendant-ps3) -- -p "/dev/ttyUSB0"Set current running apps to startup
pm2 saveGet list of PM2 processes
pm2 list
``