I need to make a 2D printer plot 100 data points (X,Y). I cant save those X,Y points in my sketch cause arduino memory is to low to keep all those 100 points. So my solution so far was to paste one by one each coordinate in the serial and wait arduino plot it.
It works but it's too tedious. So I thought abou pasting all the X,Y coordinates in the serial but only the first 4 are executed by Arduino. I think it's related to the buffer size.
Can I have a buffer size of 1MB for example? If not, can I tell arduino IDE to send the data in intervals of 1 second so the buffer nevers gets full?
Yes I have 8GB of RAM in my computer. Arduino IDE will keep that 1MB of buffer in my computer's memory and just send it to arduino when it already read the last data sent?
batata004:
Yes I have 8GB of RAM in my computer. Arduino IDE will keep that 1MB of buffer in my computer's memory and just send it to arduino when it already read the last data sent?
There are many solutions and whether you have 800 Bytes of Arduino SRAM available is unknown. But if you need to tie your Arduino sketch to the PC, this is one way: Connecting Arduino to Processing - SparkFun Learn
@mrburnette I spent the last entire night seting up my code and it finally worked (thank you @mrburnette).
But there is a prorblem: when I send the data (coordinates) to my printer using Arduino IDE serial the printer gets much more precise. When I use Processing my printer loses a lot its precision. Why?
BTW I didtn do any change to my arduino code, it is still exactly the same. I just created the Processing code to send data to my arduino as I would manually do in the serial.
What could be going on? Is Processing somehow delaying arduino or causing it to lose some "cycles"?
@AWOL I am sorry, I really thought you were fooling me around. I just didnt believe you cause when I send more than 4 coordinates at the same time in my serial arduino will only process the first 4 and after that it gets "buggy" (I think that it's related to some overflow in the serial buffer). So I ask you: if arduino can handle my 100 coordinates, why can I only send 4 of them in the Serial and all the others get lost/corrupted? Why aarduino buffer is not keeping all the coodinates I am sending and processing it as it did with the firt 4 coordinates?
this forum is full of brilliant people like @jremington who knows how to send 100 number pairs but does not know how to explain... or maybe he cant send 100 number pairs either and is just fooling around
@AWOL here comes the code. I try to use a delay(50) to make arduino wait more than needed so the buffer gets bigger and bigger (less than 100 chars) and it does not work.
Upload this to your arduino:
void setup() {
Serial.begin(115200);
while (true) {
if (Serial.available()) {
String resultado = "";
while (Serial.available()) {
delay(50);
resultado += (char)Serial.read();
}
Serial.println(resultado);
}
}
}
void loop() {
}
Open your serial (set 115200 baud) and send this (100 chars long):
And this forum is hearing a lot from @batata004 who can't explain his/her problem, can't post code other than snippets, and can't find the Portuguese section of the forum.
delay(50) is to allow the OVERFLOW. Unfortuatelly you didnt get the idea, hope another person understand it. You probably does not know what is a snippet.
Portuguese forum is terrible, only a few people can help there.
Think about it; characters are arriving at 11520 characters a second, and you're reading them out at 20 characters per second, with a 64 character buffer.
Do the arithmetic.
I can't imagine why you'd want to do that, but I'm just an unimaginative Anglo-Saxon.
@AWOL I have a 2D printing code which is too big and I am trying to isolate the problem providing you a small code. Everytime my printer reads 2 numbers from serial it stops reading, prints that coordinates and starts reading again. Usually between each print, it takes about 3 or 4 seconds.
So when it returns back to read the next data in serial it simply disappeared (it actually can read it in the second and third time, but after that the remaining serial data is gone).
You told me arduino could easily hold those 100 numbers in serial, but my code just proves you are wrong - at least in some conditions, like the code I provided you, what you say it not true.