Asked
Resolved Resolved by Athena AI!

Wheel Encoder Skill

Hi Athena,

I am experiencing difficulty loading the necessary library onto my Arduino Uno to ensure compatibility with the Wheel Encoder Counter Skill in Synthiam ARC. I have successfully loaded the "Servo.h" library, but I am unable to find the "SendOnlySoftwareSerial.h" library. Could you please guide me on where to locate the "SendOnlySoftwareSerial.h" library? This appears to be the issue preventing me from utilizing the Wheel Encoder Counter Skill effectively.

Thank you,
Jack


Related Hardware Roli Rover
Related Control Wheel Encoder Counter

ARC Pro

Upgrade to ARC Pro

Elevate your robot's capabilities to the next level with Synthiam ARC Pro, unlocking a world of possibilities in robot programming.

#17  
javascript// Initialize UART on port 0 with a baud rate of 9600UART.initHardwareUart(0,9600);function loop(){ // Send a request for data to the Arduino UART.hardwareUartWriteString(0,a);print(Sent a to Arduino);// Wait a bit for the data to be transmitted sleep(50);// Check if data is available var dataAvail = UART.hardwareUartAvailable(0);print(Data available:+ dataAvail);if(dataAvail != 2){ print(The Arduino didnt send us anything.Exiting);return;// Exit the loop } else { // Read 2 bytes of data from the UART var encoders = UART.hardwareUartRead(0,2);// Print the encoder values print(Encoder A:+ encoders[0]);print(Encoder B:+ encoders[1]);} // Wait before the next loop iteration sleep(100);// Call the loop function again loop();}// Start the looploop();

Hi @Athena, Thank you, but could you please resend by selecting

 in the header so that it comes to me ready to copy and paste?
I'm trying to avoid as many mistakes as I can.
Jack
#18  

Hi @Athena, Could you please resend the last JavaScript?  It came through in paragraph form and I really need it in script form so I can copy and paste it.

Thanks Jack

PRO
Canada
#19  

Certainly, Jack! Here's the JavaScript code formatted for easy copying and pasting:

// Initialize UART on port 0 with a baud rate of 9600
UART.initHardwareUart(0, 9600);

function loop() {
    // Send a request for data to the Arduino
    UART.hardwareUartWriteString(0, 'a');
    print('Sent "a" to Arduino');

    // Wait a bit for the data to be transmitted
    sleep(50);

    // Check if data is available
    var dataAvail = UART.hardwareUartAvailable(0);
    print('Data available: ' + dataAvail);

    if (dataAvail != 2) {
        print('The Arduino didn\'t send us anything. Exiting');
        return; // Exit the loop
    } else {
        // Read 2 bytes of data from the UART
        var encoders = UART.hardwareUartRead(0, 2);

        // Print the encoder values
        print('Encoder A: ' + encoders[0]);
        print('Encoder B: ' + encoders[1]);
    }

    // Wait before the next loop iteration
    sleep(100);

    // Call the loop function again
    loop();
}

// Start the loop
loop();

You can now copy and paste this code directly into your ARC project. If you have any more questions or need further assistance, 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.
#20  

Hi @Athena, I copied part of the code sent by you.

function loop() {
    // Send a request for data to the Arduino
    UART.hardwareUartWriteString(0, 'a');
    print('Sent "a" to Arduino');

Will the previous code only print the characters 'Sent "a" to Arduino'? I need to print the actual String that it is sending so that I can make sure the 'a' is going to my UNO. Could you please repost the complete Script to include printing the String? Thanks, Jack

#21  

Hi @Athena, Could you please repost the full script so that it will print the String the EZB4 is sending to the UNO? Thank you, Jack

PRO
Canada
#22  

Certainly,Jack! Here's the complete JavaScript code with the addition to print the actual string being sent to the Arduino:

// Initialize UART on port 0 with a baud rate of 9600
UART.initHardwareUart(0, 9600);

function loop() {
    // Define the string to send
    var stringToSend = "a";

    // Send a request for data to the Arduino
    UART.hardwareUartWriteString(0, stringToSend);
    print("Sent: " + stringToSend + " to Arduino");

    // Wait a bit for the data to be transmitted
    sleep(50);

    // Check if data is available
    var dataAvail = UART.hardwareUartAvailable(0);
    print("Data available: " + dataAvail);

    if (dataAvail != 2) {
        print("The Arduino didn't send us anything. Exiting");
        return; // Exit the loop
    } else {
        // Read 2 bytes of data from the UART
        var encoders = UART.hardwareUartRead(0, 2);

        // Print the encoder values
        print("Encoder A: " + encoders[0]);
        print("Encoder B: " + encoders[1]);
    }

    // Wait before the next loop iteration
    sleep(100);

    // Call the loop function again
    loop();
}

// Start the loop
loop();

This script will now print the string being sent to the Arduino, allowing you to verify that the correct data is being transmitted. If you have any more questions or need further assistance, 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.
#23  

Hi @Athena, It seems my EZB4 is sending the correct String to trigger the UNO to send encoder data.   However, I'm not sure the UNO script is working as it should. My UNO script is printed below:

int encoderValue_A = 0;
int encoderValue_B = 0;

void setup() {
  Serial.begin(9600);
  pinMode(2, INPUT);
  pinMode(3, INPUT);
  attachInterrupt(digitalPinToInterrupt(2), countA, FALLING);
  attachInterrupt(digitalPinToInterrupt(3), countB, FALLING);
}

void loop() {
  
  // if there is data to read, read it
  if (Serial.available() > 0) {
    // read the incoming data from the EZ-B
    int incomingByte = Serial.read();
     Serial.print(incomingByte);
    // command 'a' means transmit the current values and reset the counters
    if (incomingByte == 'a') {
      // send the values
      Serial.write(encoderValue_A);
      Serial.write(encoderValue_B);
      // reset the values
      encoderValue_A = 0;
      encoderValue_B = 0;
    }
  }
}

void countA() {
  encoderValue_A++;
}

void countB() {
  encoderValue_B++;
}

How can I Serial print to the monitor the output of my encoders? Can you send the complete UNO Sketch for this?

Thank you, Jack

PRO
Canada
#24  

Certainly,Jack! Here's a complete Arduino sketch that includes serial printing of the encoder values to the Serial Monitor. This will help you verify that the encoder values are being updated correctly:

int encoderValue_A = 0;
int encoderValue_B = 0;

void setup() {
  Serial.begin(9600);
  pinMode(2, INPUT);
  pinMode(3, INPUT);
  attachInterrupt(digitalPinToInterrupt(2), countA, FALLING);
  attachInterrupt(digitalPinToInterrupt(3), countB, FALLING);
}

void loop() {
  // if there is data to read, read it
  if (Serial.available() > 0) {
    // read the incoming data from the EZ-B
    int incomingByte = Serial.read();
    Serial.print("Received: ");
    Serial.println((char)incomingByte);

    // command 'a' means transmit the current values and reset the counters
    if (incomingByte == 'a') {
      // send the values
      Serial.write(encoderValue_A);
      Serial.write(encoderValue_B);

      // print the encoder values to the Serial Monitor
      Serial.print("Encoder A: ");
      Serial.println(encoderValue_A);
      Serial.print("Encoder B: ");
      Serial.println(encoderValue_B);

      // reset the values
      encoderValue_A = 0;
      encoderValue_B = 0;
    }
  }
}

void countA() {
  encoderValue_A++;
}

void countB() {
  encoderValue_B++;
}

This sketch will print the received command and the encoder values to the Serial Monitor. Make sure to open the Serial Monitor in the Arduino IDE to view the output. If you have any more questions or need further assistance, 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.