Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swapped from teensy3.6 to teensy4.1 and wheels no longer turning. #96

Open
cottot opened this issue Jan 13, 2025 · 1 comment
Open

Swapped from teensy3.6 to teensy4.1 and wheels no longer turning. #96

cottot opened this issue Jan 13, 2025 · 1 comment

Comments

@cottot
Copy link

cottot commented Jan 13, 2025

I inherited this robot for a project at work and I am trying to get it up and working. I was following the guide but couldn't get it to work with the teensy36 so I swapped it out with a teensy41. The problem I am running into is that the wheels just don't turn or do anything. I cabled this exactly the same as I had on my teensy36 but instead of using pins 21 and 20 I an now using 1 and 0.

#define MOTOR1_IN_A 1 // Pin no 21 is not a PWM pin on Teensy 4.x, you can use pin no 1 instead.
#define MOTOR1_IN_B 0 // Pin no 20 is not a PWM pin on Teensy 4.x, you can use pin no 0 instead.

cd linorobot2_hardware/calibration
pio run --target upload -e <your_teensy_board>
screen /dev/ttyACM0
sample or spin <--Instantly closes the screen when I type this.

This is the setup and how my cables are currently wired.

Is there any way to see if the pins I am using on the teensy are actually sending the correct signals to the BTS7960_MOTOR_DRIVER?

`// Copyright (c) 2021 Juan Miguel Jimeno
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef LINO_BASE_CONFIG_H
#define LINO_BASE_CONFIG_H

#define LED_PIN 13 //used for debugging status

//uncomment the base you're building
//#define LINO_BASE DIFFERENTIAL_DRIVE // 2WD and Tracked robot w/ 2 motors
// #define LINO_BASE SKID_STEER // 4WD robot
#define LINO_BASE MECANUM // Mecanum drive robot

//uncomment the motor driver you're using
//#define USE_GENERIC_2_IN_MOTOR_DRIVER // Motor drivers with 2 Direction Pins(INA, INB) and 1 PWM(ENABLE) pin ie. L298, L293, VNH5019
// #define USE_GENERIC_1_IN_MOTOR_DRIVER // Motor drivers with 1 Direction Pin(INA) and 1 PWM(ENABLE) pin.
#define USE_BTS7960_MOTOR_DRIVER // BTS7970 Motor Driver
// #define USE_ESC_MOTOR_DRIVER // Motor ESC for brushless motors

//uncomment the IMU you're using
#define USE_GY85_IMU
// #define USE_MPU6050_IMU
// #define USE_MPU9150_IMU
// #define USE_MPU9250_IMU
// #define USE_QMI8658_IMU
// #define USE_HMC5883L_MAG
// #define USE_AK8963_MAG
// #define USE_AK8975_MAG
// #define USE_AK09918_MAG
// #define USE_QMC5883L_MAG
// #define MAG_BIAS { 0, 0, 0 }

#define K_P 0.6 // P constant
#define K_I 0.8 // I constant
#define K_D 0.5 // D constant

/*
ROBOT ORIENTATION
FRONT
MOTOR1 MOTOR2 (2WD/ACKERMANN)
MOTOR3 MOTOR4 (4WD/MECANUM)
BACK
*/

//define your robot' specs here
#define MOTOR_MAX_RPM 140 // motor's max RPM
#define MAX_RPM_RATIO 0.85 // max RPM allowed for each MAX_RPM_ALLOWED = MOTOR_MAX_RPM * MAX_RPM_RATIO
#define MOTOR_OPERATING_VOLTAGE 24 // motor's operating voltage (used to calculate max RPM)
#define MOTOR_POWER_MAX_VOLTAGE 24 // max voltage of the motor's power source (used to calculate max RPM)
#define MOTOR_POWER_MEASURED_VOLTAGE 24 // current voltage reading of the power connected to the motor (used for calibration)
#define COUNTS_PER_REV1 144000 // wheel1 encoder's no of ticks per rev
#define COUNTS_PER_REV2 144000 // wheel2 encoder's no of ticks per rev
#define COUNTS_PER_REV3 144000 // wheel3 encoder's no of ticks per rev
#define COUNTS_PER_REV4 144000 // wheel4 encoder's no of ticks per rev
#define WHEEL_DIAMETER 0.152 // wheel's diameter in meters
#define LR_WHEELS_DISTANCE 0.271 // distance between left and right wheels
#define PWM_BITS 10 // PWM Resolution of the microcontroller
#define PWM_FREQUENCY 20000 // PWM Frequency

// INVERT ENCODER COUNTS
#define MOTOR1_ENCODER_INV false
#define MOTOR2_ENCODER_INV false
#define MOTOR3_ENCODER_INV false
#define MOTOR4_ENCODER_INV false

// INVERT MOTOR DIRECTIONS
#define MOTOR1_INV false
#define MOTOR2_INV false
#define MOTOR3_INV false
#define MOTOR4_INV false

// ENCODER PINS
#define MOTOR1_ENCODER_A 9
#define MOTOR1_ENCODER_B 10

#define MOTOR2_ENCODER_A 11
#define MOTOR2_ENCODER_B 12

#define MOTOR3_ENCODER_A 17
#define MOTOR3_ENCODER_B 16

#define MOTOR4_ENCODER_A 14
#define MOTOR4_ENCODER_B 15

// MOTOR PINS
#ifdef USE_GENERIC_2_IN_MOTOR_DRIVER
#define MOTOR1_PWM 21 //Pin no 21 is not a PWM pin on Teensy 4.x, you can swap it with pin no 1 instead.
#define MOTOR1_IN_A 20
#define MOTOR1_IN_B 1

#define MOTOR2_PWM 5
#define MOTOR2_IN_A 6
#define MOTOR2_IN_B 8

#define MOTOR3_PWM 22
#define MOTOR3_IN_A 23
#define MOTOR3_IN_B 0

#define MOTOR4_PWM 4
#define MOTOR4_IN_A 3
#define MOTOR4_IN_B 2

#define PWM_MAX pow(2, PWM_BITS) - 1
#define PWM_MIN -PWM_MAX
#endif

#ifdef USE_GENERIC_1_IN_MOTOR_DRIVER
#define MOTOR1_PWM 21 //Pin no 21 is not a PWM pin on Teensy 4.x, you can use pin no 1 instead.
#define MOTOR1_IN_A 20
#define MOTOR1_IN_B -1 //DON'T TOUCH THIS! This is just a placeholder

#define MOTOR2_PWM 5
#define MOTOR2_IN_A 6
#define MOTOR2_IN_B -1 //DON'T TOUCH THIS! This is just a placeholder

#define MOTOR3_PWM 22
#define MOTOR3_IN_A 23
#define MOTOR3_IN_B -1 //DON'T TOUCH THIS! This is just a placeholder

#define MOTOR4_PWM 4
#define MOTOR4_IN_A 3
#define MOTOR4_IN_B -1 //DON'T TOUCH THIS! This is just a placeholder

#define PWM_MAX pow(2, PWM_BITS) - 1
#define PWM_MIN -PWM_MAX
#endif

#ifdef USE_BTS7960_MOTOR_DRIVER
#define MOTOR1_PWM -1 //DON'T TOUCH THIS! This is just a placeholder
#define MOTOR1_IN_A 1 // Pin no 21 is not a PWM pin on Teensy 4.x, you can use pin no 1 instead.
#define MOTOR1_IN_B 0 // Pin no 20 is not a PWM pin on Teensy 4.x, you can use pin no 0 instead.

#define MOTOR2_PWM -1 //DON'T TOUCH THIS! This is just a placeholder
#define MOTOR2_IN_A 5
#define MOTOR2_IN_B 6

#define MOTOR3_PWM -1 //DON'T TOUCH THIS! This is just a placeholder
#define MOTOR3_IN_A 22
#define MOTOR3_IN_B 23

#define MOTOR4_PWM -1 //DON'T TOUCH THIS! This is just a placeholder
#define MOTOR4_IN_A 4
#define MOTOR4_IN_B 3

#define PWM_MAX pow(2, PWM_BITS) - 1
#define PWM_MIN -PWM_MAX
#endif

#ifdef USE_ESC_MOTOR_DRIVER
#define MOTOR1_PWM 21 //Pin no 21 is not a PWM pin on Teensy 4.x. You can use pin no 1 instead.
#define MOTOR1_IN_A -1 //DON'T TOUCH THIS! This is just a placeholder
#define MOTOR1_IN_B -1 //DON'T TOUCH THIS! This is just a placeholder

#define MOTOR2_PWM 5
#define MOTOR2_IN_A -1 //DON'T TOUCH THIS! This is just a placeholder
#define MOTOR2_IN_B -1 //DON'T TOUCH THIS! This is just a placeholder

#define MOTOR3_PWM 22
#define MOTOR3_IN_A -1 //DON'T TOUCH THIS! This is just a placeholder
#define MOTOR3_IN_B -1 //DON'T TOUCH THIS! This is just a placeholder

#define MOTOR4_PWM 4
#define MOTOR4_IN_A -1 //DON'T TOUCH THIS! This is just a placeholder
#define MOTOR4_IN_B -1 //DON'T TOUCH THIS! This is just a placeholder

#define PWM_MAX 400
#define PWM_MIN -PWM_MAX
#endif

#endif`

@cottot
Copy link
Author

cottot commented Jan 15, 2025

Bump

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant