Solenoid outputs are used for many purposes. We use the term 'solenoid' or 'coil' generically to refer to any writable, high power output. They could be connected to coils, flashers, or motors. Like the lamps, they are individually controllable.
Unlike the controlled lamps, the core API does not permit you to turn on a solenoid permanently. Instead, you either use a pulsing API, which turns it on for a short period of time (and the system turns it back off for you), or you use a custom driver to control it.
Pulsing is used for solenoids that are operated infrequently, and only for short durations at a time. These are normally used for kickers, poppers, etc. The system queues the requests and executes them one at a time, never in parallel.
The default pulse settings are controlled by the entry
in the machine description, in the "drives" section. The time
parameter sets the total length of time for the pulse. It can be an integer
value in milliseconds, or one of the TIME_xxx
values which are in
multiples of 16ms. The duty
parameter controls the duty cycle; use one of the SOL_DUTY_xxx
defines.
SOL_DUTY_100 keeps the driver on for the entire interval; SOL_DUTY_50 keeps
it on half the time, delivering half the power; and so on. The minimum duty
cycle is 1/8th full power.
If you do not specify either of these values, you will get a reasonable, but conservative default. Solenoids and flashers may have different default values. A large portion of getting a new game to work correctly is determining the correct values to use here.
sol_request
sol_request_async
sol_req_start_specific
The flashlamp APIs are similar to the solenoid pulse APIs. A flashlamp pulse is always with a 100% duty cycle, but for a much shorter period of time.
Note: it is currently possible to use the solenoid pulse APIs on flashers, but this should not be done. This will likely be enforced in the future.
flasher_pulse
flasher_pulse_short
flasher_start
Custom drivers can run for longer periods of time. They are allowed to run in parallel with anything else. They will frequently use duty cycling to avoid keeping the coil 100% active for too long, and thus they often require realtime processing to switch reliably.
These types of drivers are all implemented using templates.