reading a digiswitch

hello there,

i am having problems reading a digiswitch (rotary knob) accurate. i know the notes about the rotary knob from the playground but i do not have accurate readings with the code example. while turning the knob, the 'encoder0Pos' variable shows a jumping behaviour. it should count up, but somtimes it counts one or two numbers down despite i did not change the turning direction.

also i do not understand the interrupt function and the relation with the waveform diagram shown in on the playground.

here is a link to the knob i use:

http://www2.produktinfo.conrad.com/datenblaetter/700000-724999/705586-da-01-ml-Drehimpulsgeber_liegend_de-en.pdf

greetings,
slex