Analog 1ms sampling problem

Supporting Java SE version 7 and up
Post Reply
osmanx7
Fresh meat
Posts: 2
Joined: Fri Sep 13, 2019 8:32 am
Contact:

Analog 1ms sampling problem

Post by osmanx7 »

Dear all,

I'm using the 8/8/8 interfacekit for sound localization using three sound sensors (voltage input). Since the application is time sensitive, I'm trying to collect the data at 1ms data interval. However, the sensors readings show a repeated voltage value or zeros. what could be the problem?
Thank you in advance.
this is the constructor

Code: Select all

 public Localization(int length)
    {
        this.length = length;
        mic = new VoltageInput[3];

        try
        {
            for(int i = 0; i < 3; i++)
            {
                //Create the channels
                mic[i] = new VoltageInput();
                mic[i].setDeviceSerialNumber(443183);
                mic[i].setChannel(i);
                mic[i].open(5000);
                mic[i].setVoltageChangeTrigger(0);
                mic[i].setDataInterval(1);
            }
        }catch (PhidgetException e)
        {
            e.printStackTrace();
        }
    }
User avatar
Patrick
Lead Developer
Posts: 3399
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: Analog 1ms sampling problem

Post by Patrick »

Hi,

I'm can't see how you are reading out the values from your sample code. Make sure you are using event to get the 1ms data. The 1018 send data to the PC every 8ms, with each packet containing up to 8x analog values per channel. You will see 8x events every 8ms.

-Patrick
osmanx7
Fresh meat
Posts: 2
Joined: Fri Sep 13, 2019 8:32 am
Contact:

Re: Analog 1ms sampling problem

Post by osmanx7 »

Thank you for replying Mr. Patrick,

I'm using getVoltage() function to read the sensors' voltage. I'm quite new to Java. By using events, do you mean the voltage change event in the example?

Also if the 8/8/8 is sending the data every 8ms, how do i access each value?

this is the rest of the code used to read the sensors.
the reason I'm using an array is to apply cross correlation to the arrays and calculate the time delay (in samples). I have tried displaying the values using (ch.getVoltage()) directly and facing the same problem.

Code: Select all

public void soundSens() throws Exception
    {
        //double baseline = 0.44;
        double[] Mic1 = new double[length];
        Arrays.fill(Mic1, 0);
        double[] Mic2 = new double[length];
        Arrays.fill(Mic2, 0);

        for (int i = 0; i < length; i++)
        {
            Mic1[i] = mic[0].getVoltage();
            Mic2[i] = mic[1].getVoltage();
        }

        for (int i = 0; i < length; i++)
            System.out.printf("%f\t%f%n",Mic1[i],Mic2[i]);
    }
    
        public static void main(String[] args) throws Exception
    {
        while (true)
        {
            Localize.soundSens();
        }
    }
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests