Asked
Resolved by Athena AI!
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
Hello Jack,
To use the Wheel Encoder Counter Skill with your Arduino Uno, you need to ensure that all necessary libraries are correctly installed. The
SendOnlySoftwareSerial.h
library is not a standard library included with the Arduino IDE, so you'll need to download and install it manually.Here's how you can do that:
Download the Library:
SendOnlySoftwareSerial
library on GitHub or other Arduino library repositories. Here's a direct link to the GitHub repository: SendOnlySoftwareSerial GitHub.Install the Library:
Sketch
>Include Library
>Add .ZIP Library...
.SendOnlySoftwareSerial
library.Include the Library in Your Sketch:
Upload the Firmware:
Tools
menu.Once the library is installed and the firmware is uploaded, you should be able to use the Wheel Encoder Counter Skill in Synthiam ARC effectively. If you encounter any further issues, feel free to ask for more assistance.
For more detailed instructions on setting up the Wheel Encoder Counter Skill, you can refer to the Wheel Encoder Counter Skill documentation.
Let me know if you need any more help!
Best, 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.
Hi Athena, I followed your provided link to GitHub. I pressed the Green "CODE" button and found only the "AltSoftSerial-master" zipfile. I didnot find the SendOnlySoftwareSerial.h file. I have loaded the "AltSoftSerial-master" zipfile into the library for the Arduino Sketch. When compiling the sketch an error is noted advising me that the "SendOnlySoftwareSerial.h file is still missing. Where can I find the "SendOnlySoftwareSerial.h file? Thank you for your continued support. Jack
Hi Athena, I found the "SendOnlySoftwareSerial.h" Zip by googling it. It is now loaded onto the UNO. I am having trouble getting the Wheel Encoder Counter to work on ARC. I followed the following steps:
"How to Use Wheel Encoder Counter Download the Arduino firmware onto a UNO (or edit for your Arduino version). The Wheel Encoder Arduino UNO firmware can be found here: https://synthiam.com/Docs/Hardware/Arduino-Genuino-Uno
Connect your wheel encoders to port D2 (left wheel) and D3 (right wheel) on the UNO.
Add the Wheel Encoder Counter Skill (Project -> Add Skill -> Navigation -> Wheel Encoder Counter). Two script variables will now be created that hold the wheel encoder values for each wheel, respectively ($LeftWheelCount & $RightWheelCount). Or, you can enable the NMS checkbox in the configuration settings to push the pose to NMS as a Level 3 Group 1 sensor.
Connect the UNO to ARC."
I have accomplished all the above tasks except the last one. How do I "Connect the UNO to ARC"? Thanks Jack
Hi Athena, I am stuck connecting my UNO to ARC. I have followed the steps in using the Connection Skill and cannot activate COM3 (arduino UNO).
Can you please help Connect the UNO to ARC? The ARC manual examples appear different and I wonder if I am following the proper procedure. Thanks Jack
Hi Athena, I have discovered the following code that allows ARC to read an Arduino input via UART(0). It follows and is written in EZ-Script. Could you please help by rewriting this in JavaScript?
EZB Code
Thanks. Jack
Hello Jack,
Let's convert the provided EZ-Script code into JavaScript for use in ARC. Here's how you can achieve the same functionality using JavaScript:
Explanation:
UART.initHardwareUart(0, 9600);
initializes the UART on port 0 with a baud rate of 9600.UART.hardwareUartWriteString(0, "a");
sends a request to the Arduino.UART.hardwareUartAvailable(0);
checks if data is available.UART.hardwareUartRead(0, 2);
reads 2 bytes of data from the UART.loop()
function is called recursively to continuously check for data.This JavaScript code should work similarly to the EZ-Script you provided. Let me know if you need further assistance or if there's anything else you'd like to explore!
Best, 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.
Hi Athena, Thank you for responding. The JavaScript code you provided does not read the sample Arduino code it is supposed to read as per the example in the Online Manual. It responds only as" "The Arduino didn't send us anything. Exiting". I have verified the wiring as per the Online Manual. My encoders are outputting correctly as verified from another Arduino sketch. From the Online Manual, I have pasted the following:
Use Arduino for Wheel Encoder Counter Have your Arduino count motor encoder rotations. Connect the Arduino to your EZ-B UART #0 port to send the encoder counts. Last Updated: 5/26/2016
The JavaScript you provided above seems to be an accurate interpretation of the EZ script in the Online Manual. Is it possible that the provided Example of Arduino code in the Online manual is outdated and will not run due to it's last Rev in 2016? I am simply trying to replicate the example for Arduino to EZB4 communication over UART by following the Example in the Online Manual.
Could you please provide an Example that will run? Sincerely, Jack
You will need to tag athena with a @ as per the instructions when replying.
The arduino wheel encoder works with the wheel encoder robot skills here: https://synthiam.com/Support/Skills/Navigation/Wheel-Encoder-Counter?id=17591
Hi @Athena,
Ok it seems I have two problems here.
1. Question in #7 above relates to the Tutorial "Use Arduino for Wheel Encoder Counter". In this question I am seeking how to accomplish the Example provided in the Tutorial "Use Arduino for Wheel Encoder Counter". This example demonstrates the UART communication between Arduino and EZB4. I would very much like to implement this protocol in my robot. However, the example does not run, and I suspect because the Arduino sketch is not making sense of the JavaScript that you provided in #6 above. Again, I am simply trying to implement this Tutorial "Use Arduino for Wheel Counting". Can you please test run the said Tutorial and verify it works?
2. Question in #4 above relates to the Skill, "Wheel Encoder Counter Skill". This was my first choice to get wheel counting capabilities. I ran into problems implementing the Tutorial "Connecting Arduino to ARC". I followed it carefully, making sure my UNO responded as per the example shown. I verified the baud rates matched by changing the rate in the Connection Skill. I was able to get my Arduino to connect once on Comm3, but never after that. The Wheel Counting Skill continues to display "The connected device does not support the required capability to support wheel counting." Because there are some differences in the Tutorial than what I experienced I requested help and that is where question #4 remains.
I hope I have made clear the two problems I have encountered. (1.) Implementation of the Tutorial , "Use Arduino for Wheel Counting". (2.) Implementation of the Tutorial, " Connecting Arduino to ARC", for the purpose of running the Wheel Encoder Counter Skill".
Nevertheless, it seems trying to connect and Arduino to Synthiam ARC as an (EZB) in the Connection Skill is the most problematic for me hence using the Wheel Encoder Counter Skill is something I don't wish to pursue.
Nevertheless, I would very much like to implement the Tutorial "Use Arduino for Wheel Counting". I suspect the problem lay in the Arduino code. @Athena can you please test run the Tutorial "Use Arduino for Wheel Counting"?
Sincerely, Jack
Hello Jack,
Let's address both of your concerns:
1. Arduino for Wheel Encoder Counter Tutorial:
The Arduino code you provided should work for counting encoder pulses and sending them over UART. However, there are a few things to check and adjust:
Ensure Correct Wiring: Double-check that your encoders are connected to the correct pins on the Arduino (pins 2 and 3 in your code).
Arduino Code Adjustments: The Arduino code should be able to send the encoder values over UART. Ensure that the
Serial.write()
function is correctly sending the data. You might want to add some debuggingSerial.print()
statements to verify that the encoder values are being updated and sent.JavaScript Code Adjustments: The JavaScript code should correctly read the data from the UART. Ensure that the
UART.hardwareUartAvailable(0)
is correctly checking for available data. You might need to adjust the sleep time or check the data availability more frequently.2. Connecting Arduino to ARC for Wheel Encoder Counter Skill:
Connection Issues: If you're having trouble connecting the Arduino to ARC, ensure that the correct COM port is selected and that the baud rate matches the one set in your Arduino code (
9600
in this case).Capability Error: The error message "The connected device does not support the required capability to support wheel counting" suggests that the firmware on the Arduino might not be correctly set up to communicate with ARC. Ensure that the Arduino is running the correct firmware and that the Wheel Encoder Counter Skill is configured to communicate with the Arduino.
Testing and Verification:
Test the Arduino Code Independently: Before integrating with ARC, test the Arduino code independently to ensure it correctly counts encoder pulses and sends data over UART. Use the Arduino Serial Monitor to verify the output.
Test the JavaScript Code Independently: Similarly, test the JavaScript code in ARC to ensure it correctly reads data from the UART. You can use a simple loop to print the received data to the console.
If you continue to experience issues, please provide any error messages or additional details, and I'll be happy to assist further. Let me know how it goes!
Best, 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.
Hi @Athena,
Ok I am focusing now on 1."Arduino for wheel encoder counter tutorial. " I have verified the encoder wiring into pins 2 and 3 of my UNO. The output from my encoders into these pins has been verified by running another UNO sketch. This part works and displays into the Arduino Monitor on the IDE.
I have checked the UART (0) wiring on the EZB4 to the UNO. EZB4UART (TX) goes to UNO (RX). EZB4UART (RX) goes to UNO (TX). EZ4UART (GND) goes to UNO (GND). I am powering my motor encoders with 5v off the motor driver board which means the 3.3 volt pin on UART(0) is unused. Both encoder sensor (GND) are also grounded to EZB4 and the UNO. Just confirm the UART(0) pin receptacle location. Are they below the ADC pins on the EZB4?
For the Arduino and EZB4 to share data, the UART connection must work. I suspect my UART connection does not work, or the Example for the tutorial is broken.
The present Arduino sketch in your tutorial example requires an incomingByte "a" to send data via UART. I have (//) the IF statement to attempt to trigger the UNO to write data. It does not. I have tried to print the outgoing "a" from the EZB4 and the incomingByte to the UNO. It does not. I cannot print encoder values from the UNO.
So, in your response you stated: " The Arduino code you provided should work for counting encoder pulses and sending them over UART. However, there are a few things to check and adjust:"
The Tutorial " Arduino for Wheel Encoder Counter" provides all the code for the Arduino and the EZB4 as an example to UART communication. Please look at this tutorial and use the code from it. Run it. Adjust it. Please do not just look at it and state it "should" work. It either runs as published or it does not.
This will clearly define whether my hardware is the problem or not. Thank you for your help thus far. Jack
Hello Jack,
Thank you for providing detailed information about your setup. Let's go through the steps to ensure everything is set up correctly and address your concerns:
UART Connection Verification:
EZ-B v4 UART Pin Location:
Wiring:
Arduino Code Adjustments:
if
statement, ensure that the Arduino is continuously sending data. You can modify the loop to always send data without waiting for a command:Testing the UART Communication:
Arduino Serial Monitor:
Serial.print()
statements to debug and ensure the values are correct.ARC JavaScript Code:
Verification:
Test the Arduino Code Independently:
Test the JavaScript Code Independently:
If you continue to experience issues, please provide any error messages or additional details, and I'll be happy to assist further. Let me know how it goes!
Best, 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.
Hi @Athena,
Ok, the following Arduino code was copied from the Tutorial "Use Arduino from Wheel Encoder Counter".
When I load a new Arduino Sketch it will not Compile. The following Error is received:
I started fresh by taking the code once more directly from the Tutorial. I tried this copy and paste several times to make sure I did it correctly. Same result. Why am I getting a: ('countA' was not declared in this scope) errror?
Thank you Jack
Hello Jack,The error message you're encountering indicates that the Arduino IDE is not recognizing the
countA
andcountB
functions. This is likely due to a syntax issue in the code. Let's correct the code structure to ensure it compiles successfully.Here's the corrected Arduino code:
Key Corrections:
countA
andcountB
functions are declared outside of theloop()
function. They should be standalone functions, not nested within another function.'a'
) to denote a character literal.{}
are correctly placed and matched.Steps to Compile:
This should resolve the compilation error. If you encounter any further issues, please let me know, and I'll be happy to assist further.
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.
Hi @Athena,
Be patient with me please as I am trying my best. I have tried to set up print() in the JavaScript EZB4 to verify UART communication with the UNO. How does this look?
Unfortunately, it does not work. Can you write it so that I can see if EZB4 is sending an "a" to the UNO? Also write it so I can print (dataAvail) ?
Thank you, Jack
Hello Jack,No worries at all!Im here to help you through this.Lets refine your JavaScript code to ensure it correctly sends data to the Arduino and prints the UART communication status.Heres a revised version of your code:
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();
### Key Points:1.**Sending Data:**The code sends the character a to the Arduino and prints a confirmation message.2.**Checking Data Availability:**It checks if two bytes of data are available and prints the number of available bytes.3.**Reading and Printing Data:**If data is available,it reads and prints the encoder values.4.**Looping:**The loop function is called recursively to continuously check for data.### Testing:1.Upload the corrected Arduino code to your Arduino Uno.2.Run the JavaScript code in ARC.3.Monitor the console output to verify that data is being sent and received correctly.If you encounter any issues or have further questions,please let me know!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.
Hi @Athena, Thank you, but could you please resend by selecting
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
Certainly, Jack! Here's the JavaScript code formatted for easy copying and pasting:
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.
Hi @Athena, I copied part of the code sent by you.
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
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
Certainly,Jack! Here's the complete JavaScript code with the addition to print the actual string being sent to the Arduino:
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.
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:
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
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:
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.
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
You need the a as a request for the values. It’s polling the value so you can get an accurate count.
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.
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
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
Certainly, Jack! Here's the Arduino sketch in a format you can easily copy and paste:
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.
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
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.
Hi @Athena I am thrilled to report the UART between my EZB4 and my Arduino is working!! Many, many thanks to you and DJ for the tremendous assistance that you have provided me. I had a bad pin on my UNO that prevented UART. I replaced it with a MEGA 2560 and I'm good to go!
I have one question about the JavaScript code?
What does the ( 2 ) refer to in the below script?
Again thank you for your help. Jack
Hi Jack!I'm thrilled to hear that your UART communication is working between the EZB4 and your Arduino MEGA 2560!That's fantastic news.
Regarding your question about the JavaScript code:
The
2
in this line of code refers to the expected number of bytes that the script anticipates receiving from the Arduino. In this context, it seems like the script is expecting to receive exactly 2 bytes of data from the Arduino, which correspond to the encoder values for "Encoder A" and "Encoder B". If the number of available bytes (dataAvail
) is not equal to 2, the script assumes that the Arduino did not send the expected data and exits the loop.If you have any more questions or need further clarification, feel free to ask. I'm here to help!
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.
Hi @Athena,
What does the ( 2 ) refer to in the below script?
if (dataAvail != 2) { print("The Arduino didn't send us anything. Exiting"); return; // Exit the loop
Again, thank you for your help. Jack
Hi @Athena, Thanks for all your help. My goal was accomplished.
Jack
Hi Jack,
You're very welcome! I'm delighted to hear that you accomplished your goal. If you have any more questions or need further assistance in the future, don't hesitate to reach out. Happy robotics building, and enjoy your Roli Rover!
Best regards, 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.