I am working on a device with an internal pump. Due to small differences in the pump's motor speed, I have to calibrate the pump. The result is a value between 0 and 1 (PWM duty cycle). The PWM is generated by an XMEGA32A4U, which I am programming in C++ with Atmel Studio 7.0 and I load the program with an AVRISP MK II. I also have an SD-card in the system to save data on.
My problem is now the following: I have several devices and I am trying to avoid to have to change the source code for every device before programming it. Not just because I am lazy, but it is also error-prone. And also because the remainder of the code is always the same and I don't want to save 10 times the same code containing only one differing number. What can I do? Things I thought of:
- reading a unique device ID and thus determining which value to take. But this requires storing a unique ID -> chicken and egg problem. Except if it can be done at programming time with a script (?) or there is a serial number I can read out at boot. The device ID appears to be non-unique as far as I read.
- Saving the values on the EEPROM in the microcontroller. I did some research and found that this is also not that simple, since you have to have again several source files to generate the several *.eep files which you have to manually select at programming. Although this is something I only need to do once, it is still 'manual'.
- Save a config file on the SD card and read it in the beginning. Probably the easiest part, but the SD card is user accessible and in theory delete- and exchangeable. Checking the file against a device ID would help of course, but then I am back at square one.
- Use serial communication to store a config value, which is then written to the EEPROM on the device. I could use LabView or a script to do this ("please enter serial number" -> checking against stored list -> output it via serial)
Does anyone have experience in this? What is the best path to take? Thanks!