Neural controller for functional electrical stimulation