Skip to content

Commit

Permalink
tested on Byte
Browse files Browse the repository at this point in the history
  • Loading branch information
joshua-8 committed Oct 6, 2024
1 parent fb83532 commit 2bd224d
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 21 deletions.
125 changes: 116 additions & 9 deletions RCMv2/RCMv2.ino
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
uncomment one of the following lines depending on which hardware you have
Remember to also choose the "environment" for your microcontroller in PlatformIO
*/
#define RCM_HARDWARE_VERSION RCM_ORIGINAL // versions 1, 2, 3, and 3.1 of the original RCM hardware // https://github.com/RCMgames/RCM_hardware_documentation_and_user_guide
// #define RCM_HARDWARE_VERSION RCM_ORIGINAL // versions 1, 2, 3, and 3.1 of the original RCM hardware // https://github.com/RCMgames/RCM_hardware_documentation_and_user_guide
// #define RCM_HARDWARE_VERSION RCM_4_V1 // version 1 of the RCM 4 // https://github.com/RCMgames/RCM-Hardware-V4
// #define RCM_HARDWARE_VERSION RCM_BYTE_V2 // version 2 of the RCM BYTE // https://github.com/RCMgames/RCM-Hardware-BYTE
#define RCM_HARDWARE_VERSION RCM_BYTE_V2 // version 2 of the RCM BYTE // https://github.com/RCMgames/RCM-Hardware-BYTE
// #define RCM_HARDWARE_VERSION RCM_NIBBLE_V1 // version 1 of the RCM Nibble // https://github.com/RCMgames/RCM-Hardware-Nibble
// #define RCM_HARDWARE_VERSION RCM_D1_V1 // version 1 of the RCM D1 // https://github.com/RCMgames/RCM-Hardware-D1

Expand All @@ -25,30 +25,121 @@ uncomment one of the following lines depending on which communication method you
// https://github.com/RCMgames/useful-code/tree/main/boards
// See this page for information about how to set up a robot's drivetrain using the JMotor library
// https://github.com/joshua-8/JMotor/wiki/How-to-set-up-a-drivetrain

// all the servo drivers
JMotorDriverEsp32Servo servo1 = JMotorDriverEsp32Servo(port1);
JMotorDriverEsp32Servo servo2 = JMotorDriverEsp32Servo(port2);
JMotorDriverEsp32Servo servo3 = JMotorDriverEsp32Servo(port3);
JMotorDriverEsp32Servo servo4 = JMotorDriverEsp32Servo(port4);
JMotorDriverEsp32Servo servo5 = JMotorDriverEsp32Servo(port5);
JMotorDriverEsp32Servo servo6 = JMotorDriverEsp32Servo(port6);
JMotorDriverEsp32Servo servo7 = JMotorDriverEsp32Servo(port7);
JMotorDriverEsp32Servo servo8 = JMotorDriverEsp32Servo(port8);

// all the motor drivers
JMotorDriverTMC7300 motorA = JMotorDriverTMC7300(portA);
JMotorDriverTMC7300 motorB = JMotorDriverTMC7300(portB);
JMotorDriverTMC7300 motorC = JMotorDriverTMC7300(portC);
JMotorDriverTMC7300 motorD = JMotorDriverTMC7300(portD);
JMotorDriverTMC7300 motorE = JMotorDriverTMC7300(portE);
JMotorDriverTMC7300 motorF = JMotorDriverTMC7300(portF);
JMotorDriverTMC7300 motorG = JMotorDriverTMC7300(portG);
JMotorDriverTMC7300 motorH = JMotorDriverTMC7300(portH);

// variables for the drivers
float servo1Val = 0;
float servo2Val = 0;
float servo3Val = 0;
float servo4Val = 0;
float servo5Val = 0;
float servo6Val = 0;
float servo7Val = 0;
float servo8Val = 0;

float motorAVal = 0;
float motorBVal = 0;
float motorCVal = 0;
float motorDVal = 0;
float motorEVal = 0;
float motorFVal = 0;
float motorGVal = 0;
float motorHVal = 0;

void Enabled()
{
// code to run while enabled, put your main code here

// set all the motor drivers (you can put this in Enabled())
servo1.set(servo1Val);
servo2.set(servo2Val);
servo3.set(servo3Val);
servo4.set(servo4Val);
servo5.set(servo5Val);
servo6.set(servo6Val);
servo7.set(servo7Val);
servo8.set(servo8Val);

motorA.set(motorAVal);
motorB.set(motorBVal);
motorC.set(motorCVal);
motorD.set(motorDVal);
motorE.set(motorEVal);
motorF.set(motorFVal);
motorG.set(motorGVal);
motorH.set(motorHVal);
}

void Enable()
{
// turn on outputs

// enable all the motor drivers (you can put this in Enable())
servo1.enable();
servo2.enable();
servo3.enable();
servo4.enable();
servo5.enable();
servo6.enable();
servo7.enable();
servo8.enable();

motorA.enable();
motorB.enable();
motorC.enable();
motorD.enable();
motorE.enable();
motorF.enable();
motorG.enable();
motorH.enable();
}

void Disable()
{
// turn off outputs

// disable all the motor drivers (you can put this in Disable())
servo1.disable();
servo2.disable();
servo3.disable();
servo4.disable();
servo5.disable();
servo6.disable();
servo7.disable();
servo8.disable();

motorA.disable();
motorB.disable();
motorC.disable();
motorD.disable();
motorE.disable();
motorF.disable();
motorG.disable();
motorH.disable();
}

void PowerOn()
{
// runs once on robot startup, set pin modes and use begin() if applicable here

// TMC7300_AB.writeField(TMC7300_IRUN, 12); // current limit max 31
// TMC7300_CD.writeField(TMC7300_IRUN, 12);
// TMC7300_EF.writeField(TMC7300_IRUN, 12);
// TMC7300_GH.writeField(TMC7300_IRUN, 12);
}

void Always()
Expand All @@ -64,13 +155,29 @@ void WifiDataToParse()
{
enabled = EWD::recvBl();
// add data to read here: (EWD::recvBl, EWD::recvBy, EWD::recvIn, EWD::recvFl)(boolean, byte, int, float)

// receive values for all the variables (you can put this in WifiDataToParse())
motorAVal = EWD::recvFl();
motorBVal = EWD::recvFl();
motorCVal = EWD::recvFl();
motorDVal = EWD::recvFl();
motorEVal = EWD::recvFl();
motorFVal = EWD::recvFl();
motorGVal = EWD::recvFl();
motorHVal = EWD::recvFl();

servo1Val = EWD::recvFl();
servo2Val = EWD::recvFl();
servo3Val = EWD::recvFl();
servo4Val = EWD::recvFl();
servo5Val = EWD::recvFl();
servo6Val = EWD::recvFl();
servo7Val = EWD::recvFl();
servo8Val = EWD::recvFl();
}
void WifiDataToSend()
{
EWD::sendFl(voltageComp.getSupplyVoltage());
// add data to send here: (EWD::sendBl(), EWD::sendBy(), EWD::sendIn(), EWD::sendFl())(boolean, byte, int, float)

}

void configWifi()
Expand Down
10 changes: 5 additions & 5 deletions RCMv2/rcm.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ void setupMotors() { }
#define batMonitorPin 36

#ifndef OVERRIDE_DEFAULT_VOLTAGE_COMP
const int dacUnitsPerVolt = 350; // increasing this number decreases the calculated voltage
const int dacUnitsPerVolt = 310; // increasing this number decreases the calculated voltage
JVoltageCompMeasure<10> voltageComp = JVoltageCompMeasure<10>(batMonitorPin, dacUnitsPerVolt);
#endif

Expand Down Expand Up @@ -174,7 +174,7 @@ CRGB RSLcolor = CRGB(250, 45, 0); // orange

// chip address, motor address
#ifndef MOTOR_DRIVER_BAUD
#define MOTOR_DRIVER_BAUD 90000
#define MOTOR_DRIVER_BAUD 100000
#endif

#define portAB uartPin, 1, MOTOR_DRIVER_BAUD
Expand Down Expand Up @@ -221,7 +221,7 @@ void setupMotors()
}

#ifndef OVERRIDE_DEFAULT_VOLTAGE_COMP
const int dacUnitsPerVolt = 350; // increasing this number decreases the calculated voltage
const int dacUnitsPerVolt = 310; // increasing this number decreases the calculated voltage
JVoltageCompMeasure<10> voltageComp = JVoltageCompMeasure<10>(batMonitorPin, dacUnitsPerVolt);
#endif

Expand Down Expand Up @@ -267,7 +267,7 @@ CRGB RSLcolor = CRGB(250, 45, 0); // orange

// chip address, motor address
#ifndef MOTOR_DRIVER_BAUD
#define MOTOR_DRIVER_BAUD 110000
#define MOTOR_DRIVER_BAUD 100000
#endif

#define portAB uartPin, 0, MOTOR_DRIVER_BAUD
Expand Down Expand Up @@ -295,7 +295,7 @@ void setupMotors()
digitalWrite(motorsEnablePin, HIGH);
}
#ifndef OVERRIDE_DEFAULT_VOLTAGE_COMP
const int dacUnitsPerVolt = 350; // increasing this number decreases the calculated voltage
const int dacUnitsPerVolt = 310; // increasing this number decreases the calculated voltage
JVoltageCompMeasure<10> voltageComp = JVoltageCompMeasure<10>(batMonitorPin, dacUnitsPerVolt);
#endif

Expand Down
9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
# RCMv2
https://github.com/rcmgames/RCMv2
### open in VSCode (using [PlatformIO](https://platformio.org/platformio-ide)), or use the Arduino IDE.

### Test all ports of an [RCM BYTE](https://github.com/rcmgames/RCM-Hardware-BYTE)

### find more information about the Robot Control Module hardware here: [https://github.com/rcmgames](https://github.com/rcmgames?view_as=public)
### Open in VSCode (using [PlatformIO](https://platformio.org/platformio-ide)), or use the Arduino IDE.

## Install Driver Station App:
### Driver Station: https://github.com/rcmgames/RCMDS-new (recommended)

### https://github.com/rcmgames/RCMDS-new (recommended)

### [driver station config file](https://github.com/RCMgames/RCMDS-new/blob/v1.4.2/rcmds/data/byte%20test.txt)
### [Driver station config file "byte test"](https://github.com/RCMgames/RCMDS-new/blob/main/rcmds/data/byte%20test.txt)

### Libraries used:
* [JMotor](https://github.com/joshua-8/JMotor) library for motor control
Expand Down
2 changes: 1 addition & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ default_envs = esp32dev
monitor_speed = 115200
framework = arduino
lib_deps =
joshua1024/JMotor@~0.26.0
joshua1024/JMotor@~0.27.1
joshua1024/ESP32_easy_wifi_data@~1.4.3
fastled/[email protected]
https://github.com/micro-ROS/micro_ros_arduino#v2.0.7-iron
Expand Down

0 comments on commit 2bd224d

Please sign in to comment.