Detection of zero crossing for command and maximum for reading value