@@ -133,7 +133,7 @@ int main (int argc, char **argv)
133133 printf ("Port = %#hx\n" , wvalue );
134134 break ;
135135 case 'C' :
136- printf ("USB-1608FS Continuous sampling. Hit 's' to stop\n" );
136+ printf ("USB-1608FS Continuous sampling. Hit 's' to stop\n" );
137137 printf ("Enter desired frequency [Hz]: " );
138138 scanf ("%f" , & freq );
139139 gain = BP_10_00V ;
@@ -150,9 +150,20 @@ int main (int argc, char **argv)
150150 printf ("Actual frequency = %f\n" , freq );
151151 flag = fcntl (fileno (stdin ), F_GETFL );
152152 fcntl (0 , F_SETFL , flag | O_NONBLOCK );
153+ j = 1 ;
153154 do {
154155 nSamples = usbAInRead_USB1608FS (udev , data );
155- printf ("samples returned = %d\n" , nSamples );
156+ // add corrections
157+ for (i = 0 ; i < nSamples ; i ++ ) {
158+ sdata [i ] = (int ) (table_AIN [0 ][channel ].slope * ((float ) data [i ]) + table_AIN [0 ][channel ].offset );
159+ if (sdata [i ] >= 0x8000 ) {
160+ sdata [i ] -= 0x8000 ;
161+ } else {
162+ sdata [i ] = (0x8000 - sdata [i ]);
163+ sdata [i ] *= (-1 );
164+ }
165+ }
166+ printf ("%d: samples returned = %d\n" , j ++ , nSamples );
156167 } while (!isalpha (getchar ()));
157168 fcntl (fileno (stdin ), F_SETFL , flag );
158169 usbAInStop_USB1608FS (udev );
0 commit comments