From 31fc8ec309ee5f397bc2959fbe95e97ec11924d1 Mon Sep 17 00:00:00 2001 From: Josh Garduna Date: Wed, 13 Nov 2024 21:28:31 -0600 Subject: [PATCH] Add Dead Zone Variable; Default to 60 This change adds a deadZoneValue variable and defaults this to 60. This prevents the motor from emitting a high pitched whine when unable to move the forklift. This was tested and verified using a 12v 100RPM N20 motor. --- MiniFork_Bluepad2.0/MiniFork_Bluepad2.0.ino | 3 ++- MiniFork_PS3_Controller/MiniFork_PS3_Controller.ino | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/MiniFork_Bluepad2.0/MiniFork_Bluepad2.0.ino b/MiniFork_Bluepad2.0/MiniFork_Bluepad2.0.ino index fa34c60..44b1a16 100644 --- a/MiniFork_Bluepad2.0/MiniFork_Bluepad2.0.ino +++ b/MiniFork_Bluepad2.0/MiniFork_Bluepad2.0.ino @@ -106,7 +106,8 @@ void processGamepad(ControllerPtr ctl) { void processThrottle(int axisYValue) { float adjustedThrottleValue = axisYValue / 2; - if (adjustedThrottleValue > 15 || adjustedThrottleValue < -15) { + int deadZoneValue = 60; + if (adjustedThrottleValue > deadZoneValue || adjustedThrottleValue < -deadZoneValue) { if (hardRight) { moveMotor(rightMotor0, rightMotor1, -1 * (adjustedThrottleValue * steeringAdjustment)); } else if (hardLeft) { diff --git a/MiniFork_PS3_Controller/MiniFork_PS3_Controller.ino b/MiniFork_PS3_Controller/MiniFork_PS3_Controller.ino index b71f341..fd6f941 100644 --- a/MiniFork_PS3_Controller/MiniFork_PS3_Controller.ino +++ b/MiniFork_PS3_Controller/MiniFork_PS3_Controller.ino @@ -167,7 +167,8 @@ void notify() { } void processThrottle(int throttleValue) { adjustedThrottleValue = throttleValue; - if (adjustedThrottleValue > 15 || adjustedThrottleValue < -15) { + int deadZoneValue = 60; + if (adjustedThrottleValue > deadZoneValue || adjustedThrottleValue < -deadZoneValue) { if (hardRight) { moveMotor(rightMotor0, rightMotor1, -1 * (adjustedThrottleValue * steeringAdjustment)); } else if (hardLeft) {