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

ARC Pro is more than a tool; it's a creative playground for robot enthusiasts, where you can turn your wildest ideas into reality.

#25  

Hi @Athena How can I Serial print the encoder output without the String 'a' trigger?
I would like to see the encoder output whenever the encoders are turning. Please send the complete UNO sketch. Thank you, Jack

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++;
}
PRO
Synthiam
#26  

You need the a as a request for the values. It’s polling the value so you can get an accurate count.

PRO
Canada
#27  

To continuously print the encoder values to the Serial Monitor without waiting for a trigger,you can modify the loop to print the values at regular intervals.Heres the complete Arduino sketch for that:cpp int encoderValue_A = 0;int encoderValue_B = 0;unsigned long previousMillis = 0;const long interval = 1000; // interval at which to print the values (milliseconds)void setup(){ Serial.begin(9600);pinMode(2,INPUT);pinMode(3,INPUT);attachInterrupt(digitalPinToInterrupt(2),countA,FALLING);attachInterrupt(digitalPinToInterrupt(3),countB,FALLING);} void loop(){ unsigned long currentMillis = millis();if(currentMillis - previousMillis = interval){ previousMillis = currentMillis;// print the encoder values to the Serial Monitor Serial.print(Encoder A:);Serial.println(encoderValue_A);Serial.print(Encoder B:);Serial.println(encoderValue_B);}} void countA(){ encoderValue_A++;} void countB(){ encoderValue_B++;} This sketch will print the encoder values every second,allowing you to see the output whenever the encoders are turning.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.
#28  

Thank you DJ for your input.  I am aware of the need for the UNO to receive the 'a' to trigger the UNO to ouput the encoder values to the EZB4. I am trying to see "raw encoder values " in the Serial Monitor as I turn the encoders.  I would like to verify this part of my setup without the triggering from the EZB4. Thanks again for your input. Jack

#29  

Hi @Athena, Thank you again for your work modifying the UNO sketch.   Could you please send it to me in Script form?   I would like to cut and paste it.

Thanks Jack

:cpp int encoderValue_A = 0;int encoderValue_B = 0;unsigned long previousMillis = 0;const long interval = 1000; // interval at which to print the values (milliseconds)void setup(){ Serial.begin(9600);pinMode(2,INPUT);pinMode(3,INPUT);attachInterrupt(digitalPinToInterrupt(2),countA,FALLING);attachInterrupt(digitalPinToInterrupt(3),countB,FALLING);} void loop(){ unsigned long currentMillis = millis();if(currentMillis - previousMillis = interval){ previousMillis = currentMillis;// print the encoder values to the Serial Monitor Serial.print(Encoder A:);Serial.println(encoderValue_A);Serial.print(Encoder B:);Serial.println(encoderValue_B);}} void countA(){ encoderValue_A++;} void countB(){ encoderValue_B++;} 
PRO
Canada
#30  

Certainly, Jack! Here's the Arduino sketch in a format you can easily copy and paste:

int encoderValue_A = 0;
int encoderValue_B = 0;
unsigned long previousMillis = 0;
const long interval = 1000; // interval at which to print the values (milliseconds)

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

void loop() {
    unsigned long currentMillis = millis();
    if (currentMillis - previousMillis >= interval) {
        previousMillis = currentMillis;
        // print the encoder values to the Serial Monitor
        Serial.print("Encoder A: ");
        Serial.println(encoderValue_A);
        Serial.print("Encoder B: ");
        Serial.println(encoderValue_B);
    }
}

void countA() {
    encoderValue_A++;
}

void countB() {
    encoderValue_B++;
}

You can paste this code into your Arduino IDE and upload it to your Arduino Uno. This will allow you to see the raw encoder values in the Serial Monitor every second. 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.
#31  

Hi @Athena

Thank you for your extraordinary assistance today. I believe I can trust the scripts to be correct on both the UNO and the EZB4. I can trust the encoders to be sending pulses to the UNO and printing to the Serial Monitor. I have replaced the wiring between UART TX/RX/GND from the UNO to the EZB4.
The UNO does not appear to receiving an 'a' trigger. Perhaps I have a defective UNO board for UART. I will try a spare MEGA 2560 later this week when I can find some time.
Again, I can't thank you enough for your patient and willing support. Good night.

Sincerely, Jack

PRO
Canada
#32  

You're very welcome,Jack!I'm glad I could assist you with your project.It sounds like you have a solid plan to troubleshoot the issue by trying a different board like the MEGA 2560.If you encounter any more challenges or have further questions,feel free to reach out anytime.

Good luck with your testing,and I hope everything works smoothly with the new setup.Have a great night!

Sincerely, Athena


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.