private void Adc_Connected(object sender, EventArgs e)
        {
            // Set the ADC bit rate to 16 bit
            adc.BitRate = 16;

            Int32 counter      = 1;
            Int32 totalsamples = 1000;

            double[] readarray = new double[totalsamples];

            DateTime starttime = DateTime.Now;

            // Clear the console window
            Console.Clear();

            Console.WriteLine("Start: " + starttime.ToString("s"));

            while (counter < totalsamples)
            {
                // read the voltage from channel 1 and display on the screen
                readarray[counter] = adc.ReadVoltage(1);

                counter += 1;
            }

            DateTime endtime = DateTime.Now;

            Console.WriteLine("End: " + endtime.ToString("s"));

            double totalseconds = (endtime - starttime).TotalSeconds;

            double samplespersecond = totalsamples / totalseconds;

            Console.WriteLine(samplespersecond.ToString("N2") + " samples per second");
        }
Esempio n. 2
0
        private static void ReadADC(Object sender)
        {
            // get the voltage values from all 8 ADC channels
            try
            {
                channel1_value = adc.ReadVoltage(1);
                channel2_value = adc.ReadVoltage(2);
                if (channel1_value != 0 || channel2_value != 0)
                {
                    convertADCreadingsToTempature();
                }
            }
            catch (Exception)
            {
                Debug.WriteLine("F**k");
            }



            // reset the timer so it will run again after the preset period
            _timer.Change(TIME_INTERVAL_IN_MILLISECONDS, Timeout.Infinite);
        }
        private void Adc_Connected(object sender, EventArgs e)
        {
            // Set the ADC bit rate to 16 bit
            adc.BitRate = 16;

            // Clear the console window

            Console.Clear();

            while (true)
            {
                // read from adc channels and print to screen
                Console.WriteLine("Channel 1: " + adc.ReadVoltage(1).ToString("N3"));
                Console.WriteLine("Channel 2: " + adc.ReadVoltage(2).ToString("N3"));
                Console.WriteLine("Channel 3: " + adc.ReadVoltage(3).ToString("N3"));
                Console.WriteLine("Channel 4: " + adc.ReadVoltage(4).ToString("N3"));
                Console.WriteLine("Channel 5: " + adc.ReadVoltage(5).ToString("N3"));
                Console.WriteLine("Channel 6: " + adc.ReadVoltage(6).ToString("N3"));
                Console.WriteLine("Channel 7: " + adc.ReadVoltage(7).ToString("N3"));
                Console.WriteLine("Channel 8: " + adc.ReadVoltage(8).ToString("N3"));
                Console.SetCursorPosition(0, 0);
            }
        }