How to connect rosserial node with atmega32
I am attempting to get the avr_chatter.cpp code working with an atmega 32 using this tutorial
Using rosserial with AVR and UART
.
I have updated the avr_time.c and avr_uart.c files with the different registers and changed the MCU declaration in the make file and they all compile with no issues. The problem I am having is that when I try to connect to it with the rosrun rosserial_python serial_node.py
I get the error [ERROR] [1636863834.544456]: Unable to sync with device; possible link problem or link software version mismatch such as hydro rosserial_python with groovy Arduino
. I have tried changing the Baud rate down to 9600 along with checking that all the connections are correct and that I am trying to connect to the right port with no difference. I am running Ros melodic version 1.14.5 But I cant attach my files below due to lack of points so I have linked to my GitHub page instead.
Any help would be greatly appreciated, Mathew
Please check this thread on this error: https://answers.ros.org/question/2108...
It would be good to know on things that you have already tried
I have tried increasing the buffer size and trying different cables. Something I tested earlier today was to add a flashing light to the while loop in the avr_chatter.cpp file that has been updated on my Github. The led is supposed to turn on for 1 sec and then turn off for 1 sec but instead, it turns on for 4 sec and off for 4 sec. That leads me to believe that it's a problem with the avr_time.c file b/c that is what's controlling the timer but as far as I can tell it should be working properly. I am running the Atmega 32 at 8Mhz.
I believe you are right, this what I found in the Arduino forum.
https://forum.arduino.cc/t/verifying-...
Yes, the problem is that I am specifying the F_CPU in the make file and in the avr_chatter.cpp file and have read back the fuses as C4 D9 meaning 8Mhz internal RC clock. I don't know if it is being overwritten somehow or if the math being done as a result of the F_CPU value is somehow getting jumbled? Unfortunately, the atMega 32 is not a supported Arduino chip. If I define the F_CPU value as only 2Mhz I can get the light to the 1sec interval but the Unable to sync with device error continues.
I believe you are approaching the problem correctly. What I suggest to do next is not to run serial_nose.py from rosrun but directly from Python and debug each step. The source code link: https://github.com/ros-drivers/rosser...
One of the suggestions I read is to add rospy.spin() to this code for example that forces a return
I have been on this for about an hour but can seem to figure out where to add the rospy.spin for it to do anything that the
While not rospy.is_shutdown()
doesn't do. Also, I am probably missing something but how does stepping through the python code help to debug the avr_time.c file. Thanks, MathewI thought you said that the clock can be fixed by adjusting at 2MHz so next logical step is to fix the communication with rosserial
Sorry for the mixup I never actually set the clock at 2MHz I only told the code that I did. So I think that there is something that's scaling the clock or the time that's not working quite right.