PDA

View Full Version : 1Mhz? WHy?



Brooks
06-24-2016, 10:59 PM
I've been working on a bunch of different areas of my hexapod. One area I've been working on is parking itself after having received no active commands for a while. As a part of testing this, while it's moving, I've noticed that on occasion all 18 servos freeze. This happens to all 18 at the same time, and resetting the Arbotix doesn't "cure" the problem. A power reset does.

I currently suspect a mangled write of the pose (from writePose() in the BioloidController class). Looking into all this a bit more closely I see the servos are set to a 1Mhz data rate (RF land! I'll bet there's all kinds of problems with RF emissions), yet the pose message itself is only 62 bytes (620 bits) long. With the 33ms frame rate we get a 1.8% duty cycle.

Q1: Do we really need that high a data rate?
Q2: Has anyone else seen the "servo freeze" problem? I've made extensive changes to the code and believe it's a self-inflicted bug, but it never hurts to ask...

Xevel
06-25-2016, 06:02 AM
If you do not need it then sure you can try with lower data rates.

As for the freeze, I would recommend having a look at the packets sent on the bus to see why everyone of them stops. Use a usb adapter to dump data to a computer (any usb serial adapter thay can work at 1Mbps is ok, just connect its RX to the Data line), or better a logic analyzer (as it will also give you the timing of things, and possibly show noise too).

With a well-behaved controller you just never get the servos to freeze like that.

Brooks
06-25-2016, 10:26 AM
With a well-behaved controller you just never get the servos to freeze like that.

That's what I was afraid of!

I've just added the beginnings of multiplexer software so I can carry both the Commander and Console (getChar, print & println) data streams across the Arbotix-M serial hardware. My stub console-side code accepts & implements single-letter commands as if they came from the controller, so I can "drive" the hexapod while seeing what's logged. Hopefully this will let me figure out what's going on.

The good news is that now I have an excuse to buy a logic analyzer!

Thanks for your thoughts!

KurtEck
06-25-2016, 05:09 PM
The other thing is, wonder if you are getting some issue with one or more servos as you say, requires power cycle. rebooting does not clear...

As for debugging with Arbotix... (I use a Teensy :lol: ), But more serious, on the Arbotix, I know that the commander only outputs serial data, does not receive, so, I typically do, is to add Serial.print(xxx) statements on the Arbotix code, I then run a VB app I have where, I plug the commander into the PC, and put the XBee into a USB adapter also connected to the PC, and the VB app works, by receiving data from one port (Commander), and forward it to the XBee, anything that it receives from the XBee port, it displays in a listbox in the VB app... The app is nothing special (https://github.com/KurtE/DIY_XBee_DebugTerminal)

I think about adding some code in the app to interject debug commands, but have not done so, as again not doing much with Arbotix these days.

Brooks
06-26-2016, 07:36 AM
I've added servo-status monitoring and a audio-beep scheme so I can tell if the servos have gone wonky, and why. I've moved back from battery power to an external supply & 14 ga wire and haven't been able to reproduce the problem. So either I accidentally fixed a code bug or it's power related. Time will tell. For now I'll stay at 1mhz...

I've moved the Arbotix-M as far over on the hexapod as I can to make room for an Arduino Mega. I want the Mega for it's 4 uarts and ability to add shields with lots more uarts (for smart leg sensors). I'll hang the XBee Commander receiver off the mega and multiplex the XBee & console data streams into the Arbotix so I can do both at the same time.

Kurt, would you have used the Teensy instead of the Mega? The Mega seems straight-forward, but the Teensy's ARM processor is awfully tempting!

KurtEck
06-26-2016, 08:56 AM
Kurt, would you have used the Teensy instead of the Mega? The Mega seems straight-forward, but the Teensy's ARM processor is awfully tempting!
Without blinking! I have a few different megas around and have used them to debug some of the Bioloid stuff in the past as they do have additional UARTS... But remember they are still just 8 bit AVR processors running at 16mhz....

With the T3.2, I typically run at 120mhz, have 3 Uarts plus USB, and they do a great job of trying to make most every library work with them... As for driving AX servos, I have had good luck, with simple hookup where I tell the UART to go into half duplex mode, which does both TX and RX on one pin and the software controls the direction of that pin. But the T3.2 is a 3.3v processor, which is tolerant of +5v to IO pins. So the output on the IO pins a high is 3.3vs. This has worked fine for me. Another member Elmue has suggested another hookup which he says helps. Lately I have decided to make my boards ouput +5v on the AX-Bus by using buffer chip(s). Keep needing to get back to trying out my RPI hat version, but...

Currently I am spending more of my time testing a new Teensy Beta board. Can not post any images or the like, but these boards will be one inch longer than T3.2. Hardware floating point, 5 (or maybe 6) Uarts, multiple SPI and I2C busses, SDcard, USB, ... Currently doing most of my testing at 180mhz can go higher... More details up on pjrc forum...

Brooks
06-26-2016, 02:36 PM
I spent some time today looking at the Teensy 3.2. It's very tempting - I love the small footprint! I sure do wish it had mounting holes! [Edit: Never mind! I just found the breakout board on Tindie, complete with mounting holes].

Do you use the Teensyduino "sketch" approach, or program it from bare metal? And what do you use for editing/compiling/IDE?

KurtEck
06-26-2016, 03:37 PM
Typically I use Arduino IDE, it is not the greatest, but...

For editing Libraries and the like I am now converted over to use sublimetext 3.

There are other IDEs that others use like Visual Micro (https://forum.pjrc.com/threads/29191-Visual-Micro-with-Teensy-3-support-new-release) I believe there are plugins that work with Eclipse...

Yep lots of stuff up on Tindie. Also Sparkfun sells breakout board: https://www.sparkfun.com/products/13288

OSHPark sells T3.2 for $17, not sure if anyone has published boards up there. Mine are up on my github with zip files that can be sent to OSHPark or Seeedstudio...

jwatte
06-26-2016, 05:29 PM
FWIW: Another reason to use a high bit rate is that you can squeeze other commands into each time slot, such as polling the servos for status.
Plus you can run at a faster update rate -- 60 Hz is nice!
Yes, Teensies are nice! As is the OpenCM 9.04, if you specifically are talking to Dynamixel servos. Half the price! Older version of the IDE; has mounting holes; TTL bus direction/driing already integrated; somewhat crummier base library code.

KurtEck
06-26-2016, 06:08 PM
Yep - I have tried around 100hz without problems..

As you mentioned the OpenCM 9.04 (http://www.trossenrobotics.com/open-cm-904c) is also nice at $19.90 or about the same price as T3.2, but it is already setup for XL servos. You can use AX servos by making an adapter cable... Has anyone tried converting it over to use current Arduino environment?

tician
06-26-2016, 07:13 PM
STM32 has essentially no arduino support except that derived from Maple. The only active work I am aware of is by Roger Clark (https://github.com/rogerclarkmelbourne/Arduino_STM32) and company using an arduino-1.5-ified version of the maple core (full support only for STM32F103 like in Maple and OpenCM). The many STM32 Nucleo boards are compatible with Arduino-R3 shields, but do not have any Arduino support provided by ST (only mbed and gcc/Keil/IAR/etc.). Basically, no one is getting paid to adapt the ST hardware libraries for the STM32 to the core interfaces of the Arduino, so not the greatest progress being made.

jwatte
06-27-2016, 10:54 AM
Actually, the OpenCM 9.04-A is $9.90, and I have a bunch of 100 mil headers and Molex headers for the AX bus laying around, so I don't need the fully populated version. Also, the bag of parts to convert 9.04-A to fully populated is only $5, so board+parts is $14.90, but you have to solder.

Don't get me wrong -- I have many Teensy 3 boards (3.0, 3.1, and 3.2.) Just for the particular case of talking to Dynamixel servos, the OpenCM fits the bill very well.
Regarding modernizing the IDE -- it should be possible, especially with the "board manager" in the modern Arduino IDE, but the Robotis people don't seem very strong in the software updating department, so I wouldn't hold my breath :-(