A self-learning Neural-net-based Fuzzy logic System (NFS) is designed to determine the gains of a PID controller. The controller operates in a closed-loop system. The NFS receives the error, error integral and error derivative signals, and by fuzzy inference it adjusts the controller gains. As a result, these gains vary with time to achieve good performance compared to a conventional PID controller. A modified random optimization learning algorithm is given to train the NFS. The learning algorithm does not require a model of the plant being controlled. Instead, it uses knowledge of plant input/output behavior to update parameters of the NFS.