Update pid.c

1. Input to process should be ur instead of u
2. Dynamic memory allocation
3. Improve initialization procedure