Abilitare JavaScript per vedere questo sito.

Esempio di gestione moduli axioline

stru_axio_pdi axio

; Da chiamare nel task1, alla partenza

function InitTask1()

call initAxio()

end_fun

;--------------------------------------------------------------------------------------

function initAxio()

call initEncAxio(11, 1,TRUE) ; Encoder 1 Nastro R1

;

; Init Phoenix module on local bus

;

; 0 = 0/10V

; 1 = +/- 10V

; 2 = 0/5V

; 3 = +/- 5V

;

; Modulo AXL_F_AO4_1H (1)

;

call InitAxioSingle(0,7,0x80,1,0x0)   ; Uscita analogica (0 - 10V)

call InitAxioSingle(0,7,0x80,2,0x0)

call InitAxioSingle(0,7,0x80,3,0x0)

call InitAxioSingle(0,7,0x80,4,0x0)

call InitAxioSingle(0,7,0x80,5,0x0)   ; Formato di uscita per tutti i canali (0-30000)

;

; Modulo AXL_F_AO4_1H (2)

;

call InitAxioSingle(0,8,0x80,1,0x0)   ; Uscita analogica (0 - 10V)

call InitAxioSingle(0,8,0x80,2,0x0)

call InitAxioSingle(0,8,0x80,3,0x0)

call InitAxioSingle(0,8,0x80,4,0x0)

call InitAxioSingle(0,8,0x80,5,0x0)   ; Formato di uscita per tutti i canali (0-30000)

;

; Modulo AXL_F_AO4_1H (3)

;

call InitAxioSingle(0,9,0x80,1,0x0)   ; Uscita analogica (0 - 10V)

call InitAxioSingle(0,9,0x80,2,0x0)

call InitAxioSingle(0,9,0x80,3,0x0)

call InitAxioSingle(0,9,0x80,4,0x0)

call InitAxioSingle(0,9,0x80,5,0x0)   ; Formato di uscita per tutti i canali (0-30000)

;

; Modulo AXL_F_AI2_AO2_1H (1)

;

call InitAxioSingle(0,10,0x80,1,0xf)  ; Ingresso analogico (non collegato)

call InitAxioSingle(0,10,0x80,2,0xf)  ; Ingresso analogico (non collegato)

call InitAxioSingle(0,10,0x80,3,0x0)  ; Uscita analogica (0 - 10V)

call InitAxioSingle(0,10,0x80,4,0x0)  ; Uscita analogica (0 - 10V)

call InitAxioSingle(0,10,0x80,5,0x0)  ; Formato di uscita per tutti i canali (0-30000)

end_fun

;--------------------------------------------------------------------------------------

; Axioline ancoder module init function

;--------------------------------------------------------------------------------------

function initEncAxio(int slot_idx, int NumEnc , int FlgEna)

int resultAxioWObj,sub_idx

int Scritti

string AppoStr

;

; Da numero encoder, codifichiamo il sub_idx

;

if (NumEnc = 1)

sub_idx = 3 ; Primo encoder

else

sub_idx = 4 ; Secondo encoder

endif

;

; Encoder struct

;

axio.rid = 0

axio.slot = slot_idx

axio.index = 0x80

axio.subindex = sub_idx  ; incremental encoder 1/2

axio.datatype = -10  ; OCTET_STRING

axio.datalen = sizeof(set_encoder) ; 44

axio.phase = -1   ; locking: let's wait the answer from device to go after wobj

; 1  .0 = 1 activate

; 2  .1 = 1 round

; 4  .2 = 0 symmetrical

; 8  .3 = 0 reserved

; 10 .4 = 0 no zero signal

; 20 .5 = 1 monitoring ON

; 40 .6.7 = 00 latch input mode off

; 80 .8.9 = 11 quadruple evaluation

; 100 .10.11 reserved

;       .12...15 = 000 Direct setting of the reference point by the controller

if (FlgEna)

set_encoder.basic_config = 0x0321 ; Encoder abilitato

else

set_encoder.basic_config = 0x0300 ; Encoder disabilitato

endif

set_encoder.reserved1 = 0

set_encoder.output_config = 0

set_encoder.output_pulse_time = 1

set_encoder.conv_fact = 0x00010001

set_encoder.modulo_val = 1

set_encoder.enc_inc_val = 1

set_encoder.limit_val_out_1 = 0

set_encoder.limit_val_out_2 = 0xFFFFFFFF

set_encoder.reference_val = 0

set_encoder.offset_zref = 0

set_encoder.transm_fact = 1

set_encoder.reserved2 = 0

resultAxioWObj = axio_wobj(axio, set_encoder)

if (resultAxioWObj < 0)

Scritti = str_format(AppoStr, "AXIO_WOBJ Rid %d Slot %d index %d Sub %d Error: %d",axio.rid,axio.Slot,axio.index,axio.Subindex,resultAxioWObj)

inf_report(0x100,AppoStr)

else

Scritti = str_format(AppoStr, "AXIO_WOBJ Rid %d Slot %d index %d Sub %d ok",axio.Rid,axio.Slot,axio.index,axio.Subindex)

inf_report(0x100,AppoStr)

endif

end_fun

;--------------------------------------------------------------------------------------

;--------------------------------------------------------------------------------------

; InitPhoenix

; Inizializza moduli I/O phoenix

;--------------------------------------------------------------------------------------

function InitAxioSingle(int Rid,int Slot,int index,int Sub,int Val)

int resultAxioWObj

int Scritti

string AppoStr

axio.rid     = Rid

axio.slot    = Slot

axio.index   = Index

axio.subindex= Sub

axio.dataType= 0

axio.phase   = -1

axio.dataLen  = sizeof(val)

resultAxioWObj  = axio_wobj(axio,val)

if (resultAxioWObj < 0)

Scritti = str_format(AppoStr, "AXIO_WOBJ Rid %d Slot %d index %d Sub %d Val %d Error: %d",Rid,Slot,index,Sub,Val,resultAxioWObj)

inf_report(0x100,AppoStr)

else

Scritti = str_format(AppoStr, "AXIO_WOBJ Rid %d Slot %d index %d Sub %d Val %d ok",Rid,Slot,index,Sub,Val)

inf_report(0x100,AppoStr)

endif

end_fun

 

  

Keyboard Navigation

F7 for caret browsing
Hold ALT and press letter

This Info: ALT+q
Page Header: ALT+h
Topic Header: ALT+t
Topic Body: ALT+b
Contents: ALT+c
Search: ALT+s
Exit Menu/Up: ESC