10-29-2015 03:52 PM
I have a waveform graph that I am plotting continuously to from a virtual Ai channel. I appear to have everything working now but only one small problem. My plot on the graph is slow and has a lag compared to how fast my input signal is changing. How do I fix this?? Is it one of the properties that I have set in the waveform graph or plot that is causing the problem?
In the following code, I am creating the task and virtual channels in a "Initialization" Sub that is called when the program starts. The timing configuration is done on a button click event when the scaling of the respective channel is changed. Another button.click (swScopeOnOff) event starts the task and then jumps to DataAcquiring( ).
I have changed the sampling rate and the sampleperchannel in the timing configuration to no avail. No noticeable changes on my plot to graph. Still slow. Does everything in my code appear to be fine as written? Is there something in the way the WaveformGraph properties or Plot properties are set that could be over-riding things? Open to suggestions. Thank you.
Try 'Create Daq virtual channels myTask.AIChannels.CreateVoltageChannel("cDAQ9184-1A4BA5FMod1/ai0", "", AITerminalConfiguration.Differential, -10, 10, "Linear Scale") myTask.AIChannels.CreateVoltageChannel("cDAQ9184-1A4BA5FMod1/ai1", "", AITerminalConfiguration.Differential, -10, 10, "Linear Scale") myTask.AIChannels.CreateVoltageChannel("cDAQ9184-1A4BA5FMod1/ai2", "", AITerminalConfiguration.Differential, -10, 10, "Linear Scale") myTask.AIChannels.CreateVoltageChannel("cDAQ9184-1A4BA5FMod1/ai3", "", AITerminalConfiguration.Differential, -10, 10, "Linear Scale") myTask.AIChannels.CreateVoltageChannel("cDAQ9184-1A4BA5FMod1/ai4", "", AITerminalConfiguration.Differential, -10, 10, "Linear Scale") myTask.AIChannels.CreateVoltageChannel("cDAQ9184-1A4BA5FMod1/ai5", "", AITerminalConfiguration.Differential, -10, 10, "Linear Scale") myTask.AIChannels.CreateVoltageChannel("cDAQ9184-1A4BA5FMod1/ai6", "", AITerminalConfiguration.Differential, -10, 10, "Linear Scale") myTask.AIChannels.CreateVoltageChannel("cDAQ9184-1A4BA5FMod1/ai7", "", AITerminalConfiguration.Differential, -10, 10, "Linear Scale") myTask.AIChannels.CreateVoltageChannel("cDAQ9184-1A4BA5FMod1/ai16", "", AITerminalConfiguration.Differential, -10, 10, "Linear Scale") myTask.AIChannels.CreateVoltageChannel("cDAQ9184-1A4BA5FMod1/ai17", "", AITerminalConfiguration.Differential, -10, 10, "Linear Scale") myTask.AIChannels.CreateVoltageChannel("cDAQ9184-1A4BA5FMod1/ai18", "", AITerminalConfiguration.Differential, -10, 10, "Linear Scale") myTask.AIChannels.CreateVoltageChannel("cDAQ9184-1A4BA5FMod1/ai19", "", AITerminalConfiguration.Differential, -10, 10, "Linear Scale") myTask.AIChannels.CreateVoltageChannel("cDAQ9184-1A4BA5FMod1/ai20", "", AITerminalConfiguration.Differential, -10, 10, "Linear Scale") myTask.AIChannels.CreateVoltageChannel("cDAQ9184-1A4BA5FMod1/ai21", "", AITerminalConfiguration.Differential, -10, 10, "Linear Scale") myTask.AIChannels.CreateVoltageChannel("cDAQ9184-1A4BA5FMod1/ai22", "", AITerminalConfiguration.Differential, -10, 10, "Linear Scale") myTask.AIChannels.CreateVoltageChannel("cDAQ9184-1A4BA5FMod1/ai23", "", AITerminalConfiguration.Differential, -10, 10, "Linear Scale") myTask.Stop() Catch ex As DaqException MessageBox.Show(ex.Message) End Try sampleRate = numEdtCycleRate.Value myTask.Timing.ConfigureSampleClock("", sampleRate, SampleClockActiveEdge.Rising, SampleQuantityMode.ContinuousSamples, 100) Public Sub dataAcquiring() reader = New AnalogMultiChannelReader(myTask.Stream) Dim data() As AnalogWaveform(Of Double) ' = reader.ReadWaveform(0) 'While Scope switch is on, stream each Ai channel's data continuously to its respective WaveForm graph Do While swScopeOnOff.Value = True data = reader.ReadWaveform(sampleRate) wfgCh0.PlotWaveform(data(0)) wfgCh1.PlotWaveform(data(1)) wfgCh2.PlotWaveform(data(2)) wfgCh3.PlotWaveform(data(3)) wfgCh4.PlotWaveform(data(4)) wfgCh5.PlotWaveform(data(5)) wfgCh6.PlotWaveform(data(6)) wfgCh7.PlotWaveform(data(7)) wfgCh8.PlotWaveform(data(8)) wfgCh9.PlotWaveform(data(9)) wfgCh10.PlotWaveform(data(10)) wfgCh11.PlotWaveform(data(11)) wfgCh12.PlotWaveform(data(12)) wfgCh13.PlotWaveform(data(13)) wfgCh14.PlotWaveform(data(14)) wfgCh15.PlotWaveform(data(15)) Loop reader = Nothing data = Nothing End Sub
10-29-2015 04:09 PM
I figured it out. Disregard.