Anyone found solution of Arduino Mega/Due Lost Sync with device problem ?

1,167 views
Skip to first unread message

Zahid Mehmood

unread,
Aug 26, 2020, 4:17:54 AM8/26/20
to LINOROBOT
I am currently using Arduino Mega with Pi 3. while testing the motor's direction with the help of  roslaunch minimal.launch and twist keyboard I found an error of Lost synch with the device on the minimal launch terminal. Although the robot takes my first command correctly,  after that command, the robot wheels start rotating and it lost the sync connection with the device. 

I am unable to solve this issue, I also tested Arduino Due but still, the problem is the same.
People are reporting the same issue from the past 2 years on this forum but I haven't found anyone telling the solution to this problem.  

jime...@gmail.com

unread,
Aug 26, 2020, 1:36:47 PM8/26/20
to LINOROBOT
Can you try these instructions: https://github.com/linorobot/linorobot/issues/44

Zahid Mehmood

unread,
Aug 26, 2020, 2:57:07 PM8/26/20
to LINOROBOT
Hi Juan!  
I have already uploaded the code in the Pi 3 with the help of the instructions in your mentioned link. Now,  I wanted to ask you about the Mega "Lost Sync with the device problem". I can't find any solution on the google forum. I am currently in the Motor direction testing phase (2.3.1). the Robot takes only 1 command from teleop keyboard then I got an error in the minimal launch terminal of Lost Sync with the device problem - restarting and it continues trying to restart the connection in the loop but never succeed in establishing the connection again. 

One more thing I have noticed, both motors of my 2wd robot move in the forward direction when I give the command for a forward move from the teleop keyboard. But when I give any other command link  Back, Left, or Right, only one wheel of the robot rotates. I don't know why but if both motors rotate in one direction its means the connection is correct but for the other directions, only single motor rotates.  Note: I applied 1 command from the Teleop keyboard at a time after that the Lost Sync with device occurred. So, all of these testing I have done one by one; terminating the minimal. launch.

I found a conversation on Rotation of motor in only one direction in this link: https://groups.google.com/g/linorobot/c/O-Bj_cW1JzI  But I think the problem he is indicating isn't the actual problem because we define 2WD robot and LN298 Driver on the top of the config then it's not the actual problem. but some how I have chnage the Staring _PIN to any other Placeholder pin that I am not using. So, Please help me in these two problem.

Zahid Mehmood

unread,
Aug 27, 2020, 12:19:36 PM8/27/20
to LINOROBOT
I have noticed one more thing today. 

when I remove the encoder pins from Mega then the motors are working fine with the help of twist keyboard commands without giving any Lost sync errors. But when I attached the encoders pin again to the mega external interrupt pins 2,3 & 18,19. It again giving the same Lost sync error. 

One more thing, If I rotate the wheels with my hand to check the encoder readings the wheel automatically starts rotating. even I haven't sent any command from twist keyboard.  So, to check the encoders I remove the motor PWM pin to check the encoder values.  Please, anyone, help me to resolve this issue. 

peter.h...@gmail.com

unread,
Aug 27, 2020, 5:14:15 PM8/27/20
to LINOROBOT
Check the wiring of the encoders are they receiving 5 volts or if you are powering from the mega that they are not shorted to ground

peter

Logan Naidoo

unread,
Oct 4, 2020, 12:21:40 PM10/4/20
to LINOROBOT
Hi Zahid,
I tried both mega and DUE for this project on 4wd/mecanum settings.DUE may have the interrupts needed (8 for 4 x wheel encoders) but prob is the DUE is a 3.3v controller card and most sensors on market are 5v logic. So DUE is not an option unless you get all sensors with 3.3v or use logic level converters (makes wiring messy).  If you use Mega on 4wd its really a waste of effort because there is no enough interrupt pins to drive 4 wheel encoders.  A teensy 4.0 also is the same issue as the DUE , that is 3.3v i/o pin logic.  So without access to the teensy 3.x platform you can use the mega to drive 4 wheels but really only in "skid-steer" config.  I mean the actual config settings will be for 2wd setup with rear wheels using the motor +/- from the front wheels which has the encoders connected. With mecanum wheels you will get full rotation on the Z axis but will not be able to diagonal move the robot.
Trying to get Mega/Due setup in 4wd config is going to cause lost sync problems either with DUE 3.3v logic or the Mega's inability to handle interrupts needed for all four wheels.
If you going for 2wd robot then the mega should work fine without any sync issues.
The best bet for this wonderful design from the author/creator would be to use teensy 3.1/3.2 as it appears tried and tested by many on this group. It has the required interrupt pins for 4wd and 5v TTL logic to service the sensors recommended in the parts list.
It makes me now realise why Arduino DUE and Teensy 4 are not as popular as their predecessors even though they boast all that power - the sensor market has not yet fully embraced the 3.3v logic power requirements as yet !!

Nilanjan Fernando

unread,
Oct 13, 2020, 6:18:17 AM10/13/20
to LINOROBOT
I solved this problem by using two Arduino Mega boards. programme one Arduino to get the imu values from the MPU6050 and other Arduino to control the motors with encoder readings. And make sure you powered the Arduino using external power supply rather using Pi3 power. And also, you need to make some changers in the launch files in order to use two separate Mega boards at the same time. Refer the attachment to get an idea about those changers.
linorobot_changes.zip

Mohammed Sherief

unread,
Mar 2, 2021, 1:46:19 AM3/2/21
to LINOROBOT
Hello,

I am also using an Arduino Mega right now. Few questions from my side
1. Arduino has 6 interrupt pins, 2 of which is SDA, SDL , needed for IMU . We still have 4 interrupt pins , so a 2WD should still work on the Mega.
I mean theoretically it should work. Any idea why the mega doesn't work.
2. Can we use the mega to drive the motors and encoders and use an arduino UNO for IMU . Anybody using this setup.

Sherief.
Reply all
Reply to author
Forward
0 new messages