*** Wartungsfenster jeden ersten Mittwoch vormittag im Monat ***

Skip to content
Snippets Groups Projects
Commit 911a1b02 authored by Schabbauer, Johannes's avatar Schabbauer, Johannes
Browse files

Trying example programs

parent 45c1a66a
No related branches found
No related tags found
No related merge requests found
'<ADbasic Header, Headerversion 001.001>
' Process_Number = 1
' Initial_Processdelay = 2000
' Eventsource = Timer
' Control_long_Delays_for_Stop = No
' Priority = High
' Version = 1
' ADbasic_Version = 6.3.1
' Optimize = Yes
' Optimize_Level = 4
' Stacksize = 1000
' Info_Last_Save = ATI098-60 ATI098-60\labuser
'<Header End>
#include adwinpro_all.inc
#include ADwin_utils.inc
' Array Size Settings
' TODO: check these values in labscript_devices files
#define ZERO 32768 ' Zero Volts in Adwin 16bit representation
#define MAXEVENTS 100000 ' Max number of events that can be stored
#define AOUTFIFO 100000 ' Max number of changing the AOUT set value
#define PIDFIFO 20 ' Max number of changing the AIN channel for PID feedback to AOUT
#define PIDNO 28 ' Number of implemented PIDs
#define MAXTICOEVENTS 2000 ' Max number of Digital Output events
#define AINFIFO 100000 ' Size of Array to transmit AIN values to the runner PC
' Set Module Adresses
' TODO get or set these values from labscript ?
#define DIO1 1 'DIO Card 32
#define DIO2 2 'DIO Card 32
#define AIN1 3 'AIN Card 8/16
#define AIN2 4 'AIN Card 8/16
#define AOUT1 5 'AOUT Card 8/16
#define AOUT2 6 'AOUT Card 8/16
' Declare Arrays for Analog Data from experiment control software
DIM DATA_1[MAXEVENTS] AS Long 'analog time
DIM DATA_2[MAXEVENTS] AS Long 'Analog Out change monitor
DIM DATA_3[MAXEVENTS] AS Long 'Analog Out PID change monitor
' Format: DATA_{module}{channel} + 100 for PID channels
DIM DATA_50[AOUTFIFO] AS Long AS Fifo 'AOUT1 Channel 00
DIM DATA_51[AOUTFIFO] AS Long AS Fifo 'AOUT1 Channel 01
DIM DATA_52[AOUTFIFO] AS Long AS Fifo 'AOUT1 Channel 02
DIM DATA_53[AOUTFIFO] AS Long AS Fifo 'AOUT1 Channel 03
DIM DATA_54[AOUTFIFO] AS Long AS Fifo 'AOUT1 Channel 04
DIM DATA_55[AOUTFIFO] AS Long AS Fifo 'AOUT1 Channel 05
DIM DATA_56[AOUTFIFO] AS Long AS Fifo 'AOUT1 Channel 06
DIM DATA_57[AOUTFIFO] AS Long AS Fifo 'AOUT1 Channel 07
DIM DATA_60[AOUTFIFO] AS Long AS Fifo 'AOUT2 Channel 00
DIM DATA_61[AOUTFIFO] AS Long AS Fifo 'AOUT2 Channel 01
DIM DATA_62[AOUTFIFO] AS Long AS Fifo 'AOUT2 Channel 02
DIM DATA_63[AOUTFIFO] AS Long AS Fifo 'AOUT2 Channel 03
DIM DATA_64[AOUTFIFO] AS Long AS Fifo 'AOUT2 Channel 04
DIM DATA_65[AOUTFIFO] AS Long AS Fifo 'AOUT2 Channel 05
DIM DATA_66[AOUTFIFO] AS Long AS Fifo 'AOUT2 Channel 06
DIM DATA_67[AOUTFIFO] AS Long AS Fifo 'AOUT2 Channel 07
' Declare Arrays for PID channels for each AOUT channel
DIM DATA_150[PIDFIFO] AS Long AS Fifo 'PID for AOUT1 Channel 00
DIM DATA_151[PIDFIFO] AS Long AS Fifo 'PID for AOUT1 Channel 01
DIM DATA_152[PIDFIFO] AS Long AS Fifo 'PID for AOUT1 Channel 02
DIM DATA_153[PIDFIFO] AS Long AS Fifo 'PID for AOUT1 Channel 03
DIM DATA_154[PIDFIFO] AS Long AS Fifo 'PID for AOUT1 Channel 04
DIM DATA_155[PIDFIFO] AS Long AS Fifo 'PID for AOUT1 Channel 05
DIM DATA_156[PIDFIFO] AS Long AS Fifo 'PID for AOUT1 Channel 06
DIM DATA_157[PIDFIFO] AS Long AS Fifo 'PID for AOUT1 Channel 07
DIM DATA_160[PIDFIFO] AS Long AS Fifo 'PID for AOUT2 Channel 00
DIM DATA_161[PIDFIFO] AS Long AS Fifo 'PID for AOUT2 Channel 01
DIM DATA_162[PIDFIFO] AS Long AS Fifo 'PID for AOUT2 Channel 02
DIM DATA_163[PIDFIFO] AS Long AS Fifo 'PID for AOUT2 Channel 03
DIM DATA_164[PIDFIFO] AS Long AS Fifo 'PID for AOUT2 Channel 04
DIM DATA_165[PIDFIFO] AS Long AS Fifo 'PID for AOUT2 Channel 05
DIM DATA_166[PIDFIFO] AS Long AS Fifo 'PID for AOUT2 Channel 06
DIM DATA_167[PIDFIFO] AS Long AS Fifo 'PID for AOUT2 Channel 07
'Declare Arrays for Digital Data from experiment control software
DIM DATA_10[MAXTICOEVENTS] AS Long 'DIO1 TiCo times
DIM DATA_11[MAXTICOEVENTS] AS Long 'DIO1 Digital Outputs
DIM DATA_20[MAXTICOEVENTS] AS Long 'DIO2 TiCo times
DIM DATA_21[MAXTICOEVENTS] AS Long 'DIO2 Digital Outputs
'Declare Arrays that are used for AIN transmission
DIM DATA_4[AINFIFO] AS LONG AS FIFO
DIM DATA_5[AINFIFO] AS LONG AS FIFO
DIM DATA_6[AINFIFO] AS LONG AS FIFO
' TODO what are these used for ?
DIM remainder AS LONG
DIM oldReglerIPG AS LONG
'Declare Tico Data Transfer Arrays
DIM TICO_MEMORY1[150] AS LONG
DIM TICO_MEMORY2[150] AS LONG
'Declare PID SETTINGS Arrays
DIM p_pid[PIDNO] AS FLOAT
DIM i_pid[PIDNO] AS FLOAT
DIM d_pid[PIDNO] AS FLOAT
DIM sum[PIDNO], ra_alt_diff[PIDNO] AS FLOAT
DIM ra_diff, diff, lin AS FLOAT
DIM ra, regler AS LONG
'Declare Other Variables
DIM processIdx AS LONG
DIM aEventIdx AS LONG
DIM dEventIdx AS LONG
DIM timer AS LONG
DIM i AS LONG 'number in for loops
'Declare Array for reading/writing AIN and AOUT Channels
DIM act_values[28] AS LONG ' Analog values measured from AINs
DIM set_values[16] AS LONG ' Set values to be written to AOUTs
'declare ADC FIFO variables
DIM ADC_Channel_FIFO1 AS LONG
DIM ADC_Channel_FIFO2 AS LONG
DIM ADC_Channel_FIFO3 AS LONG
DIM ADC_stepsize AS LONG
DIM ADC_start AS LONG
DIM ADC_enable AS LONG
DIM ADC_fifo_update AS LONG
DIM ADC_average_update AS LONG
DIM ADC_average1 AS LONG
DIM ADC_average2 AS LONG
DIM ADC_average3 AS LONG
DIM ADC_fifo_frequ AS FLOAT
'========================================================================================================================================
'= LOWINIT =
'========================================================================================================================================
init:
'Set Processdelay to 2us and return it to the experiment control software
PROCESSDELAY = 2000 ' TODO wirte it from labscript ?
par_1 = PROCESSDELAY
par_2 = 0
'Initialize Variables
processIdx = 0
aEventIdx = 1
dEventIdx =1
par_14 = 0 'timer variable
'Set DIO Channels As Outputs
' TODO do we want to set this dynamically from labscript ?
P2_DIGPROG(DIO1, 1111b) 'Channel 0-31
P2_DIGPROG(DIO2, 1111b) 'Channel 32-63
CPU_Dig_IO_Config(000010b) 'SET Adwin T12 DIO as digital input for falling edge (DIG I 0-1) and rising Edge DIG I 0-0
'Reset Tico and initialize data transfer Arrays
P2_tico_reset(2^(DIO1-1) + 2^(DIO2-1)) '(0000000000010001b) 'Resets DIO Modules
P2_tdrv_init(DIO1, 1, TICO_MEMORY1) 'Data Transfer to Module DIO1
P2_tdrv_init(DIO2, 1, TICO_MEMORY2) 'Data Transfer to Module DIO2
'Load the digital event data into the memory two DIO modules
P2_setdata_long(TICO_MEMORY1, 1, 1, MAXTICOEVENTS, DATA_10, 1, 1) 'Time for digital channels
P2_setdata_long(TICO_MEMORY1, 2, 1, MAXTICOEVENTS, DATA_11, 1, 1) 'Output values of the digital channels 0-31
P2_setdata_long(TICO_MEMORY2, 1, 1, MAXTICOEVENTS, DATA_20, 1, 1) 'Time for digital channels
P2_setdata_long(TICO_MEMORY2, 2, 1, MAXTICOEVENTS, DATA_21, 1, 1) 'Output values of the digital channels 32-63
'Turn Module LEDs on
P2_SET_LED(DIO1, 1)
P2_SET_LED(DIO2, 1)
P2_SET_LED(AIN1, 1)
P2_SET_LED(AIN2, 1)
P2_SET_LED(AOUT1, 1)
P2_SET_LED(AOUT2, 1)
'========================================================================================================================================
'= PID PARAMETERS =
'========================================================================================================================================
''' # Setting for the ADC
'Parameter for ADC
ADC_stepsize=par_4
ADC_start=par_9
ADC_enable=par_5
ADC_fifo_update=ADC_stepsize-1
ADC_average_update=100-1
'FIFOs leeren
FOR i=0 TO 7
FIFO_CLEAR(10*AOUT1 + i)
FIFO_CLEAR(10*AOUT2 + i)
FIFO_CLEAR(10*AOUT1 + i + 100)
FIFO_CLEAR(10*AOUT2 + i + 100)
NEXT i
FIFO_CLEAR(4)
FIFO_CLEAR(5)
FIFO_CLEAR(6)
'Mittelwerte zurcksetzen
ADC_average1=0
ADC_average2=0
ADC_average3=0
ADC_fifo_frequ=1.0/ADC_stepsize ''number of values that are averaged depending on the timestep of the fifo
'den FIFOs die ADC Channels zuweisen
ADC_Channel_FIFO1=1
ADC_Channel_FIFO2=2
ADC_Channel_FIFO3=3
'Shift Data in each Array to desynchronize chaching of the arrays in the event loop. this prevents single events from taking
'a lot of time when all arrays are recached at the same event.
' TODO deleted chaching fix
' Set analog outputs for the first time in the sequence.
set_values[1] = DATA_50
set_values[2] = DATA_51
set_values[3] = DATA_52
set_values[4] = DATA_53
set_values[5] = DATA_54
set_values[6] = DATA_55
set_values[7] = DATA_56
set_values[8] = DATA_57
set_values[9] = DATA_60
set_values[10] = DATA_61
set_values[11] = DATA_62
set_values[12] = DATA_63
set_values[13] = DATA_64
set_values[14] = DATA_65
set_values[15] = DATA_66
set_values[16] = DATA_67
''### Setzen der Stellwerte an die Analogausgnge
P2_Write_DAC8(AOUT1,set_values,1) ' sende neue stellwerte an die Analog out Karten
P2_Write_DAC8(AOUT2,set_values,9)
P2_Start_DAC(AOUT1) ' starte das rausschreiben der analog output werte
P2_Start_DAC(AOUT2)
'initalize tico digital outputs
P2_set_par(DIO1,1,1,DATA_11[dEventIdx]) 'Initilisiere digitalausgnge fr tico
P2_set_par(DIO2,1,1,DATA_21[dEventIdx]) 'Initilisiere digitalausgnge fr tico
''increase event index by 1
inc dEventIdx
P2_set_par(DIO2,1,2,81) 'initialisiere Zählvariable für tico
P2_set_par(DIO1,1,2,81) 'initialisiere Zählvariable für tico
P2_set_par(DIO2,1,3,dEventIdx) 'Setze index nächstes event für tico
P2_set_par(DIO1,1,3,dEventIdx) 'Setze index nächstes event für tico
'### P2_ADCF_MODE im Timer Modus. Anweisung sollte m�glichst am Ende der init stehen
P2_ADCF_MODE(2^(AIN1-1),0) '2=module No.2, 1=timer mode(always measure)start timer mode (immediate before the EVENT Part)
P2_Set_Average_Filter(AIN1,2)
'P2_Set_Gain(AIN1,1,1)
'P2_Set_ADF(010b,5010h,1) 'check this 'change sampling frequency for card 2 module No2 5010h is the adress and the measurement time is (value-1)*10ns+250ns and value ranges from 31 (default setting) to 1 check again
P2_ADCF_MODE(2^(AIN2-1),0) 'module No.6 set as 2^6=0100000 in binary, 1=timer mode(always measure)start timer mode (immediate before the EVENT Part)
P2_Set_Average_Filter(AIN2,2)
' P2_Set_Gain(AIN2,1,2)
' P2_Set_Gain(AIN2,2,1)
' P2_Set_Gain(AIN2,3,0)
' P2_Set_Gain(AIN2,5,3)
' P2_Set_Gain(AIN2,6,2)
' P2_Set_Gain(AIN1,7,2)
' P2_Set_Gain(AIN1,6,0)
'Check_Card(6)
'Par_20 = Peek((68050100h OR shift_left(6,20)))
'### Set the Sampling Rate of the AIN cards. The Period is given by T = 250ns + (value-1)* 10ns. The value is set by writing to the correct register using POKE(register,value)
' TODO what's going on here ???
CHECK_CARD(AIN1)
POKE((68050100h OR shift_left(AIN1,20)),1)
CHECK_CARD(AIN2)
POKE((68050100h OR shift_left(AIN2,20)),1)
'Start Conversion for first Event
P2_Sync_All(2^(AIN1-1)+2^(AIN2-1))
'P2_Sync_All(100010b)
'Wait for 200 * 10ns to make sure that first ADC values are ready
CPU_Sleep(200)
'========================================================================================================================================
'= EVENT LOOP =
'========================================================================================================================================
EVENT:
timer = READ_TIMER_SYNC()
'Read istwerte at all ADC Channels
P2_READ_ADCF8(AIN1, act_values, 1) 'READ CHANNEL 1-8 OF AIN MODULE 1
P2_READ_ADCF8(AIN2, act_values, 21) 'READ CHANNEL 1-8 OF AIN MODULE 2
'Start conversion at all ADC Channels Synced for next Event
'P2_Sync_All(100010b)
P2_Sync_All(2^(AIN1-1)+2^(AIN2-1))
'COMPUTE NEW SET VALUES
' DELETED PID etc. for OUTPUT CHANNELS !
'### Werte ausgeben
if(processIdx = 20) then ' TODO why wait for 20 process cycles, is this a measued value ??
P2_set_par(DIO1,1,20,1) 'starte tico event Modul 1
P2_set_par(DIO2,1,20,1) 'starte tico event Modul 5
endif
''### Setzen der Stellwerte an die Analogausgänge (t= 27)
P2_Write_DAC8(AOUT1,set_values,1) ''sende neue stellwerte an die Analog out Karten
P2_Write_DAC8(AOUT2,set_values,9)
'Write all DAC Channels Synced
P2_Sync_All(2^(AOUT1-1)+2^(AOUT2-1))
'### Rausschreiben ADC Arrays
DATA_4 = act_values[ADC_Channel_FIFO1]
DATA_5 = act_values[ADC_Channel_FIFO2]
DATA_6 = act_values[ADC_Channel_FIFO3]
'DATA_3[processIdx]=stellwert[12]
inc processIdx
If (DATA_1[aEventIdx+1] = processIdx)THEN 'check wether next event reached
inc aEventIdx 'set index to next event
ENDIF
'### Programmterminierung
IF (processIdx > Par_3 ) THEN ' TODO get parameter from labscript
END 'end loop when last last timing event completed
ENDIF
'### Debug Timer
par_13=READ_TIMER_SYNC() -timer
par_15=processIdx
'if ( par_13 > par_14 ) then
' par_14=par_13 'Laufzeit (ca. t=1700)
' par_15=processIdx
'endif
'if(processIdx < FIFOLENGTH) then
'DATA_2[processIdx-1] = stellwert[5]
'DATA_2[processIdx-1]=stellwert[12]
'DATA_3[processIdx-1] = stellwert[12]
'endif
FINISH:
P2_DAC(AOUT1,5,ZERO) 'Analogausgang 3 (feshbachcurrent lower) auf sicheren wert setzen
P2_DAC(AOUT2,5,ZERO) 'Analogausgang 13 (feshbachcurrent upper) auf sicheren wert setzen
P2_DAC(AOUT1,6,36700) 'Analogausgang 6 (ipg power) auf sicheren wert (1.2) setzen entspricht 20W
' P2_SET_LED(DIO1,0) 'LED am Modul 1 ausschalten = DIO32
' P2_SET_LED(DIO2,0) 'LED am Modul 5 ausschalten = DIO32
' P2_SET_LED(AIN1,0) 'LED am Modul 2 ausschalten = Ain 16bit
' P2_SET_LED(AIN2,0)
' P2_SET_LED(AOUT1,0) 'LED am Modul 3 ausschalten = AOUT 8/18
' P2_SET_LED(AOUT2,0) 'LED am Modul 4 ausschalten = AOUT 8/18
P2_tico_stop_process(TICO_MEMORY1,1)
P2_tico_stop_process(TICO_MEMORY2,1)
PAR_2 = 0
......@@ -12,86 +12,85 @@
' Info_Last_Save = ATI098-60 ATI098-60\labuser
'<Header End>
#include adwinpro_all.inc
#include ADwin_utils.inc
'Array Size Settings
#define N 32768 'Zero Volts in Adwin 16bit representation
#define MAXEVENTS 100001 'Max number of events that can be stored
#define FIFOLENGTH 10000000 'Max number of measurements in each FIFO
#define PIDNO 28 'Number of implemented PIDs
#define MAXTICOEVENTS 2001 'Size of Tico Memory
' Array Size Settings
' TODO: check these values in labscript_devices files
#define ZERO 32768 ' Zero Volts in Adwin 16bit representation
#define MAXEVENTS 100000 ' Max number of events that can be stored
#define AOUTFIFO 100000 ' Max number of changing the AOUT set value
#define PIDFIFO 20 ' Max number of changing the AIN channel for PID feedback to AOUT
#define PIDNO 28 ' Number of implemented PIDs
#define MAXTICOEVENTS 2000 ' Max number of Digital Output events
#define AINFIFO 100000 ' Size of Array to transmit AIN values to the runner PC
'Set Module Adresses
' TODO get these values from labscript ?
#define DIO1 1 'DIO Card 32
#define DIO2 2 'DIO Card 32
#define AIN1 3 'AIN Card 8/18
#define AIN2 4 'AIN Card 8/18
#define AOUT1 5 'AOUT Card 8/18
#define AOUT2 6 'AOUT Card 8/18
' Set Module Adresses
' TODO get or set these values from labscript ?
#define DIO1 1 'DIO Card 32
#define DIO2 2 'DIO Card 32
#define AIN1 3 'AIN Card 8/16
#define AIN2 4 'AIN Card 8/16
#define AOUT1 5 'AOUT Card 8/16
#define AOUT2 6 'AOUT Card 8/16
'Declare Arrays for Data from experiment control software
DIM DATA_100[100000] AS Long 'analog time
DIM DATA_101[100000] AS Long 'Analog Out Channel 01
DIM DATA_102[100000] AS Long 'Analog Out Channel 02
DIM DATA_103[100000] AS Long 'Analog Out Channel 03
DIM DATA_104[100000] AS Long 'Analog Out Channel 04
DIM DATA_105[100000] AS Long 'Analog Out Channel 05
DIM DATA_106[100000] AS Long 'Analog Out Channel 06
DIM DATA_107[100000] AS Long 'Analog Out Channel 07
DIM DATA_108[100000] AS Long 'Analog Out Channel 08
DIM DATA_109[100000] AS Long 'Analog Out Channel 09
DIM DATA_110[100000] AS Long 'Analog Out Channel 10
DIM DATA_111[100000] AS Long 'Analog Out Channel 11
DIM DATA_112[100000] AS Long 'Analog Out Channel 12
DIM DATA_113[100000] AS Long 'Analog Out Channel 13
DIM DATA_114[100000] AS Long 'Analog Out Channel 14
DIM DATA_115[100000] AS Long 'Analog Out Channel 15
DIM DATA_116[100000] AS Long 'Analog Out Channel 16
' TODO WHY do we use only one time array
DIM DATA_117[MAXTICOEVENTS] AS Long 'digital time
DIM DATA_118[MAXTICOEVENTS] AS Long 'digital output Tico ch1
DIM DATA_119[MAXTICOEVENTS] AS Long 'digital output Tico ch5
' Declare Arrays for Analog Data from experiment control software
DIM DATA_1[MAXEVENTS] AS Long 'analog time
DIM DATA_2[MAXEVENTS] AS Long 'Analog Out change monitor
DIM DATA_3[MAXEVENTS] AS Long 'Analog Out PID change monitor
' Format: DATA_{module}{channel} + 100 for PID channels
DIM DATA_50[AOUTFIFO] AS Long AS Fifo 'AOUT1 Channel 00
DIM DATA_51[AOUTFIFO] AS Long AS Fifo 'AOUT1 Channel 01
DIM DATA_52[AOUTFIFO] AS Long AS Fifo 'AOUT1 Channel 02
DIM DATA_53[AOUTFIFO] AS Long AS Fifo 'AOUT1 Channel 03
DIM DATA_54[AOUTFIFO] AS Long AS Fifo 'AOUT1 Channel 04
DIM DATA_55[AOUTFIFO] AS Long AS Fifo 'AOUT1 Channel 05
DIM DATA_56[AOUTFIFO] AS Long AS Fifo 'AOUT1 Channel 06
DIM DATA_57[AOUTFIFO] AS Long AS Fifo 'AOUT1 Channel 07
DIM DATA_60[AOUTFIFO] AS Long AS Fifo 'AOUT2 Channel 00
DIM DATA_61[AOUTFIFO] AS Long AS Fifo 'AOUT2 Channel 01
DIM DATA_62[AOUTFIFO] AS Long AS Fifo 'AOUT2 Channel 02
DIM DATA_63[AOUTFIFO] AS Long AS Fifo 'AOUT2 Channel 03
DIM DATA_64[AOUTFIFO] AS Long AS Fifo 'AOUT2 Channel 04
DIM DATA_65[AOUTFIFO] AS Long AS Fifo 'AOUT2 Channel 05
DIM DATA_66[AOUTFIFO] AS Long AS Fifo 'AOUT2 Channel 06
DIM DATA_67[AOUTFIFO] AS Long AS Fifo 'AOUT2 Channel 07
' Declare Arrays for PID channels for each AOUT channel
DIM DATA_150[PIDFIFO] AS Long AS Fifo 'PID for AOUT1 Channel 00
DIM DATA_151[PIDFIFO] AS Long AS Fifo 'PID for AOUT1 Channel 01
DIM DATA_152[PIDFIFO] AS Long AS Fifo 'PID for AOUT1 Channel 02
DIM DATA_153[PIDFIFO] AS Long AS Fifo 'PID for AOUT1 Channel 03
DIM DATA_154[PIDFIFO] AS Long AS Fifo 'PID for AOUT1 Channel 04
DIM DATA_155[PIDFIFO] AS Long AS Fifo 'PID for AOUT1 Channel 05
DIM DATA_156[PIDFIFO] AS Long AS Fifo 'PID for AOUT1 Channel 06
DIM DATA_157[PIDFIFO] AS Long AS Fifo 'PID for AOUT1 Channel 07
DIM DATA_160[PIDFIFO] AS Long AS Fifo 'PID for AOUT2 Channel 00
DIM DATA_161[PIDFIFO] AS Long AS Fifo 'PID for AOUT2 Channel 01
DIM DATA_162[PIDFIFO] AS Long AS Fifo 'PID for AOUT2 Channel 02
DIM DATA_163[PIDFIFO] AS Long AS Fifo 'PID for AOUT2 Channel 03
DIM DATA_164[PIDFIFO] AS Long AS Fifo 'PID for AOUT2 Channel 04
DIM DATA_165[PIDFIFO] AS Long AS Fifo 'PID for AOUT2 Channel 05
DIM DATA_166[PIDFIFO] AS Long AS Fifo 'PID for AOUT2 Channel 06
DIM DATA_167[PIDFIFO] AS Long AS Fifo 'PID for AOUT2 Channel 07
'Declare Arrays to store regler values
DIM DATA_121[100000] AS Long 'Analog Out Channel 01
DIM DATA_122[100000] AS Long 'Analog Out Channel 02
DIM DATA_123[100000] AS Long 'Analog Out Channel 03
DIM DATA_124[100000] AS Long 'Analog Out Channel 04
DIM DATA_125[100000] AS Long 'Analog Out Channel 05
DIM DATA_126[100000] AS Long 'Analog Out Channel 06
DIM DATA_127[100000] AS Long 'Analog Out Channel 07
DIM DATA_128[100000] AS Long 'Analog Out Channel 08
DIM DATA_129[100000] AS Long 'Analog Out Channel 09
DIM DATA_130[100000] AS Long 'Analog Out Channel 10
DIM DATA_131[100000] AS Long 'Analog Out Channel 11
DIM DATA_132[100000] AS Long 'Analog Out Channel 12
DIM DATA_133[100000] AS Long 'Analog Out Channel 13
DIM DATA_134[100000] AS Long 'Analog Out Channel 14
DIM DATA_135[100000] AS Long 'Analog Out Channel 15
DIM DATA_136[100000] AS Long 'Analog Out Channel 16
'Declare Arrays for Digital Data from experiment control software
DIM DATA_10[MAXTICOEVENTS] AS Long 'DIO1 TiCo times
DIM DATA_11[MAXTICOEVENTS] AS Long 'DIO1 Digital Outputs
DIM DATA_20[MAXTICOEVENTS] AS Long 'DIO2 TiCo times
DIM DATA_21[MAXTICOEVENTS] AS Long 'DIO2 Digital Outputs
'Declare Arrays that are used for FIFO
DIM DATA_1[FIFOLENGTH] AS LONG 'FIFOs
DIM DATA_2[FIFOLENGTH] AS LONG 'FIFOs
DIM DATA_3[FIFOLENGTH] AS LONG 'FIFOs
'Declare Look up Table Arrays
DIM DATA_154[LUTLENGTH] AS LONG 'SB
DIM DATA_162[LUTLENGTH] AS LONG 'IPGaom verylow PD
DIM DATA_152[LUTLENGTH] AS LONG 'IPGaom highpower PD
DIM DATA_153[LUTLENGTH] AS LONG 'IPGaom low PD
'DIM DATA_151[LUTLENGTH] AS LONG 'SLM low power PD gain1
'DIM DATA_172[LUTLENGTH] AS LONG 'SLM very low power PD gain50
DIM DATA_170[4200] AS FLOAT 'SLM Feed Forward Waveform
'Declare Arrays that are used for AIN transmission
DIM DATA_4[AINFIFO] AS LONG AS FIFO
DIM DATA_5[AINFIFO] AS LONG AS FIFO
DIM DATA_6[AINFIFO] AS LONG AS FIFO
' TODO what are these used for ?
DIM remainder AS LONG
DIM oldReglerIPG AS LONG
'Declare Tico Data Transfer Arrays
DIM TICO_MEMORY1[150] AS LONG' AT DRAM_extern
DIM TICO_MEMORY2[150] AS LONG' AT DRAM_extern
DIM TICO_MEMORY1[150] AS LONG
DIM TICO_MEMORY2[150] AS LONG
'Declare PID SETTINGS Arrays
DIM p_pid[PIDNO] AS FLOAT
......@@ -110,8 +109,8 @@ DIM timer AS LONG
DIM i AS LONG 'number in for loops
'Declare Array for reading/writing AIN and AOUT Channels
DIM istwert[28] AS LONG
DIM stellwert[16] AS LONG
DIM act_values[28] AS LONG ' Analog values measured from AINs
DIM set_values[16] AS LONG ' Set values to be written to AOUTs
'declare ADC FIFO variables
DIM ADC_Channel_FIFO1 AS LONG
......@@ -135,7 +134,7 @@ DIM ADC_fifo_frequ AS FLOAT
init:
'Set Processdelay to 2us and return it to the experiment control software
PROCESSDELAY = 2000
PROCESSDELAY = 2000 ' TODO wirte it from labscript ?
par_1 = PROCESSDELAY
par_2 = 0
......@@ -155,14 +154,14 @@ init:
'Reset Tico and initialize data transfer Arrays
P2_tico_reset(2^(DIO1-1) + 2^(DIO2-1)) '(0000000000010001b) 'Resets DIO Modules
P2_tdrv_init(DIO1, 1, TICO_MEMORY1) 'Data Transfer to Module DIO1
P2_tdrv_init(DIO2, 1, TICO_MEMORY2) 'Data Transfer Module DIO2
P2_tdrv_init(DIO2, 1, TICO_MEMORY2) 'Data Transfer to Module DIO2
'Load the digital event data into the memory two DIO modules
P2_setdata_long(TICO_MEMORY1, 1, 1, MAXTICOEVENTS, DATA_117, 1, 1) 'Time for digital channels
P2_setdata_long(TICO_MEMORY1, 2, 1, MAXTICOEVENTS, DATA_118, 1, 1) 'Output values of the digital channels 0-31
P2_setdata_long(TICO_MEMORY1, 1, 1, MAXTICOEVENTS, DATA_10, 1, 1) 'Time for digital channels
P2_setdata_long(TICO_MEMORY1, 2, 1, MAXTICOEVENTS, DATA_11, 1, 1) 'Output values of the digital channels 0-31
P2_setdata_long(TICO_MEMORY2, 1, 1, MAXTICOEVENTS, DATA_117, 1, 1) 'Time for digital channels
P2_setdata_long(TICO_MEMORY2, 2, 1, MAXTICOEVENTS, DATA_119, 1, 1) 'Output values of the digital channels 32-63
P2_setdata_long(TICO_MEMORY2, 1, 1, MAXTICOEVENTS, DATA_20, 1, 1) 'Time for digital channels
P2_setdata_long(TICO_MEMORY2, 2, 1, MAXTICOEVENTS, DATA_21, 1, 1) 'Output values of the digital channels 32-63
'Turn Module LEDs on
P2_SET_LED(DIO1, 1)
......@@ -177,7 +176,7 @@ init:
'========================================================================================================================================
''' # Settingf for the ADC
''' # Setting for the ADC
'Parameter for ADC
ADC_stepsize=par_4
ADC_start=par_9
......@@ -186,54 +185,59 @@ init:
ADC_average_update=100-1
'FIFOs leeren
'FIFO_Clear(1)
'FIFO_Clear(2)
'FIFO_Clear(3)
'Mittelwerte zurücksetzen
FOR i=0 TO 7
FIFO_CLEAR(10*AOUT1 + i)
FIFO_CLEAR(10*AOUT2 + i)
FIFO_CLEAR(10*AOUT1 + i + 100)
FIFO_CLEAR(10*AOUT2 + i + 100)
NEXT i
FIFO_CLEAR(4)
FIFO_CLEAR(5)
FIFO_CLEAR(6)
'Mittelwerte zurcksetzen
ADC_average1=0
ADC_average2=0
ADC_average3=0
ADC_fifo_frequ=1.0/ADC_stepsize ''number of values that are averaged depending on the timestep of the fifo
'den FIFOs die ADC Channels zuweisen
ADC_Channel_FIFO1=par_6
ADC_Channel_FIFO2=par_7
ADC_Channel_FIFO3=par_8
ADC_Channel_FIFO1=1
ADC_Channel_FIFO2=2
ADC_Channel_FIFO3=3
'Shift Data in each Array to desynchronize chaching of the arrays in the event loop. this prevents single events from taking
'a lot of time when all arrays are recached at the same event.
' TODO deleted chaching fix
' Set analog outputs for the first time in the sequence.
' Because the AOUT channels have 16bit accuracy, we resrict the values to 16 digits.
' TODO restrict
stellwert[1]=DATA_101[1] AND 00000000000000001111111111111111b
stellwert[2]=DATA_102[1] AND 00000000000000001111111111111111b
stellwert[3]=DATA_103[1] AND 00000000000000001111111111111111b
stellwert[4]=DATA_104[1] AND 00000000000000001111111111111111b
stellwert[5]=((DATA_105[1] AND 00000000000000001111111111111111b)-((DATA_113[1] AND 00000000000000001111111111111111b) -N)) AND 00000000000000001111111111111111b
stellwert[6]=DATA_106[1] AND 00000000000000001111111111111111b
stellwert[7]=DATA_107[1] AND 00000000000000001111111111111111b
stellwert[8]=DATA_108[1] AND 00000000000000001111111111111111b
stellwert[9]=DATA_109[1] AND 00000000000000001111111111111111b
stellwert[10]=DATA_110[1] AND 00000000000000001111111111111111b
stellwert[11]=DATA_111[1] AND 00000000000000001111111111111111b
stellwert[12]=DATA_112[1] AND 00000000000000001111111111111111b
stellwert[13]=((DATA_105[1] AND 00000000000000001111111111111111b)+((DATA_113[1] AND 00000000000000001111111111111111b) -N)) AND 00000000000000001111111111111111b
stellwert[14]=DATA_114[1] AND 00000000000000001111111111111111b
stellwert[15]=DATA_115[1] AND 00000000000000001111111111111111b
stellwert[16]=DATA_116[1] AND 00000000000000001111111111111111b
''### Setzen der Stellwerte an die Analogausgänge
P2_Write_DAC8(AOUT1,stellwert,1) ' sende neue stellwerte an die Analog out Karten
P2_Write_DAC8(AOUT2,stellwert,9)
set_values[1] = DATA_50
set_values[2] = DATA_51
set_values[3] = DATA_52
set_values[4] = DATA_53
set_values[5] = DATA_54
set_values[6] = DATA_55
set_values[7] = DATA_56
set_values[8] = DATA_57
set_values[9] = DATA_60
set_values[10] = DATA_61
set_values[11] = DATA_62
set_values[12] = DATA_63
set_values[13] = DATA_64
set_values[14] = DATA_65
set_values[15] = DATA_66
set_values[16] = DATA_67
''### Setzen der Stellwerte an die Analogausgnge
P2_Write_DAC8(AOUT1,set_values,1) ' sende neue stellwerte an die Analog out Karten
P2_Write_DAC8(AOUT2,set_values,9)
P2_Start_DAC(AOUT1) ' starte das rausschreiben der analog output werte
P2_Start_DAC(AOUT2)
'initalize tico digital outputs
P2_set_par(DIO1,1,1,DATA_118[dEventIdx]) 'Initilisiere digitalausgänge für tico
P2_set_par(DIO2,1,1,DATA_119[dEventIdx]) 'Initilisiere digitalausgänge für tico
P2_set_par(DIO1,1,1,DATA_11[dEventIdx]) 'Initilisiere digitalausgnge fr tico
P2_set_par(DIO2,1,1,DATA_21[dEventIdx]) 'Initilisiere digitalausgnge fr tico
''increase event index by 1
inc dEventIdx
......@@ -246,20 +250,20 @@ init:
'### P2_ADCF_MODE im Timer Modus. Anweisung sollte m�glichst am Ende der init stehen
P2_ADCF_MODE(010b,0) '2=module No.2, 1=timer mode(always measure)start timer mode (immediate before the EVENT Part)
P2_ADCF_MODE(2^(AIN1-1),0) '2=module No.2, 1=timer mode(always measure)start timer mode (immediate before the EVENT Part)
P2_Set_Average_Filter(AIN1,2)
'P2_Set_Gain(AIN1,1,1)
'P2_Set_ADF(010b,5010h,1) 'check this 'change sampling frequency for card 2 module No2 5010h is the adress and the measurement time is (value-1)*10ns+250ns and value ranges from 31 (default setting) to 1 check again
P2_ADCF_MODE(0100000b,0) 'module No.6 set as 2^6=0100000 in binary, 1=timer mode(always measure)start timer mode (immediate before the EVENT Part)
P2_ADCF_MODE(2^(AIN2-1),0) 'module No.6 set as 2^6=0100000 in binary, 1=timer mode(always measure)start timer mode (immediate before the EVENT Part)
P2_Set_Average_Filter(AIN2,2)
P2_Set_Gain(AIN2,1,2)
P2_Set_Gain(AIN2,2,1)
P2_Set_Gain(AIN2,3,0)
P2_Set_Gain(AIN2,5,3)
P2_Set_Gain(AIN2,6,2)
P2_Set_Gain(AIN1,7,2)
P2_Set_Gain(AIN1,6,0)
' P2_Set_Gain(AIN2,1,2)
' P2_Set_Gain(AIN2,2,1)
' P2_Set_Gain(AIN2,3,0)
' P2_Set_Gain(AIN2,5,3)
' P2_Set_Gain(AIN2,6,2)
' P2_Set_Gain(AIN1,7,2)
' P2_Set_Gain(AIN1,6,0)
'Check_Card(6)
'Par_20 = Peek((68050100h OR shift_left(6,20)))
......@@ -287,23 +291,13 @@ EVENT:
timer = READ_TIMER_SYNC()
'Read istwerte at all ADC Channels
P2_READ_ADCF8(AIN1, istwert, 1) 'READ CHANNEL 1-8 OF AIN MODULE 1
P2_READ_ADCF8(AIN2, istwert, 21) 'READ CHANNEL 1-8 OF AIN MODULE 2
P2_READ_ADCF8(AIN1, act_values, 1) 'READ CHANNEL 1-8 OF AIN MODULE 1
P2_READ_ADCF8(AIN2, act_values, 21) 'READ CHANNEL 1-8 OF AIN MODULE 2
'Start conversion at all ADC Channels Synced for next Event
'P2_Sync_All(100010b)
P2_Sync_All(2^(AIN1-1)+2^(AIN2-1))
' set values for virtual analog input channels to use different PID parameters
istwert[14]=istwert[8] ''PIboxFeshATT
istwert[16]=istwert[1] ''Feshbach sample and hold
istwert[13]=istwert[5] '' MotcurStrong different pid but same input as motcurrent
istwert[12]=istwert[2] ''IPGaom very low from IPG high power PD with different amplification
istwert[18]=istwert[22] ''Different PID Parameters for SLM PD 22 (Gain 50)
istwert[19]=istwert[22] ''Different PID Parameters for SLM PD 22 (Gain 50)
istwert[20]=istwert[21] ''Different PID Parameters for SLM PD 21 (Gain 1)
istwert[11] = istwert [3]
istwert[10]=istwert[11]
'COMPUTE NEW SET VALUES
' DELETED PID etc. for OUTPUT CHANNELS !
......@@ -319,25 +313,21 @@ EVENT:
endif
''### Setzen der Stellwerte an die Analogausgänge (t= 27)
P2_Write_DAC8(AOUT1,stellwert,1) ''sende neue stellwerte an die Analog out Karten
P2_Write_DAC8(AOUT2,stellwert,9)
P2_Write_DAC8(AOUT1,set_values,1) ''sende neue stellwerte an die Analog out Karten
P2_Write_DAC8(AOUT2,set_values,9)
'P2_Start_DAC(AOUT1) '' starte das rausschreiben der neuen analog output werte
'P2_Start_DAC(AOUT2)
'Write all DAC Channels Synced
P2_Sync_All(2^(AOUT1-1)+2^(AOUT2-1))
'### Rausschreiben ADC Arrays
if ( processIdx < FIFOLENGTH ) then
DATA_1[processIdx]=istwert[ADC_Channel_FIFO1]
DATA_2[processIdx]=istwert[ADC_Channel_FIFO2]
DATA_3[processIdx]=istwert[ADC_Channel_FIFO3]
'DATA_3[processIdx]=stellwert[12]
endif
DATA_4 = act_values[ADC_Channel_FIFO1]
DATA_5 = act_values[ADC_Channel_FIFO2]
DATA_6 = act_values[ADC_Channel_FIFO3]
'DATA_3[processIdx]=stellwert[12]
inc processIdx
If (DATA_100[aEventIdx+1] = processIdx)THEN 'check wether next event reached
If (DATA_1[aEventIdx+1] = processIdx)THEN 'check wether next event reached
inc aEventIdx 'set index to next event
ENDIF
......@@ -363,8 +353,8 @@ EVENT:
FINISH:
P2_DAC(AOUT1,5,N) 'Analogausgang 3 (feshbachcurrent lower) auf sicheren wert setzen
P2_DAC(AOUT2,5,N) 'Analogausgang 13 (feshbachcurrent upper) auf sicheren wert setzen
P2_DAC(AOUT1,5,ZERO) 'Analogausgang 3 (feshbachcurrent lower) auf sicheren wert setzen
P2_DAC(AOUT2,5,ZERO) 'Analogausgang 13 (feshbachcurrent upper) auf sicheren wert setzen
P2_DAC(AOUT1,6,36700) 'Analogausgang 6 (ipg power) auf sicheren wert (1.2) setzen entspricht 20W
P2_SET_LED(DIO1,0) 'LED am Modul 1 ausschalten = DIO32
......
'<ADbasic Header, Headerversion 001.001>
' Process_Number = 1
' Initial_Processdelay = 10000
' Eventsource = Timer
' Control_long_Delays_for_Stop = No
' Priority = High
' Version = 1
' ADbasic_Version = 6.3.1
' Optimize = Yes
' Optimize_Level = 1
' Stacksize = 1000
' Info_Last_Save = ATI098-60 ATI098-60\labuser
'<Header End>
#include adwinpro_all.inc
init:
PROCESSDELAY = 100000
event:
P2_DAC(par_81,par_82,par_83)
P2_Digout(par_91, par_92, par_93)
'<ADbasic Header, Headerversion 001.001>
' Process_Number = 2
' Initial_Processdelay = 10000
' Eventsource = Timer
' Control_long_Delays_for_Stop = No
' Priority = High
' Version = 1
' ADbasic_Version = 6.3.1
' Optimize = Yes
' Optimize_Level = 1
' Stacksize = 1000
' Info_Last_Save = ATI098-60 ATI098-60\labuser
'<Header End>
#include adwinpro_all.inc
init:
PROCESSDELAY = 100000
event:
P2_DAC(par_81,par_82,par_83)
P2_Digout(par_91, par_92, par_93)
File added
'<ADbasic Header, Headerversion 001.001>
' Process_Number = 1
' Initial_Processdelay = 10000
' Eventsource = Timer
' Control_long_Delays_for_Stop = No
' Priority = High
' Version = 1
' ADbasic_Version = 6.2.0
' Optimize = Yes
' Optimize_Level = 1
' Stacksize = 1000
' Info_Last_Save = PC-MB-VM-W7-BMW PC-MB-VM-W7-BMW\Markus Borchers
'<Header End>
dim i as long
dim data_1[50000] as long
dim data_3[10000] as long as fifo
dim data_5[1000] as String
#if PROCESSOR = T12 then
dim data_2[50000] as float32
dim data_4[10000] as float32 as fifo
dim data_6[50000] as float64
dim data_7[10000] as float64 as fifo
#else
#if PROCESSOR = T121 then
dim data_2[50000] as float32
dim data_4[10000] as float32 as fifo
dim data_6[50000] as float64
dim data_7[10000] as float64 as fifo
#else
dim data_2[50000] as float
dim data_4[10000] as float as fifo
#endif
#endif
lowinit:
for i = 1 to 80
par[i] = i
fpar[i] = i + 0.12345
data_3 = i
data_4 = i + 0.12345
#if PROCESSOR = T12 then
data_7 = i + 100.12345
#endif
#if PROCESSOR = T121 then
data_7 = i + 100.12345
#endif
next
for i = 1 to 50000
data_1[i] = i
data_2[i] = i + 0.123456789
#if PROCESSOR = T12 then
data_6[i] = i + 0.123456789
#endif
#if PROCESSOR = T121 then
data_6[i] = i + 0.123456789
#endif
next
data_5 = "Hello World!"
' processdelay 100 kHz
#if PROCESSOR = T9 then
processdelay = 400
#endif
#if PROCESSOR = T10 then
processdelay = 400
#endif
#if PROCESSOR = T11 then
processdelay = 3000
#endif
#if PROCESSOR = T12 then
processdelay = 10000
#endif
#if PROCESSOR = T121 then
processdelay = 10000
#endif
event:
inc par_1
fpar_1 = fpar_1 + 0.001
#! /usr/bin/python3
# -*- coding: cp1252 -*-
''' Demonstrate all functions from the ADwin-Python-Module '''
# Copyright 2017 J�ger Computergesteuerte Messtechnik GmbH
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import sys
import time
import ctypes
import logging
import numpy as np
try:
import ADwin
except ImportError:
sys.path.append(r"C:\ADwin\Developer\Python")
import ADwin
RAISE_EXCEPTIONS = 1
NO_YES = ("no", "yes")
DEVICENUMBER = 0x1
PROCESSORTYPE = "12"
PROCESS = "example.TC1"
adw = ADwin.ADwin(DEVICENUMBER, RAISE_EXCEPTIONS)
def init():
# Boot ADwin-System
if adw.Test_Version():
print("boot ADwin-system... ", end="", flush=True)
if sys.platform == "win32":
BTL = adw.ADwindir + "adwin" + PROCESSORTYPE + ".btl"
if sys.platform.startswith("linux"):
BTL = "adwin" + PROCESSORTYPE + ".btl"
adw.Boot(BTL)
print("ok")
# Test_Version
print("test_version()... ", end="", flush=True)
if adw.Test_Version() == 0:
print("ok")
else:
print("not ok")
print("process is running:", NO_YES[adw.Process_Status(1)])
print("processdelay:", adw.Get_Processdelay(1))
# ProcessorType
print("processor_type:", adw.Processor_Type())
def load_process(PROCESS):
# Load and start process
print("load process... ", end="", flush=True)
adw.Load_Process(PROCESS)
time.sleep(0.2)
print("ok")
print("start process... ", end="", flush=True)
adw.Start_Process(1)
time.sleep(0.2)
print("ok")
print("process is running:", NO_YES[adw.Process_Status(1)])
print("workload... ", end="", flush=True)
adw.Workload() # first call with invalid value
time.sleep(0.2)
print(adw.Workload(), "%")
if (PROCESSORTYPE == "9") or (PROCESSORTYPE == "10"):
print("free memory, type pm_local:", adw.Free_Mem(1), "byte")
print("free memory, type dm_local:", adw.Free_Mem(3), "byte")
print("free memory, type dram_ext:", adw.Free_Mem(4), "byte")
if PROCESSORTYPE == "11":
print("free memory, type pm_local:", adw.Free_Mem(1), "byte")
print("free memory, type em_local:", adw.Free_Mem(2), "byte")
print("free memory, type dm_local:", adw.Free_Mem(3), "byte")
print("free memory, type dram_ext:", adw.Free_Mem(4), "byte")
if (PROCESSORTYPE == "12") or (PROCESSORTYPE == "121"):
print("free memory, type cm:", adw.Free_Mem(5), "kbyte")
print("free memory, type um:", adw.Free_Mem(6), "kbyte")
# Long-Parameter
for i in range(1, 81):
adw.Set_Par(i, i)
print("\nGet_Par: ", end="", flush=True)
for i in range(1, 9):
print(adw.Get_Par(i), end=", ")
print(adw.Get_Par(10))
print("Get_Par_All:", adw.Get_Par_All()[:10])
print("Get_Par_Block:", adw.Get_Par_Block(10, 10)[:])
# Float-Parameter
for i in range(1, 81):
adw.Set_FPar(i, i+0.1)
print("Get_FPar: ", end="", flush=True)
for i in range(1, 9):
print(adw.Get_FPar(i), end=", ")
print(adw.Get_FPar(10))
print("Get_FPar_All:", adw.Get_FPar_All()[:5])
print("Get_FPar_Block:", adw.Get_FPar_Block(10, 10)[:5])
try:
# Double-Parameter
for i in range(1, 81):
adw.Set_FPar_Double(i, i+0.1)
print("Get_FPar_Double: ", end="", flush=True)
for i in range(1, 9):
print(adw.Get_FPar_Double(i), end=", ")
print(adw.Get_FPar_Double(10))
print("Get_FPar_All_Double:", adw.Get_FPar_All_Double()[:])
print("Get_FPar_Block_Double:", adw.Get_FPar_Block_Double(10, 10)[:])
except AttributeError:
logging.warning("double-parameter not implemented!")
# Datas
for i in range(1, 8):
print("Data_Type", i, adw.Data_Type(i), ", Data_Length:", adw.Data_Length(i))
# long-Data
DATATYPE = ctypes.c_int32 * 100
ARR = DATATYPE(0)
for i in range(100):
ARR[i] = i
adw.SetData_Long(ARR, 1, 1, 100)
# also possible:
# type list: adw.SetData_Long(range(100, 200), 1, 1, 100)
# type array: adw.SetData_Long(array.array('l', range(100,200)), 1, 1, 100)
print("GetData_Long:", adw.GetData_Long(1, 10, 20)[:])
# float-Data
DATATYPE = ctypes.c_float * 100
ARR = DATATYPE(0)
for i in range(100):
ARR[i] = i + 0.1
adw.SetData_Float(ARR, 2, 1, 100)
print("GetData_Float:", adw.GetData_Float(2, 10, 20)[:5])
if (PROCESSORTYPE == "12") or (PROCESSORTYPE == "121"):
try:
# double-Data
DATATYPE = ctypes.c_double * 100
ARR = DATATYPE(0)
for i in range(100):
ARR[i] = i + 0.1
adw.SetData_Double(ARR, 6, 1, 100)
print("GetData_Double:", adw.GetData_Double(6, 10, 20)[:5])
except (AttributeError, ADwin.ADwinError):
logging.warning("double-data not implemented!")
# Fifo, type long
print("Fifo_Full(3):", adw.Fifo_Full(3), "- Fifo_Empty(3):", adw.Fifo_Empty(3))
print("Get some values from fifo:", adw.GetFifo_Long(3, 10)[:])
print("Fifo_Full(3):", adw.Fifo_Full(3), "- Fifo_Empty(3):", adw.Fifo_Empty(3))
print("Set some values to the fifo... ", end="", flush=True)
adw.SetFifo_Long(3, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 10)
print("ok")
print("Fifo_Full(3):", adw.Fifo_Full(3), "- Fifo_Empty(3):", adw.Fifo_Empty(3))
print("clear_fifo... ", end="", flush=True)
adw.Fifo_Clear(3)
print("ok")
print("Fifo_Full(3):", adw.Fifo_Full(3), "- Fifo_Empty(3):", adw.Fifo_Empty(3))
# Fifo, type float
print("Fifo_Full(4):", adw.Fifo_Full(4), "- Fifo_Empty(4):", adw.Fifo_Empty(4))
print("Get some values from fifo:", adw.GetFifo_Float(4, 10)[:])
print("Set some values to the fifo... ", end="", flush=True)
adw.SetFifo_Float(4, [1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8, 9.9, 10.0], 10)
print("ok")
# Fifo, type double
if (PROCESSORTYPE == "12") or (PROCESSORTYPE == "121"):
try:
print("Fifo_Full(7):", adw.Fifo_Full(7), "- Fifo_Empty(7):", adw.Fifo_Empty(7))
print("Get some values from fifo:", adw.GetFifo_Double(7, 10)[:])
print("Set some values to the fifo... ", end="", flush=True)
adw.SetFifo_Double(7, [1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8, 9.9, 10.0], 10)
print("ok")
except ADwin.ADwinError:
logging.warning("double-fifo not implemented!")
# Data_2 <-> File
print("data2file... ", end="", flush=True)
adw.Data2File('data2.dat', 2, 1, 50000, 0)
print("ok")
print("file2data... ", end="", flush=True)
adw.File2Data('data2.dat', ADwin.ADwin.ADWIN_DATATYPE_SINGLE, 2, 1)
print("ok")
# String
STR = "The answer to this is very simple. It was a joke. \n" \
+"It had to be a number, an ordinary, smallish number, and I chose that one.\n" \
+"Binary representations, base thirteen, Tibetan monks are all complete nonsense.\n" \
+"I sat at my desk, stared into the garden and thought '42 will do' I typed it out. " \
+"End of story."
adw.SetData_String(5, STR)
print("String_Length:", adw.String_Length(5))
STR = adw.GetData_String(5, 400)
print("GetData_String:", STR.decode())
print("Stop_Process... ", end="", flush=True)
adw.Stop_Process(1)
print("ok")
print("Clear_Process... ", end="", flush=True)
adw.Clear_Process(1)
print("ok")
if __name__=="__main__":
init()
# set par
adw.Set_Par(1, 2000)
print("Get_Par_All:", adw.Get_Par(1))
times = np.arange(10,10000,100, dtype=np.uint32)
values = np.arange(30000,50000,100, dtype=np.uint32)
adw.SetData_Long(times.ctypes,1,1,times.size)
adw.SetFifo_Long(5,values.ctypes,values.size)
print(np.ctypeslib.as_array(adw.GetData_Long(1,1,times.size)))
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment