Also since this is a thread about PID tuning, let me throw up some suggestions for Trial and Error Parameter Adjustment. If the math in the mbed method isn't working for you, use these rules of thumb to get the performance you want.
Parameters and what they do (sort of)
P_Param: the bigger the number the harder the controller pushes.
I_Param: the SMALLER the number (except for 0, which turns it off,) the more quickly the controller reacts to load changes, but the greater the risk of oscillations.
D_Param: the bigger the number the more the controller dampens oscillations (to the point where performance can be hindered)
These are rules of thumb and aren't exactly what's going on inside the controller, but they should help when deciding which number to change and in which direction.
And lastly, if the second you enable the controller the output goes in the wrong direction and pegs at 0 or 100%, you've got the sign of the P_Param wrong. That is, if you've got a 3 in there, make it -3.