Go Down

Topic: Arduino Bandwidth (Read 1 time) previous topic - next topic

Alicefaisal

Hello,

In my project I am trying to send text from Arduino (A) to Arduino (B) using LEDs and photo-detectors. I have noticed that I can get a successful communication link for short words. When I send a sentence the first few characters are received correctly and the rest is gibberish. I am not sure where the problem is.


In my attempt to figure where the problem is I am trying to determine the bandwidth of the Arduino. Can I connect the two Arduinos and communicate them using serial as a test (no components)?
Could the problem be from my choice of micro-controller?

PerryBebbington

Hello Alicefaisal,
Welcome to the forum.

Please read 'how to use this forum - please read', there's a clue in the title. Then follow the instructions.
Quote
I am not sure where the problem is.
There's a problem with your code. Or your circuit. Or something. Not sure how you expect us to help when you've kept these things secret from us. Please note that while there are clever people here I do not believe a single one is telepathic.


PerryBebbington


Quote
In this post, I am trying to figure a way to determine the bandwidth of serial communication.
Whatever you set it to in your code.

Way more than necessary for sending a sentence or 2 over serial, even if you select the lowest available baud rate.



DrAzzy

Using wires instead of LEDs and photodetectors, 115200 baud is easy. Your problem is likely with that part of the setup
ATTinyCore for x4/x5/x61/x7/x8/x41/1634/828/x313 megaTinyCore for the megaavr ATtinies - Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts, mosfets, awesome prototyping board in my store http://tindie.com/stores/DrAzzy

jremington

Quote
Could the problem be from my choice of micro-controller?
No, code or circuit problem.

Post the details, following directions in the "How to use this forum" post, and forum members can help.

westfw

Quote
I am trying to figure a way to determine the bandwidth of serial communication
It's complicated.   The Serial UART hardware will max out at about 2Mbps, and SPI at I think 8Mhz, but at that speed you have about 16 machine instructions per byte to do whatever processing is needed. (in an AVR-based Arduino like an Uno or Nano.)
You didn't say what hardware interface you're using, or what sort of speed you're TRYING to get, or what sort of infrared protocols you're using, so it's difficult to say whether the problems are because of bandwidth limitations, or because of other problems.  I'd say that 115200bps IRDA should be "easy" (but the hardware doesn't directly support IRDA), and 4Mbps IRDA is "unlikely."  Maybe 2400bps over typical 40kHz carrier IRRC...  IRDA is probably a good protocol to try to copy...


PerryBebbington

#6
Nov 02, 2019, 11:33 am Last Edit: Nov 02, 2019, 11:34 am by PerryBebbington
Quote
Please find this pseudocode for both the transmitter and receiver sides:
Erm, as you presumably have this working I suggest it would be more helpful to post your actual code.

Code: [Select]
String a, b, c, qmsg;

String (upper case S) is known to cause problems on Arduino. Use C strings instead, for example:

Code: [Select]
char myStringData[] = {"Some text I want to send or receive"};
or
Code: [Select]

#define bufferSize 50    //Size of buffer required
char myStringData[bufferSize];


For the details of why String causes problems search these fora, there are plenty of examples and explanations.



jremington


PerryBebbington

There are better people than me here to comment on code, but I'll give you what I can...

LED.jpg shows an LED with no resistor, this will damage the LED or the Arduino output or both. You must use current limiting resistors with LEDs

You code is full of delay();s, this can only be a source of problems.
As already suggested, do not use String (upper case S).
You repeatedly write Laser high then high again without ever writing it low.

My opinion is there is no point looking any further until the obvious things are addressed.

Also, please learn to break code down into functions and call the functions from loop();, rather than cramming everything into loop();. Some comments would be good too, I am having to work really hard to tell what the code is supposed to do.

Maybe someone else will spot something else that needs attention.


PerryBebbington

#9
Nov 05, 2019, 05:01 pm Last Edit: Nov 05, 2019, 05:01 pm by PerryBebbington
Quote
I imposed the delay to have synchronous communication.
Your original question asked about 'bandwidth', which is probably not the rigth term in the circumstances, but I think we all knew what you meant. The delays are eating up almost all the available 'bandwidth'. If you think you need to use delay then you almost certainly have other problems that delay is masking. I suggest you read Serial basics


Quote
I have tried using array of char, but I faced some issues with breaking the String array into a char array. because in the Tx code every array element is 5 chars, which will cause a problem at the conversion side.
I've no idea what that means. It would help to post what you tried and explain the problems you had.


Quote
I am sorry, I forgot to add comments. I will edit the post now.
Don't.
Go away and work on the things above and most of all work on using functions. Then come back tomorrow or next week or whenever and post code with functions that have meaningful names and comments that make sense of what you have done.




Go Up