BasicMicroUK - Forums

www.basicmicro.co.uk
It is currently Fri Sep 21, 2018 2:35 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Roboclaw support on Teensy 3.1 - Also fix on Atmega32u4
PostPosted: Sun Feb 23, 2014 7:31 pm 
Offline
Master

Joined: Tue Nov 21, 2006 5:34 pm
Posts: 662
Recently I started to play around with some Teensy 3.1 boards and having fun. These little boards have an ARM processor that run at 96mhz with 4 serial ports (including USB). I am also having fun designing and fabricating my own carrier boards for these. But that is off topic. There are threads about this up on Lynxmotion and Trossen forums, such as: http://www.lynxmotion.net/viewtopic.php?f=26&t=9119

But while testing some of this stuff out, I found out the RoboClaw as well as the underlying support libraries like BMSerial do not work on the Teensy. With the help of Paul at PJRC(Teensy) as well as LinuxGuy, we are working up updating some of these libraries to work on the Teensy. While I am at it, I am putting some of the updated libraries up on my Orion github project (
https://github.com/KurtE/Orion/tree/master/Libraries ).

So far I have not uploaded a slightly modified version of Roboclaw library. There is one casting issue as well as a fault. I will if anyone is interested. Instead I uploaded a different version of the library, that instead of passing in the pin numbers to use, you instead pass in a pointer to a Stream object. Both HardwareSerial as well as SoftwareSerial as well as BMSerial are all derived from Stream. So you can simply create the RoboClaw object passing in something like &Serial3...

I have also uploaded the modified version of BMSerial, that currently works like it does for Arduino Due processors. That is if you pass in the IO pins for the TX/RX of a hardware Serial port it will use that Serial port. However in neither case does it work for bitbanging to other IO pins.

While looking over the changes that Pual did for the Teensy, I noticed that there is an issue in the code base for Arduino boards like the Leonardo and any others based on the Atmega32u4 (Arduino Micro, maybe Yun, maybe Tre), in that IO pins 0, 1 do not map to the Serial object, but instead Serial1. So I made I mod to my version to hopefully fix this.


Top
 Profile  
 
 Post subject: Re: Roboclaw support on Teensy 3.1 - Also fix on Atmega32u4
PostPosted: Wed Mar 05, 2014 10:12 pm 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 7:00 pm
Posts: 1316
Location: Temecula, CA
The software serial routines in BMSerial are just a modified version of SoftwareSerial which doesn't current support Due(eg arm). If someone writes a decent software bitbanged serial library for Due we'd be happy to get it added. For now the only option on Due(or other arm arduinos) is to use the hardware serial ports. I expect arduino hasn't don't a bitbanged library specifically because the arm based arduinos have many more hardware uarts so in theory don't need bitbanged serial.

_________________
Tech Support
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
 Post subject: Re: Roboclaw support on Teensy 3.1 - Also fix on Atmega32u4
PostPosted: Fri Mar 07, 2014 4:40 pm 
Offline
Master

Joined: Tue Nov 21, 2006 5:34 pm
Posts: 662
Yep - I agree on the Due, you should hook up things like the Roboclaw to one of the Hardware serial ports and the official version of BMSerial detects those pins and uses the Serial1, Serial2 and Serial3 objects when appropriate. My updates to this part also detect the right IO pins on Teensy 3.1s. Also as I mentioned the current code will not work properly on the Arduinos that are Atmega32u4 based like (Leonardo, Yun, Micro), where pins 0,1 do not map to Serial, but instead map to Serial1).

Note: Personally I prefer my version of your Roboclaw library that I pass in a pointer to a stream object. That way I can hook it up to whichever hardware that I like without having to change the library for some different processor. Example my board that is based on Atmega644p like the Arbotix board used in Trossen Robots.

Again off topic of Roboclaw, but my changes I mentioned also add support for BMPS2 on the Teensy. That is I detect that both Rx/Tx are on the same pin and it is the TX pin of the UART. I configure for Half duplex and added code to tell the system when to go between input mode and output mode. This is the same support I use to support AX servos on Teensy. As I look at the Due manual, I believe it has the same level of hardware support for half duplex. But uses a different mechanism to tell input vs output (you only enable one of these at a time). I have not tried doing any of this on the Due as I am not actively doing anything these days with a Due. Could try if someone is interested, but...

As for SoftwareSerial support Paul of PJRC(Teensy) has added output only support for Teensy in his version of SoftwareSerial. I thought about trying to add this into the official BMSerial as I do think this would be good to support some of the other devices like you led displays... But now looking at the websites I do not see any of these up there for sale, so maybe not worth worrying about.

Kurt

Edit: Actually looking back at the Arduino Due, I am not sure the USART supports half duplex their Universal Synchronous Receiver does...


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

phpBB SEO