A mechanical lung simulator can be used to simulate specific lung pathologies, to test lung-function equipment, and in instruction. A new approach to mechanical simulation of lung behavior is introduced that uses a computer-controlled active mechatronic system. The main advantage of this approach is that the static and dynamic properties of the simulator can easily be adjusted via the control software. A nonlinear single-compartment mathematical model of the artificially ventilated respiratory system has been derived and incorporated into the simulator control system. This model can capture both the static and dynamic compliance of the respiratory system as well as nonlinear flow-resistance properties. Parameters in this model can be estimated by using data from artificially ventilated patients. It is shown that the simulation model fits patient data well. This mathematical model of the respiratory system was then matched to a model of the available physical equipment (the simulator, actuators, and the interface electronics) in order to obtain the desired lung behavior. A significant time delay in the piston motion control loop has been identified, which can potentially cause oscillations or even instability for high compliance values. Therefore, a feedback controller based on the Smith-predictor scheme was developed to control the piston motion. The control system, implemented on a personal computer, also includes a user-friendly interface to allow easy parameter setting.