memorize 0 angle to DC motor

hi
how I can memorize 0 angle to a DC motor with arduino, I know how to control the position of a Dc motor with the encoder but the problem is the reading of position when the arduino plug in ,if I set the posotion of DC motor to a set point for example 90 degree and disconnect the arduino and reconnect it the angle is 0 and dc motor rotate 90 degrees again! but I want to dc motor stop at this position az 90 degree and don’t rotate

Give it a way of knowing about that 0 position. For example, most (3D) printers use end stops. At start up it moves towards the end stop and when it hits it it knows it's at 0. Or if it's rotary, add a sensor/switch which gets pressed when 0 (or and other number really). That's the only way to know for sure, including movement while it was off.

Other option is to save it to EEPROM. Downside, the number of times you can write to an EEPROM address is limited before it wears out...

Use a limit switch and something on the motor shaft to define the zero position. Every time the Arduino is powered up, drive the motor until the switch is activated.

I think you mean stepper motor here ?

Most steppers you can drive against a physical
Stop and stall it , then you know where it is , providing you gave it enough steps to drive it at least to the stop . You could do that bit in setup

hammy:
I think you mean stepper motor here ?

Most steppers you can drive against a physical
Stop and stall it , then you know where it is , providing you gave it enough steps to drive it at least to the stop . You could do that bit in setup

The poster said DC motor with encoder.

The glib answer is to use an absolute encoder, not incremental, but a homing switch and homing cycle at start
up is usually the easiest cheapest method.

Can’t do angles on a DC motor as you cant stop it at a specific point on a revolution , unless it has a low ratio gearbox on it and the motor is turning lots of revolutions and you are looking at the output of that?? - hence suspected he meant a stepper motor or something else , can’t see how his DC motor has moved “90 deg when he plugs it in” never seen that ... despite what the OP said ....