K8055 analoge input to output

good morning
I would like my digital outputs operate with analog input A1.
BV.by 1 volt on the input A1,than are output 1 on
at 2 volt on the input A1,than are output 1,2 on
at 3 volt on the input A1,than are output 1,2,3 on
at 4 volt on the input A1,than are output 1,2,3,4 on

Sory for my bad englich
Thanks Charles

[quote=“ch@rles”]good morning
I would like my digital outputs operate with analog input A1.
BV.by 1 volt on the input A1,than are output 1 on
at 2 volt on the input A1,than are output 1,2 on
at 3 volt on the input A1,than are output 1,2,3 on
at 4 volt on the input A1,than are output 1,2,3,4 on

Sory for my bad englich
Thanks Charles[/quote]

hmm a K8055 voltmeter?

okay, if my understanding of the board is correct, A1 accepts 0-5v and gives values 0-255 so every 51 (255 divided by 5) is one volt
set the digital channel accordingly :-
(in this VB example I created a form and dropped a timer on it called Timer1, I also added a label called Label1 to display the volts on the form)

Public Class Form1

    'You will be using these methods/functions so you need to have them declaired here
    Public Declare Function ReadAnalogChannel Lib "k8055d.dll" (ByVal Channel As Integer) As Integer
    Public Declare Sub SetDigitalChannel Lib "k8055d.dll" (ByVal Channel As Integer)
    Public Declare Sub ClearAllDigital Lib "k8055d.dll" ()
    Public Declare Function OpenDevice Lib "k8055d.dll" (ByVal CardAddress As Integer) As Integer
    Public Declare Sub CloseDevice Lib "k8055d.dll" ()

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        'timer setup
        Timer1.Enabled = True                                                                  'Enable the timer
        Timer1.Interval = 250                                                                   'Quarter of a second delay between readings
    End Sub

        Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
        OpenDevice(0)
        Dim intVoltValue As Integer = ReadAnalogChannel(1) / 55                'This will be the reading from the analogue input converted to a Volt value
        Me.Label1.Text = Str(intVoltValue) & " Volts"                                   'Displays the Volts on the form
        ClearAllDigital()
        For intOutChan = 1 To intVoltValue                                                  'This will be the number of outputs that get set
            SetDigitalChannel(intOutChan)
        Next
        CloseDevice()
    End Sub

End Class

C

[quote=“chrisstubbs67”]
okay, if my understanding of the board is correct, A1 accepts 0-5v and gives values 0-255 so every 51 (255 divided by 5) is one volt
set the digital channel accordingly :-
(in this VB example I created a form and dropped a timer on it called Timer1, I also added a label called Label1 to display the volts on the form)

Public Class Form1

'You will be using these methods/functions so you need to have them declaired here
Public Declare Function ReadAnalogChannel Lib "k8055d.dll" (ByVal Channel As Integer) As Integer
Public Declare Sub SetDigitalChannel Lib "k8055d.dll" (ByVal Channel As Integer)
Public Declare Sub ClearAllDigital Lib "k8055d.dll" ()
Public Declare Function OpenDevice Lib "k8055d.dll" (ByVal CardAddress As Integer) As Integer
Public Declare Sub CloseDevice Lib "k8055d.dll" ()

Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
    'timer setup
    Timer1.Enabled = True                                                                  'Enable the timer
    Timer1.Interval = 250                                                                   'Quarter of a second delay between readings
End Sub

    Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
    OpenDevice(0)
    Dim intVoltValue As Integer = ReadAnalogChannel(1) / 55                'This will be the reading from the analogue input converted to a Volt value
    Me.Label1.Text = Str(intVoltValue) & " Volts"                                   'Displays the Volts on the form
    ClearAllDigital()
    For intOutChan = 1 To intVoltValue                                                  'This will be the number of outputs that get set
        SetDigitalChannel(intOutChan)
    Next
    CloseDevice()
End Sub

End Class

C[/quote]

as a footnote if you change the timer tick event to :-

    Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
        OpenDevice(0)
        WriteAllDigital(ReadAnalogChannel(1))
        CloseDevice()
    End Sub

you have created a rather cool little 5v A/D convertor (okay deviating from the thread a little now)

An issue of which to be aware is that the ADCs on the K8055 use the USB’s 5V power supply as their reference voltage.

While the USB 5V supply on most computers is reasonably accurate (4.9 to 5.1V) the USB 2.0 specification allows 4.75 to 5.25 Volts. Some powered hubs using barely regulated “wall wart” power supplies are often higher than 5.25V with low loads, then drop off as multiple devices are connected.

Obviously this variance in the reference voltage of up to +/- 5% affects the accuracy of the 8055’s ADC inputs…