Hello, 
I would like some help about a project for an embedded system with stepper motors.
To do this, my program allows to extinct and to turn on again the system thanks to relays.
When you turn on the device, the Arduino switches on the device, reads some variables of EEPROM adresses (to know which step the motor is currently.). When you turn on the device, the Arduino switches off after having updating the values of the variables in the same EEPROM adresses.
My features "turn on" and "turn off" have been well functionning. And I also tried my program to read and write EEPROM adresses' values. this program correctly functions. However, when I assemble both programs, after switching on the device, my motor never achieves to know its position. The read values are wrong.
Would you know why? Thank a lot in advance for all answers.
Have a nice afternoon
You are having trouble with a program. How are we to help without being able to see the program? Read the "how to use the forum" stickies to see how to properly format and post your program, please.
When you turn on the device, the Arduino switches on the device, reads some variables of EEPROM adresses (to know which step the motor is currently.).
That might work in your setup, but in general it does NOT work reliably because the motors can move (or be moved) when the power is off.
Normally, you have a home sensor (usually something optical) and every time you power-up (and sometimes more frequently) you rotate the motor to re-locate the home position.
And you probably need a home sensor anyway, unless you plan on manually homing the motor every so-often.
Hello,
Thank you for both answers !
Indeed, DVDdoug, the motors can move when the power is off. However I never touch the motor even if the power is OFF. I don't have a home sensor... unfortunately..
groundfungus : Excuse me, I was annotating my program for easier access.
Here you are my program and the wiring (realized on OrCAD CIS LITE SCHEMATIC software). Do not hesitate to ask me if you have any questions.
Thank a lot for your help ...
Paramètres utilisateurs à modifier.pdf (109 KB)
Please post your code using code tags.
** **[code]** **
your code here
** **[/code]** **
so it will look like
your code here
If your code is too large, just attach the ino (you might have to rename it to .txt). I did manage to copy from the PDF, but reading the PDF itself is very strange with a double / triple column layout.
All your Nb_ variables seems to be integers; you are however using eeprom.read() and eeprom.write() which works on bytes and hence you're missing half the data. Also, based on your eeprom addresses, your Nb_ variables seems to be bytes.
If you need integers, use eeprom.put() and eeprom.get() and adjust the addressing to cater for integer (2 bytes). Else change your Nb_ variables to byte.
I don't know if this is the cause of your problem though.
Hello sterretje !
Thank you for your help !
I try to translate int "Nb_variables" to byte thanks to "Nb_variables_faible" and "Nb_variables_fortes".
I also try to use EEPROM.get and put with integers. But it doesn't work...
Maybe I badly translate int to bytes... I will check it !
Programme.txt.ino (23.5 KB)