Up | Adam-6000 Series | Adam-4000 Series | Adam-6060

Release Notes
 

  

 
Adam-6060

ADAM 6060 EXAMPLE CODE
Assuming you have configured an ADAM 6060 module with IP address 10.0.0.100, the following example will set relay 0 and 5 to 1 and
relay 1,2,3,4 to 0.  The example will also read the 6 opto isolated inputs. 

Note: You can configure the polarity of the digital inputs with the ADAM Ethernet utility. 

The recommended way of communicating over ModbusTCP is to open a socket and keep it open for the session and then close it. 
This is the default behaviour for the Adam6060 class.  For all functions a tuple ok,txt,val/msg is returned. 
If success ok is 1 and data is found in val.  If Failure ok is 0 and error text found in txt.

Adam-6060 Demo Sample Profile

Firmware changes with Adam-6060

To support different firmware of Adam-6060 - there are two python modules available

  • adam6060.py
  • adam6060_22.py

The adam6060_22 supports the firmware version 2.2.

Example 35 : Robust Adam-6060 Scripting

# import the class
from adam6000 import *
# connect using the specified IP address, default keep the connection open
try:
  a=Adam6000('10.0.0.100')
except:
  print 'no connection for this IP address'
else:
    # set relay 0,5 to 1 and 1,2,3,4 to 0
  ok,txt,msg=a.WriteRelay(0,1)
  ok,txt,msg=a.WriteRelay(1,0)
  ok,txt,msg=a.WriteRelay(2,0)
  ok,txt,msg=a.WriteRelay(3,0)
  ok,txt,msg=a.WriteRelay(4,0)
  ok,txt,msg=a.WriteRelay(5,1) 

  # read the individual relay values back
  ok,txt,val=a.ReadRelay(0)
  ok,txt,val=a.ReadRelay(1)
  ok,txt,val=a.ReadRelay(2)
  ok,txt,val=a.ReadRelay(3)
  ok,txt,val=a.ReadRelay(4)
  ok,txt,val=a.ReadRelay(5)

  # read all relay values back with one single call
  ok,txt,val=a.ReadRelays()

  # read all DI values with one single call
  ok,txt,val=a.ReadDIs()

  # read the individual DI values
  ok,txt,val=a.ReadDI(0)
  ok,txt,val=a.ReadDI(1)
  ok,txt,val=a.ReadDI(2)
  ok,txt,val=a.ReadDI(3)
  ok,txt,val=a.ReadDI(4)
  ok,txt,val=a.ReadDI(5)

  # check the timeout (default 1.0 sec
  print 'Timeout is',a.timeout
  # set the new timeout to 2.0
  a.timeout=2.0
  print 'New Timeout is',a.timeout

# close the connection
a.close() 

WHERE DO I PUT THE SCRIPTS FOR IO?
A structured way of setting up IO scripting is:

Central.Start
Open the connections here.  If unsuccessful initialization set a global variable for access elsewhere
Central.Stop
Close communication here.
Central.Scripts
In central you can define a number of useful scripts.  You can simplify syntax by defining your own access functions.
Actions
It is useful to define a set of event handlers that will call your user defined scripts.  
Scheduler
The scheduler mat be set up to periodically call one of the defined actions.

Example: Implement a camera trigger by testing a DI input on a Adam 6060 module.

Central.Start
from adam6060 import *
RisingEdge=0
try:
  io=Adam6060('10.0.0.100')
except:
  print 'No connection'
  IoOK=0
else:
  IoOK=1
  ok,txt,val=io.ReadDI(0)
  Cur=val
Central.Stop
io.close()
Central.Scripts
def IsTrigger():
  if IoOK:
    ok,txt,val=io.ReadDI(0)
    RisingEdge=val-Cur
    Cur=val
    if RisingEdge==1: ExecuteCmd('GrabExecute','')
Actions
Userdefined function CheckTrig
Command:Script
Parameter:Script.IsTrigger() 
Scheduler
Call:CheckTrig
  

Scorpion Vision Version XII : Build 646 - Date: 20170225
Scorpion Vision Software® is a registered trademark of Tordivel AS.
Copyright © 2000 - 2017 Tordivel AS.