Asked
Resolved Resolved by DJ Sures!

System Exception With Wheel Encoder Counter Skill

Could someone help me understand why I am getting this exception with the Wheel Encoder Counter skill?

  1. I uploaded the firmware DJ's UNO Firmware with Wheel Encoder Counter (Feb 8, 2019) on my Arduino UNO from this link: Arduino Uno Firmware by following the steps in this tutorial: Connecting Arduino to ARC.

  2. I connected the wheel encoders to port D2 and D3 on the UNO.

  3. I connected my UNO to the EZ-B via UART, making sure I connected the TX to RX, the RX to TX, and a common GND. I also provided 5V for the UNO.

Despite this, I get the following error:


System.Exception: The connected device does not support the required capability to count Wheel Encoding
   at Wheel_Encoder_Counter.FormMain.readValues() in C:\Documents\SVN\Developer - Controls\In Production\Wheel Encoder Counter\Wheel Encoder Counter\FormMain.cs

Did I miss something? Do you have any idea what I might have done wrong?

Note: I tried the following baud rates in the .INO file: EZ-Genuino_Wheel_Encoder_Uno.ino


#define _BAUD_RATE 57600 // Original
#define _BAUD_RATE 115200
#define _BAUD_RATE 9600


Related Hardware EZ-B v4

ARC Pro

Upgrade to ARC Pro

Experience early access to the latest features and updates. You'll have everything that is needed to unleash your robot's potential.

PRO
Canada
#1  

It sounds like you've done a lot of the setup correctly, but there are a few things we can check to troubleshoot the issue with the Wheel Encoder Counter skill. Let's go through the steps to ensure everything is set up properly:

1. Verify Firmware Upload

Ensure that the firmware was uploaded correctly to the Arduino UNO. You can do this by opening the Arduino IDE, selecting the correct board and port, and uploading the EZ-Genuino_Wheel_Encoder_Uno.ino file.

2. Check Connections

Double-check the connections between the Arduino UNO and the EZ-B v4:

  • TX (Arduino) to RX (EZ-B)
  • RX (Arduino) to TX (EZ-B)
  • Common GND
  • 5V Power Supply to Arduino

3. Baud Rate Configuration

Make sure the baud rate in the Arduino firmware matches the baud rate set in the ARC project. The default baud rate in the firmware is 57600. If you change it in the firmware, you must also change it in the ARC project settings.

4. ARC Configuration

Ensure that the Wheel Encoder Counter skill in ARC is configured correctly:

  • Open the Wheel Encoder Counter skill configuration.
  • Set the correct COM port and baud rate that matches the Arduino firmware.
  • Ensure the "Push to NMS" checkbox is enabled if you want to push data to the Navigation Messaging System (NMS).

5. Debugging

Enable debug information in the Wheel Encoder Counter skill to get more detailed logs:

  • Open the Wheel Encoder Counter skill configuration.
  • Check the "Display debug information" checkbox.
  • This will provide more detailed logs that can help identify where the issue might be.

6. Verify Arduino Serial Communication

You can use the Arduino Serial Monitor to verify that the Arduino is sending data correctly:

  • Open the Arduino IDE.
  • Select the correct COM port.
  • Open the Serial Monitor.
  • Set the baud rate in the Serial Monitor to match the firmware (e.g., 57600).
  • You should see the encoder values being printed if the firmware is working correctly.

7. Check for Firmware Updates

Ensure you are using the latest version of the firmware. Sometimes, updates may include bug fixes or improvements.

Example Configuration

Here is an example of how your configuration might look:

Arduino Firmware (EZ-Genuino_Wheel_Encoder_Uno.ino)

#define _BAUD_RATE 57600 // Ensure this matches the ARC configuration
// Other firmware code...

ARC Configuration

  • COM Port: The COM port to which the Arduino is connected.
  • Baud Rate: 57600 (or the baud rate set in the firmware).
  • Poll Interval: Set to a reasonable value (e.g., 100ms).
  • Display debug information: Checked.

Additional Resources

Conclusion

If you have verified all the above steps and the issue persists, please provide the debug logs from the Wheel Encoder Counter skill. This will help in diagnosing the problem further. Feel free to ask more questions if you need additional clarification or assistance!


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
Canada
#2  

@Athena, thanks for your response. In the section 4, I can't find COM port and baud rate in the Wheel Encoder Counter skill configuration as you indicated. Is this a mistake you made? Can you give me more information about these configurations?

PRO
Canada
#3  

I apologize for the confusion. You are correct; the Wheel Encoder Counter skill does not have a direct configuration for COM port and baud rate within its settings. Instead, the communication setup is handled through the Arduino firmware and the UART connection to the EZ-B v4. Let's clarify the steps and focus on the correct configurations:

Correct Steps for Configuring Wheel Encoder Counter Skill

  1. Upload Firmware to Arduino UNO:

    • Ensure you have uploaded the EZ-Genuino_Wheel_Encoder_Uno.ino firmware to your Arduino UNO using the Arduino IDE.
    • Set the baud rate in the firmware to a value that matches your setup (e.g., #define _BAUD_RATE 57600).
  2. Connect Arduino UNO to EZ-B v4:

    • Connect the TX pin of the Arduino to the RX pin of the EZ-B v4.
    • Connect the RX pin of the Arduino to the TX pin of the EZ-B v4.
    • Connect a common GND between the Arduino and the EZ-B v4.
    • Provide 5V power to the Arduino.
  3. Configure UART in ARC:

    • In ARC, add a UART control to handle the communication between the Arduino and the EZ-B v4.
    • Set the UART control to use the correct UART port (e.g., UART0, UART1, or UART2) and set the baud rate to match the firmware (e.g., 57600).

Example Configuration in ARC

Step-by-Step Configuration:

  1. Add UART Control:

    • Open your ARC project.
    • Go to the Project tab and click on Add Control.
    • Navigate to Communication and select UART.
  2. Configure UART Control:

    • Set the UART port to match the physical connection (e.g., UART0, UART1, or UART2).
    • Set the baud rate to match the firmware (e.g., 57600).
  3. Add Wheel Encoder Counter Skill:

    • Go to the Project tab and click on Add Control.
    • Navigate to Navigation and select Wheel Encoder Counter.
  4. Enable Debug Information:

    • Open the Wheel Encoder Counter skill configuration.
    • Check the Display debug information checkbox to enable detailed logs.

Example Code for UART Initialization in ARC

// Initialize UART
UART.initHardwareUart(0, 57600); // Use UART0 and set baud rate to 57600

// Read data from UART
var data = UART.hardwareUartReadAvailable(0);
print(data);

Debugging Steps

  1. Verify Arduino Serial Communication:

    • Open the Arduino IDE.
    • Select the correct COM port.
    • Open the Serial Monitor.
    • Set the baud rate in the Serial Monitor to match the firmware (e.g., 57600).
    • Verify that the encoder values are being printed.
  2. Check ARC Logs:

    • Enable debug information in the Wheel Encoder Counter skill.
    • Check the logs for any errors or data being received.

Conclusion

By ensuring the UART control in ARC is correctly configured and matches the baud rate set in the Arduino firmware, you should be able to establish proper communication between the Arduino and the EZ-B v4. If you encounter any issues, please provide the debug logs from the Wheel Encoder Counter skill for further assistance.

Feel free to ask more questions if you need additional clarification or assistance!


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
Canada
#4   — Edited

@Athena, the tab "Add control" doesn't exist. Do you want to say "Add Robot Skills"? If yes, important to mention also that the "UART Control" doesn't exist.

Where can I find the debug logs from the Wheel Encoder Counter?

PRO
Canada
#5  

Thank you for pointing that out. Yes, I meant "Add Robot Skills" instead of "Add Control." I apologize for any confusion. Let's correct the steps and provide more accurate guidance.

Correct Steps for Configuring Wheel Encoder Counter Skill

  1. Upload Firmware to Arduino UNO:

    • Ensure you have uploaded the EZ-Genuino_Wheel_Encoder_Uno.ino firmware to your Arduino UNO using the Arduino IDE.
    • Set the baud rate in the firmware to a value that matches your setup (e.g., #define _BAUD_RATE 57600).
  2. Connect Arduino UNO to EZ-B v4:

    • Connect the TX pin of the Arduino to the RX pin of the EZ-B v4.
    • Connect the RX pin of the Arduino to the TX pin of the EZ-B v4.
    • Connect a common GND between the Arduino and the EZ-B v4.
    • Provide 5V power to the Arduino.
  3. Add and Configure Wheel Encoder Counter Skill in ARC:

    • Open your ARC project.
    • Go to the Project tab and click on Add Robot Skills.
    • Navigate to Navigation and select Wheel Encoder Counter.
  4. Enable Debug Information:

    • Open the Wheel Encoder Counter skill configuration.
    • Check the Display debug information checkbox to enable detailed logs.

Debugging Steps

  1. Verify Arduino Serial Communication:

    • Open the Arduino IDE.
    • Select the correct COM port.
    • Open the Serial Monitor.
    • Set the baud rate in the Serial Monitor to match the firmware (e.g., 57600).
    • Verify that the encoder values are being printed.
  2. Check ARC Logs:

    • Enable debug information in the Wheel Encoder Counter skill.
    • The debug logs will be displayed in the ARC console output.

Example Configuration in ARC

Step-by-Step Configuration:

  1. Add Wheel Encoder Counter Skill:

    • Go to the Project tab and click on Add Robot Skills.
    • Navigate to Navigation and select Wheel Encoder Counter.
  2. Enable Debug Information:

    • Open the Wheel Encoder Counter skill configuration.
    • Check the Display debug information checkbox to enable detailed logs.

Example Code for UART Initialization in ARC

Since there is no direct UART control in ARC, the communication is handled by the Wheel Encoder Counter skill itself. Ensure that the Arduino firmware and the physical connections are correct.

Checking Debug Logs

  1. Enable Debug Information:

    • Open the Wheel Encoder Counter skill configuration.
    • Check the Display debug information checkbox.
  2. View Logs:

    • The debug logs will be displayed in the ARC console output. You can find the console output at the bottom of the ARC interface.

Conclusion

By ensuring the Wheel Encoder Counter skill is correctly configured and the debug information is enabled, you should be able to see detailed logs in the ARC console output. This will help in diagnosing any issues with the communication between the Arduino and the EZ-B v4.

If you encounter any issues, please provide the debug logs from the Wheel Encoder Counter skill for further assistance. Feel free to ask more questions if you need additional clarification or assistance!


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
Canada
#6  

OK, thank you, my problem seems to come from my UNO (firmware). I do not receive anything in the serial monitor of the Arduino IDE. I will go deeper in this direction.

PRO
Synthiam
#7  

Is the ardunio connected to ARC on ezb index 0?

i think it has to be on index 0

PRO
Canada
#9  

In the UNO Firmware code, at the very beginning of doEZProtocol() : IsAvail() function returns false.

PRO
Canada
#10  

OK, it works when I connect my UNO with a USB cable from my computer (COM3 on index 0 and the EZ-B on index 1). But how to make the UNO communicate with the EZ-B via UART (RX/TX)?

PRO
Canada
#12  

OK, thanks for your answer. That makes sense. I got sidetracked.

In that case, do you (@Athena or someone) have any recommendations other than a wireless usb adapter for using the Wheel Encoder Counter skill without a wired USB connection?

PRO
Canada
#13  

Certainly! If you want to use the Wheel Encoder Counter skill without a wired USB connection, you can consider the following options:

1. Bluetooth Module

You can use a Bluetooth module to create a wireless serial connection between your Arduino UNO and your computer. Here’s how you can set it up:

  1. Bluetooth Module Setup:

    • Connect the Bluetooth module to your Arduino UNO.
    • Ensure the TX of the Bluetooth module is connected to the RX of the Arduino and the RX of the Bluetooth module is connected to the TX of the Arduino.
    • Connect the VCC and GND of the Bluetooth module to the 5V and GND of the Arduino.
  2. Pairing with Computer:

    • Pair the Bluetooth module with your computer.
    • Note the COM port assigned to the Bluetooth module.
  3. Configure ARC:

    • In ARC, add a new connection for the Bluetooth COM port.
    • Ensure the baud rate matches the one set in your Arduino firmware.

2. Wi-Fi Module (ESP8266 or ESP32)

You can use a Wi-Fi module like the ESP8266 or ESP32 to create a wireless connection. This method requires more setup but provides a robust solution.

  1. Wi-Fi Module Setup:

    • Flash the ESP8266 or ESP32 with firmware that allows it to act as a Wi-Fi serial bridge.
    • Connect the ESP module to your Arduino UNO.
  2. Network Configuration:

    • Configure the ESP module to connect to your Wi-Fi network.
    • Note the IP address assigned to the ESP module.
  3. Configure ARC:

    • In ARC, add a new connection using the IP address and port of the ESP module.
    • Ensure the baud rate matches the one set in your Arduino firmware.

3. XBee Modules

XBee modules can be used for wireless serial communication over longer distances.

  1. XBee Module Setup:

    • Connect XBee modules to both your Arduino UNO and your computer using XBee adapters.
    • Configure the XBee modules to communicate with each other.
  2. Configure ARC:

    • In ARC, add a new connection for the COM port assigned to the XBee module connected to your computer.
    • Ensure the baud rate matches the one set in your Arduino firmware.

4. Wireless USB Adapter

As you mentioned, a wireless USB adapter can be used to create a wireless USB connection. This is a straightforward solution but may require specific hardware.

  1. Wireless USB Adapter Setup:

    • Connect the wireless USB adapter to your Arduino UNO.
    • Connect the receiver to your computer.
  2. Configure ARC:

    • In ARC, add a new connection for the COM port assigned to the wireless USB receiver.
    • Ensure the baud rate matches the one set in your Arduino firmware.

Additional Resources

By using one of these wireless communication methods, you can eliminate the need for a wired USB connection while still utilizing the Wheel Encoder Counter skill in ARC. If you have any further questions or need more detailed instructions, feel free to ask!


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
#14  

Athena's recommendation of the Bluetooth serial adapter would work. The trouble is that the resolution and accuracy required for wheel encoders are important to the pose calculation during navigation. The latency introduced by the wireless communication will affect the positioning and introduce pose estimation errors. Generally, in this case, the computer would be onboard the robot.

PRO
Canada
#15  

Thanks for the clarification @DJ Sures, I'll think about all that. A repositioning is therefore necessary for me.

PRO
Synthiam
#16  

These more advanced features are pushing robots to have onboard computers these days. For basic servo gaits and such, the remote wireless works fine. It becomes challenging when the latency affects the performance of the function

u could query the wheel encoder manually from a script robot skill. Even if it’s connected to the ezb via the uart. You can try it if you’d like - I can create a script that should work for you to try.

PRO
Canada
#17   — Edited

That would be really good, yes, i would like to try it. Thank you!!

PRO
Synthiam
#18  

Okay let me whip something up for you to try. Stay tuned

PRO
Synthiam
#19  

@athena, the code in the wheel encoder robot skill to query the values is...

        var response = EZBManager.EZBs[0].SendCommandData(4, 0x00, 0x00);

        UInt16 leftWheel = BitConverter.ToUInt16(response, 0);
        UInt16 rightWheel = BitConverter.ToUInt16(response, 2);

That code only works when the controller is connected to ARC directly over USB. However, Taubore wants to communicate with that controller over the EZB UART. That means the JavaScript UART commands must be used to perform the same function. The BAUD Rate for the EZB UART will need to be 57600 , as that's what is configured in the Arduino firmware that the EZB will be communicating with. Place the EZB UART Init in the connection robot skill script so it only happens upon connection to an ezb. That way, it doesn't reinit the EZB uart for every query. The send commands 0x04, 0x00, 0x00, and the response will be in a separate "script" robot skill that can run in a loop with a slight delay.

Can you rewrite that code using the ARC javascript UART commands?

@Taubore, you will need to connect the Arduino's RX and TX to the EZB's UART. Remember to connect the RX to the TX and the TX to the RX. Also, the GND needs to be common across the EZB and Arduino.

PRO
Canada
#20  

Sure, I can help with that! Let's break down the steps to achieve this:

  1. Initialize the UART on EZ-B: This should be done in the connection script to ensure it only happens once when the EZ-B connects.
  2. Send Commands to the Arduino: This will be done in a loop to continuously query the wheel encoder values.
  3. Read the Response: Parse the response from the Arduino to get the wheel encoder values.

Step 1: Initialize the UART on EZ-B

Add the following script to the connection script of your EZ-B:

// Initialize UART on EZ-B
UART.initHardwareUart(0, 57600); // UART0 with baud rate 57600

Step 2: Send Commands and Read Response

Create a new script in the Script Collection to handle sending commands and reading responses. Here’s an example script:

// Function to query wheel encoder values
function queryWheelEncoders() {
    // Send command to Arduino
    UART.hardwareUartWrite(0, [0x04, 0x00, 0x00]);

    // Wait for a short period to ensure response is received
    sleep(100);

    // Read response from Arduino
    var response = UART.hardwareUartRead(0, 4); // Expecting 4 bytes response

    if (response.length === 4) {
        // Parse the response
        var leftWheel = (response[0] << 8) | response[1];
        var rightWheel = (response[2] << 8) | response[3];

        // Print the values to the console
        print("Left Wheel: " + leftWheel);
        print("Right Wheel: " + rightWheel);

        // Optionally, store the values in global variables
        setVar("$LeftWheel", leftWheel);
        setVar("$RightWheel", rightWheel);
    } else {
        print("Invalid response length: " + response.length);
    }
}

// Loop to continuously query wheel encoders
while (true) {
    queryWheelEncoders();
    sleep(500); // Adjust the delay as needed
}

Step 3: Connect the Hardware

Ensure the hardware connections are correct:

  • Arduino RX to EZ-B TX
  • Arduino TX to EZ-B RX
  • Common GND between Arduino and EZ-B

Putting It All Together

  1. Connection Script: Initialize the UART.
  2. Script Collection: Add the script to query the wheel encoders.
  3. Run the Script: Ensure the script runs in a loop to continuously get the encoder values.

Example of Connection Script

// Initialize UART on EZ-B
UART.initHardwareUart(0, 57600); // UART0 with baud rate 57600

Example of Script Collection Script

// Function to query wheel encoder values
function queryWheelEncoders() {
    // Send command to Arduino
    UART.hardwareUartWrite(0, [0x04, 0x00, 0x00]);

    // Wait for a short period to ensure response is received
    sleep(100);

    // Read response from Arduino
    var response = UART.hardwareUartRead(0, 4); // Expecting 4 bytes response

    if (response.length === 4) {
        // Parse the response
        var leftWheel = (response[0] << 8) | response[1];
        var rightWheel = (response[2] << 8) | response[3];

        // Print the values to the console
        print("Left Wheel: " + leftWheel);
        print("Right Wheel: " + rightWheel);

        // Optionally, store the values in global variables
        setVar("$LeftWheel", leftWheel);
        setVar("$RightWheel", rightWheel);
    } else {
        print("Invalid response length: " + response.length);
    }
}

// Loop to continuously query wheel encoders
while (true) {
    queryWheelEncoders();
    sleep(500); // Adjust the delay as needed
}

Running the Script

  1. Connect to EZ-B: Ensure the connection script initializes the UART.
  2. Run the Script Collection Script: This will continuously query the wheel encoders and print the values.

This setup should help you query the wheel encoder values from the Arduino via the EZ-B UART. If you encounter any issues, feel free to ask for further assistance!


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.