# macros to operate the VMIC 4116 DAC using the generic VME record # # hp 24.01.2001 # # # # global definitions # global dac_record,dac_channel,dac_value,dac_last_used # # using generic vme record 1 dac_record = "6idd:vme1." # # stores the number of the last channel used dac_last_used = 0 # # addresses of the eight channels dac_channel[0] = 0x60 dac_channel[1] = 0x62 dac_channel[2] = 0x64 dac_channel[3] = 0x66 dac_channel[4] = 0x68 dac_channel[5] = 0x6A dac_channel[6] = 0x6C dac_channel[7] = 0x6E # # last bit value send to DAC dac_value[0] = 0x8000 dac_value[1] = 0x8000 dac_value[2] = 0x8000 dac_value[3] = 0x8000 dac_value[4] = 0x8000 dac_value[5] = 0x8000 dac_value[6] = 0x8000 dac_value[7] = 0x8000 # # # ################################################################################ # # dac_volt # # hp 24.01.2001 # # sets one channel of DAC to a voltage value # ################################################################################ # def dac_volt ' { local chan,volt,dig if ($# == 0) { printf("\ndac_volt (hp) 24.01.2001\n\n") chan = getval("Channel",dac_last_used) volt = getval("Voltage",-10+dac_value[chan]*20/65536) } else { if ($# != 2) { printf("usage: dac_volt channel (0 to 7) value (between -10 and +10)\n") exit } chan = $1 volt = $2 } if ((chan<0) | (chan>7)) { printf("dac_volt: channel must be between 0 and 7 but is %i\n",channel) exit } if ((volt<-10) | (volt>10)) { printf("dac_volt: value must be between -10 and +10 but is %i\n",volt) exit } dig = (volt+10)*65536/20 if (dig == 65536) dig = 65535 dac_bit chan dig }' # # # # ################################################################################ # # dac_bit # # hp 24.01.2001 # # sets one channel of DAC to bit value # ################################################################################ # def dac_bit ' { local channel,val if ($# == 0) { printf("\ndac_bit (hp) 24.01.2001\n\n") channel = getval("Channel",dac_last_used) val = getval("Bit value",dac_value[channel]) } else { if ($# != 2) { printf("usage: dac_bit channel (0 to 7) value (between 0 and 65535)\n") exit } channel = $1 val = $2 } val = int(val) if ((channel<0) | (channel>7)) { printf("dac_bit: channel must be between 0 and 7 but is %i\n",channel) exit } if ((val<0) | (val>65535)) { printf("dac_bit: value must be between 0 and 65535 but is %i\n",val) exit } dac_last_used = channel dac_value[channel] = val _dac_check_init _dac_put sprintf("%s%s",dac_record,"ADDR") dac_channel[channel] _dac_put sprintf("%s%s",dac_record,"VAL") val }' # # # # ################################################################################ # # dac_init # # hp 24.01.2001 # # initialize the generic vme record for the use with the DAC VMIC 4116 # ################################################################################ # def dac_init ' { local init_field,i printf("\ndac_init (hp) 24.01.2001\n\n") # field names init_field[0][0] = "DESC" init_field[1][0] = "SCAN" init_field[2][0] = "AMOD" init_field[3][0] = "DSIZ" init_field[4][0] = "NUSE" init_field[5][0] = "RDWT" # field values init_field[0][1] = "DAC VMIC4116 hp 24.01.01" init_field[1][1] = 0 init_field[2][1] = 0 init_field[3][1] = 1 init_field[4][1] = 1 init_field[5][1] = 1 for (i=0;i<=5;i++) { _dac_put sprintf("%s%s",dac_record,init_field[i][0]) init_field[i][1] } # switching of the fail light _dac_put sprintf("%s%s",dac_record,"ADDR") 0x70 _dac_put sprintf("%s%s",dac_record,"VAL") 0x4100 # prepare channel zero for work _dac_put sprintf("%s%s",dac_record,"ADDR") 0x60 }' # # # # ################################################################################ # # _dac_put # # hp 24.01.2001 # # do an epics_put and check for errors # ################################################################################ # def _dac_put ' { local v1,v2,status if ($# != 2) { printf("usage: _dac_put field value\n") exit } v1 = $1 v2 = $2 status = epics_put(v1,v2) if (status != 1) { printf("_dac_put: error writing value %f to field %s\n",v2,v1) } }' # # # # ################################################################################ # # _dac_check_init # # hp 24.01.2001 # # check if generic vme record was initialized for VMIC 4116 DAC # ################################################################################ # def _dac_check_init ' { local desc desc = epics_get(sprintf("%s%s",dac_record,"DESC")) if (desc != "DAC VMIC4116 hp 24.01.01") { printf("\n_dac_check_init (hp) 24.01.2001\n\n") printf("Generic vme record %s**** might not be initialized correctly\n",dac_record) dac_init } }' # # # #