Roboclaw & Nucleo 64 Issues
Roboclaw & Nucleo 64 Issues
I am having a difficult time getting my STM32F446 Nucelo-64 to control my 2x15A Roboclaw Motorcontroller.
The code I am using does not seem to be working, the motors do not turn on. I have verified that the motors do turn on in the Motion Studio, works like a charm. I have also verified the buadrate and the address. The code compiles but nothing else. I am a novice here so hopefully I am missing something obvious. Here is my code:
///////////////////////////////////
// Include the RoboClaw Arduino library
#include "RoboClaw.h"
// Create the RoboClaw object, passing it the hardware serial pointer
RoboClaw roboclaw(&Serial, 10000);
#define address 0x80
void setup() {
// Start serial communication
roboclaw.begin(38400);
}
void loop() {
// Call command on RoboClaw object, in this case turning motor 1 in the forward direction at full speed
roboclaw.ForwardM1(address, 127);
delay(2000);
roboclaw.ForwardM1(address, 0);
delay(2000);
}
/////////////////////////////////////////////
I have connected TX and RX pins of the Nucleo Board to the S1 and S2 I/O pins. I have connected the ground pin of the S1 pin the the ground of the Nucleo Board. I am using the Hardware serial becuase I was running into some other errors compiling with the Software Serial. Can anyone help?
The code I am using does not seem to be working, the motors do not turn on. I have verified that the motors do turn on in the Motion Studio, works like a charm. I have also verified the buadrate and the address. The code compiles but nothing else. I am a novice here so hopefully I am missing something obvious. Here is my code:
///////////////////////////////////
// Include the RoboClaw Arduino library
#include "RoboClaw.h"
// Create the RoboClaw object, passing it the hardware serial pointer
RoboClaw roboclaw(&Serial, 10000);
#define address 0x80
void setup() {
// Start serial communication
roboclaw.begin(38400);
}
void loop() {
// Call command on RoboClaw object, in this case turning motor 1 in the forward direction at full speed
roboclaw.ForwardM1(address, 127);
delay(2000);
roboclaw.ForwardM1(address, 0);
delay(2000);
}
/////////////////////////////////////////////
I have connected TX and RX pins of the Nucleo Board to the S1 and S2 I/O pins. I have connected the ground pin of the S1 pin the the ground of the Nucleo Board. I am using the Hardware serial becuase I was running into some other errors compiling with the Software Serial. Can anyone help?
- Basicmicro Support
- Posts: 1594
- Joined: Thu Feb 26, 2015 9:45 pm
Re: Roboclaw & Nucleo 64 Issues
I recommend you start with a ReadVersion command instead. This will take the CRC16 calculation out of the equation and it tests both read and write.
Do you have an oscilloscope? If so check the TX and RX lines. Robolcaw needs a minimum 0 to 2v signal.
Unfortunately I've never used one of these boards so I don't know what kind of gotchas there may be vs regular Arduino code. I believe our arduino library is generic enough there shouldn't be any problems but without actually testing on a Nucleo board I just don't know for sure. Hopefully someones else in the forums has experience with them.
Do you have an oscilloscope? If so check the TX and RX lines. Robolcaw needs a minimum 0 to 2v signal.
Unfortunately I've never used one of these boards so I don't know what kind of gotchas there may be vs regular Arduino code. I believe our arduino library is generic enough there shouldn't be any problems but without actually testing on a Nucleo board I just don't know for sure. Hopefully someones else in the forums has experience with them.
Re: Roboclaw & Nucleo 64 Issues
I've had good luck getting serial communication to work using the pins in other programs so I don't think they are to blame. When I try to run the ReadVersion sample code as given it gives me this very long error code:
///////////////////////////////////////////////////////////////////////////////////
PacketSerialReadVersion:9:32: error: no matching function for call to 'RoboClaw::RoboClaw(SoftwareSerial*, int)'
9 | RoboClaw roboclaw(&serial,10000);
| ^
In file included from C:\Users\grego\Desktop\roboclaw(arduino)\examples\PacketSerialReadVersion\PacketSerialReadVersion.ino:5:
C:\Users\grego\Documents\Arduino\libraries\RoboClaw/RoboClaw.h:128:2: note: candidate: 'RoboClaw::RoboClaw(HardwareSerial*, uint32_t)'
128 | RoboClaw(HardwareSerial *hserial,uint32_t tout);
| ^~~~~~~~
C:\Users\grego\Documents\Arduino\libraries\RoboClaw/RoboClaw.h:128:27: note: no known conversion for argument 1 from 'SoftwareSerial*' to 'HardwareSerial*'
128 | RoboClaw(HardwareSerial *hserial,uint32_t tout);
| ~~~~~~~~~~~~~~~~^~~~~~~
C:\Users\grego\Documents\Arduino\libraries\RoboClaw/RoboClaw.h:24:7: note: candidate: 'constexpr RoboClaw::RoboClaw(const RoboClaw&)'
24 | class RoboClaw : public Stream
| ^~~~~~~~
C:\Users\grego\Documents\Arduino\libraries\RoboClaw/RoboClaw.h:24:7: note: candidate expects 1 argument, 2 provided
C:\Users\grego\Desktop\roboclaw(arduino)\examples\PacketSerialReadVersion\PacketSerialReadVersion.ino: In function 'void setup()':
PacketSerialReadVersion:16:3: error: 'rc' was not declared in this scope
16 | rc.begin(38400);
| ^~
C:\Users\grego\Desktop\roboclaw(arduino)\examples\PacketSerialReadVersion\PacketSerialReadVersion.ino: In function 'void loop()':
PacketSerialReadVersion:22:6: error: 'rc' was not declared in this scope
22 | if(rc.ReadVersion(address,version)){
| ^~
exit status 1
no matching function for call to 'RoboClaw::RoboClaw(SoftwareSerial*, int)'
///////////////////////////////////////////////////////////////////////////////////////
I've tried the ReadVersion code on an Arduino Uno and it works flawlessly, all the RoboClaw example codes do. I can't make sense of this error code.
///////////////////////////////////////////////////////////////////////////////////
PacketSerialReadVersion:9:32: error: no matching function for call to 'RoboClaw::RoboClaw(SoftwareSerial*, int)'
9 | RoboClaw roboclaw(&serial,10000);
| ^
In file included from C:\Users\grego\Desktop\roboclaw(arduino)\examples\PacketSerialReadVersion\PacketSerialReadVersion.ino:5:
C:\Users\grego\Documents\Arduino\libraries\RoboClaw/RoboClaw.h:128:2: note: candidate: 'RoboClaw::RoboClaw(HardwareSerial*, uint32_t)'
128 | RoboClaw(HardwareSerial *hserial,uint32_t tout);
| ^~~~~~~~
C:\Users\grego\Documents\Arduino\libraries\RoboClaw/RoboClaw.h:128:27: note: no known conversion for argument 1 from 'SoftwareSerial*' to 'HardwareSerial*'
128 | RoboClaw(HardwareSerial *hserial,uint32_t tout);
| ~~~~~~~~~~~~~~~~^~~~~~~
C:\Users\grego\Documents\Arduino\libraries\RoboClaw/RoboClaw.h:24:7: note: candidate: 'constexpr RoboClaw::RoboClaw(const RoboClaw&)'
24 | class RoboClaw : public Stream
| ^~~~~~~~
C:\Users\grego\Documents\Arduino\libraries\RoboClaw/RoboClaw.h:24:7: note: candidate expects 1 argument, 2 provided
C:\Users\grego\Desktop\roboclaw(arduino)\examples\PacketSerialReadVersion\PacketSerialReadVersion.ino: In function 'void setup()':
PacketSerialReadVersion:16:3: error: 'rc' was not declared in this scope
16 | rc.begin(38400);
| ^~
C:\Users\grego\Desktop\roboclaw(arduino)\examples\PacketSerialReadVersion\PacketSerialReadVersion.ino: In function 'void loop()':
PacketSerialReadVersion:22:6: error: 'rc' was not declared in this scope
22 | if(rc.ReadVersion(address,version)){
| ^~
exit status 1
no matching function for call to 'RoboClaw::RoboClaw(SoftwareSerial*, int)'
///////////////////////////////////////////////////////////////////////////////////////
I've tried the ReadVersion code on an Arduino Uno and it works flawlessly, all the RoboClaw example codes do. I can't make sense of this error code.
- Basicmicro Support
- Posts: 1594
- Joined: Thu Feb 26, 2015 9:45 pm
Re: Roboclaw & Nucleo 64 Issues
You need to modify the example ot use the hardware serial port. The default uses SoftwareSerial which does not exist for Nucleo(or any non Atmel based Arduino as far as I know).