get high rate analog data from interface kit

Supporting Java SE version 7 and up
biowolp

get high rate analog data from interface kit

Postby biowolp » Wed Oct 05, 2011 2:49 pm

In the manual I see:

Changing the Data Rate
You can change the data rate for each Analog Input from 1 millisecond to 1 second. By default, the analog input data set is sent to the PC every 8ms. If, for example, you set the data rate to 1ms, you will receive a packet containing 8 miliseconds worth of 1 ms samples every 8ms.

However, in class SensorChangeEvent, function getValue() returns an int. I don't see anything that returns a "packet". How do you get the
set of 8 values expected?

biowolp

erik
King of the Lab
Posts: 476
Joined: Fri Mar 06, 2009 12:42 pm
Location: Calgary, Canada
Contact:

Re: get high rate analog data from interface kit

Postby erik » Wed Oct 05, 2011 3:43 pm

The packet containing the eight data points trigger eight separate events, provided the change between the data points are above the Sensitivity property or Sensitivity is set to 0. This is why there is no array of data returned by getValue. If you set a counter in the Event Handler, it should increase by 1000 every second, whereas counting the number of incoming packets (if possible) would only be 125.

biowolp

Re: get high rate analog data from interface kit

Postby biowolp » Thu Oct 06, 2011 10:01 am

Hi Eric,

Thanks, your reply was helpful in understanding the output. There are still anomalies tho. When I set the change sensitivity to 0 I no longer get all the outputs expected. Is there some hidden interaction between change sensitivity and event triggering? Also it seems that event response time can be a factor. Can events be lost if the host code has not returned from the last event?

TomB



erik wrote:The packet containing the eight data points trigger eight separate events, provided the change between the data points are above the Sensitivity property or Sensitivity is set to 0. This is why there is no array of data returned by getValue. If you set a counter in the Event Handler, it should increase by 1000 every second, whereas counting the number of incoming packets (if possible) would only be 125.

erik
King of the Lab
Posts: 476
Joined: Fri Mar 06, 2009 12:42 pm
Location: Calgary, Canada
Contact:

Re: get high rate analog data from interface kit

Postby erik » Thu Oct 06, 2011 10:36 am

Changing the Sensitivity works as follows:

If the Sensitivity is set to 10, then the Analog Input's SensorValue must change by at least 10 in order for an event to occur - going from 200 to 210 (or from 210 to 200) will result in one event triggered. If the Sensitivity is set to 200, then, for example, the analog input needs to go from 425 to 625 (or 625 to 425) before an event is triggered. If the value changed by 199, no event.

In order to get all the data when you set the DataRate to 1ms, the analog input needs to change by the amount in the Sensitivity setting every millisecond. Alternatively, you can set Sensitivity to 0 and you will get all the data events regardless if the value changes or not.


It is possible to lose events if the EventHandler is too long. If you are attaching the Error listener to the InterfaceKit, it will turn up as a PacketLost or Overrun exceptions. You can consider having the EventHandlers simply starting new threads to handle the incoming data.


Return to “Java”

Who is online

Users browsing this forum: No registered users and 2 guests