I just got a UNO Q 4 GB, and I am wondering if I can set UART1 (i.e. Serial()) to a baud rate of 1 Mbps? I am using straight ARDUINO IDE 2.3.7.
Thank you
I am not sure yet if the hardware supports that speed or not.
However for the most part, I found it mainly only works at 115200, as
currently that is what the zephyr debug monitor is configured to communicate at over the Serial object.
And at least with KiTTY on WIndow Serial.begin at any other speed, I don't see anything come out...
I am using a ROBOTIS BT-410 which restricts me to 57.6 Kbps and this worked fine (see enclosed pictures).
But my ultimate goal is to interface UART1 with a ROBOTIS DXL SHLD MKR so that I control DXLs with Dynamixel2Arduino library at 1 Mbps at half-duplex. And so far I have failed!
Have you tried this kind of project yet?
#include <Dynamixel2Arduino.h>
#define DXL_SERIAL Serial // On UNO Q, Pin 0 (RX) Pin 1 (TX)
// #define DEBUG_SERIAL Serial
const int DXL_DIR_PIN = 2; // DYNAMIXEL Shield DIR PIN (TX Enable)
const uint8_t DXL_ID = 1;
const float DXL_PROTOCOL_VERSION = 2.0;
Dynamixel2Arduino dxl(DXL_SERIAL, DXL_DIR_PIN);
//This namespace is required to use Control table item names
using namespace ControlTableItem;
void setup() {
// put your setup code here, to run once:
pinMode(LED_BUILTIN, OUTPUT);
// Set Port baudrate to 57600bps. This has to match with DYNAMIXEL baudrate.
dxl.begin(57600);
// Set Port Protocol Version. This has to match with DYNAMIXEL protocol version.
dxl.setPortProtocolVersion(DXL_PROTOCOL_VERSION);
// Get DYNAMIXEL information
dxl.ping(DXL_ID);
// Turn off torque when configuring items in EEPROM area
dxl.torqueOff(DXL_ID);
dxl.setOperatingMode(DXL_ID, OP_POSITION);
dxl.torqueOn(DXL_ID);
// Limit the maximum velocity in Position Control Mode. Use 0 for Max speed
dxl.writeControlTableItem(PROFILE_VELOCITY, DXL_ID, 0);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
// Please refer to e-Manual(http://emanual.robotis.com/docs/en/parts/interface/dynamixel_shield/) for available range of value.
// Set Goal Position in RAW value
dxl.setGoalPosition(DXL_ID, 1000);
delay(1000);
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(1000);
dxl.setGoalPosition(DXL_ID, 2000);
delay(1000);
}
But if I ran the above sketch with BT-410 (at 57.6K) instead of the DXL SHLD MKR(at 57.6K) then I could detect that some DXL packets are going through UART1: one “!Q” print out for each SetGoalPosition() command.
So somehow, my jumper wires were not set up right? Or that UART1 does not like to be manipulated as half-duplex?
It has been awhile since I used the DynamixelToArduino code base. That was with Teensy boards.
Max Baud on these boards:
Not sure, I know that on a different thread:
Evaluated Uno Q Router / Bridge Latency with MAX31855 - UNO Family / UNO Q - Arduino Forum
The fastest that would work between the two processors was supposedly
maybe 460800, but I don't know if that is true or not. And if it is not sure
if that is as fast as the ST... lpuart can output or if it is a limitation on the other
side with Python under the linux.
Also The Serial object, is a UART and not LPUART so may also be different.
But the underlying thing is not sure what the Zephyr console does if the Serial speed is changed.
I did try Serial at 460800
void setup() {
// put your setup code here, to run once:
Serial.begin(460800);
}
void loop() {
static uint32_t loop_count = 0;
Serial.println(loop_count++);
delay(1000);
// put your main code here, to run repeatedly:
}
And restarted SSH window at that speed and it appears to work,
137
138
139
140
141
142
143
144
145
1000000 appears to work as well. So there is hope
@Merlin513 - Have you tried out the Dynamixels on this yet? Looks like time for me to pull some out.
Not sure I have time today, but what some of my first steps would be to
see what comes out the TX/RX/DIR pins to see what is happening.
Assuming we get proper packet data coming out of the TX pin, then need to check with Scope or logic analyzer when the DIR pin changes. Often times with some boards, the code does not properly flush out all of the TX before it
switches the DIR pin, truncating the messages.
Not yet just normal servos
A lot depends on your computer and what it can support. It has to receive the data then decode it then display it. Also it is running several additional tasks (Linux, Mac, and Windoz) do that for sure.
With the said delay(1000) code, are you not blocking the MCU for 1 sec period? If not, then are you suspending the task for 1 sec period? If the later is true, then who helps to resume the task and how?
Not sure what you are asking here, yes the main thread is delayed by 1 second.
In the case of zephyr the kernel will resume it.
In the case of this sketch it is simply panning back and forth between two positions. With Dynamixel servos they control the actual movement.
You have clealy undrstood what I have asked and I have also got the answer. Thank you.
An update to my experiments yesterday.
I pulled out a Dynamixel Shield, that I had used several years ago on a Robot,
and I spare Hexapod Leg, I used for debugging and rigged up power with 5Amp 12v power wall wart and the like:
Sorry about the mess here including dust.
I hacked up their Ping example:
/*******************************************************************************
* Copyright 2016 ROBOTIS CO., LTD.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
#include <Arduino_RouterBridge.h>
#include <Dynamixel2Arduino.h>
#define DXL_SERIAL Serial
#define DEBUG_SERIAL Monitor
const int DXL_DIR_PIN = 2; // DYNAMIXEL Shield DIR PIN
const uint8_t DXL_ID = 1;
const float DXL_PROTOCOL_VERSION = 2.0;
Dynamixel2Arduino dxl(DXL_SERIAL, DXL_DIR_PIN);
//This namespace is required to use Control table item names
using namespace ControlTableItem;
void setup() {
// put your setup code here, to run once:
Monitor.begin();
// Use Serial to debug.
// DEBUG_SERIAL.begin(115200);
// Set Port baudrate to 57600bps. This has to match with DYNAMIXEL baudrate.
dxl.begin(1000000);
// Set Port Protocol Version. This has to match with DYNAMIXEL protocol version.
dxl.setPortProtocolVersion(DXL_PROTOCOL_VERSION);
}
void loop() {
// put your main code here, to run repeatedly:
DEBUG_SERIAL.print("PROTOCOL ");
DEBUG_SERIAL.print(DXL_PROTOCOL_VERSION, 1);
DEBUG_SERIAL.print(", ID ");
DEBUG_SERIAL.print(DXL_ID);
DEBUG_SERIAL.print(": ");
if(dxl.ping(DXL_ID) == true){
DEBUG_SERIAL.print("ping succeeded!");
DEBUG_SERIAL.print(", Model Number: ");
DEBUG_SERIAL.println(dxl.getModelNumber(DXL_ID));
}else{
DEBUG_SERIAL.print("ping failed!, err code: ");
DEBUG_SERIAL.println(dxl.getLastLibErrCode());
}
delay(500);
FindServos();
if (DEBUG_SERIAL.available()) {
while(DEBUG_SERIAL.available()) DEBUG_SERIAL.read();
DEBUG_SERIAL.println("*** Paused ***");
while(!DEBUG_SERIAL.available()) {}
while(DEBUG_SERIAL.available()) DEBUG_SERIAL.read();
}
}
char buffer[128];
DYNAMIXEL::InfoFromPing_t ping_info[32];
void FindServos(void) {
DEBUG_SERIAL.println(" Try Protocol 2 - broadcast ping: ");
DEBUG_SERIAL.flush(); // flush it as ping may take awhile...
if (uint8_t count_pinged = dxl.ping(DXL_BROADCAST_ID, ping_info,
sizeof(ping_info)/sizeof(ping_info[0]))) {
DEBUG_SERIAL.print("Detected Dynamixel : \n");
for (int i = 0; i < count_pinged; i++)
{
sprintf(buffer, " %u, Model:%d, Ver:%d\n", ping_info[i].id, ping_info[i].model_number, ping_info[i].firmware_version);
DEBUG_SERIAL.print(buffer);
#if 0
DEBUG_SERIAL.print(" ");
DEBUG_SERIAL.print(ping_info[i].id, DEC);
DEBUG_SERIAL.print(", Model:");
DEBUG_SERIAL.print(ping_info[i].model_number);
DEBUG_SERIAL.print(", Ver:");
DEBUG_SERIAL.println(ping_info[i].firmware_version, DEC);
#endif
//g_servo_protocol[i] = 2;
}
}else{
DEBUG_SERIAL.print("Broadcast returned no items : ");
DEBUG_SERIAL.println(dxl.getLastLibErrCode());
}
}
Getting some results:
, Model Number: .21060PROTOCOL 1, ID 0: ping succeeded!
Try Protocol 2 - broadcast ping: 1, Model:1060, Ver:42
Detected Dynamixel :
16, Model:1060, Ver:41
18, Model:1060, Ver:41
., ID : 01PROTOCOL 2ping failed!, err code:
3 Try Protocol 2 - broadcast ping:
1, Model:1060, Ver:42
16, Model:1060, Ver:41
Detected Dynamixel :
18, Model:1060, Ver:41
ping succeeded!12, ID .0PROTOCOL : 1060, Model Number:
Try Protocol 2 - broadcast ping:
16, Model:1060, Ver:41
18, Model:1060, Ver:41
Detected Dynamixel :
201., ID PROTOCOL
, Model Number: 1060ping succeeded!: Try Protocol 2 - broadcast ping:
16, Model:1060, Ver:41
18, Model:1060, Ver:41
Detected Dynamixel :
*** Paused ***
Shows some results from Logic Analyzer:
and V2 Ping
It does show a possible problem with my current servos/configuration
May play later with this. Have to remember how to reconfigure the servos.
Been a while!
Hello All, I very much appreciate all the hints/discussions, with help from ROBOTIS engineers, I found that I needed to ADDITIONALLY connect 3.3 V and 5 V from the UNO Q over to the DXL SHLD MKR in order to make all things work together. And they do work together even at 1 Mbps for UART1 (see enclosed picture).
As @KurtE managed to use UNO Q with the original DXL SHIELD which was specified for 5V GPIO, I just tried that option too, and it DOES WORK!
![]()
Glad you got it working!
Will play more later. May swap out the shield for some other adapter. I think I read it outputs 3.3v to IO pins, but should double check...
The ROBOTIS e-manual says that the original DXL SHIELD has a 5V TTL circuit which can be 5V tolerant (whatever that means).
It will be good for you to check out why the Q4 (3.3V TTL) works with the DXL Shield (5V TTL) - hopefully without any long-term bad effects on the UNO-Q4.
I need to save some money to get yours SALEAE Logic Analyzer. Very cool tool!
I think a lot of the STM32 processors have some +5v tolerance,
As I mentioned I will probably swap over to something else.
I do have one of the ones you have. I also could probably adapt over
to using an openCM 485 exp board, or one of my Teensy boards.
Will have to play!
Update
I was converting over to a different setup
and probably hit the higher voltage to the wrong place...
And heard a pop and that Q4 is now toast... Aargh... another one on order
Oh NO! So sorry to hear that. On my end, I was tinkering between UNO Q and good old 485-EXP! And to be safe I used XL-330s as I only need to power them at 5V (I am staying away from the 12V Robotis Actuators for now). Enclosed is a picture of my setup.
This setup does work for the EXP-485/XL-330 as well as for the UNO Q. The Power to the 485-EXP was ALSO POWERING the UNO Q via the 5V connection! (bonus during runtime) ROBOTIS engineers confirmed that it is “safe” to use 12 V servos with this set up.
When I put 12 V on my 485-EXP (from 2015), I got a surprise as my 3.3 V Pin measured 5.07 V!
Fortunately, I also found that I do not need the 3.3V pins connected between UNO Q and 485-EXP to make the Q work with ROBOTIS actuators.
I also noticed that in this configuration the Q only activates its MCU side (Red LED #3 is operating), the Blue LED #2 (i.e. MPU indicator) did not come on.
Ordered a new 485-EXP for just in case!
Looks like that the “design” approach used on the 485-EXP was way different from the ones used for the DXL SHIELD and DXL SHIELD MKR! But delighted that “ancient” tech (485-EXP) can still work with “modern” tech (UNO-Q).















