SOLO Arduino Library – Hello World

Introduction

In this article, we would like to help with the first step in order to make communication between SOLO and Arduino using our Arduino library that works on top of digital protocols. Using this library you are able to send complex orders to SOLO using protocols such as UART and CANopen.

We will start to discuss the Arduino setup and then explain the UART and CANopen alternatives as they will change the schematic between Arduino and SOLO plus a couple of code lines! We will start with UART which is easy in terms of Hardware demands and we will finish with the CANopen protocol as the suggested one in terms of quality of communication but with the throwback of requiring an Arduino Shield as not on board protocol supported by Arduino.

Is also possible to access the Code documentation here, which lists in detail the Library code

Arduino IDE

In order to program your Arduino, you need an IDE capable of compiling and flashing your Arduino. Alternatives are possible, but we stick to the official Arduino IDE over our examples.

Include The Library

In order to use the library you first need to include the library in the Arduino IDE. You can do it in the Arduino IDE with Sketch>include Library> Manage Libraries… >SOLOMotorControllers > Install, As in the image show

SOLO Arduino Library - Hello World 1

After restarting the Arduino IDE is also possible to see our example in the Arduino IDE File>Examples>SOLOMotorControllers> as show in the image too

SOLO Arduino Library - Hello World 2

Manually Include The Library

Manually is possible to install the library following this step:

1. Download the library from our GitHub repo:

SOLO Arduino Library - Hello World 3

2. Include the library in the ARDUINO IDE*:

2.1. Unzip the downloaded library.

2.2. Create a new zip folder and insert on it the file you find in the SOLO-motor-controllers-ARDUINO-library/src (the name can be “SOLO”)

2.3. In the Arduino IDE go to Sketch > Include Library > Add.Zip Library.. And selected the zip file created in the previous step 2.2

SOLO Arduino Library - Hello World 4

*A deeper documentation on how to include the library is possible to be found on the Arduino website.

3. At this point when you compile a sketch that include the SOLO ARDUINO library, it will succeed.

SOLO Arduino Library - Hello World 5

UART

The library supports the UART protocol, which is used to send and receive packet information. The protocol itself is one of the most common and widespread protocols thanks to the simplicity of use and implementation. The trade-off of simplex protocol and cheaper hardware requirements is the stability of the protocol itself, as it does not prevent communication errors or it is not designed for network systems or for high-density communication.

Tips

As a suggestion for a stable and quality solution, we invite users that choose the UART protocol to use the functions of reading and setting with thrift as they will reduce the performance of the system, as the protocol itself will distract SOLO to the main goal of the motor motion.

SOLO Controllers Configuration

SOLO devices are able to use the UART protocol with different Baud Rates that define the speed with which the communication happens.
A high Baud Rates determinate a faster communication and a less performance demand on SOLO, for this reason, the default UART Baud Rate for solo is set to 937500 but is possible to be changed it in the Motion Terminal, in the section: Action / Configuration / UART Line baud-rate[bits/s]*

If the SOLO has a different baud rate than ARDUINO the communication will not work. Is possible to change the ARDUINO baud rate directly using the library, as in the construction line you can set the baud rate.

Arduino Uno Tips

As probably a lot of users will start to work with Arduino Uno is important to say that Arduino Uno support only a slower baud rate of 115200, so you must change the baud-rate of your SOLO device and restart it in order to align SOLO with the limitation of Arduino. The baud rate will be saved in the SOLO memory, so it is not needed to repeat this process every SOLO restart.

Arduino Considerations

We see higher baud-rate can be not well handled by Arduino and make the communication and the library not work well.

Arduino Note

NOTE 1: Whenever you want to program your ARDUINO UNO board through the ARDUINO IDE, YOU need to disconnect the UART_RX of ARDUINO UNO, by not doing this, you might get some errors in ARDUINO IDE during uploading the code.

( In ARDUINO UNO, there is only 1 line of UART which is shared between the UART to USB convertor of the ARDUINO board itself which is also used for flashing the ARDUINO UNO board as well. To know more, read this post on the ARDUINO website. )

NOTE 2: For Arduinos rated at +5V, to have a consistent start-up while Arduino is connected to SOLO, you need to make sure that the +5V output of SOLO is also connected to the +5V of Arduino

(Arduino might disturb SOLO during boot-up stages due to over-current drained from TX and RX lines.)

Schematic

In order to have communication between Arduino and SOLO we need to connect the 2 devices.

Over the UART protocol we need to have this general condition and connect this pinout:
Device 1 TX to Device 2 RX
Device 2 RX to Device 1 RX
GND Device 1 to GND Device 2

*Device 1 can be ARDUINO or SOLO, the same for Device 2.

ARDUINO models have different pin numbers and locations to be used. And some models have more than 1 UART protocol line to be used. A reference here.

Wirings

SOLO UNO wiring

SOLO MINI wiring

Tips

We suggest not to use the default serial line of the Arduino as it can be shared with USB port of it! But what does it mean in practice?
If you run a program, using the default serial line, printing command to the serial monitor and use our library, you will see a lot of ??? in the serial monitor. That symbols are in reality communication shared between SOLO and Arduino. It’s not only hard to read the serial monitor, but all the text printed using Serial are also going inside the communication between the 2 boards creating noise and extra pressure over the protocol. If the Serial print is highly used it can lead to a complete distortion of the normal communication between the devices. In this case, the suggestion is to reduce the character to be printed in the serial monitor or to use a different Serial line considering also changing the type of ARDUINO used as ARDUINO Uno has only one option but Mega, Due and other models have different UART lines.

Example Code

Is possible to see example codes in the example folder of the repository.

For this time we will use this code:

The previous code will simply print the temperature read from SOLO board. 

Is also interesting to share with you a bit of code related to the alternative in the construction of the SOLO class that gives the possibility to change the parameters of the protocol. 

CANopen

For the most demanding and industry-based applications, the library supports the CANopen protocol, which can be used as a protocol between Arduino and SOLO, simple to use as the UART section of the library. In nutshell, the protocol is much more strong in comparison to UART, able to support high-intensity communication, error handling, and networking. The throwback of this will be the requirement of extra hardware as Arduino doesn’t have it embedded, so an Arduino shield board is required. SOLO has the CAN on board so it’s self-sufficient if used in different CANopen environments rather than Arduino.

As the CANopen is not on board for ARDUINO we choose to develop the protocol on top of the MCP2515 chip that is available for Arduino in several formats as a shield or as an external board.

The compatible solutions are: CAN-BUS Shield V2.0 or Arduino MKR CAN Shield, during this article we will give more visibility to the CAN-BUS Shield V2.0 as it looks reasonable more convenient for Arduino Uno users.  

SOLO Controllers Configuration

If the SOLO has a different baud rate than ARDUINO the communication will not work. Is possible to change the ARDUINO baud rate directly using the library, as in the construction line you can set the baud rate. You can change the SOLO baudrate in the Motion Terminal, in the section: Action / Configuration / CANopen baud-rate[kbits/s]*

Schematic

In order to have communication between Arduino and SOLO we need to connect the 2 devices.

Over the CAN open protocol we need to have this general condition and connect this pinout:
Device 1 CANH to Device 2 CANH
Device 2 CANL to Device 1 CANL
GND Device 1 to GND Device 2

*Device 1 can be Arduino or SOLO, the same for Device 2.

Wirings

SOLO UNO wiring

SOLO MINI wiring

Example Code

Is possible to see example codes in the example folder of the repository.

For this time we will use this code:

The previous code will simply print the temperature read from SOLO board. 

Is also interesting to share with you a bit of code related to the alternative in the construction of the SOLO class that gives the possibility to change the parameters of the protocol. 

Errors

Communication errors can happen for a lot of reasons and thinking the communication will be every time successful can not be the correct approach for every application. So here is an example that shows how to check possible errors, this will help to make code more resilient. .

*Error handle have no difference between UART and CANopen
* The Get and Set functions have no difference between UART and CANopen
If you are stuck, here is a simple list a common reason:
– If SOLO E2 led is not blinking there are some issues and a proper power cycle of SOLO is needed
– If communication has an issue check that SOLO and Arduino have the correct baud-rate setup

Final Tips

As you probably get a lot of possibilities are given within the library, you can use different Arduino boards or different protocols (UART, CANopen) too, and most of the considerations are based on your specific requirements and constraints but as general considerations, we personally overall suggest to use CANopen protocol using Arduino shield + Arduino Uno, and when you have space or hardware constraints we suggest to evaluate the UART protocol using Arduino Due or similar + a light usage of the communication.

Share This

Share This

Share this post with your friends!