Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

VB.NET multi-cards displacement – analog input synchronization

Hi,

 

I’m creating a VB.NET application which requires synchronization between analog inputs and a displacement measure (50000 pulses / meter) – displacement speed : 1m/s.

 

Used hardware

  • PCI 6528 (get/set digital I/O)

  • PCI 6220 (analog inputs)

  • PCI 6602 (displacement)

  • RTSI cable between 6528 and 6220

 

When the measurement is authorized (one input on 6528), I need acquire simultaneously, for a 10 meters displacement

  • time reference for each pulse

  • displacement

  • 2 analog inputs

 

To be continued …

0 Kudos
Message 1 of 17
(6,133 Views)

VB.NET code structure

 

  • 1 task for analog inputs : “TskAnalogInputs”

    • First channel : Dev3/ai0, Differential, -10 V  +10 V

    • Second channel : Dev3/ai2, Differential, -10 V  +10 V

    • Clock : 1 sample on request

 

  • 1 task for displacement measurement : “TskDisplacement”

    • First channel : Dev1/ctr0 as “LinD”, TwoPulseCounting, 20 µm per count

    • Clock : 1 sample on request

 

  • 1 task for digital inputs : not implemented yet

  

User controls are autogenerated and instancied into the main form

 

To be continued …

0 Kudos
Message 2 of 17
(6,116 Views)

The callback looks like

 

Public Sub OnMyDataReady(ByVal Sender as Object, ByVal e as UC_TskDisplacement.TaskEventArgs)

 

  ‘ Called when data are available

     

  ‘ Access analog data

  AI=TskAnalogInputs.Read()

 

  ‘ Store data into structure

  Str_Acq(idx).Time=environment.TickCount ‘ time (ms)

  Str_Acq(idx).Displacement=e.GetData(0)  ‘ displacement

  Str_Acq(idx).Analog0=AI(0) ‘ AI0

  Str_Acq(idx).Analog2=AI(1) ‘ AI2

 

  idx=idx+1  ‘ idx is a table index (integer)

 

End Sub

 

To be continued …

0 Kudos
Message 3 of 17
(6,114 Views)

Str_Acquisition is a structure defined as :

 

‘ Acquisition informations

Private structure Str_Acq

  Dim Time as integer

  Dim Displacement as Double

  Dim Analog0 as double

  Dim Analog2 as double

End Structure

 

 

 

To be continued …

0 Kudos
Message 4 of 17
(6,113 Views)

I’m able to separately :

  • take time reference of each pulse (in callback).

  • read the displacement (in callback)

  • read analog inputs synchronized with a counter (no displacement task runs)

but when trying to synchronize the whole, I loose counts (precision is divided by 50 – the smallest displacement measure I can see is 1 mm) !

 

I think the callback access counter and AI too slowly, but I don’t know how to change this to get the right precision (20 µm).

 

Can you help me ?

Thanks,

 

“Pas bavard”

0 Kudos
Message 5 of 17
(6,112 Views)

I'm only a LabVIEW user and can't comment usefully about any of the VB.net code.  However, I DO think you should change the following:

Used hardware

  • PCI 6528 (get/set digital I/O)
  • PCI 6220 (analog inputs)
  • PCI 6602 (displacement)
  • RTSI cable between 6528 and 6220

I don't think the RTSI connection on the 6528 does you any good.  However, if you were to connect the 6220 (analog in) to the 6602 (displacement), then you could accomplish synchronization in hardware.

 

It sounds like your approach so far is to depend on software polling to take individual readings one at a time.  You'll be capable of much higher measurement rates if you instead let the data acq boards buffer your readings.

 

In LabVIEW this would be a pretty straightforward.  I don't know how one would approach it with VB.net.

 

-Kevin P.

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
Message 6 of 17
(6,103 Views)

Hi Kevin,

Thanks for the answer.

I will take a look on the RTSI cable.

 

It sounds like your approach so far is to depend on software polling to take individual readings one at a time.  You'll be capable of much higher measurement rates if you instead let the data acq boards buffer your readings.

I do that because I haven't found what I need on forums nor in DAQmx examples (I found for a simple counter, not displacement counters). I'm OK to use the board to buffer readings, but how can I do that with my application ? How can I route the counter signal to the analog board and get the counter value at the same time ?

 

In LabVIEW this would be a pretty straightforward.  I don't know how one would approach it with VB.net.

Smiley Wink Yes, but I have no choice : VB.NET or nothing ...

 

Thanks,

"Pas bavard"

0 Kudos
Message 7 of 17
(6,098 Views)
Hi,
 
I changed the position of the RTSI cable,
0 Kudos
Message 8 of 17
(6,076 Views)
Hi,
 
I changed the position of the RTSI cable, but
0 Kudos
Message 9 of 17
(6,076 Views)
Hi,
 
I changed the position of the RTSI cable, but have
0 Kudos
Message 10 of 17
(6,076 Views)