Serial outgoing data dropped/lost

Hi all, this is my first post.I have an original Arduino Mega 2560 R3 and I'm very happy with it.A friend of mine has developed a shield and a small sketch capable to stimulate secured Progammable Logic Devices (like PAL or GAL) in order to recreate equations of these devices.Pratically this sketch perfoms a brute force attack on the PLD trying every possible inputs combinations and recording the resulting outputs (which then need to analyzed) In short, I have trouble with the output of this sketch though we both have same Arduino with same shield and run the same sketch.Binary output should be of exactly 8MB but I got always less (sometimes 7.99MB, sometimes 7.80MB and so on) it seems some bytes get lost or dropped.The issue should concern serial data speed trasmission, I tried to set 9600 baud instead of the default of 115200 and I get a full dump of 8MB but my friend has no problem at whatever speed he tries. I can't post here his sketch to respect his will but I can say it's really simple.I'm going mad about, I'm starting to think about a fault on my Arduino.I have also reprogrammed the ATmega 16U2 firmware without luck.Tried different O.S., different USB cables, external PSU but still the same I hope someone can put some light on this.Thanks in advance.

Sounds to me like the device receiving the serial output can't keep up with 115200 baud. You could try the next step down: 57600.

Hi and thanks for replying.Yes, it's what I'm trying but I started from the lowest rate of 9600 baud and I always get good output.But at this speed a full dump will take half a day (compared to 20 minutes at 11500)! Then, why my friend has no issue at all whatever speed he tries (also the higher of 1000000 baud)?Could this depend only from different computer receiving data?I also tried on more powerful machines than mine.

P.S. We both use IDE 1.0.5-r2. Are there in virtual COM some settings that could help (like control flow or FIFO buffer)?

Are you sending the data from the Arduino to a PC or are you receiving the data into the Arduino? If so from where and through what interface? And where are you putting 8MB of data?

...R

Hi, obviously I'm sending binary data from Arduino to PC through USB cable and then capture it (8MB) with a terminal program (I use Putty). It's really a strange issue given that the friend of mine has no issue at all with the same exact hardware and software set-up.I'm starting to think about a fault in my Arduino Mega 2560 R3.

caius: It's really a strange issue given that the friend of mine has no issue at all with the same exact hardware and software set-up.

So he has the exact same PC with all the same software running on it? That would be odd.

I still think there is something wrong with your PC. Did you and your buddy try swapping Arduinos to see if the problem moved with the Arduino or stayed with your PC?

I don't know if it has same PC but for sure he uses the same O.S. (Windows XP and Seven), same board (Arduino Mega 2560 R3), same IDE (1.0.5-r3), same sketch and same shield developed by himself.Since he is far from me I can't swap boards, that why I'm thinking to get another Mega 2560 R3 or a good clone.I repeat, if use slower speed of9600 baud I have no issue at all.

Yes, we know that 9600 baud works. You have said it several times. Now try 57,600 baud which should take only 40 minutes (twice as long as 115,200 baud).

No, 57600 doesn't work, I get incomplete dump but I just tried 38400 baud and I got a proper 8MB output (it took 36 minutes).Now I'm trying other times just to be sure this is the maximum speed I can use .If it's confirmed, I'm wondering why I can push it up and what is wrong.

P.S. The sketch uses the command :

bitSet(UCSR0A, U2X0);

to double speed of the UART port.Is this correct?

UPDATE: After a good one, I get a wrong reading with 38400 baud,.Now I'm trying with 28800.

caius: The sketch uses the command :

bitSet(UCSR0A, U2X0);

to double speed of the UART port.Is this correct?

Why do people use complicated stuff and then come here to have it fixed ????

As far as I know the command Serial.begin(baudrate) does all the setting that is required. It certainly works on my Uno up to 1Mbaud.

If your friend's Mega is running the identical code this particular line of code can't be the problem.

I strongly suspect you need to try your Mega with a different PC and a different USB cable.

...R

Robin2: As far as I know the command Serial.begin(baudrate) does all the setting that is required. It certainly works on my Uno up to 1Mbaud

.

Infact my friend can use also 1000000 baud without any problem

If your friend's Mega is running the identical code this particular line of code can't be the problem.

Yes, it's running identical code.

I strongly suspect you need to try your Mega with a different PC and a different USB cable.

Already tried different PC (two notebooks and two desktops), different O.S. (Windows XP, Seven and Ubuntu 14.04), still same issue

As the simple problems seem to have been eliminated …

caius:
I have also reprogrammed the ATmega 16U2 firmware without luck.

This is Big Boy stuff. Could it be the basis for the problem? (It is certainly not something I would fiddle with if another Mega was working with the normal setting. Has your friend’s Mega had the same reprogramming for the 16U2?

Have you tried a simple program to send data at different baud rates. If there is a problem with your Mega it should show up with any data.

…R

Robin2:
This is Big Boy stuff. Could it be the basis for the problem? (It is certainly not something I would fiddle with if another Mega was working with the normal setting. Has your friend’s Mega had the same reprogramming for the 16U2?

Yes, it has same firmware 0001 of ATmega 16U2

Have you tried a simple program to send data at different baud rates. If there is a problem with your Mega it should show up with any data.

Not yet.But, as far I can see, the problem occurs when there is a considerable amount of data transmitted from Arduino to PC, certainly I can’t reproduce the issue with a simple “Hello World” sketch.

caius: I can't reproduce the issue with a simple "Hello World" sketch.

Does simple stuff like that - or, say a few hundred bytes, work at all baud rates?

You could write some code that sends the same 100 bytes over and over and have a short PC program that would check that it is being received ok.

I don't think you have explained how your Mega is obtaining the data to be sent to the PC. Perhaps that is where the problem lies?

...R

Robin2: Does simple stuff like that - or, say a few hundred bytes, work at all baud rates?

Yes, simple programs with few trasmitting data work at all baud rates

Instead, my 8Mb dumps at higher speed are almost complete, they only miss few bytes, more high the speed, more bytes are missing.

I don't think you have explained how your Mega is obtaining the data to be sent to the PC. Perhaps that is where the problem lies?

If you had been more careful to read my first post, you would understand where they come from the data :) They are read from a secured 24 PLD (PAL or GAL) through the use of proper shield (nothing of complicated, just a socket connected to Arduino I/O and some 10KOhm resistors which acts as pull-up/pull-down ).But the problem could not lie in this shield since my friend has same set-up (same shield and same PLD to dump)

caius: If you had been more careful to read my first post,

I'm not the one with the problem ! Your first post was a long time ago and I have probably read 1 hundred other problems since. Don't expect me to remember them all.

They are read from a secured 24 PLD (PAL or GAL) through the use of proper shield (nothing of complicated, just a socket connected to Arduino I/O and some 10KOhm resistors which acts as pull-up/pull-down ).But the problem could not lie in this shield since my friend has same set-up (same shield and same PLD to dump)

The problem lies somewhere. Until you know where it is you can't exclude any source. Have you tried swapping your PLD to work on your friend's Mega.

Can you generate 8MB within your Mega and send all that correctly to the PC at high baudrates? If you can then the input process must be suspect.

You need to devise a careful series of tests that prove that each separate part of the system is working.

...R