Hi!
I was wondering if this possible to compile / run a program passing it a parameter like you usally do with c programs.
Let's say I have 100 programs with 100 communication adresses and some variables I want to change. All of them have the same behaviour.
What I would do is go 1 by 1 changing manually the variables of each one. That's why I was wondering if you could compile a program with arguments so the arguments would be the variables I need to use.
A workaround i thought about is writing a program that uses fstream to write into the files passed as parameters. But not sure if its the best way to do it.
Suppose you had a way of providing your Arduino with a variable that could be read when it turns on, that doesn't change when you modify the code? Suppose that you could write that variable to each device once, and it would remain there forever? Would that suffice?
Then please read about EEPROM (if it's available for your Arduino, because since you didn't tell us which one you have, we don't have any way of helping). There may be other non-volatile options for the processor you have, if it doesn't have EEPROM.
This sounds very demanding and time consuming but yeah , having to go through 100 devices is time consuming but sounds like a solution. Generating 100 sketches with different variables sounds worse than what you suggested, I'll look into it.
I mostly use arduino uno, but its open to any arduino family device with any communication protocol that uses adresses.
Here's a use case example. I have a code for my n Nano devices which is identical on every one. At startup, the code loads an identity and personality from the EEPROM. That consists of a node number, and a list of attached devices. That list defines the behavior of the node completely, including what and how it communicates with other nodes. I wrote that table once to each device. Now, a year later, I'm still modifying the code, but I write the same image to every node when I do an update, because the personality is in EEPROM, not in the uploaded code.
Hope that helps.
Yes , that kind of works, because each time I do a new version of the program I could just load the same program to each device and since the variables are defined in the EPROM I shouldn't have to go through all of them to update the code.
I guess you need to have good labeling on the devices to not mess up. Any recomendations?
Simple is good. I label them 1...N, same as the node number, AND the number is on each board the Nanos plug into. An alternative might be to put something on the carrier board that identifies the board function - like a '595 shift register attached to a dip switch where you set the unit ID. It's up to you, it depends so much on the application. I suggest you think on it a bit, come back with a proposal, and we can discuss it's benefits and limitations.
Your initial idea of compile-time args isn't necessarily wrong, but it still leaves you needing to put the right devices in the right places, so ymmv.
Each board is a slave from its master with some time variables depending which stepper is controlling. They are in order and attached to a wall. So i think 1...n would work. I would think of putting a label on the back with the values but maybe having a simple arduino EPROM debug would be easier.
I don't understand what do you mean by this, could you explain a little bit more?
I don't know where compiled arduinos sketches goes or if they can be uploaded with command lines(I'm guessing you can) but I liked the EEPROM and it looks simple enough so I would go with that.