Rev 326 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 326 | Rev 357 | ||
---|---|---|---|
Line 110... | Line 110... | ||
110 | case 3: |
110 | case 3: |
111 | return 1; |
111 | return 1; |
112 | } |
112 | } |
113 | return i; |
113 | return i; |
114 | }; |
114 | }; |
- | 115 | ||
- | 116 | #define ADC_VCC 3.3 |
|
- | 117 | #define AMP_IB_min -1.15e-6 |
|
- | 118 | #define ADC_IB_min 2355 |
|
- | 119 | #define AMP_IB_max 0.2e-6 |
|
- | 120 | #define ADC_IB_max 2665 |
|
- | 121 | ||
- | 122 | double sa02ampIb(int adc) { |
|
- | 123 | if (adc <= ADC_IB_min) return AMP_IB_min; |
|
- | 124 | if (adc > ADC_IB_max) return AMP_IB_max; |
|
- | 125 | return AMP_IB_min + ((AMP_IB_max-AMP_IB_min)/(ADC_IB_max-ADC_IB_min)) * (adc - ADC_IB_min); |
|
- | 126 | } |
|
- | 127 | ||
- | 128 | double sa02adc2V(int adc) { |
|
- | 129 | adc &=0xFFF; |
|
- | 130 | return ADC_VCC * (double)adc/4096; |
|
- | 131 | } |
|
- | 132 | ||
- | 133 | double sa02adc2Vp(int adc) { |
|
- | 134 | adc &=0xFFF; |
|
- | 135 | return ADC_VCC * (double)adc/4096 + 1.0e+4 * sa02ampIb(adc); |
|
- | 136 | } |
|
- | 137 | ||
- | 138 | double sa02adc2Vm(int adc) { |
|
- | 139 | adc &=0xFFF; |
|
- | 140 | return ADC_VCC * (2. * (double)adc/4096. - 1.) + 5.1e+4 * sa02ampIb(adc); |
|
- | 141 | } |
|
- | 142 | ||
- | 143 | double sa02adc2V38(int adc) { |
|
- | 144 | adc &=0xFFF; |
|
- | 145 | return ADC_VCC * (2. * (double)adc/4096.) + 5.1e+4 * sa02ampIb(adc); |
|
- | 146 | } |
|
- | 147 | ||
- | 148 | double sa02adc2Va(int adc) { |
|
- | 149 | adc &=0xFFF; |
|
- | 150 | return ADC_VCC * (double)adc/4096. - (ADC_VCC/2. + 0.06); |
|
- | 151 | } |
|
115 | 152 | ||
116 | //------------------------------------------------------------------------- |
153 | //------------------------------------------------------------------------- |
117 | 154 | ||
118 | uint32_t sa02Write(uint32_t sa02BoardNumber, uint32_t regh, uint32_t regl, uint32_t *response) |
155 | uint32_t sa02Write(uint32_t sa02BoardNumber, uint32_t regh, uint32_t regl, uint32_t *response) |
119 | 156 | ||
Line 134... | Line 171... | ||
134 | } |
171 | } |
135 | 172 | ||
136 | //------------------------------------------------------------------------- |
173 | //------------------------------------------------------------------------- |
137 | int Sa02DaqMode (uint32_t mode) { |
174 | int Sa02DaqMode (uint32_t mode) { |
138 | VME_A32D32_W(sa02Address+FEB_DAQMODE,mode); |
175 | VME_A32D32_W(sa02Address+FEB_DAQMODE,mode); |
139 | return 0; |
176 | return 0; |
140 | } |
177 | } |
141 | 178 | ||
142 | int Sa02SetPtsOutput(uint32_t mask) { |
179 | int Sa02SetPtsOutput(uint32_t mask) { |
143 | VME_A32D32_W(sa02Address+FEB_DEBUGMON,mask); |
180 | VME_A32D32_W(sa02Address+FEB_DEBUGMON,mask); |
144 | return 0; |
181 | return 0; |
145 | } |
182 | } |
146 | 183 | ||
147 | int Sa02SetNeve (uint32_t neve) { |
184 | int Sa02SetNeve (uint32_t neve) { |
148 | 185 | ||
149 | VME_A32D32_W(sa02Address+FEB_SETNEVE,neve); |
186 | VME_A32D32_W(sa02Address+FEB_SETNEVE,neve); |
150 | return 0; |
187 | return 0; |
151 | } |
188 | } |
152 | 189 | ||
153 | uint32_t Sa02GetNeve (uint32_t*inputtriggers) { |
190 | uint32_t Sa02GetNeve (uint32_t*inputtriggers) { |
154 | uint32_t neve=0; |
191 | uint32_t neve=0; |
155 | VME_A32D32_R(sa02Address+FEB_GETNEVE,&neve); |
192 | VME_A32D32_R(sa02Address+FEB_GETNEVE,&neve); |
156 | *inputtriggers = (neve >> 16) &0xFFFF; |
193 | *inputtriggers = (neve >> 16) &0xFFFF; |
Line 170... | Line 207... | ||
170 | return neve; |
207 | return neve; |
171 | } |
208 | } |
172 | 209 | ||
173 | int sa02Reset1( void ) { |
210 | int sa02Reset1( void ) { |
174 | uint32_t rdy=1; |
211 | uint32_t rdy=1; |
175 | 212 | ||
176 | VME_A32D32_W(sa02Address+FEB_DATA_RST,rdy); |
213 | VME_A32D32_W(sa02Address+FEB_DATA_RST,rdy); |
177 | 214 | ||
178 | return 0; |
215 | return 0; |
179 | } |
216 | } |
180 | 217 | ||
Line 194... | Line 231... | ||
194 | return 0; |
231 | return 0; |
195 | } |
232 | } |
196 | 233 | ||
197 | int Sa02SelectTriggerWithMaskAndLength (uint32_t trg, uint32_t mask, uint32_t len) { |
234 | int Sa02SelectTriggerWithMaskAndLength (uint32_t trg, uint32_t mask, uint32_t len) { |
198 | VME_A32D32_W(sa02Address+FEB_SELTRG, trg | (mask << 4) | (len << 16) ); |
235 | VME_A32D32_W(sa02Address+FEB_SELTRG, trg | (mask << 4) | (len << 16) ); |
199 | return 0; |
236 | return 0; |
200 | } |
237 | } |
201 | - | ||
202 | 238 | ||
203 | int Sa02SoftwareTrigger (void ) { |
239 | int Sa02SoftwareTrigger (void ) { |
204 | uint32_t rdy =1; |
240 | uint32_t rdy =1; |
205 | VME_MWRST(); |
241 | VME_MWRST(); |
206 | VME_MW(VME_A32, VME_D32,sa02Address+FEB_SWTRG,rdy); |
242 | VME_MW(VME_A32, VME_D32,sa02Address+FEB_SWTRG,rdy); |
207 | VME_MWEXEC(); |
243 | VME_MWEXEC(); |
208 | return 0; |
244 | return 0; |
209 | } |
245 | } |
210 | - | ||
211 | - | ||
212 | 246 | ||
213 | int Sa02TestPulseEnable (uint32_t board, uint32_t enable ) { |
247 | int Sa02TestPulseEnable (uint32_t board, uint32_t enable ) { |
214 | 248 | ||
215 | uint32_t response[2]= {0,0}; |
249 | uint32_t response[2]= {0,0}; |
216 | return sa02Cmd(board,FEB_TP, enable, 0, 0 ,1,response); |
250 | return sa02Cmd(board,FEB_TP, enable, 0, 0 ,1,response); |
Line 845... | Line 879... | ||
845 | data=0x10; |
879 | data=0x10; |
846 | val=sa02Cmd(board, cmd, data, chip, channel ,1,response); |
880 | val=sa02Cmd(board, cmd, data, chip, channel ,1,response); |
847 | Delay(0.01); |
881 | Delay(0.01); |
848 | cmd=FEB_ADC_READ; |
882 | cmd=FEB_ADC_READ; |
849 | val=sa02Cmd(board, cmd, data, chip, channel ,1,response); |
883 | val=sa02Cmd(board, cmd, data, chip, channel ,1,response); |
850 | doubleval = |
884 | doubleval = sa02adc2Vp(val); |
851 | sa02Printf("VDD = %6.3f V\n",doubleval); |
885 | sa02Printf("VDD = %6.3f V\n",doubleval); |
852 | sdata[i++]=doubleval; |
886 | sdata[i++]=doubleval; |
853 | 887 | ||
854 | cmd=FEB_MUX; |
888 | cmd=FEB_MUX; |
855 | data=0x11; |
889 | data=0x11; |
856 | val=sa02Cmd(board, cmd, data, chip, channel ,1,response); |
890 | val=sa02Cmd(board, cmd, data, chip, channel ,1,response); |
857 | Delay(0.01); |
891 | Delay(0.01); |
858 | cmd=FEB_ADC_READ; |
892 | cmd=FEB_ADC_READ; |
859 | val=sa02Cmd(board, cmd, data, chip, channel ,1,response); |
893 | val=sa02Cmd(board, cmd, data, chip, channel ,1,response); |
860 | doubleval = |
894 | doubleval = sa02adc2Vp(val); |
861 | sa02Printf("V+2 = %6.3f V\n",doubleval); |
895 | sa02Printf("V+2 = %6.3f V\n",doubleval); |
862 | sdata[i++]=doubleval; |
896 | sdata[i++]=doubleval; |
863 | 897 | ||
864 | cmd=FEB_MUX; |
898 | cmd=FEB_MUX; |
865 | data=0x12; |
899 | data=0x12; |
866 | val=sa02Cmd(board, cmd, data, chip, channel ,1,response); |
900 | val=sa02Cmd(board, cmd, data, chip, channel ,1,response); |
867 | Delay(0.01); |
901 | Delay(0.01); |
868 | cmd=FEB_ADC_READ; |
902 | cmd=FEB_ADC_READ; |
869 | val=sa02Cmd(board, cmd, data, chip, channel ,1,response); |
903 | val=sa02Cmd(board, cmd, data, chip, channel ,1,response); |
870 | doubleval = |
904 | doubleval = sa02adc2Vm(val); |
871 | sa02Printf("V-2 = %6.3f V\n",doubleval); |
905 | sa02Printf("V-2 = %6.3f V\n",doubleval); |
872 | sdata[i++]=doubleval; |
906 | sdata[i++]=doubleval; |
873 | 907 | ||
874 | 908 | ||
875 | cmd=FEB_MUX; |
909 | cmd=FEB_MUX; |
876 | data=0x13; |
910 | data=0x13; |
877 | val=sa02Cmd(board, cmd, data, chip, channel ,1,response); |
911 | val=sa02Cmd(board, cmd, data, chip, channel ,1,response); |
878 | Delay(0.01); |
912 | Delay(0.01); |
879 | cmd=FEB_ADC_READ; |
913 | cmd=FEB_ADC_READ; |
880 | val=sa02Cmd(board, cmd, data, chip, channel ,1,response); |
914 | val=sa02Cmd(board, cmd, data, chip, channel ,1,response); |
881 | doubleval = |
915 | doubleval = sa02adc2Vm(val); |
882 | sa02Printf("VSS = %6.3f V\n",doubleval); |
916 | sa02Printf("VSS = %6.3f V\n",doubleval); |
883 | sdata[i++]=doubleval; |
917 | sdata[i++]=doubleval; |
884 | 918 | ||
885 | cmd=FEB_MUX; |
919 | cmd=FEB_MUX; |
886 | data=0x20; |
920 | data=0x20; |
887 | val=sa02Cmd(board, cmd, data, chip, channel ,1,response); |
921 | val=sa02Cmd(board, cmd, data, chip, channel ,1,response); |
888 | Delay(0.01); |
922 | Delay(0.01); |
889 | cmd=FEB_ADC_READ; |
923 | cmd=FEB_ADC_READ; |
890 | val=sa02Cmd(board, cmd, data, chip, channel ,1,response); |
924 | val=sa02Cmd(board, cmd, data, chip, channel ,1,response); |
891 | if (sa02BoardType>2) |
925 | if (sa02BoardType>2) |
892 | doubleval = |
926 | doubleval = sa02adc2Vm(val); |
893 | else |
927 | else |
894 | doubleval = |
928 | doubleval = sa02adc2V(val); |
895 | sa02Printf("VTH1 = %6.3f V\n",doubleval); |
929 | sa02Printf("VTH1 = %6.3f V\n",doubleval); |
896 | sdata[i++]=doubleval; |
930 | sdata[i++]=doubleval; |
897 | 931 | ||
898 | cmd=FEB_MUX; |
932 | cmd=FEB_MUX; |
899 | data=0x30; |
933 | data=0x30; |
900 | val=sa02Cmd(board, cmd, data, chip, channel ,1,response); |
934 | val=sa02Cmd(board, cmd, data, chip, channel ,1,response); |
901 | Delay(0.01); |
935 | Delay(0.01); |
902 | cmd=FEB_ADC_READ; |
936 | cmd=FEB_ADC_READ; |
903 | val=sa02Cmd(board, cmd, data, chip, channel ,1,response); |
937 | val=sa02Cmd(board, cmd, data, chip, channel ,1,response); |
904 | if (sa02BoardType>2) |
938 | if (sa02BoardType>2) |
905 | doubleval = |
939 | doubleval = sa02adc2Vm(val); |
906 | else |
940 | else |
907 | doubleval = |
941 | doubleval = sa02adc2V(val); |
908 | sa02Printf("VTH2 = %6.3f V\n",doubleval); |
942 | sa02Printf("VTH2 = %6.3f V\n",doubleval); |
909 | sdata[i++]=doubleval; |
943 | sdata[i++]=doubleval; |
910 | 944 | ||
911 | cmd=FEB_MUX; |
945 | cmd=FEB_MUX; |
912 | data=0x40; |
946 | data=0x40; |
913 | val=sa02Cmd(board, cmd, data, chip, channel ,1,response); |
947 | val=sa02Cmd(board, cmd, data, chip, channel ,1,response); |
914 | Delay(0.01); |
948 | Delay(0.01); |
915 | cmd=FEB_ADC_READ; |
949 | cmd=FEB_ADC_READ; |
916 | val=sa02Cmd(board, cmd, data, chip, channel ,1,response); |
950 | val=sa02Cmd(board, cmd, data, chip, channel ,1,response); |
917 | doubleval = |
951 | doubleval = sa02adc2Vp(val); |
918 | sa02Printf("VCC12 = %6.3f V\n",doubleval); |
952 | sa02Printf("VCC12 = %6.3f V\n",doubleval); |
919 | sdata[i++]=doubleval; |
953 | sdata[i++]=doubleval; |
920 | 954 | ||
921 | cmd=FEB_MUX; |
955 | cmd=FEB_MUX; |
922 | data=0x50; |
956 | data=0x50; |
923 | val=sa02Cmd(board, cmd, data, chip, channel ,1,response); |
957 | val=sa02Cmd(board, cmd, data, chip, channel ,1,response); |
924 | Delay(0.01); |
958 | Delay(0.01); |
925 | cmd=FEB_ADC_READ; |
959 | cmd=FEB_ADC_READ; |
926 | val=sa02Cmd(board, cmd, data, chip, channel ,1,response); |
960 | val=sa02Cmd(board, cmd, data, chip, channel ,1,response); |
927 | doubleval = |
961 | doubleval = sa02adc2Vp(val); |
928 | sa02Printf("VCC15 = %6.3f V\n",doubleval); |
962 | sa02Printf("VCC15 = %6.3f V\n",doubleval); |
929 | sdata[i++]=doubleval; |
963 | sdata[i++]=doubleval; |
930 | 964 | ||
931 | cmd=FEB_MUX; |
965 | cmd=FEB_MUX; |
932 | data=0x60; |
966 | data=0x60; |
933 | val=sa02Cmd(board, cmd, data, chip, channel ,1,response); |
967 | val=sa02Cmd(board, cmd, data, chip, channel ,1,response); |
934 | Delay(0.01); |
968 | Delay(0.01); |
935 | cmd=FEB_ADC_READ; |
969 | cmd=FEB_ADC_READ; |
936 | val=sa02Cmd(board, cmd, data, chip, channel ,1,response); |
970 | val=sa02Cmd(board, cmd, data, chip, channel ,1,response); |
937 | doubleval = |
971 | doubleval = sa02adc2Vp(val); |
938 | sa02Printf("VCC25 = %6.3f V\n",doubleval); |
972 | sa02Printf("VCC25 = %6.3f V\n",doubleval); |
939 | sdata[i++]=doubleval; |
973 | sdata[i++]=doubleval; |
940 | 974 | ||
941 | cmd=FEB_MUX; |
975 | cmd=FEB_MUX; |
942 | data=0x70; |
976 | data=0x70; |
943 | val=sa02Cmd(board, cmd, data, chip, channel ,1,response); |
977 | val=sa02Cmd(board, cmd, data, chip, channel ,1,response); |
944 | Delay(0.01); |
978 | Delay(0.01); |
945 | cmd=FEB_ADC_READ; |
979 | cmd=FEB_ADC_READ; |
946 | val=sa02Cmd(board, cmd, data, chip, channel ,1,response); |
980 | val=sa02Cmd(board, cmd, data, chip, channel ,1,response); |
947 | doubleval = |
981 | doubleval = sa02adc2V38(val); |
948 | sa02Printf("V+3.8 = %6.3f V\n",doubleval); |
982 | sa02Printf("V+3.8 = %6.3f V\n",doubleval); |
949 | sdata[i++]=doubleval; |
983 | sdata[i++]=doubleval; |
950 | 984 | ||
951 | cmd=FEB_MUX; |
985 | cmd=FEB_MUX; |
952 | data=0x00; |
986 | data=0x00; |