Gwyscope documentation

open hardware SPM controller with advanced sampling support

User Tools

Site Tools


simple_scan_by_lua

This is an old revision of the document!


Lua scan

This simple client connects to the server and sets the operation regime to proportional feedback (typically used in contact mode, difference between value of signal on input and some setpoint value makes piezo to extend or shrink, depending on settings). Then it sets some basic parameters of feedback loop and sets feedback on. It sets the scanning velocity and then it scans 1×1 micrometer in 50×50 pixels using a Lua script, scanning point by point. Finally, it stops the feedback, shrinks the z-piezo and exits.

Used commands and their parameters:

state: mode: proportional to set the mode, which connects inputs, outputs and sets many other parameters as defined in hwserver.ini file on the server

set: pid_p: 0, pid_i: 0.1, pid_d: 0, pid_setpoint: 0.2 to set the feedback loop parameters

set_feedback: feedback: true to start the feedback loop, which should make z-piezo to extend and probe to reach the surface if the sample is in reachable distance, setpoint is correct and settings in hwserver.ini match the experimental configuration.

set_scan: speed: 1e-6 to set the scanning speed to 1 micrometer per second

run_scan_script: n: 2500, script:

local scan = {}

function scan.runit()
  gws_clear(p)
  for x = 0, 10e-6, 0.2e-6
  do
      for y = 0, 10e-6, 0.2e-6
         do
            gws_move_to(p, x, y, 0)
            gws_store_point(p, x, y, 0)
         end
   end
end
return scan

get_scan_ndata: n to get how many points were already measured (repeated until all 50 values are measured)

get_scan_data: from: 0, to: 2500 to get all the data at once (data could be red also sequentially as they are measured altering the “from” and “to” value).

set_feedback: feedback: false to stop the feedback

move_to: zreq: 0.0 to move the z-piezo to zero after the feedback is stopped.

To explore it further, see the simple client implementations in C and in Python.

simple_scan_by_lua.1780318804.txt.gz · Last modified: 2026/06/01 15:00 by pklapetek