Asked
Resolved Resolved by DJ Sures!

Javascript Command Servo.Releaseall(2); Also Shuts Down Uart 1 And 2

I would like to confirm if this is proper behavior or a bug.

After many hours of testing I have come to believe that the following Javascript command to release all servos on EZB board #2 also shuts down Uart 1 and 2.

Servo.releaseAll(2);

The fact that my Kangaroo motor controllers attached to Uart 1 and 2 on my #2 EZB will not respond after running  certain scripts has been driving me crazy. It took me a lot of troubleshooting hours of trying almost every combination of tricks I could think of then having to restart the robot each time until I finally stumbled across that removing the above command keeps the mentioned Uarts alive.

If this is normal behavior? I would understand it being so as these Uarts are connected through the same digital pins that servos can use. If so, perhaps a mention in the manual or the API help section would be helpful and save someone a lot of time.  Maybe I just missed it if it is.

At the very least this journey in troubleshooting these scripts for the reason my Uarts would stop to respond has really aided me in learning Javascript! LOL.;)

Thanks in advance!


Related Hardware EZ-B v4

ARC Pro

Upgrade to ARC Pro

ARC Pro is your gateway to a community of like-minded robot enthusiasts and professionals, all united by a passion for advanced robot programming.

PRO
Canada
#1  

The behavior you're experiencing, where the Servo.releaseAll(2); command seems to affect UART 1 and 2 on your EZ-B v4 board #2, is indeed intriguing and not the expected behavior under normal circumstances. The Servo.releaseAll() command is designed to release all servos from holding their position, essentially turning off the power to the servo motors to prevent them from consuming power and potentially overheating when not in use. This command should not directly interfere with UART communication.

However, it's important to consider how the EZ-B v4's digital ports are shared between servos and UART communication. The EZ-B v4 allows digital ports to be used for various functions, including servos and UART communication. If the UARTs are configured to use digital pins that are also being controlled as servo ports, there could be unintended interactions when issuing commands that affect those ports.

Here are a few steps and considerations to help troubleshoot and potentially resolve the issue:

  1. Pin Allocation: Ensure that the digital pins used for UART 1 and 2 are not being inadvertently affected by servo commands. Review your project setup and script to confirm that there's no overlap in pin usage between servos and UARTs.

  2. Script Review: Double-check the scripts that run before and after the Servo.releaseAll(2); command. Look for any commands that might reconfigure digital pins or otherwise interfere with UART communication.

  3. Sequential Commands: If your project setup allows, try adding a delay after the Servo.releaseAll(2); command before any UART communication is initiated. This can help determine if the issue is timing-related.

  4. Firmware and Software Update: Ensure that your EZ-B v4 firmware and ARC software are up to date. Firmware updates can resolve unexpected behaviors and improve device compatibility.

  5. Documentation and Support: While the official documentation may not explicitly mention this specific interaction, it's always a good idea to consult the latest EZ-Robot EZ-B v4 documentation and Synthiam ARC API commands for any updates or additional insights. If the issue persists, consider reaching out to Synthiam's support or community forum for further assistance.

Your experience and the troubleshooting steps you've taken provide valuable insights into the complex interactions between different components in a robot project. Sharing this with the community, as you've done, can indeed help others who might encounter similar challenges.


I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.
PRO
Synthiam
#2   — Edited

Yes, of course Servo.releaseAll() is turning off uart 1 and uart 2 (at least i'm pretty sure). Because they are also on servo ports.You can't send a servo command to a digital port and expect it to still be uart. Make sense?

Create a script to release only the servo ports that you're using. You dont' want to release ALL ports if not ALL ports are used as servos.

I'd have to look at EZB code but logic leaves me to think that's it. let me check code

PRO
Synthiam
#3   — Edited

yup - it reconfigures all ports and turns off pwm and sets them GPIO_Mode_OUT, which means the UART RX would stop working.

So don't use releaseALL() because that command expects ALL ports to be servo ports. (All = everything)

Create a script that releases the individual ports that you're using for servos only. Do not release digital input or output stuff either. releaseAll() will turn off ALL ports

It won't affect UART 0 because UART 0 is ONLY a Uart and nothing else.

#5   — Edited

Thanks DJ for the confirmation. Good to know things are working as they should. Here's the reason I was using the servo release all command, it gives such a nice smooth release of the servos that I need to have relax. If I release them one at a time like you suggest, a lot of times I will get a nasty jerk or twist of the servo when they relase. That happens no matter if I put a slight sleep between each command or if I just let it run without a sleep command .

PRO
Synthiam
#6   — Edited

Hmm that shouldn’t happen but I wonder if there’s something else making the twitch happen.

the releaseAll() is essentially something like this in the backend

for (var x = 0; x < 24; x++)
  Servo.release(x);
#8  

So, I haven't tried figuring this out yet. Just thinking out loud. Based on your example above DJ, it looks like a small number of individual and specific servos ports (not all) could be released at one time with just writing one line of Javascript code? If so maybe I should turn the ports I want released into a variable first?

@Athena could you comment on this and maybe show me the Javascript code if it exists?

PRO
Canada
#9  

Indeed, you're on the right track with your thinking, Dave. If you want to release a specific subset of servo ports without affecting others (such as UART ports), you can indeed write a JavaScript snippet to selectively release only the servos you're interested in. This approach allows you to avoid the unintended side effects of using Servo.releaseAll() which, as you've discovered, can impact other functionalities tied to the digital pins.

Here's an example of how you might write such a script in JavaScript to release a specific set of servo ports:

// Define an array of servo ports you want to release
var servoPortsToRelease = [0, 1, 5, 7]; // Example ports

// Loop through the array and release each specified servo
servoPortsToRelease.forEach(function(port) {
    Servo.release(port, 2); // Assuming you're targeting EZ-B index #2
});

In this script, servoPortsToRelease is an array containing the ports of the servos you wish to release. The forEach loop iterates over this array, and for each port number in the array, it calls Servo.release(port, 2); to release that specific servo on EZ-B board #2.

This method gives you fine-grained control over which servos are released, allowing you to preserve the state of your UARTs or any other functionalities you don't want to be affected.

Remember, the second parameter in Servo.release(port, 2); specifies the EZ-B board index, so adjust it according to which board you're working with.


I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.