MethodSCRIPT: Tips & Tricks
These Tips & Tricks will guide you to create your first MethodSCRIPT, debug the script, solve any errors and visualize the results. At the end, you will find example scripts. Alternatively, watch the MethodSCRIPT webinar recording to get introduced by our MethodSCRIPT expert.
MethodSCRIPT is the language our latest generation of potentiostats speaks. It allows you to communicate directly with the potentiostat (module) from any operating system or microcontroller. Supported devices include EmStat4S, EmStat4M, MultiEmStat4, EmStat Pico, Sensit Smart and the Sensit BT.
Get started with your first MethodSCRIPT Watch MethodSCRIPT webinarEdit your first script in PSTrace
The software PSTrace controls all PalmSens instruments. Now lets connect an instrument that supports MethodSCRIPT to your computer, and start PSTrace.
- Connect your instrument in PSTrace
- Select a technique and set the parameters. For example LSV from -0.5 V to 0.5V.
- Click “Show MethodSCRIPT” on the bottom
- Edit a setting, for example lets double the scan rate from 0.1 V/s to 0.2 V/s.
- Copy the script to clipboard.
The resulting code will look like this:
e var c var p set_pgstat_chan 1 set_pgstat_mode 0 set_pgstat_chan 0 set_pgstat_mode 2 set_max_bandwidth 40 set_range_minmax da -500m 500m set_range ba 590u set_autoranging ba 59n 590u set_e -500m cell_on meas_loop_lsv p c -500m 500m 10m 100m pck_start pck_add p pck_add c pck_end endloop on_finished: cell_off
If you can’t see Show MethodSCRIPT button, please enable it by going to the tools –> general settings –> Show MethodSCRIPT editor as shown in the image below.
Edit your code using Notepad++
You can use any text editor to change the MethodSCRIPT code. If you prefer Notepad++, you can get correct syntax highlighting by using the MethodSCRIPT UDL file.
To get highlighting for MethodSCRIPT files ending with .mscr in Notepad++, please follow these steps:
- Download and unzip the MethodSCRIPT UDL file.
- In Notepad++, select Language, User defined language, Define your language, import.
- Select the MethodSCRIPT_UDL.xml file.
Every .mscr file you open, will automatically load with the correct syntax highlighting.
Download MethodSCRIPT UDL file for Notepad++
Learn the MethodSCRIPT commands
The script consists of a series of pre-defined commands. Each command starts with the command string, followed by a pre-defined number of arguments. Arguments are separated by a ‘ ‘ (space) character. Each command is terminated by a ‘n’ (newline) character. The ‘n’ is omitted in most examples. Each line is limited to a maximum of 128 characters. Comments can be added by having the first non-whitespace character on the line be ‘#’.
To send a script to the device, first send “en”. This sets the device into MethodSCRIPT mode. To terminate the script, add a line containing only a ‘n’. The following examples send hello world.
e #This is a comment send_string "hello world"
The response to this script will be:
en ← Ack of the execute script cmd ‘e’ Thello worldn ← Reply of the “send_string “hello world”” cmd n ← End of script
For all commands, please check the MethodSCRIPT documentation.
Download the MethodSCRIPT documentationDebug your script with Tera Term
When debugging your script, you would like to get immediate feedback: on which line is there an error? The PalmSens instruments that support MethodSCRIPT, can communicate via a serial connection. Tera Term is an open-source and free terminal emulator program. It is often used for serial communication. Via this serial communication, you can send your MethodSCRIPT commands and see the response of the MethodSCRIPT interpreter.
To setup TeraTerm:
- Download TeraTerm
- Setup the terminal to receive and transmit LF: line feed.
- Enable local echo
- Select the Consolas font, regular style, size 10
- Connect your instrument
- As a serial port setup, select a COM port with FTDI in the device instance ID (in case of EmStat Pico) or one that shows EmStat4 (for the EmStat4 LR or HR) in the device friendly name.
- Choose 230400 bit/s as speed for the EmStat Pico based potentiostats, and 921600 bit/s for the EmStat4 based potentiostats.
- Save the setup


To enter scripts via Tera Term, please paste scripts from the clipboard by using your right mouse button. Manually typing your commands is only doable for short commands. Typing long commands or even scripts will trigger a timeout error 0009. This is an example of pasting the hello world script from the clipboard in TeraTerm. Note the two new lines after “hello world”, for which you can press the enter key twice:
Error handling
Errors can occur that prevent the execution of the MethodSCRIPT. These errors can occur either during the parsing of the script or during the execution of the script (runtime).
Error format
- XXXX = The error code, see table below, where:
- L = Line number, starting at 1
- C = Line character number, starting at 1 (only visible during parsing)
#Error during parsing !XXXX: Line L, Col Cn #Error during runtime !XXXX: Line Ln
Comment lines only count during parsing
The reported line number for runtime errors does not count comment lines. For parsing errors, the comment lines do count.
Solving the error
If you encounter an error, look up the description of the error in the table below. The description of the error combined with the line number, helps you to find the incorrect command. The MethodSCRIPT documentation will guide with examples of how to use each command.
Download the MethodSCRIPT documentationError description table
| Error code | Description |
| 0x0001 | An unspecified error has occurred |
| 0x0002 | An invalid VarType has been used |
| 0x0003 | The command was not recognized |
| 0x0004 | Unknown register |
| 0x0005 | Register is read-only |
| 0x0006 | Communication mode invalid |
| 0x0007 | An argument has an unexpected value |
| 0x0008 | Command exceeds maximum length |
| 0x0009 | The command has timed out |
| 0x000B | Cannot reserve the memory needed for this var |
| 0x000C | Cannot run a script without loading one first |
| 0x000E | An overflow has occurred while averaging a measured value |
| 0x000F | The given potential is not valid |
| 0x0010 | A variable has become either “NaN” or “inf” |
| 0x0011 | The input frequency is invalid |
| 0x0012 | The input amplitude is invalid |
| 0x0014 | Cannot perform OCP measurement when cell on |
| 0x0015 | CRC invalid |
| 0x0016 | An error has occurred while reading / writing flash |
| 0x0017 | The specified flash address is not valid for this device |
| 0x0018 | The device settings have been corrupted |
| 0x0019 | Authentication error |
| 0x001A | Calibration invalid |
| 0x001B | This command or part of this command is not supported by the current device |
| 0x001C | Step Potential must at least 1 DAC LSB for this technique |
| 0x001D | Pulse Potential must at least 1 DAC LSB for this technique |
| 0x001E | Amplitude must at least 1 DAC LSB this technique |
| 0x001F | Product is not licensed for this technique |
| 0x0020 | Cannot have more than one high speed and/or max range mode enabled |
| 0x0021 | The specified PGStat mode is not supported |
| 0x0022 | Channel set to be used as Poly WE is not configured as Poly WE |
| 0x0023 | Command is invalid for the selected PGStat mode |
| 0x0024 | The maximum number of vars to measure has been exceeded |
| 0x0025 | The specified PAD mode is unknown |
| 0x0026 | An error has occurred during a file operation |
| 0x0027 | Cannot open file, a file with this name already exists |
| 0x0028 | Variable divided by zero |
| 0x0029 | GPIO pin mode is not known by the device |
| 0x002A | GPIO configuration is incompatible with the selected operation |
| 0x002B | CRC of received line was incorrect (CRC16-ext) |
| 0x002C | ID of received line was not the expected value (CRC16-ext) |
| 0x002D | Received line was too short to extract a header (CRC16-ext) |
| 0x002E | Settings are not initialized |
| 0x002F | Channel is not available for this device |
| 0x0030 | Calibration process has failed |
| 0x0032 | Critical cell overload, aborting measurement to prevent damage. |
| 0x0033 | FLASH ECC error has occurred |
| 0x0034 | Flash program operation failed |
| 0x0035 | Flash Erase operation failed |
| 0x0036 | Flash page/block is locked |
| 0x0037 | Flash write operation on protected memory |
| 0x0038 | Flash is busy executing last command. |
| 0x0039 | Operation failed because block was marked as bad |
| 0x003A | The specified address is not valid |
| 0x003B | An error has occurred while attempting to mount the filesystem |
| 0x003C | An error has occurred while attempting to format the filesystem memory |
| 0x003D | A timeout has occurred during SPI communication |
| 0x003E | A timeout has occurred somewhere |
| 0x003F | The calibrations registers are locked, write actions not allowed. |
| 0x0040 | Memory module not supported. |
| 0x0041 | Flash memory format not recognized or supported. |
| 0x0042 | This register is locked for current permission level. |
| 0x0043 | Register is write-only |
| 0x0044 | Command requires additional initialization |
| 0x0045 | Configuration not valid for this command |
| 0x0046 | The multiplexer was not found. |
| 0x0047 | The filesystem has to be mounted to complete this action. |
| 0x0048 | This device is not a multi-device, no serial available. |
| 0x004A | MCU register access is not allowed, only RAM and peripherals are accessible. |
| 0x004B | Runtime (comm) command argument too short to be valid. |
| 0x004C | Runtime (comm) command argument has an invalid format. |
| 0x004E | Hibernate wake up source is invalid |
| 0x004F | Hibernate requires at least one wake up source, none was given. |
| 0x0050 | Wake pin for hibernate not configured as input |
| 0x0051 | The code provided to the permission register was not valid. |
| 0x0052 | An overrun error occurred on a communication interface (e.g. UART). |
| 0x0053 | Argument length incorrect for this register. |
| 0x0055 | The GPIO pins requested to change do not exist on this instrument. |
| 0x0056 | The selected GPIO pin mode is not allowed (by NVM config or device type). |
| 0x0057 | The on-board flash module has timed out. |
| 0x0058 | Timing error during fast measurement (possibly caused by communication). |
| 0x005A | The instrument cannot meet the requested measurement timing. |
| 0x005B | The variable type is already being measured. |
| 0x006D | The COMM command expected an hexadecimal value, but received something else. |
| 0x006E | The COMM command expected a decimal value, but received something else. |
| 0x0071 | The provided key does not fit the lock on this register. |
| 0x0072 | I2C port expander did not acknowledge a command |
| 0x0073 | Filesystem module not supported |
| 0x0074 | The IP address is not available (yet). |
| 0x007A | There is no measurement channel left for the requested measurement. |
| 0x007B | Temperature measurements during EIS with > 8 kHz are not supported. |
| 0x007C | The specified mode is unknown |
| 0x007D | The ADXL367 did not acknowledge an I2C command |
| 0x007E | An unexpected error occurred during an I2C operation. |
| 0x007F | I2C bus timeout during I2C operation (probably caused by I2C target device). |
| 0x0080 | The CE is oscillating. |
| 0x0082 | Operation requires system warnings to be cleared. |
| 0x0083 | Filesystem operations are not supported on this device. |
| 0x0084 | The requested variable type does not support ranging. |
| 0x0085 | The selected GPIO pin does not support harware synchronisation. |
| 0x0086 | Hardware select must be disabled before the role pin can be disabled. |
| 0x0087 | The role pin must be configured before the hadware select can be enabled |
| 0x0088 | The instrument has reserved this GPIO pin to be controlled by hardware (e.g. file system or HW-sync). |
| 0x0089 | This GPIO pin cannot be unlocked, as it was not locked in the first place |
| 0x008A | This GPIO pin can only be used for interfacing with a specific external memory |
| 0x008B | The BiPot should be disabled. |
| 0x008C | iR compensation should be disabled. |
| 0x008D | The key provided for the reset command is incorrect. |
| 0x008E | The SPI interface is not confgiured while it is required for the filesystem |
| 0x008F | The SPI interface requires the SPI pins to be configured to ‘peri 1’ |
| 0x0091 | The GPIO is locked for a multiplexer (e.g. Mux8R2 or PicoMux) |
| 0x0092 | The GPIO is locked for external storage (e.g. SD-card or NAND flash) |
| 0x0093 | The GPIO is locked for an external LED |
| 0x0094 | The GPIO is locked for hardware synchronisation |
| 0x0095 | The GPIO is locked for external PGStat signals |
| 0x0096 | The GPIO is locked for some special purpose on this instrument |
| 0x0097 | An attempt was made to access a GPIO using a key while it is unlocked |
| 0x0098 | The configuration set using the Peripheral configuration (0x01) register is invalid |
| 0x0099 | Filesystem file is corrupt |
| 0x009A | Filesystem failed to format |
| 0x009B | Filesystem I/O error |
| 0x009C | Filesystem didn’t have enough memory to perform the operation |
| 0x009D | Filesystem path was too long to handle |
| 0x009E | Filesystem the path was not valid |
| 0x009F | Filesystem could not find the file specified |
| 0x00A0 | Filesystem FM not supported |
| 0x00A1 | Filesystem doesn’t have a listing |
| 0x00A2 | Filesystem is not initialized |
| 0x00A3 | Filesystem file is open, but it should not have been |
| 0x00A4 | Filesystem file is not open |
| 0x00A5 | Filesystem does not support this feature |
| 0x00A6 | Filesystem expected something which is not true. |
| 0x00A7 | Filesystem could not find the path |
| 0x00A8 | Access denied due to prohibited access or directory full |
| 0x00A9 | The file/directory object is invalid |
| 0x00AA | The physical drive is write protected |
| 0x00AB | The logical drive number is invalid |
| 0x00AC | There is no valid filesystem volume |
| 0x00AD | The format operation was aborted due to any problem |
| 0x00AE | The operation is rejected according to the file sharing policy |
| 0x00AF | Working buffer could not be allocated |
| 0x00B0 | Too many files opened at once by filesystem |
| 0x00B1 | Parameter given to the filesystem is invalid |
| 0x00B2 | The file mode is invalid (should be readonly, new, append, overwrite). |
| 0x00B3 | The pin mode requred for the LED mapping is not allowed for this pin |
| 0x00B4 | The pin mode requred for the HW-sync role is not allowed for this pin |
| 0x00B5 | The pin mode requred for the HW-sync start mapping is not allowed for this pin |
| 0x00B6 | Use of the encrypted filesystem failed |
| 0x00B7 | The user key is not in a valid state for this cmmand |
| 0x00B8 | The communications protocol is not in valid lock state for this command |
| 0x4001 | The script command is unknown |
| 0x4004 | An unexpected character was encountered |
| 0x4005 | The script is too large for the internal script memory |
| 0x4008 | This optional argument is not valid for this command |
| 0x4009 | The stored script is generated for an older firmware version and cannot be run |
| 0x400B | Measurement loops cannot be placed inside other measurement loops |
| 0x400C | Command not supported in current situation |
| 0x400D | Scope depth too large |
| 0x400E | The command had an invalid effect on scope depth |
| 0x400F | Array index out of bounds |
| 0x4010 | I2C interface was not initialized with i2c_config command |
| 0x4011 | This is an error, NAck flag not handled by script |
| 0x4012 | Something unexpected went wrong. |
| 0x4013 | I2C clock frequency not supported by hardware |
| 0x4014 | Non integer SI vars cannot be parsed from hex or binary representation |
| 0x4016 | RTC was selected as wake-up source and selected time is not supported |
| 0x4017 | Arrays must be the same size but are not |
| 0x4018 | The script has ended unexpectedly. |
| 0x4019 | The script command is only valid for a multichannel (combined) device |
| 0x401A | The script command cannot be called from within a measurement loop. |
| 0x401B | the pck sequence is called wrong |
| 0x401C | The maximum amounts of variables per packet has been exceeded. |
| 0x401D | The file path is too long for the file system. |
| 0x401E | Insufficient memory to store array index |
| 0x4020 | A timeout has occurred for one of the script commands |
| 0x4021 | The mux is not initialized/configured. |
| 0x4022 | Measurement loop timing is too fast to use with multiplexer |
| 0x4023 | The script command is only valid for a device with iR compensation |
| 0x4024 | The resistance value is to big for the whole autorange range |
| 0x4025 | The resistance value is to big for current current range |
| 0x4026 | The variable already exists when declared |
| 0x4027 | This command requires the cell to be enabled with the cell_on command |
| 0x4028 | This command requires the cell to be disabled with the cell_off command |
| 0x4029 | The technique requires that at least one step should be made |
| 0x402A | The variable names do not fit in memory anymore, try using shorter names. |
| 0x402B | The variable name did not start with ‘a’-‘z’ or otherwise contained anything other than ‘a’-‘z’, ‘0’-‘9’ and ‘_’. |
| 0x402C | The variable name is too long to be processed. |
| 0x402D | The file mode is invalid. |
| 0x402E | The file mode does not support a counter in the file path. |
| 0x402F | The file path with the maximum counter value already exists. |
| 0x4030 | There are too many files open already. |
| 0x4031 | The specified multi device type is not defined. |
| 0x4032 | Cannot set the potential (or potential range) within the active measurement loop. |
| 0x4033 | Cannot set the current (or current range) within the active measurement loop. |
| 0x4034 | The used feature is not licensed on this product. |
| 0x4035 | The given filter type is unknown or not supported. |
| 0x4036 | The given command is only allowed within measurement loops. |
| 0x4037 | A computation has resulted in an overflow |
| 0x4038 | The array access was not correctly formed |
| 0x4039 | The literal argument was not correctly formed |
| 0x403A | The subarray declaration was out of bounds for the source array |
| 0x403B | A file needs to be opened before it can be written to |
| 0x403C | The MethodScript output mode is unknown |
| 0x4200 | MScript argument value cannot be negative for this command |
| 0x4201 | MScript argument value cannot be positive for this command |
| 0x4202 | MScript argument value cannot be zero for this command |
| 0x4203 | MScript argument value must be negative for this command (also not zero) |
| 0x4204 | MScript argument value must be positive for this command (also not zero) |
| 0x4205 | MScript argument value is outside the allowed bounds for this command |
| 0x4206 | MScript argument value cannot be used for this specific instrument |
| 0x4207 | MScript argument datatype (float/int) is invalid for this command |
| 0x4208 | MScript argument reference was invalid (not ‘a’ – ‘z’) |
| 0x4209 | MScript argument variable type is invalid or not supported for this command |
| 0x420A | An unexpected, additional, (optional) MScript argument was provided |
| 0x420B | MScript argument variable is not declared |
| 0x420C | MScript argument is of type var, which is not supported by this command |
| 0x420D | MScript argument is of type literal, which is not supported by this command |
| 0x420E | MScript argument is of type array, which is not supported by this command |
| 0x420F | MScript argument array size is insufficient |
| 0x4210 | An f-string contains an opening brace that is never closed |
| 0x4211 | MScript argument is an array element, which is not supported by this command |
| 0x7FFF | A fatal error has occurred, the device must be reset |
Visualize the results in PSTrace
PSTrace can visualize currents and voltages. Each package of data PSTrace receives, can consist of time, voltage and a current. If you have verified in TeraTerm that your script is free of errors and sends back data packages, it is time to copy the MethodSCRIPT into the PSTrace editor.
SWV Example script
This script will perform an SWV measurement from -0.5 V to 0.5 V.
e var c var p var f var g set_pgstat_chan 0 set_pgstat_mode 2 # Set maximum required bandwidth based on frequency * 4, # however since SWV measures 2 datapoints, we have to multiply the # bandwidth by 2 as well set_max_bandwidth 80 # Set potential window. # The max expected potential for SWV is EEnd + EAmp * 2 – EStep. # This measurement would also work without this command since it # stays within the default potential window of -1.1 V to 1.1V set_pot_range -500m 690m # Set current range for a maximum expected current of 2 uA set_cr 2u # Disable autoranging set_autoranging 2u 2u # Turn cell on for measurement cell_on # Perform SWV meas_loop_swv p c f g -500m 500m 10m 100m 10 # Send package with set potential, # ”forward current – reverse current”, # ”forward current” # ”reverse current” pck_start pck_add p pck_add c pck_add f pck_add g pck_end endloop # Turn off cell when done or aborted on_finished: cell_offView more examples on GitHub








