Motor controller circuit with inverting switch (automatic cover driver)

I need some help on a circuit i need to make, for a tonnau cover open and close

The basic principle of the circuit is i hit a switch, the switch tuns on a relay, the relay starts the motor, cover opens and automatically stops when hiting a microswitch on the tonnau cover that indicates the open state (of the cover) and keeps it that way until i hit the switch again.
Then when i push the switch again, the cover should close and on the fully closed position hit a microswitch that resets the circuit or enables the first part again...

I have a few ideas, but nothing concrete and i can't find any simmilar circuits :(

This is a circuit I made for a lift that should work with your cover.

Push one button the lid goes up push the other button and the lid goes down.

Now if you only want to push one button or toggle one switch to make it go up or down you need to swap out the up down buttons for a three pole.


If you use a latching push button for the changeover switch in the bottom of this picture, this circuit does what you want, with two limit switches and two relays. The diodes are there to protect the rest of the system from sparks off the motor.

Hen door.jpg