Adafruit Feather M0 compile issue

General discussion of using Roboclaw motor controllers
Muskateer
Posts: 19
Joined: Tue Feb 16, 2016 10:24 am
Adafruit Feather M0 compile issue

Post by Muskateer »

I have an Adafruit Feather M0 with LoRa radio. It does not have software serial support.

The code will not compile.
I am trying to use pins 0 and 1 for Hardware serial. Here is a code example.
The following lines appear to be conflicts:
#include "BMSerial.h"
RoboClaw roboclaw(0,1,10000);

Error from Arduino_IDE Compiler:

Using library RoboClaw in folder: C:\Program Files (x86)\Arduino\libraries\RoboClaw (legacy)
Using library Servo at version 1.1.2 in folder: C:\Program Files (x86)\Arduino\libraries\Servo
exit status 1
no matching function for call to 'RoboClaw::RoboClaw(int, int, int)'

If I comment out and change the RoboClaw to the following then it will compile:
//#include "BMSerial.h" //Note: I believe BMSerial.h is redundante I think it has been included in NewSerial
RoboClaw roboclaw(0,1); //Use hardware serial pins 0 and 1. Adding Timeout parameter fails compilation.

What do I need to do to get Hardware serial to work? I think the timeout parameter would be nice if I can get it to work..
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: Adafruit Feather M0 compile issue

Post by Basicmicro Support »

Please download and use the latest arduino library. The latest version takes a SoftwareSerial or Serial pointer as an argument. See the bareminimum example for the syntax for use with a hardware serial port.
Muskateer
Posts: 19
Joined: Tue Feb 16, 2016 10:24 am
Re: Adafruit Feather M0 compile issue

Post by Muskateer »

I am pretty sure I have the latest software.
It compiles just fine with the bare minimum file if I select the Arduino Mega2560. But when I change it to the Adafruit Feather M0 with LoRa (Native USB support). The compilation fails. It does not like the include for the SerialSoftware.h; And it doesn't like the Roboclaw(&serial, 10000) command.
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: Adafruit Feather M0 compile issue

Post by Basicmicro Support »

You will need to check if software serial is supported on the Feather. Not all arduinos have software serial support(eg Due, Zero).

Is this the Adafruit Feather 32u4 Bluefruit LE module? Because that is based on the Atmel32u4(same chip as leonardo uses). That chip only supports software serial on a limited set of pins. You will need to look for an example of using software serial on the board and modify the roboclaw exmaple appropriately.
Muskateer
Posts: 19
Joined: Tue Feb 16, 2016 10:24 am
Re: Adafruit Feather M0 compile issue

Post by Muskateer »

Yes it is the same micro as the Zero. (From Adafruit: At the Feather M0's heart is an ATSAMD21G18 ARM Cortex M0 processor, clocked at 48 MHz and at 3.3V logic, the same one used in the new Arduino Zero.)

Therefor I need to use hardware serial, it sounds like.
I noticed if I change the roboclaw command to: RoboClaw roboclaw(&serial1, 10000), that the project will then compile properly as long as I comment out the SoftwareSerial.h include statement. Will it work like this? Or is this an unfortunate case where I chose the wrong micro and for some reason I absolutely have to use SoftwareSerial to use RoboClawl (which doesn't seem logical to me).
Maybe I can run it without using the RoboClaw library and just send the proper commands over hardware serial.
I really don't know, I am out of ideas but I really want to use the Feather it is small and has 32K of ram to support other items on this project such as GPS logging functions.
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: Adafruit Feather M0 compile issue

Post by Basicmicro Support »

Yes, you will need to use the hardware serial port and remove the softwareserial.h from the example to compile for ARM based arduinos. Also most ARM based arduinos have more than one hardware serial port, eg serial1,serial2,serial3...etc. You will need to find out what pins are for what ports and then wire it up accordingly.

Arduino doesnt support softwareserial on any ARM processors as far as I am aware.
Muskateer
Posts: 19
Joined: Tue Feb 16, 2016 10:24 am
Re: Adafruit Feather M0 compile issue

Post by Muskateer »

Thank You, that really clears things up. Everywhere I was reading you "Must use Software Serial with the RoboClaw Library." So, that is really a good to know information.
I did get it to compile without Software serial and by setting the Serial to Serial1 for RoboClaw. I am hoping to get to test it yet this weekend with 10 foot battery leads (10 Gauge and twisted). Unfortunately one thing I forgot to ask was in regards to the S1, S2 lines. I know one of them is 5 Volt tolerant. I only have 3.3 volts available I hope that works....I will look through the datasheet before I power it up. I know it won't hurt the circuit but I suppose it may not reach a valid high on the Receive line. I forgot to bring a level shifter with me.
Muskateer
Posts: 19
Joined: Tue Feb 16, 2016 10:24 am
Re: Adafruit Feather M0 compile issue

Post by Muskateer »

I believe I am talking to the roboclaw through Packet Serial using Hardware Serial. I am running at 38,400 baud through about a 6 foot twisted pair cable. Battery wire length is about 18 feet "for now" using home made 10 gauge twisted pair wiring. I have not connected any motors yet.
I am reading 12.4 volts main battery through the Ion Motion software.
However, via packet Serial all I am reading is "USB Rboclaw 2x45a v4.1.16" using the ReadVersion command. I have tried reading the Main Battery Voltage but it seems to lock up the serial1 port. As of yet, I have not gotten any other commands to work. I am not certain of the syntax. I would like to read some other items such as Logic Voltage, Main Battery Voltage, Temperature and a few other items.
I will not be using encoders, so that example doesn't help much.
I had to tie Battery Ground to my Arduino Feather M0 board. Tying logic ground from the RoboClaw did not seem to work.
Muskateer
Posts: 19
Joined: Tue Feb 16, 2016 10:24 am
Re: Adafruit Feather M0 compile issue

Post by Muskateer »

Currently I am running the electric trolling motor off of the RoboClaw via Hardware Serial. I am running it 10 seconds on and 2 seconds off.Speed setting of 64. Everything seems to be working good.
Setup: 18 feet of 10 gauge twisted pair for power wiring.
4 feet of 10 gauge wire for M1 (trolling motor).
I am reading the following:
Version information .
MainBatteryvoltage.

Unable to read temperature ...get a compiler error on the &temp symbol.'

Ripple: Measured ripple with a DVM set to AC is about 20mV.
Onboard Capacitors are not getting warm.
Battery Voltage:
RoboClaw measuring 12.7 Volts. Multimeter reading is about 12.5 volts.

Additional Info: I have no idea why I can't read the temperature, but I suspect it may be in the library. I don't know C well enough to try and fix it.
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: Adafruit Feather M0 compile issue

Post by Basicmicro Support »

Send a copy of your scketch to support@ionmc.com and I'll take a look at it.

Post Reply