Forum Rule: Always post complete source code & details to reproduce any issue!
Page 1 of 3 1 2 3 LastLast
Results 1 to 25 of 65

Thread: W.A.L.T.E.R. 2.0 and the Teensy 3.1

  1. #1
    Member geekguy's Avatar
    Join Date
    Feb 2014
    Location
    Beaverton, OR
    Posts
    66

    W.A.L.T.E.R. 2.0 and the Teensy 3.1

    I have been back to working on W.A.L.T.E.R. 2.0 for a few weeks now. I'm currently using an Arduino Mega ADK to control the locomotion subsystem and reactive behaviors. I just got my first Teensy3.1 boards, and thought it would be cool to see how much of my code would work on them. I don't expect any of it to really work 100% correctly, and know that I will have to make modifications to get everything working right.

    My code doesn't do anything unusual, but it does depend on several Adafruit libraries for sensors and displays, which I have wired up on a solder less breadboard. It's all I2C stuff. I've run this stuff with my Arduino Mega ADK, as well as a Raspberry Pi, and BeagleBone Black (both in Python), so am confident I can eventually get it all working on the Teensy3.1 too.

    8-Dale

  2. #2
    Senior Member
    Join Date
    Jun 2013
    Location
    So. Calif
    Posts
    2,828
    I apologize, but neither I or Google could find what a W.A.L.T.E.R. 2.0 is?

  3. #3
    Member geekguy's Avatar
    Join Date
    Feb 2014
    Location
    Beaverton, OR
    Posts
    66
    Quote Originally Posted by stevech View Post
    I apologize, but neither I or Google could find what a W.A.L.T.E.R. 2.0 is?
    Try W.A.L.T.E.R. 2.0 on the Lynxmotion Forums.

    8-Dale

  4. #4
    Member geekguy's Avatar
    Join Date
    Feb 2014
    Location
    Beaverton, OR
    Posts
    66
    I have a version of my IMU Test sketch that compiles clean for my Teensy 3.1 now. The next step is to check my display and sensor breadboard out to make sure it is all working. My kitty sometimes likes to sabotage my circuits, so I have to keep double checking them. Since everything on the breadboard is I2C, I am hoping everything will work out reasonably.

    All of my code is in Git at W.A.L.T.E.R. 2.0 repo or my SBC repo.

    8-Dale
    Last edited by geekguy; 02-07-2014 at 10:48 PM. Reason: Added Git repo URLs.

  5. #5
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    21,825
    Are there any photos or even rough sketches of Walter might look like?


    Edit: if you find any Adafruit library that does not "just work" on Teensy 3.1, please let me know the details? I'll fix it.
    Last edited by PaulStoffregen; 02-07-2014 at 11:36 PM.

  6. #6
    Member geekguy's Avatar
    Join Date
    Feb 2014
    Location
    Beaverton, OR
    Posts
    66
    Quote Originally Posted by PaulStoffregen View Post
    Are there any photos or even rough sketches of Walter might look like?
    Yes, I have quite a few pictures of W.A.L.T.E.R. 2.0., but your forum software won't let me upload any of them. If I find any libraries that don't work, I will let you know.

    8-Dale

  7. #7
    Quote Originally Posted by PaulStoffregen View Post
    Are there any photos or even rough sketches of Walter might look like?


    Edit: if you find any Adafruit library that does not "just work" on Teensy 3.1, please let me know the details? I'll fix it.
    And that right there is why I am so quick to support you and Limor Fried.

    Cheers

  8. #8
    Member geekguy's Avatar
    Join Date
    Feb 2014
    Location
    Beaverton, OR
    Posts
    66

    Talking

    Quote Originally Posted by Wirelessmonk View Post
    And that right there is why I am so quick to support you and Limor Fried.

    Cheers
    It's the same here! I buy a lot of stuff from Adafruit because it's great stuff and just works, and because Lady Ada does so much for the community. Paul and Robin are the same way, and they are practically right in my backyard - about 12 miles from me as the crow flies. I like to support local businesses, especially when they have the integrity of Paul and Robin.

    8-Dale

  9. #9
    Member geekguy's Avatar
    Join Date
    Feb 2014
    Location
    Beaverton, OR
    Posts
    66
    I just made a place for a Teensy3.1, right next to the display and sensor breadboard on W.A.L.T.E.R. It sure does look small, compared to the Arduino Mega ADK board right next to it!

    8-Dale

  10. #10
    Member geekguy's Avatar
    Join Date
    Feb 2014
    Location
    Beaverton, OR
    Posts
    66
    Quote Originally Posted by PaulStoffregen View Post
    Are there any photos or even rough sketches of Walter might look like?
    I just created a Flikr account for pictures. Let me know if this works.

    8-Dale

  11. #11
    Member geekguy's Avatar
    Join Date
    Feb 2014
    Location
    Beaverton, OR
    Posts
    66
    I connected my Teensy 3.1 up to the display and sensor breadboard on W.A.L.T.E.R. 2.0. So far, both displays (seven segment and matrix 8x8) work. The DS1307 real time clock also works.

    I've decided to go for it, and convert all my code for the Arduino Mega ADK board to run on the Teensy 3.1. I am going to have issues I will have to fix, including in the Adafruit libraries, and will have a lot of questions. Right now, I'm trying to figure out why TeensyDuino can't find the Adafruit_BMP085_Unified.h file - it's right where it is supposed to be. This problem is in the Adafruit_10DOF_Unified.h file.

    I'll get back to this after I get some more calories into my body.

    8-Dale

  12. #12
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    21,825
    Quote Originally Posted by geekguy View Post
    Right now, I'm trying to figure out why TeensyDuino can't find the Adafruit_BMP085_Unified.h file - it's right where it is supposed to be. This problem is in the Adafruit_10DOF_Unified.h file.
    If you turn on verbose info in File > Preferences, you'll get the exact compiler commands. Sometimes the full pathnames of the files in those commands help to show if it's using the wrong file.

  13. #13
    Member geekguy's Avatar
    Join Date
    Feb 2014
    Location
    Beaverton, OR
    Posts
    66
    Edit: I was wrong. My Teensy 3.1 is being programmed.

    8-Dale
    Last edited by geekguy; 02-09-2014 at 04:31 AM. Reason: Being wrong

  14. #14
    Member geekguy's Avatar
    Join Date
    Feb 2014
    Location
    Beaverton, OR
    Posts
    66
    Quote Originally Posted by PaulStoffregen View Post
    If you turn on verbose info in File > Preferences, you'll get the exact compiler commands. Sometimes the full pathnames of the files in those commands help to show if it's using the wrong file.
    This has helped quite a bit so far!

    8-Dale

  15. #15
    Member geekguy's Avatar
    Join Date
    Feb 2014
    Location
    Beaverton, OR
    Posts
    66
    There is a bug in the version of RTClib I am using (from Adafruit). It still claims the RTC is not running, even when it is. This is not good. I've been testing with my Arduino Mega ADK (a known environment) board to make sure everything on the display and sensor board is working.

    I thought I had fixed the bug for the Teensy 3.1 RTClib, but I didn't. It is now fixed! Now, I am going to go through the other copies I have of this library and make sure they all have my fix.

    8-Dale

  16. #16
    Member geekguy's Avatar
    Join Date
    Feb 2014
    Location
    Beaverton, OR
    Posts
    66
    OK, I have a clean build of my Navigation3_Displays sketch for the Teensy 3.1 now. I had to remove all references to the BMerial and RoboClaw libraries, because they are just not compatible with the Teensy 3.1 right now. The BMSerial library is based on SoftwareSerial (formerly NewSoftSerial).

    Here is the relevent part of the opening comment from BMSerial.h:
    Code:
    Modified version of SoftwareSerial.cpp (formerly NewSoftSerial.cpp) -
    Multi-instance software serial library for Arduino/Wiring
    -- Interrupt-driven receive and other improvements by ladyada
       (http://ladyada.net)
    -- Tuning, circular buffer, derivation from class Print/Stream,
       multi-instance support, porting to 8MHz processors,
       various optimizations, PROGMEM delay tables, inverse logic and
       direct port writing by Mikal Hart (http://www.arduiniana.org)
    -- Pin change interrupt macros by Paul Stoffregen (http://www.pjrc.com)
    -- 20MHz processor support by Garrett Mace (http://www.macetech.com)
    -- ATmega1280/2560 support by Brett Hagman (http://www.roguerobotics.com/)
    
    -- Added support for half duplex single pin operation
    -- Added readln,readdec,readhex,readbin
    -- Added read timeout option
    I have no idea at present how best to proceed with this. I'm not sure whether I should just work from the RoboClaw library, and ignore BMSerial altogether, or maybe even write my own RoboClaw library just for the Teensy 3.1. Both alternatives seem like a lot of work, so I want to pick the right path to go down.

    My gut tells me that writing a Teensy 3.1 specific version of the RoboClaw library wouldn't necessarily be the best route to go. I'd prefer any code I write to be reusable for all platforms.

    Feedback welcome!

    8-Dale

  17. #17
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    21,825
    Quote Originally Posted by geekguy View Post
    I had to remove all references to the BMerial and RoboClaw libraries, because they are just not compatible with the Teensy 3.1 right now. The BMSerial library is based on SoftwareSerial (formerly NewSoftSerial).
    Could you post links for those libraries? I'll take a look...

  18. #18
    Member geekguy's Avatar
    Join Date
    Feb 2014
    Location
    Beaverton, OR
    Posts
    66
    Quote Originally Posted by PaulStoffregen View Post
    Could you post links for those libraries? I'll take a look...
    OK, wonderful!

    Here are the RoboClaw and BMSerial libraries. There is other stuff in the archive too, but I don't need to use it.

    Right now, I'm trying to get the RoboClaw library to work with NewSoftSerial, since BMSerial is based on that. It would be nice to have the option of either using a software serial or hardware serial port for RoboClaw. My original intention is to have the RoboClaw 2x5 controller on Serial3. I have the SSC-32 on Serial2.

    Thanks much for your time, Paul! I know you're very busy.

    8-Dale

  19. #19
    Member geekguy's Avatar
    Join Date
    Feb 2014
    Location
    Beaverton, OR
    Posts
    66
    I have finally connected my display and sensor breadboard to the Teensy 3.1!!

    First, the good news:

    The BMP180 Temperature/Pressure (part of the 10DOF IMU breakout board) sensor is working fine.

    The TCS34725 RGB color and TMP006 heat sensors are working fine.

    The Parallax PING and Sharp IR range sensors are working great.

    I have communication with the SSC-32 Servo controller on HardwareSerial2().

    I am using my versions of the Adafruit_10DOF_Unified (Hybotics_10DOF_Unified) and Adafruit_BMP085_Unified (Hybotics_BMP180_Unified) libraries, and they are working.

    Now, the bad news:

    The L3GD20 Gyro (part of the 10DOF IMU breakout board) does not seem to work, apparently it is not detected - commented all Gyro related code out. I will look at the Adafruit_L3GD20 library and see if I can find any issues.

    I am getting readings from the LMS303DLHC (part of the 10DOF IMU breakout board) Accelerometer and LMS303DLHC Magnetometer (Compass), but am not sure they are correct. More testing andvalidation is needed.

    I have also created a version of Paul's software serial library (Hybotics_SoftSerial), but it does not build clean. A table needs to be created for 48 MHz and 96 Mhz speeds, in this format:

    Code:
    static const DELAY_TABLE PROGMEM table[] = {
      //  baud    rxcenter    rxintra    rxstop  tx
      { 115200,   3,          21,        21,     18,     },
      { 57600,    20,         43,        43,     41,     },
      { 38400,    37,         73,        73,     70,     },
      { 31250,    45,         89,        89,     88,     },
      { 28800,    46,         98,        98,     95,     },
      { 19200,    71,         148,       148,    145,    },
      { 14400,    96,         197,       197,    194,    },
      { 9600,     146,        297,       297,    294,    },
      { 4800,     296,        595,       595,    592,    },
      { 2400,     592,        1189,      1189,   1186,   },
      { 1200,     1187,       2379,      2379,   2376,   },
      { 600,      2379,       4759,      4759,   4755,   },
      { 300,      4759,       9523,      9523,   9520,   },
    };
    There are also other issues I don't know how to correct, because I've never done any serial port programming. If this can be fixed, I might be able to use this serial library to make the RoboClaw library work. I have the RoboClaw 2x5 Motor Controller set to be on HardwareSerial3(). I'll need to use a Software Serial port for the XBee and any other serial devices.

    Overall, I am pretty happy with these first results of running the code for W.A.L.T.E.R. 2.0 on the Teensy 3.1! This is all basically out of the box! I just transferred the connections for everything from the Arduino Mega ADK directly over to the Teensy 3.1. Of course, I had to adjust settings in the header file to accomodate the hardware differences on the Teensy 3.1, but that was easy.

    8-Dale

  20. #20
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    21,825
    I took a quick look at these libraries.

    BMSerial has support for using real hardware serial on Arduino Due. I just added a couple #defines to use that on Teensy 3.1. You must use pins 0+1, or 7+8 or 9+10.

    RoboClaw had some va_arg. I tried a simple fix, but I don't have the hardware to verify if this really works. It does at least compile.
    Attached Files Attached Files

  21. #21
    Member geekguy's Avatar
    Join Date
    Feb 2014
    Location
    Beaverton, OR
    Posts
    66
    Quote Originally Posted by PaulStoffregen View Post
    I took a quick look at these libraries.

    BMSerial has support for using real hardware serial on Arduino Due. I just added a couple #defines to use that on Teensy 3.1. You must use pins 0+1, or 7+8 or 9+10.

    RoboClaw had some va_arg. I tried a simple fix, but I don't have the hardware to verify if this really works. It does at least compile.
    Thanks very much, Paul!

    I will check these out today. I just have to move the RoboClaw connection over to the Teensy 3.1. Everything else is already connected to it.

    8-Dale

  22. #22
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    6,632
    Hi Dale and Paul,

    My quick look through, I believe the changes you made were to make it work like the Due that if you are on a hardware port, it will use that code instead, which is great. But if not, it will still try to use the software serial code and its timing tables. But l am now looking at the real SoftwareSerial code base, you have it special cased to handle both going to a hardware serial port as well as to do software bit banging to the Teensy 3.x. So Dale, have you tried to simply replace BMSerial with SoftwareSerial? If not I would suggest trying it. I might give it a try later. Looking at my earlier Rover code on the Arduino using the roboclaw, I see that I was not using their library at the time. Also looks like I was still into using the streaming library :lol: ...
    Code:
    void PACKETS_OneArg(byte bCmd, byte bArg) {
        byte bCRC = (PACKETS_ADDRESS + bCmd + bArg) & 0x7f;    // calculate the checksum 
        PacketSerial << _BYTE(PACKETS_ADDRESS) << _BYTE(bCmd) << _BYTE(bArg) << _BYTE(bCRC);
    }
    
    inline void PACKETS_DriveForwardM1(byte bVal) {
        PACKETS_OneArg(0, bVal);
    }

  23. #23
    Member geekguy's Avatar
    Join Date
    Feb 2014
    Location
    Beaverton, OR
    Posts
    66
    Quote Originally Posted by KurtE View Post
    Hi Dale and Paul,
    Hi Kurt! We are everywhere!

    Quote Originally Posted by KurtE View Post
    So Dale, have you tried to simply replace BMSerial with SoftwareSerial? If not I would suggest trying it. I might give it a try later. Looking at my earlier Rover code on the Arduino using the roboclaw, I see that I was not using their library at the time. Also looks like I was still into using the streaming library :lol: ...
    Yes, that was the first thing I tried. I tried just plugging in various versions of a software serial library, including SoftwareSerial, NewSoftSerial, etc. I'm pretty sure I did it right. It did not work. Serial port programming is definitely not my strong point though.

    I'm going to transfer the last connection (the RoboClaw 2x5) from the Arduino Mega ADK board over to the Teensy 3.1 today, adjust code accordingly, and test Paul's fixes to the BMSerial and RoboClaw libraries.

    Then I have to figure out why the Adafruit_L3GD20 (Gyroscope), and Adafruit_LSM303DLHC_Unified (Accelerometer and Magnetometer) libraries don't seem to be working right. There might be some CPU speed specific stuff in them that has to be adjusted. I know I have good I2C communication with everything, because the other Adafruit stuff is just working as it should.

    8-Dale

  24. #24
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    21,825
    Any word if the mods I posted on reply #20 actually work? I don't have the real hardware here for testing, but at least that code compiles and I believe it follows the original programmer's intentions.

    If it does work, maybe we can get the Basic Micro folks to merge the changes back to their official version?

  25. #25
    Member geekguy's Avatar
    Join Date
    Feb 2014
    Location
    Beaverton, OR
    Posts
    66
    Quote Originally Posted by PaulStoffregen View Post
    I took a quick look at these libraries.

    BMSerial has support for using real hardware serial on Arduino Due. I just added a couple #defines to use that on Teensy 3.1. You must use pins 0+1, or 7+8 or 9+10.

    RoboClaw had some va_arg. I tried a simple fix, but I don't have the hardware to verify if this really works. It does at least compile.
    I noticed you addied two more parameters to the RoboClaw constructor:

    uint32_t tout
    bool doack

    Are there specific values I should be using for these? Should I have doack set to true?

    I just created a version of my W.A.L.T.E.R. 2.0 navigation code that uses your new BMSerial and RoboClaw libraries. I added dummy values for tout and doack just so I could do a test build, and everything built and loaded into the Teensy 3.1.

    I've uncommented all the RoboClaw related code and switched the RoboClaw serial connection over to the Teensy 3.1. I'm ready to start testing now! Apparently the Orion folks changed the name of at least two routines, because I had to change a couple calls in my code.

    Everything builds and loads into the Teensy 3.1 now!

    8-Dale

Posting Permissions

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