from adam import *
PortCOM1=0
MaxModules=4
a=Adam( PortCOM1 )
ok,txt,baud,cs,modules = a.AutoDetect(MaxModules)
if ok:
print 'Adam network found','Baud:',baud,'Checkum:',cs
for module in modules:
print 'Module[%d]' % module['Module'],module['Name']
else:
print 'No Adam network found'
# assume 4050 module as module 1, 4060 module as module 2, 4021 module as module 3
# digital output on module 1
# set the bits 0,1,2 to 1,0,1 - equvivalent to 0x5
ok,txt,msg=a.DigDataOut1Ch( 1, 0, 1 )
ok,txt,msg=a.DigDataOut1Ch( 1, 1, 0 )
ok,txt,msg=a.DigDataOut1Ch( 1, 2, 1 )
# set the value directly to 0x5 with one single call
ok,txt,msg=a.DigDataOutXCh( 1, 5 )
# digital input on module 1, returns outputs and inputs
ok,txt,outs,ins=a.DigDataInXCh( 1)
# digital output on module 2
# set the relay 0 and 3 to high, set relay 1,2 to low
ok,txt,msg= a.DigDataOut1Ch( 2, 0, 1 )
ok,txt,msg= a.DigDataOut1Ch( 2, 3, 1 )
ok,txt,msg= a.DigDataOut1Ch( 2, 1, 0 )
ok,txt,msg= a.DigDataOut1Ch( 2, 2, 0 )
# analog output on module 3
# assume the unit is configured for 0-10V, set the module to 5.5V
ok,txt,msg=a.AnaDataOutAsFloat( 3, 5.0 )
# done - terminate all IO
a.close()
|