SCN5 And SCN6 Dyadic System Electric Linear Actuator Device Capabilities
Functions
init()
getmodule()
terminate()
getdeviceinfo()
-- HIGH LEVEL API (z3scn and z3scnpro device extension)
gohome()
gocenter()
goposition()
loadposition()
submitcheck()
submit() or showme()
checkscn()
-- LOW LEVEL API (z3scnpro device extension)
start_preload_command()
clear_preload_command()
move_abs()
hmoveabs()
moveinc()
hmoveinc()
movejog()
hmovejog()
moveorg()
hmoveorg()
movepoint()
checkpfin()
checkalarm()
checkservo()
checkson()
setson()
checkstatus()
setspeed()
setaccel()
setgain()
dumpparams()
setparam()
readparam()
loadparam()
readspeedaccel()
clearcmd()
getsioerror()
Initialization
init(COM [, id=0, strokeMode=0, accel=78, gain=6, normalSpd=8000, homeSpd=2000]) function
init() initialize the device extension and open serial com. This function takes one mandatory parameter, the COM port, all other are optional.
in addition to the COM port the default value of parameters are:
id = 0 -- (value from 0 to 15)
stroke mode 0=100mm, 1=50mm, 2=100mm, 3=150mm, 4=200mm
accel = 78 -- (value from 70 to 1000)
gain = 6 -- (value from 6 to 10)
normal speed = 8000 -- (value from 1000 to 20000)
home speed = 2000 -- (value from 1000 to 5000)Example:
-- init SCN6 actuator on port COM3 with default paramaters
dev.init(3)
getmodule() function
getmodule() is used to register the module with zCube core engine (included in zCube runtime app or z3engine DLL)
both functions init() and getmodule() are required to initialize zCube core engine, see the example below.
-- register main module
z3e.mainmodule(dev.getmodule())Example To Initialize the SCN5 or SCN6 device (z3scn device extension)
-- load core engine and create the global z3e instance,
-- if not already created by zCube Runtime
if z3e == nil then z3e = require("z3engine") end
-- load device extension and create the scn instance
local dev= require("z3scn")
-- init core
z3e.init()
-- init scn device with COM Port 2
if dev.init(2) then
-- register main module
z3e.mainmodule(dev.getmodule())
-- your script here
-- end of script
dev.terminate()
endterminate() function
Use terminate() when you no longer need the extension just before quitting or at the end of script.
This function closes the win32 COM library, stop listening inputs and unloads all services loaded by the extension if needed. It is mandatory to call it with z3scn device extension to cleanup COM library.
-- end of script
dev.terminate()getdeviceinfo(selector) function
get device information and capabilities
-- SELECTOR STRING
-- ---------------------------------------------------------------------------
--[[
"version"
]]
-- return version as string
-- example:
local z3dll_vers = scn.getdeviceinfo("version")
--[[
"name"
]]
-- return name of extension as string
-- example:
local device_name = scn.getdeviceinfo("name")
--[[
"type"
]]
-- return the class number of the device (see the device type class)
-- example:
local class_num = scn.getdeviceinfo("type")
--[[
"ticks"
]]
-- return number of ticks elapsed since PC startup
-- example:
-- if scn.getdeviceinfo("ticks") > old_tick then print("time elapsed!") end
-- DEVICE CAPABILITIES
-- ---------------------------------------------------------------------------
-- (WIP 2022-04) ...
HIGH LEVEL API (z3scn and z3scnpro device extensions)
The high level API is very easy to use and recommended to get started quickly with SCN5 or SCN6 actuators. This involved more 5 years of R&D to optimize the API and give you a maximum performance with SCN6. All the hard work has been done internally to let you focus on your project in place of dealing with the management of actuators. All high-level functions automatically stop to respond in the event of an incident on the actuator (alarm/error).
gohome() function
preload command to go home position, run submitcheck() command to execute the command. It’s recommended to run the gohome() and the gocenter() functions after the initialization of your SCN device.
dev.gohome()
dev.submitcheck()gocenter() function
preload command to go center position, run submitcheck() command to execute the command. It’s recommended to run the gohome() and the gocenter() functions after the initialization of your SCN device.
dev.gocenter()
dev.submitcheck()goposition(double mm) function
move actuator to the position (in millimeter). showme() (or submit()) command is optional but recommended
dev.goposition(55.0)
dev.showme()loadposition(double mm) function
preload position (in millimeter). must be followed by submitcheck() command to move the actuator.
dev.loadposition(75.0)
dev.submitcheck()submitcheck() function
execute all preloaded commands and wait until the target position is reached. It’s recommended to run the submitcheck() function after calling gohome() or gocenter() or loadposition() functions.
showme() or submit() function
execute all preloaded commands return immediately. Useful to get a maximum performance with goposition() function
checkscn() function
check if an incident has occurred (error or alarm has been set or the servo has been turned off), return 0 if OK
local scnPos = 44.5428
dev.goposition(scnPos)
dev.showme()
if dev.checkscn() >0 then print("SCN Error!") endz3scn device extension (full example using high-level API)
-- #####################################################################
-- # sample script to test device
-- # for zCUBE Engine Lua extension module
-- # Copyright (c)2022 by Zappadoc - All Rights Reserved.
-- # https://www.eksimracing.org
-- This source code, module, lib and all information, data, and algorithms
-- associated with it are subject to change without notice.
-- Change history:
-- 2022.01.30: created - zappadoc
-- License
-- https://zappadoc.com/terms-conditions
-- DISCLAIMER:
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-- IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-- TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-- OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
-- OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
-- IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-- All product names are trademarks or registered trademarks of their respective holders.
-- #####################################################################
package.path = package.path..";.\\lua\\?.lua;.\\lua\\scripts\\?.lua;.\\lua\\socket\\?.lua;.\\lua\\mime\\?.lua;.\\lua\\jit\\?.lua"
package.cpath = package.cpath..";.\\lua\\?.dl;.\\lua\\scripts\\?.dlll"
function full_test_device()
if z3e == nil then z3e = require("z3engine") end
z3e.init()
-- load device extension
local dev = require("z3scn")
-- init scn with COM Port 4 and default parameters
if dev.init(4) then
-- register main module
z3e.mainmodule(dev.getmodule())
print("Start Testing...")
-- ---------------------------------------------------
-- constants
local z3vers = z3e.getinfo("version")
-- SCN actuator 100mm
local max_stroke = 100
local pos_center = max_stroke / 2
local pos_min_safe = (max_stroke * 0.05)
local pos_max_safe = (max_stroke * 0.95)
-- is UI functions present?
local z3api = z3e.getinfo("engine")
isZ3UIRuntimePresent = false
if z3api == "extended" then isZ3UIRuntimePresent = true end
-- go home position
dev.gohome()
dev.submitcheck()
z3e.sleep(100)
-- go center position
dev.gocenter()
dev.submitcheck()
z3e.sleep(100)
local move=0
local c=0
while(c<30) do
c=c+1
for i=pos_center, pos_max_safe do
if(i%2)==0 then
move=i
else
move=5+i
end
if(move<pos_min_safe) then
move = pos_min_safe
end
if(move>pos_max_safe) then
move = pos_max_safe
end
print(string.format("move: %.2f\n", move))
dev.goposition(move)
dev.submit()
z3e.sleep(1)
end
end
-- return to center position
dev.gocenter();
dev.submitcheck();
z3e.sleep(100);
end
-- notify device extension
dev.terminate()
print("Test Done!")
end
function z3close()
-- catch the close event sent by z3 runtime to make sure
-- the com is closed properly when you exit the app
dev.terminate()
end
-- run test
full_test_device()
LOW LEVEL API (z3scnpro device extension)
The low level API exposes almost all Dyadic functions and is recommended for expert only. All functions are documented in Dyadic Electric Linear Actuator SCN5 and SCN6 official publication (pdf). A PRO annual subscription to EKSIMRacing foundation is required to get z3scnpro device extension.








