How much can I store

My project consists of a robot with two stepper motors and three servo motors. Connected to an Arduino Uno with a CNC Shield. It's basically like a programmable SCARA robot.

I need to create a c library, external to the Arduino code, this would run on netbeans and would have two functions as follows:


parameters ( m1, m2, m3, m4, m5 )

This function uses a library to write to the serial port and what Arduino gets is a string with the following format
m1,m2,m3,m4,m5
Those are just the positions that the motors should be at.


run()

It tells Arduino all positions were already sent and it should run them one after the other.


What would be the best way to save all the positions?
I was thinking of something like an array int, but I have some questions about that

First, it's not going to be resizable, and I don't know how many times the parameters function is going to be executed before the run function

Second, is there a limit on how many integers can I store in an array, given that Arduino has a fixed amount of memory?

Thanks in advance!

jorge1701:
First, it's not going to be resizable, and I don't know how many times the parameters function is going to be executed before the run function

You need to size the array for the maximum amount of data you will need to store in it. Or you could just send the commands to the Arduino in real time. In that case, the Arduino would only need to store at most one set of motor positions. The PC sends the parameters, the Arduino acts on the received parameters, when it's time for another movement the PC sends new parameters, and so on.

jorge1701:
Second, is there a limit on how many integers can I store in an array, given that Arduino has a fixed amount of memory?

Yes. Depending on which Arduino board you're using, each int either takes 2 or 4 bytes of RAM.

pert:
The PC sends the parameters, the Arduino acts on the received parameters, when it's time for another movement the PC sends new parameters, and so on.

That's already a way to use it, but I'm making this for a friend that's a teacher and he wanted to add this other way to execute them.

pert:
Yes. Depending on which Arduino board you're using, each int either takes 2 or 4 bytes of RAM.

I'm using Arduino Uno

On the Uno, each int is 2 bytes. The Uno has 2 kB of RAM. So 2048 B RAM / (5 parameters/step * 2 B/parameter) = 204 steps. So the absolute maximum number of steps you could store in RAM on your Uno is 204. However, that would only be if you had the entire RAM for storing steps. The rest of your code is using RAM as well so really you have much less than 2 kB available to store your data. The Arduino IDE will tell you how much dynamic memory is used for globals at the end of the compilation. That's only for globals though. You also need sufficient free RAM for local usage, and the Arduino IDE can't tell you how much that is.

pert:
On the Uno, each int is 2 bytes. The Uno has 2 kB of RAM. So 2048 B RAM / (5 parameters/step * 2 B/parameter) = 204 steps. So the absolute maximum number of steps you could store in RAM on your Uno is 204. However, that would only be if you had the entire RAM for storing steps. The rest of your code is using RAM as well so really you have much less than 2 kB available to store your data. The Arduino IDE will tell you how much dynamic memory is used for globals at the end of the compilation. That’s only for globals though. You also need sufficient free RAM for local usage, and the Arduino IDE can’t tell you how much that is.

Thanks! I’ll have all of that in mind.
I’ll be using a linked list to save the parameters, I think it’s the best way but I’ll be open to other suggestions if you have them.

Thanks!

typedef struct Node
{
  int angle1;
  int angle2;
  int angle3;
  int height;
  int open;
  int time;
  Nodo* next;
};

Grab something like a teensy3.2. All your code plops right in and runs. But you suddenly have 64K or RAM as opposed to 2K.

-jim lee