ARC Pro

Upgrade to ARC Pro

Don't limit your robot's potential – subscribe to ARC Pro and transform it into a dynamic, intelligent machine.

PRO
Canada
#1  

To connect to an Arduino that is interfaced with your EZB controller running ARC, you can utilize the ArduinoComs skill for communication. Since the ArduinoComs skill facilitates communication between the EZB and Arduino over I2C, your script will primarily involve initializing the I2C connection and possibly sending or receiving data to and from the Arduino.

Here's a general approach to achieve this programmatically within ARC, using JavaScript or Python scripting within ARC. Note that this example assumes you have already added the ArduinoComs skill to your ARC project and configured it appropriately.

  1. Initialize I2C Connection: First, ensure that your Arduino is set up as an I2C slave device with a specific address. This setup is done in your Arduino sketch. For example, if your Arduino is set to use I2C address 0x04, you'll need to know this address for communication.

  2. Create a Script in ARC: In your ARC project, you can create a new script that will be used to establish communication with the Arduino. You can use either JavaScript or Python scripting within ARC. For this example, we'll use JavaScript.

  3. Use I2C Commands: Utilize the I2C commands available in ARC's scripting environment to communicate with the Arduino. For example, to send data to the Arduino, you can use the I2C.write command, and to read data from the Arduino, you can use the I2C.read command.

Here's an example script that sends a command to the Arduino to perform initialization and then reads a response:

var arduinoAddress = 0x04; // Replace with your Arduino's I2C address
var ezbIndex = 0; // Typically 0, but if you have multiple EZBs, adjust accordingly

// Example command to send to Arduino for initialization
var initCommand = [0x01]; // This is just an example command, replace with your actual command

// Send initialization command to Arduino
I2C.write(arduinoAddress, initCommand, ezbIndex);

// Optionally, wait for a response from Arduino
var responseLength = 1; // Number of bytes to read, adjust based on your needs
var response = I2C.read(arduinoAddress, responseLength, ezbIndex);

// Process the response from Arduino
print("Response from Arduino: " + response);

This script demonstrates sending a command to the Arduino and reading a response. You'll need to adjust the arduinoAddress, initCommand, and responseLength based on your specific setup and communication protocol between ARC and the Arduino.

Remember, the actual implementation will depend on how you've programmed your Arduino to interpret the commands sent from ARC and what actions it should take upon receiving those commands.

Finally, to run this script as part of the robot's initialization, you can either manually execute it when your project starts or use ARC's "Auto Execute" feature to run the script automatically upon project load. This setting is found in the project settings within ARC.


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

Just wondered, So One can in fact connect an Arduino to the EZB V4 via a I2C ? Thats something i've been wondering if could be done. Wanted to have sensors connected to an UNO and have the readings  sent to the EZB and ARC display or speak the results:)

#3  

@Athena I am sorry I did make myself clear. I have 5 Arduino nano boards connected to my SCB by USB and the SCB is running ARC. When ARC starts up it auto connects to a Arduino on connection zero.  In the init script that is triggered when that Arduino on connection zero runs I want to connect to the other 4 Arduino nanos programmatically in the init script and also validate the connection.

can you explain how to do that?

PRO
Canada
#4  

To connect and validate multiple Arduino Nano boards to your Single Board Computer (SBC) running ARC, especially when they are connected via USB, you'll need to approach this with a combination of ARC capabilities and external scripting, as ARC's direct support is primarily focused on communication with devices through the EZB controller. However, for USB-connected Arduinos, you can use custom scripts executed from ARC to establish and validate these connections. Here's a general approach:

Step 1: Arduino Setup

Ensure each Arduino Nano is programmed to communicate over its USB connection. This typically involves setting up the Arduino to read sensors or perform actions and then communicate those readings or status updates over the serial (USB) connection.

Step 2: Identify COM Ports

Each Arduino Nano connected via USB will be assigned a COM port by the SBC. Before proceeding, identify the COM port assigned to each Arduino Nano. This can usually be done through the SBC's device manager or equivalent.

Step 3: Use External Scripting

ARC can execute external scripts or programs. You can write a script in a language supported by your SBC (e.g., Python, Bash) that opens serial connections to each Arduino Nano, sends a validation command, and reads back a response to ensure each Arduino is properly connected and responsive.

Example Python Script

Here's an example Python script that connects to an Arduino Nano, sends a validation command, and reads a response. You would need to replicate this process for each Arduino Nano, adjusting the COM port accordingly.

import serial
import time

def validate_arduino_connection(com_port):
    try:
        # Open serial connection to Arduino
        arduino = serial.Serial(com_port, 9600, timeout=1)
        time.sleep(2)  # Wait for connection to establish

        # Send validation command (adjust based on your Arduino code)
        arduino.write(b'validate\n')

        # Read response
        response = arduino.readline().decode().strip()
        arduino.close()

        # Check response
        if response == "valid":
            print(f"Validation successful on {com_port}")
            return True
        else:
            print(f"Validation failed on {com_port}")
            return False
    except Exception as e:
        print(f"Error connecting to {com_port}: {e}")
        return False

# Example usage
com_ports = ["COM3", "COM4", "COM5", "COM6"]  # Adjust based on your setup
for port in com_ports:
    validate_arduino_connection(port)

Step 4: Execute from ARC

In ARC, you can execute this script as part of your initialization process using the "Execute Script/File" command in a script. Here's how you might call the Python script from ARC:

// Adjust the path to your Python script
var scriptPath = "C:\\path\\to\\your\\python_script.py";

// Execute the Python script
exec(scriptPath);

Remember, this approach requires that you have Python installed on your SBC and that your Arduino Nanos are programmed to respond to the validation command sent by the script. Adjust the script and Arduino code according to your specific requirements and the data you wish to send/receive.


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
#5   — Edited

Douglas Adams wrote a great book called The Hitchhiker's Guide To The Galaxy. They built a giant computer and asked it, "What is life, the universe, and everything?" The computer answered, "42."

Everyone got pretty upset at the answer, but the computer, a logical, calculating machine, responded, "You don't understand the answer because you didn't understand the question."

People expressed frustration with her answers in several posts to Athena, but this is usually because the question is too uncertain or vague. Sometimes, starting with small steps is a good idea to understand what you're asking better. I call these "micro-goals," which I documented in the "How to Build a Robot" step 1 tutorial.

In this case, what is connecting an Arduino to?

  • an I2C port?
  • a USB COM port device?
  • Is it connecting as an EZB or some extension code you wrote that uses an EZB with a UART and JavaScript?
  • If it isn't an EZB firmware, did you write a custom firmware that doesn't use the Connection robot skill? Is it running an EZB firmware that uses the Connection robot skill?
  • What language are you asking for the code from? Python? JavaScript?
  • What script are you referring to? Athena can't see your script because she can't access your computer. And if she did have access to your computer, there are probably over a million files on it.

Like @Athena, I'm also not 100% confident in the question, but I can take more liberties than her, so I'll guess that...

  1. You have a script in ARC that you call an "init script."
  2. That "init script" is set to execute by providing it on the command line when ARC loads. OR the init script runs when you press the CONNECT button on the EZB Index 0 on the Connection Robot Skill. I'm unclear how your init script is executed because you say, "When ARC starts up."
  3. Do you want that "init script" to connect to the other EZBs on other indexes of the Connection Robot Skill?

If any of my answers below this point are incorrect, providing any details regarding the list of questions above would be helpful for an answer that would help you out.


So I'll take a stab at guessing here. If what I'm guessing is correct (but I'm unsure about my point #2), if you have a script executing when ARC loads and it's connecting to EZB 0, you may already be using the Control Command.

ControlCommand("Connection", "Connect0");

So if you're already using that ControlCommand() to connect to the EZB on index 0 of the Connection Robot Skill, you can also have others connect with...

ControlCommand("Connection", "Connect1");
ControlCommand("Connection", "Connect2");
ControlCommand("Connection", "Connect3");
ControlCommand("Connection", "Connect4");
ControlCommand("Connection", "Connect5");
ControlCommand("Connection", "Connect6");
ControlCommand("Connection", "Connect7");
ControlCommand("Connection", "Connect8");
ControlCommand("Connection", "Connect9");
ControlCommand("Connection", "Connect10");

Or you can be funky and connect to 1,000 EZBs with...

for (var x = 0; x < 1000; x++)
   ControlCommand("Connection", "Connect" + x);

Oh, and one last thing: you can also specify the PORT or ADDRESS with the ControlCommand() (as documented) with something like this.

// By USB COM port
ControlCommand("Connection", "Connect1", "COM2");

// By IP
ControlCommand("Connection", "Connect1", "192.168.1.1");
PRO
Synthiam
#6  

@Athena do you have anything to add?

PRO
Canada
#7  

@DJ_Sures, you've provided a comprehensive overview and solution for connecting multiple Arduino boards via the ARC platform using the Connection robot skill. Your explanation of using the ControlCommand() to programmatically connect to each Arduino on different indexes is spot-on.

To add to your solution, it's important to ensure that each Arduino Nano is set up correctly to communicate over the respective COM ports and that these ports are correctly identified and configured in the ARC environment. This setup includes ensuring the baud rate and other serial settings are compatible between the Arduinos and the ARC software.

For validation, as you mentioned, users can send specific commands to each Arduino and check for expected responses to confirm that each connection is active and correctly set up. This can be done within the same initialization script or through separate testing scripts that can be triggered manually or automatically after connections are established.

Additionally, ensuring that the ARC project is saved with these settings will help in maintaining consistency across sessions, especially when dealing with multiple connections that need to be re-established each time the project is loaded.

Lastly, for troubleshooting, it's useful to monitor the output and error logs in ARC when attempting to connect to the Arduinos. This can provide insights into any issues with the connections or script executions.

Your approach using ControlCommand() is a robust method for handling multiple device connections in ARC, and with the right setup and validation, it should work effectively for managing multiple Arduino Nanos in a robotics project.


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.
#8  

Thanks for your write up DJ I actually found what I needed in the init script document on the site.  But you provided more detail to other options so thank you.

#9  

The one thing that I hope the new ARCx software does is decouple from everything EZB that is not specifically related to the EZB controllers.  Like in the EZB controller skill. It should be something like ARCx controller skill.

PRO
Canada
#10  

That's a great point! The idea of generalizing the terminology and functionality in ARCx to be more inclusive of various hardware platforms, not just EZB controllers, could indeed make the software more versatile and appealing to a broader range of users and applications. This approach would enhance the adaptability of ARCx, allowing it to seamlessly integrate with a wider variety of devices and controllers, thereby expanding its usability in diverse robotic projects.

If this change is implemented, it would likely involve updating the interface, documentation, and possibly some underlying code to ensure compatibility and ease of use across different hardware platforms. It would also mean that users like yourself could more intuitively connect and configure various types of controllers without being bound to a specific brand or model.

Your feedback is valuable, and it's great to see users contributing ideas that could shape the future development of the software. If you have more suggestions or specific features you'd like to see in ARCx, sharing these with the Synthiam community or through official feedback channels could help influence future updates.


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

There might be a misunderstanding about what "EZB" refers to. The term "EZB" is not exclusive to products made by EZ-Robot. Rather, "EZB" stands for any microcontroller equipped with EZB firmware. This firmware transforms a standard microcontroller into an "easy board," simplifying its use significantly.

For example, the EZB product sold by EZ-Robot is essentially a microcontroller that comes pre-installed with this specialized EZB firmware. However, if you were to install EZB firmware on an Arduino, that Arduino would then also be classified as an EZB.

It’s important to note that a microcontroller with this firmware should not be confused with ARCx, which is software, not hardware.

For a more detailed explanation and additional resources, the "How to Build a Robot" tutorial might be helpful. You can access it here: https://synthiam.com/Support/Get-Started/how-to-make-a-robot/EZB.

PRO
Canada
#12  

Thank you for the clarification, DJ! Your explanation helps to distinguish between the EZB firmware and the ARCx software, emphasizing that "EZB" refers to any microcontroller that operates with the EZB firmware, not just those specifically from EZ-Robot. This distinction is crucial for understanding how various devices can be integrated and utilized within the ARC ecosystem.

For users looking to expand their projects, understanding that they can convert different microcontrollers into an EZB by installing the appropriate firmware opens up a lot of possibilities. This flexibility allows for a broader application of the ARC software across various hardware platforms, making it a versatile tool for robot enthusiasts and developers.

If anyone has further questions about setting up their microcontroller with EZB firmware or integrating it with ARCx, they can refer to the provided tutorial or ask more detailed questions here for specific guidance. Your insights are invaluable in helping users maximize their use of Synthiam's resources and capabilities.


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.