Would you like to react to this message? Create an account in a few clicks or log in to continue.

You are not connected. Please login or register

Simulide stops responding with Arduino and serial communication

3 posters

Go down  Message [Page 1 of 1]

RicardoKers



I'm having problems simulating the Arduino serial communication. After a few seconds of simulation, the Simulide stops responding and need to be closed.
The simulation is very simple, only one Arduino communicating with a hardware connected to a serial to usb converter, no other components are used in the simulation.
The Arduino program is attached.
I tried with Arduino uno and Arduino duemilanove.
And I tested versions 0.3.11 (win32), 0.4.14-SR4 (win32), 0.4.14-SR4 (win64) and 0.4.15-SR1 (win64) of the simulide and had the same problem in all of them.
The strange thing is that everything works correctly for about 40 seconds after that the Simulide stops responding.
My computer is a notebook with an I7-10750H processor and 32GB of RAM.
Thank you for your help
Attachments
Simulide stops responding with Arduino and serial communication AttachmentSeguidorDeLinhaSerial.zip
You don't have permission to download attachments.
(4 Kb) Downloaded 4 times

arcachofo

arcachofo

Difficult to know what is happening.

Have you tried at lower serial baudrate?

How is the simulation speed doing?

Are you using serial monitor to see if the transmission is doing as espected?



RicardoKers



I ran a few more tests and noticed that with higher baud rates the program was losing some data. So I reduced the baudrate to 1200 and the data loss apparently didn't happen anymore. Even so, after a few seconds the Simulide crashed and had to be closed.

Something interesting happens with the speed of the simulation, in some tests the speed remained between 99 and 100% until the simulator crashes. In other tests, the speed decreased over time, starting at 100% and then slowly reducing 95%, 88% 76%, 67% and reaching 55% when the simulator crashed.

In short, the simulator crashes at high or low baudrate, with or without data loss, and with high or low simulation speeds.

To simplify the tests I am connecting to the computer a duemilanove arduino (external hardware) and in this arduino I am using a very simple program, which only performs the communication with the simulated arduino through the serial. The test program is attached.
Attachments
Simulide stops responding with Arduino and serial communication AttachmenthardwareDeTeste.zip
You don't have permission to download attachments.
(1 Kb) Downloaded 0 times

BenZr



I have tried to reproduce the problem connecting a physical Arduino Mega board in place of the robot. The mega board send repeatedly  the 4 bytes packets (255, sensorLeft, sensorCenter, sensorRight) with varying sensor values to your simulated program and when receiving the angle command (10,90, or 170) , the Arduino Mega  lights a different LED (red, green blue).
I have run with gdb  the debug version of simulide 0.4.15-SR1, to try to  backtrace where the program stalls.    
I have been able to  reproduce the problem at 9600 and 115200 baud rates. Note that if I wait between  the transmission of the packets (ex delay(500)), the program works fine.  
I do not know if it is useful, but here is screen-copy of the backtrace hitting Ctrl-C when the simulator stalls  
Simulide stops responding with Arduino and serial communication Screen11

RicardoKers likes this post

arcachofo

arcachofo

Thanks BenZr, now I have an idea of what is happening.

I think he main problem is that the robot (or whatever is sending data to simulide) is sending data faster than it is being read.
Anyway simulide should not stall in this case, so there is an issue to solve here.

A workaround is sending data less often:
BenZr wrote:Note that if I wait between  the transmission of the packets (ex delay(500)), the program works fine.  
500 ms is probably too much for a line follower, but 50 ms or 100 ms should be enought.

The problem is related to how USB to Serial "cables" work.
USB to RS-232 adapter does not send byte by byte like Serial, but in packets.
Read this to have an idea: http://blog.ilektronx.com/2010/02/xbee-and-ftdi-latency-and-dropped.html

Some setting can be sometimes configured:

Simulide stops responding with Arduino and serial communication 7807

So in this case, using USB to RS-232 adapters you should send a packed of data, then wait some time (more than the driver timeout) so the data is actually transmitted, then send another packet of data.

Or: send packet, wait for a reply, wait some more time, send another packet...

Also some usb-serial adapters can't handle 115200 very well.
Always use the lowest baudrate needed.

RicardoKers and BenZr like this post

Sponsored content



Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum