PID library giving nan out output

but the only output i get of the output is "nan"

Does the phrase "garbage in; garbage out" mean anything to you? If your input is NAN, your output will be NAN, too. Check that BEFORE whining here.