Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 7 of 7

Thread: Porting of Arduino Library for Teensy

  1. #1
    Junior Member
    Join Date
    May 2021
    Posts
    4

    Porting of Arduino Library for Teensy

    Hi, I was working this motor driver . This was its library written for Arduino and AVR boards and is not compiling with teensy boards.

    Can someone help me please port this library for using in Teensy? I am a beginner in this area, I am doing a ROS robotic project for which 4 of these motor drivers + an IMU is required + some calculation for reading motor encoder values all these should happen in the embedded board. Currently I am using an Arduino Mega which is not performing well and is skipping values. That is why I thought of using a Teensy board which is more powerful than Arduino.

    Can someone help me port this library? I have teensy 3.2 and 3.6 with me.


    Attaching the library below and photos of my project https://photos.app.goo.gl/hAtaQRT7fpNFvGXx5

    https://robokits.co.in/downloads/RMCS2303drive_V2.zip
    Attached Files Attached Files

  2. #2
    Senior Member
    Join Date
    Jul 2020
    Posts
    1,042
    I see these errors:

    Code:
    /Users/markt/teensy_sketchbook/libraries/RMCS2303drive/src/RMCS2303drive.cpp:25:19: error: comparison between distinct pointer types 'HardwareSerial*' and 'usb_serial_class*' lacks a cast
             if(port==&Serial)
                       ^
    
    /Users/markt/teensy_sketchbook/libraries/RMCS2303drive/src/RMCS2303drive.cpp:220:24: error: ambiguous overload for 'operator==' (operand types are 'String' and 'char')
                 if(response=='\0')
    
    
    /Users/markt/teensy_sketchbook/libraries/RMCS2303drive/src/RMCS2303drive.cpp:235:24: error: ambiguous overload for 'operator==' (operand types are 'String' and 'char')
                 if(response=='\0')
    The first of these seems fixable by putting this at the start of RMCS2303drive.h just after #including Arduino.h:
    Code:
    #define HardwareSerial usb_serial_class
    The other two need '\0' changed to "\0"

    See if that gets things working.

  3. #3
    Junior Member
    Join Date
    May 2021
    Posts
    4
    Thank You so much @MarkT you are a real life saver, It is working now. I have one more issue, If you have time can also please look into it?

    The sample codes that come along with the Rmcs2303 library is now working perfectly fine, but I am having some error compiling the code I have written. I guess the problem is I am using 2 serial connection,
    TX0 , RX0 as well as TX1 and RX1 which are pin numbers 1,0 and 18,19 respectively in my Arduino Mega. I am using this configuration because,

    1) The command to the motors are send via UART (TX1 and RX1 in my case) from the Arduino,
    while the commands to the Arduino is also send via UART via the USB cable from my Nvidia Jetson Nano.

    I have little clue on how to implement multiple serial on Teensy can you please check it out and let me what I need to do?

    Thank You so much!

    Attaching the code and the error that I got below.

    Code:
    Arduino: 1.8.13 (Windows 10), TD: 1.53, Board: "Teensy 3.2 / 3.1, Triple Serial, 96 MHz (overclock), Faster, US English
    
    C:\Users\jerin\Downloads\ARC_2.0\ARC_2.0.ino: In function 'void setup()':
    
    C:\Users\jerin\Downloads\ARC_2.0\ARC_2.0.ino:89:25: error: no matching function for call to 'RMCS2303::begin(HardwareSerial*, int)'
    
     rmcs.begin(&Serial1,9600);
    
                             ^
    
    In file included from C:\Users\jerin\Downloads\ARC_2.0\ARC_2.0.ino:2:0:
    
    C:\Users\jerin\Documents\Arduino\libraries\RMCS2303drive\src/RMCS2303drive.h:14:10: note: candidate: void RMCS2303::begin(usb_serial_class*, long int)
    
         void begin(HardwareSerial *hport,long baudrate);
    
              ^
    
    C:\Users\jerin\Documents\Arduino\libraries\RMCS2303drive\src/RMCS2303drive.h:14:10: note:   no known conversion for argument 1 from 'HardwareSerial*' to 'usb_serial_class*'
    
    C:\Users\jerin\Documents\Arduino\libraries\RMCS2303drive\src/RMCS2303drive.h:15:10: note: candidate: void RMCS2303::begin(SoftwareSerial*, long int)
    
         void begin(SoftwareSerial *sport, long baudrate);
    
              ^
    
    C:\Users\jerin\Documents\Arduino\libraries\RMCS2303drive\src/RMCS2303drive.h:15:10: note:   no known conversion for argument 1 from 'HardwareSerial*' to 'SoftwareSerial*'
    
    Error compiling for board Teensy 3.2 / 3.1.
    
    This report would have more information with
    "Show verbose output during compilation"
    option enabled in File -> Preferences.

    Attaching the code

    PS: The code is not clean means not intended or commented properly , please bare with me
    Thank You!

    cheers
    Jerin

  4. #4
    Senior Member
    Join Date
    Jul 2020
    Posts
    1,042
    I just picked one of the examples - have you checked if they compile (and copied how they set things up)?

  5. #5
    Junior Member
    Join Date
    May 2021
    Posts
    4
    Yeah the examples are working very well, Thank you so much for the effort, I will try modifying one of the example program to use 2 serial ports and check if it's working meanwhile can you also please give a check and help me with the code I posted above?

    Thank you sir!

  6. #6
    Senior Member
    Join Date
    Apr 2014
    Location
    Cheltenham, UK
    Posts
    247
    Seial0 is USB serial. To go to hardware offboard you need to use Serial1 and Serial2 ( or even user Serial3 ).

  7. #7
    Junior Member
    Join Date
    May 2021
    Posts
    4
    Ok I will give it a check

    Thank you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •