Obviously everyone would say "don't leave it on for too long" but suppose the machine in question doesn't necessarily have somebody watching it at all times that's aware of the "intermittent duty" nature of the solenoid.
The CPU could impose a time limit, be connected to a temperature sensor, or "pick and hold" via PWM. However, this all would depend on the software working properly, and even a CPU running rock-solid software could still freeze up if the power supply gets noisy or unstable. If it froze while the solenoid was energized, then you'd better hope that someone sees it that knows to shut down the machine when a solenoid is stuck, otherwise you can say goodbye to the solenoid.
I have a couple ideas for how one might protect against solenoid burnout due to a CPU malfunction. A watchdog timer that, if it expires, drops out power to all the solenoids and motors, ideally via a relay or MOSFET that's independent of what the CPU uses to control them normally. That way, this will work even if the MOSFET you're controlling directly from the CPU fails shorted for some weird reason. And, if you design it properly so that watchdog doesn't also reset the CPU, then the CPU could intentionally let that watchdog expire as a backup way to stop everything if the CPU detects, for example, current flowing on the power bus when there shouldn't be any (i.e. current flow that doesn't "add up" to how many devices are active, current flowing when all devices are off, etc.)
Another way, at least for intermittent-duty-only solenoids, would be to have a circuit with a couple 555 timers, where the first one times full power to the solenoid, and then when the first one expires, the second one takes over, doing PWM at slightly above the lowest duty cycle necessary to keep the arm extended/retracted if that's necessary in the application. If it's not, then you would just have one timer that does a "pick and drop" function instead, not letting the solenoid be on for more than a second at a time no matter what the CPU says.
Finally, in keeping with the "CPU independent protection" theme, if you had a temperature sensor on each solenoid going back to a simple comparator circuit, the comparator could prohibit that solenoid from operating if the temperature gets too high, along with sending an alarm signal back to the CPU. This would probably be the ideal solution, because it could catch unforeseen issues such as a malfunctioning sensor causing the solenoid to "machine gun" or an odd software glitch that did not cause a total freeze-up of the CPU, therefore not triggering a watchdog timer.
Note that this isn't a safety-critical system I'm dealing with, only looking out for expensive "domino" failures, particularly with software freezes which may cost literally nothing to fix if it's not a recurring problem: just cycle power, end of story. Even if the CPU's power supply has an actual failure, solenoids are relatively expensive compared to power supply capacitors or a voltage regulator.
The CPU could impose a time limit, be connected to a temperature sensor, or "pick and hold" via PWM. However, this all would depend on the software working properly, and even a CPU running rock-solid software could still freeze up if the power supply gets noisy or unstable. If it froze while the solenoid was energized, then you'd better hope that someone sees it that knows to shut down the machine when a solenoid is stuck, otherwise you can say goodbye to the solenoid.
I have a couple ideas for how one might protect against solenoid burnout due to a CPU malfunction. A watchdog timer that, if it expires, drops out power to all the solenoids and motors, ideally via a relay or MOSFET that's independent of what the CPU uses to control them normally. That way, this will work even if the MOSFET you're controlling directly from the CPU fails shorted for some weird reason. And, if you design it properly so that watchdog doesn't also reset the CPU, then the CPU could intentionally let that watchdog expire as a backup way to stop everything if the CPU detects, for example, current flowing on the power bus when there shouldn't be any (i.e. current flow that doesn't "add up" to how many devices are active, current flowing when all devices are off, etc.)
Another way, at least for intermittent-duty-only solenoids, would be to have a circuit with a couple 555 timers, where the first one times full power to the solenoid, and then when the first one expires, the second one takes over, doing PWM at slightly above the lowest duty cycle necessary to keep the arm extended/retracted if that's necessary in the application. If it's not, then you would just have one timer that does a "pick and drop" function instead, not letting the solenoid be on for more than a second at a time no matter what the CPU says.
Finally, in keeping with the "CPU independent protection" theme, if you had a temperature sensor on each solenoid going back to a simple comparator circuit, the comparator could prohibit that solenoid from operating if the temperature gets too high, along with sending an alarm signal back to the CPU. This would probably be the ideal solution, because it could catch unforeseen issues such as a malfunctioning sensor causing the solenoid to "machine gun" or an odd software glitch that did not cause a total freeze-up of the CPU, therefore not triggering a watchdog timer.
Note that this isn't a safety-critical system I'm dealing with, only looking out for expensive "domino" failures, particularly with software freezes which may cost literally nothing to fix if it's not a recurring problem: just cycle power, end of story. Even if the CPU's power supply has an actual failure, solenoids are relatively expensive compared to power supply capacitors or a voltage regulator.