Thank you all for their nice suggestions and comments. @gr5, suppose if I use command G0 X1 it will move the head once, later if I again execute this it will not move the head? If I want to scan the head from point 1 to point 2 with stem size 0.5mm, I have to pass a gcode such as "G0 Xk" where k is calculated as Pi where Pi previous location+0.5?
Thanks a lot.