FORUM
Hi. So I'm trying to get the Solo mini to work with an Arduino Mega. I've already gotten the Solo mini to work with my motor using the online motion terminal, so I know the motor, motor controller, and power supply work together well, but I can't get the motor controller to respond to the Arduino. I'm using the TX3 and RX3 pins on the Arduino, so I changed the 3 instances of "Serial." to "Serial3." while installing the library. When I tried the code to get the Solo mini's temperature from the website(lightly modified for using Serial3 for the mini and Serial for Arduino's terminal):
#include <SOLOMotorController.h>
SOLOMotorController *SOLO_Obj1;
float Temperature=0;
void setup() {
Serial.begin(9600);
Serial3.begin(115200);
SOLO_Obj1 = new SOLOMotorController(0);
}
void loop() {
Temperature = SOLO_Obj1->GetTemperature();
Serial.println("\n Read from SOLO");
Serial.println(Temperature,7);
delay(1000);
}
The Arduino terminal just responds with:
Read from SOLO
-1.0000000
I hooked TX3 and RX3 to an oscilloscope and TX3 is transmitting cleanly, but RX3 just stays at about 3.3V without any data coming across.
Any idea why the Solo mini won't respond?
Two points to consider:
1- Have you changed the UART baud rate of SOLO in Motion Terminal before working with Arduino to 115200? ( after changing the baud rate a power-recycle is required)
2- as you are using the serial3 on Arduino, you also need to change the function "bool SOLOMotorController::ExeCMD(unsigned char cmd[])" within "SOLOMotorController.cpp" file as it's using only the main serial port, so the function should get the following form, and as you can see the functions for reading and writing from the serial port are changed now:
bool SOLOMotorController::ExeCMD(unsigned char cmd[]) { unsigned char _cmd[] = {INITIATOR,INITIATOR,cmd[0],cmd[1],cmd[2],cmd[3],cmd[4],cmd[5],CRC,ENDING}; unsigned char _readPacket[10]; Serial3.write(_cmd,10); while(Serial3.availableForWrite() == 0); // wait till end of writing Serial3.readBytes(_readPacket, 10); //read received data if (_readPacket[0] == _cmd[0] && _readPacket[1] == _cmd[1] && _readPacket[2] == _cmd[2] && _readPacket[3] == _cmd[3] && _readPacket[8] == _cmd[8] && _readPacket[9] == _cmd[9]) { cmd[0] = _readPacket[2]; cmd[1] = _readPacket[3]; cmd[2] = _readPacket[4]; cmd[3] = _readPacket[5]; cmd[4] = _readPacket[6]; cmd[5] = _readPacket[7]; } else { cmd[0] = ERROR; cmd[1] = ERROR; cmd[2] = ERROR; cmd[3] = ERROR; cmd[4] = ERROR; cmd[5] = ERROR; } if(cmd[2] == ERROR && cmd[3] == ERROR && cmd[4] == ERROR && cmd[5] == ERROR) return false; else return true; }
If you found the answers helpful and you could solve your problems, please kindly verify here to help others in the future.
@gabriel_from_onda, thanks for reporting back the progress and good job
Regards
Milad
If you found the answers helpful and you could solve your problems, please kindly verify here to help others in the future.