Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

How to write from P0.8 to P0.15

Hello

 

I'm using this code for turn on the bits of Port0:

 

    Private Sub TURN_ON (ByVal Line_Name As String)
        Dim digitalWriteTask As New Task
        Dim writer As New DigitalSingleChannelWriter(digitalWriteTask.Stream)

        Select Case Line_Name
           

            Case "Line0"

                Try
                    digitalWriteTask.DOChannels.CreateChannel("Dev1/Port0/line0", "port0", ChannelLineGrouping.OneChannelForEachLine)
                    writer.WriteSingleSampleSingleLine(True, True)
                    Exit Sub
                Catch exception As DaqException
                    MessageBox.Show(exception.Message)
                Finally
                    digitalWriteTask.Dispose()
                End Try

 

          Case "Line1"

                ....................

                ....................

       End select

 

End Sub

 

 

 

 

    Private Sub TURN_OFF (ByVal Line_Name As String)
        Dim digitalWriteTask As New Task
        Dim writer As New DigitalSingleChannelWriter(digitalWriteTask.Stream)

        Select Case Line_Name


            Case "Line0"

                Try
                    digitalWriteTask.DOChannels.CreateChannel("Dev1/Port0/line0", "port0", ChannelLineGrouping.OneChannelForEachLine)
                    writer.WriteSingleSampleSingleLine(True, False)
                    Exit Sub
                Catch exception As DaqException
                    MessageBox.Show(exception.Message)
                Finally
                    digitalWriteTask.Dispose()
                End Try

 

          Case "Line"

                ....................

                ....................

 

        End Select

 

    End Sub

 

 

BUT IT DON'T WORK FOR LINE 8....LINE15. WHY??

 

CAN YOU SEND ME A CODE EXAMPLE THAT TURN ON AND OFF ONE BIT AT TIME LINE 8....LINE15? THANKS

 

 

 

 

0 Kudos
Message 1 of 12
(5,406 Views)
Hi,
0 Kudos
Message 2 of 12
(5,399 Views)

Hi,

0 Kudos
Message 3 of 12
(5,399 Views)

Hi,

 

I know this doesn't solve your problem but you could reduce your code, both subs and all the select case code to one short sub.

 

Private Sub WritePort(ByVal Line_Name As String, ByVal Value As Boolean)


        Dim digitalWriteTask As New Task
        Dim writer As New DigitalSingleChannelWriter(digitalWriteTask.Stream)

        Dim Line As String = Line_Name.Substring(Line_Name.Length - 1, 1)

        Try
            digitalWriteTask.DOChannels.CreateChannel("Dev1/Port0/line" & Line, "port" & Line, ChannelLineGrouping.OneChannelForEachLine)
            writer.WriteSingleSampleSingleLine(True, Value)
            'You don't need 'Exit Sub' here
        Catch exception As DaqException
            MessageBox.Show(exception.Message)
        Finally
            digitalWriteTask.Dispose()
        End Try

    End Sub

 

Sorry this doesn't solve your issue

 

Curt

0 Kudos
Message 4 of 12
(5,399 Views)

Hello,

my problem is still unresolved...

What I must do for write from P0.8 to P0.15

 

Thanks

0 Kudos
Message 5 of 12
(5,387 Views)

Hi,

 

I don't know what hardware you are using, but is it possible that there are two 8 bit ports on your device and not one 16 bit port?

If that is the case then try using something like this for bits 8 to 15

 

"Dev1/Port1/line0", "port1"

 

where line0 = line8 and line7 = line15

 

Curt

0 Kudos
Message 6 of 12
(5,377 Views)

Hello peppepeazella,

 

in the following link you can find an example of how you can generate continuous analog waveform with variable rate internal clock using Visual Basic .NET 

Continuous Analog Waveform Generation with Variable Rate Internal Clock in Visual Basic .NET

http://zone.ni.com/devzone/cda/epd/p/id/4775

 

I am also sending you a link where you will be able to find examples regarding DAQmx functions for .NET.

 

NI-DAQmx, NI-VISA and NI-488.2 .NET Example Locations

http://digital.ni.com/public.nsf/allkb/39F4B9264B94308C8625729D0067F9AF?OpenDocument

 

Please let me know if this is of assistance.

 

Thank you,


Antonios
0 Kudos
Message 7 of 12
(5,365 Views)

 

Sorry But I don't have found nothing that help me

I' have still the problem to drive P0.8 line

0 Kudos
Message 8 of 12
(5,351 Views)

Hi,

 

What type of device are you using?

 

Curt

0 Kudos
Message 9 of 12
(5,348 Views)

Hello

 

my hardware is USB - 6212

 

THanks

0 Kudos
Message 10 of 12
(5,332 Views)