Velleman k8055 usb experiment interface board

Thread Starter

denison

Joined Oct 13, 2018
328
Using laptop usb power only getting 4.68 voltage out at dac2. code set at 255. Connected 9v to clamp and result is the same. How can I fix this to get full 5 volts and more accurate results for lower codes?
An Arduino microcontroller programmer board gives same result with usb power only. This is fixed with a 9 volt power source.
 

MrChips

Joined Oct 2, 2009
30,707
Using laptop usb power only getting 4.68 voltage out at dac2. code set at 255. Connected 9v to clamp and result is the same. How can I fix this to get full 5 volts and more accurate results for lower codes?
An Arduino microcontroller programmer board gives same result with usb power only. This is fixed with a 9 volt power source.
What are the voltages for values just below 255?
Does the output voltage change linearly with output values from 0 to 255?
 

Thread Starter

denison

Joined Oct 13, 2018
328
What are the voltages for values just below 255?
Does the output voltage change linearly with output values from 0 to 255?
The output voltage is given by- (number/255)x5. This makes it very linear. Values just below 255 are just below 4.68.
The connection scheme shown by velleman is rather strange. It shows a 220vac power supply connected to a transformer taking it to a lower voltage. Then there is a full wave bridge rectifier. (4 diodes). Then a capacitor to smooth the wave. Then this is connected to the clamp pin of the k8055 and ground pin. No voltage regulator. The dc voltage must be between 5 and 30v.
There must be a voltage regulator on the board. Cannot see it anywhere on the schematic or visually.
I suppose I could try this set up to see if it gives me a better result. Can't see why my regulated 9 volt supply doesn't work.
 

sarahMCML

Joined May 11, 2019
363
The output voltage is given by- (number/255)x5. This makes it very linear. Values just below 255 are just below 4.68.
The connection scheme shown by velleman is rather strange. It shows a 220vac power supply connected to a transformer taking it to a lower voltage. Then there is a full wave bridge rectifier. (4 diodes). Then a capacitor to smooth the wave. Then this is connected to the clamp pin of the k8055 and ground pin. No voltage regulator. The dc voltage must be between 5 and 30v.
There must be a voltage regulator on the board. Cannot see it anywhere on the schematic or visually.
I suppose I could try this set up to see if it gives me a better result. Can't see why my regulated 9 volt supply doesn't work.
What are you measuring the analog output voltage with? Don't forget the output impedance is 1k5!
 

Thread Starter

denison

Joined Oct 13, 2018
328
hi den,
These documents are from my old project with the K8055 circa 2007.!
I still have the PCB [some where]
They may help with your project.
E
Hi Eric, The schematic shows the power supply (clamp) leading to the ULN2803 chip. That is not a voltage regulator. Can you see a voltage regulator anywhere on the schematic? The schematic must be wrong. I will try a diode on the power supply input before the clamp. I am thinking the clamp may be a zener diode. I have built quite accurate power supplies in the past using a zener and no voltage regulator.
I have had nothing but problems with the k8055 board. Do you know of a good board for getting data in and out of a usb computer port.
I have all the other references you have supplied. The problem seems to be the power that comes to the board from the computer usb port. It may be possible to stop power but still allow data from the usb port somehow.
 
Last edited:

nsaspook

Joined Aug 27, 2009
13,079
Results of two Velleman boards using a Linux DAQ driver and a small C program to set the DAC to 255.
PXL_20210519_030514753.jpgPXL_20210519_035920328.jpgPXL_20210519_040233401.jpgPXL_20210519_040436660.jpg

The DAC voltage is limited on the old K8055 board. The PVM110N-1 is better.

C:
int main(int argc, char *argv[])
{
    int do_ao_only = false;
    uint8_t i = 0, j = 75;

    if (do_ao_only) {
        if (init_dac(0.0, 25.0, false) < 0) {
            printf("Missing Analog AO subdevice\n");
            return -1;
        }


        while (true) {
            set_dac_raw(0, sine_wave[255 - i++] << 4);
            set_dac_raw(1, sine_wave[255 - j++] << 4);
        }
    } else {

        if (init_daq(0.0, 25.0, false) < 0) {
            printf("Missing Analog subdevice(s)\n");
            return -1;
        }
        if (init_dio() < 0) {
            printf("Missing Digital subdevice(s)\n");
            return -1;
        }
       
        set_dac_raw(0,255); // show max Voltage

        while (1) {
            get_data_sample();
            led_lightshow(0);
        }
    }
    return 0;
}

Some userland daq setup code functions to control the boards.

/*
* File:   daq.h
* Author: root
*
* Created on September 21, 2012, 6:49 PM
*/

#ifndef DAQ_H
#define DAQ_H

#ifdef __cplusplus
extern "C" {
#endif

#define PVV_C   0
#define CCV_C   1
#define SYV_C   2
#define B1V_C   3
#define B2V_C   4
#define INV_C   5
#define VD5_C   7
#define PVC_C   8
#define CCC_C   9
#define BAC_C   10   

#define LPCHANC        16

#include <stdint.h>
#include <comedilib.h>

    struct didata {
        uint32_t D0 : 1; //
        uint32_t D1 : 1; //
        uint32_t D2 : 1; //
        uint32_t D3 : 1; //
        uint32_t D4 : 1; //
        uint32_t D5 : 1; //
        uint32_t D6 : 1; //
        uint32_t D7 : 1; //
    };

    union dio_buf_type {
        uint32_t dio_buf;
        struct didata d;
    };

    typedef struct bmcdata {
        double pv_voltage, cc_voltage, input_voltage, b1_voltage, b2_voltage, system_voltage, logic_voltage;
        double pv_current, cc_current, battery_current;
        struct didata datain;
        union dio_buf_type dataout;
        int32_t adc_sample[32];
        int32_t dac_sample[32];
        int32_t utc;
    }
    bmctype;

    extern volatile struct bmcdata bmc;
    extern struct didata datain;
    extern struct dodata dataout;

    int init_daq(double, double, int);
    int init_dac(double, double, int);
    int init_dio(void);
    int adc_range(double, double);
    int dac_range(double, double);
    double get_adc_volts(int);
    int set_dac_volts(int, double);
    int set_dac_raw(int, lsampl_t);
    int get_dio_bit(int);
    int put_dio_bit(int, int);
    int set_dio_input(int);
    int set_dio_output(int);
    int get_data_sample(void);
    double lp_filter(double, int, int);
#ifdef __cplusplus
}
#endif

#endif /* DAQ_H */

#include <stdio.h> /* for printf() */
#include <unistd.h>
#include <stdbool.h>
#include <stdint.h>
#include <comedilib.h>
#include "daq.h"

int subdev_ai = 0; /* change this to your input subdevice */
int chan_ai = 0; /* change this to your channel */
int range_ai = 0; /* more on this later */
int aref_ai = AREF_GROUND; /* more on this later */
int maxdata_ai, ranges_ai, channels_ai;

int subdev_ao = 0; /* change this to your input subdevice */
int chan_ao = 0; /* change this to your channel */
int range_ao = 0; /* more on this later */
int aref_ao = AREF_GROUND; /* more on this later */
int maxdata_ao, ranges_ao, channels_ao;

int subdev_di = 0; /* change this to your input subdevice */
int chan_di = 0; /* change this to your channel */
int range_di = 0; /* more on this later */
int maxdata_di, ranges_di, channels_di, datain_di;

int subdev_do = 0; /* change this to your input subdevice */
int chan_do = 0; /* change this to your channel */
int range_do = 0; /* more on this later */
int maxdata_do, ranges_do, channels_do, datain_do;

int subdev_dio; /* change this to your input subdevice */
int aref_dio; /* more on this later */

comedi_t *it;
comedi_range *ad_range, *da_range;
bool ADC_OPEN = false, DIO_OPEN = false, ADC_ERROR = false, DEV_OPEN = false,
    DIO_ERROR = false, HAS_AO = false, DAC_ERROR = false;

int init_daq(double min_range, double max_range, int range_update)
{
    int i = 0;

    if (!DEV_OPEN) {
        it = comedi_open("/dev/comedi0");
        if (it == NULL) {
            comedi_perror("comedi_open");
            ADC_OPEN = false;
            DEV_OPEN = false;
            return -1;
        }
        DEV_OPEN = true;
    }

    subdev_ai = comedi_find_subdevice_by_type(it, COMEDI_SUBD_AI, subdev_ai);
    if (subdev_ai < 0) {
        return -2;
        ADC_OPEN = false;
    }


    subdev_ao = comedi_find_subdevice_by_type(it, COMEDI_SUBD_AO, subdev_ao);
    if (subdev_ao < 0) {
        HAS_AO = false;
    } else {
        HAS_AO = true;
    }

    printf("Subdev AI  %i ", subdev_ai);
    channels_ai = comedi_get_n_channels(it, subdev_ai);
    printf("Analog  Channels %i ", channels_ai);
    maxdata_ai = comedi_get_maxdata(it, subdev_ai, i);
    printf("Maxdata %i ", maxdata_ai);
    ranges_ai = comedi_get_n_ranges(it, subdev_ai, i);
    printf("Ranges %i ", ranges_ai);
    ad_range = comedi_get_range(it, subdev_ai, i, range_ai);
    if (range_update) {
        ad_range->min = min_range;
        ad_range->max = max_range;
    }
    printf(": ad_range .min = %.3f, max = %.3f\r\n", ad_range->min,
        ad_range->max);

    if (HAS_AO) {
        printf("Subdev AO  %i ", subdev_ao);
        channels_ao = comedi_get_n_channels(it, subdev_ao);
        printf("Analog  Channels %i ", channels_ao);
        maxdata_ao = comedi_get_maxdata(it, subdev_ao, i);
        printf("Maxdata %i ", maxdata_ao);
        ranges_ao = comedi_get_n_ranges(it, subdev_ao, i);
        printf("Ranges %i ", ranges_ao);
        da_range = comedi_get_range(it, subdev_ao, i, range_ao);
        printf(": da_range .min = %.3f, max = %.3f\r\n", da_range->min,
            da_range->max);
    }

    ADC_OPEN = true;
    comedi_set_global_oor_behavior(COMEDI_OOR_NUMBER);
    return 0;
}

int init_dac(double min_range, double max_range, int range_update)
{
    int i = 0;

    if (!DEV_OPEN) {
        it = comedi_open("/dev/comedi0");
        if (it == NULL) {
            comedi_perror("comedi_open");
            ADC_OPEN = false;
            DEV_OPEN = false;
            return -1;
        }
        DEV_OPEN = true;
    }

    subdev_ao = comedi_find_subdevice_by_type(it, COMEDI_SUBD_AO, subdev_ao);
    if (subdev_ao < 0) {
        HAS_AO = false;
    } else {
        HAS_AO = true;
    }

    if (HAS_AO) {
        printf("Subdev AO  %i ", subdev_ao);
        channels_ao = comedi_get_n_channels(it, subdev_ao);
        printf("Analog  Channels %i ", channels_ao);
        maxdata_ao = comedi_get_maxdata(it, subdev_ao, i);
        printf("Maxdata %i ", maxdata_ao);
        ranges_ao = comedi_get_n_ranges(it, subdev_ao, i);
        printf("Ranges %i ", ranges_ao);
        da_range = comedi_get_range(it, subdev_ao, i, range_ao);
        printf(": da_range .min = %.3f, max = %.3f\r\n", da_range->min,
            da_range->max);
    }

    comedi_set_global_oor_behavior(COMEDI_OOR_NUMBER);
    return 0;
}

int adc_range(double min_range, double max_range)
{
    if (ADC_OPEN) {
        ad_range->min = min_range;
        ad_range->max = max_range;
        return 0;
    } else {
        return -1;
    }
}

int dac_range(double min_range, double max_range)
{
    if (ADC_OPEN) {
        da_range->min = min_range;
        da_range->max = max_range;
        return 0;
    } else {
        return -1;
    }
}

int set_dac_volts(int chan, double voltage)
{
    lsampl_t data;
    int retval;

    data = comedi_from_phys(voltage, da_range, maxdata_ao);
    bmc.dac_sample[chan] = data;
    retval = comedi_data_write(it, subdev_ao, chan, range_ao, aref_ao, data);
    if (retval < 0) {
        comedi_perror("comedi_data_write in set_dac_volts");
        DAC_ERROR = true;
    }
    return retval;
}

int set_dac_raw(int chan, lsampl_t voltage)
{
    int retval;

    retval = comedi_data_write(it, subdev_ao, chan, range_ao, aref_ao, voltage);
    if (retval < 0) {
        comedi_perror("comedi_data_write in set_dac_raw");
        DAC_ERROR = true;
    }
    return retval;
}

double get_adc_volts(int chan)
{
    lsampl_t data[16];
    int retval;

    retval = comedi_data_read_n(it, subdev_ai, chan, range_ai, aref_ai, &data[0], 8);
    if (retval < 0) {
        comedi_perror("comedi_data_read in get_adc_volts");
        ADC_ERROR = true;
        return 0.0;
    }
    bmc.adc_sample[chan] = data[0];
    return comedi_to_phys(data[0], ad_range, maxdata_ai);
}

int set_dio_output(int chan)
{
    return comedi_dio_config(it,
        subdev_dio,
        chan,
        COMEDI_OUTPUT);
}

int set_dio_input(int chan)
{
    return comedi_dio_config(it,
        subdev_dio,
        chan,
        COMEDI_INPUT);
}

int get_dio_bit(int chan)
{
    lsampl_t data;
    int retval;

    retval = comedi_data_read(it, subdev_di, chan, range_di, aref_dio, &data);
    if (retval < 0) {
        comedi_perror("comedi_data_read in get_dio_bits");
        DIO_ERROR = true;
        return 0;
    }
    return data;
}

int put_dio_bit(int chan, int bit_data)
{
    lsampl_t data = bit_data;
    int retval;

    retval = comedi_data_write(it, subdev_do, chan, range_do, aref_dio, data);
    if (retval < 0) {
        comedi_perror("comedi_data_write in put_dio_bits");
        DIO_ERROR = true;
        return -1;
    }
    return 0;
}

int init_dio(void)
{
    int i = 0;

    if (!DEV_OPEN) {
        it = comedi_open("/dev/comedi0");
        if (it == NULL) {
            comedi_perror("comedi_open");
            DIO_OPEN = false;
            DEV_OPEN = false;
            return -1;
        }
        DEV_OPEN = true;
    }

    subdev_di = comedi_find_subdevice_by_type(it, COMEDI_SUBD_DI, subdev_di);
    if (subdev_di < 0) {
        return -1;
        DIO_OPEN = false;
    }
    subdev_do = comedi_find_subdevice_by_type(it, COMEDI_SUBD_DO, subdev_do);
    if (subdev_do < 0) {
        return -1;
        DIO_OPEN = false;
    }

    printf("Subdev DI  %i ", subdev_di);
    channels_di = comedi_get_n_channels(it, subdev_di);
    printf("Digital Channels %i ", channels_di);
    maxdata_di = comedi_get_maxdata(it, subdev_di, i);
    printf("Maxdata %i ", maxdata_di);
    ranges_di = comedi_get_n_ranges(it, subdev_di, i);
    printf("Ranges %i \r\n", ranges_di);

    printf("Subdev DO  %i ", subdev_do);
    channels_do = comedi_get_n_channels(it, subdev_do);
    printf("Digital Channels %i ", channels_do);
    maxdata_do = comedi_get_maxdata(it, subdev_do, i);
    printf("Maxdata %i ", maxdata_do);
    ranges_do = comedi_get_n_ranges(it, subdev_do, i);
    printf("Ranges %i \r\n", ranges_do);
    DIO_OPEN = true;
    return 0;
}

int get_data_sample(void)
{

    //    bmc.pv_voltage = get_adc_volts(PVV_C);
    //    bmc.cc_voltage = get_adc_volts(CCV_C);

    bmc.datain.D0 = get_dio_bit(0);
    put_dio_bit(0, bmc.dataout.d.D0);
    put_dio_bit(1, bmc.dataout.d.D1);
    put_dio_bit(2, bmc.dataout.d.D2);
    put_dio_bit(3, bmc.dataout.d.D3);
    put_dio_bit(4, bmc.dataout.d.D4);
    put_dio_bit(5, bmc.dataout.d.D5);
    put_dio_bit(6, bmc.dataout.d.D6);
    put_dio_bit(7, bmc.dataout.d.D7);
    return 0;
}

double lp_filter(double new, int bn, int slow) // low pass filter, slow rate of change for new, LPCHANC channels, slow/fast select (-1) to zero channel
{
    static double smooth[LPCHANC] = {0};
    double lp_speed, lp_x;

    if ((bn >= LPCHANC) || (bn < 0)) // check for proper array position
        return new;
    if (slow) {
        lp_speed = 0.033;
    } else {
        lp_speed = 0.125;
    }
    lp_x = ((smooth[bn]*100.0) + (((new * 100.0)-(smooth[bn]*100.0)) * lp_speed)) / 100.0;
    smooth[bn] = lp_x;
    if (slow == (-1)) { // reset and return zero
        lp_x = 0.0;
        smooth[bn] = 0.0;
    }
    return lp_x;
}
 

Thread Starter

denison

Joined Oct 13, 2018
328
Results of two Velleman boards using a Linux DAQ driver and a small C program to set the DAC to 255.
View attachment 238954View attachment 238955View attachment 238956View attachment 238957

The DAC voltage is limited on the old K8055 board. The PVM110N-1 is better.

C:
int main(int argc, char *argv[])
{
    int do_ao_only = false;
    uint8_t i = 0, j = 75;

    if (do_ao_only) {
        if (init_dac(0.0, 25.0, false) < 0) {
            printf("Missing Analog AO subdevice\n");
            return -1;
        }


        while (true) {
            set_dac_raw(0, sine_wave[255 - i++] << 4);
            set_dac_raw(1, sine_wave[255 - j++] << 4);
        }
    } else {

        if (init_daq(0.0, 25.0, false) < 0) {
            printf("Missing Analog subdevice(s)\n");
            return -1;
        }
        if (init_dio() < 0) {
            printf("Missing Digital subdevice(s)\n");
            return -1;
        }
      
        set_dac_raw(0,255); // show max Voltage

        while (1) {
            get_data_sample();
            led_lightshow(0);
        }
    }
    return 0;
}

Some userland daq setup code functions to control the boards.

/*
* File:   daq.h
* Author: root
*
* Created on September 21, 2012, 6:49 PM
*/

#ifndef DAQ_H
#define DAQ_H

#ifdef __cplusplus
extern "C" {
#endif

#define PVV_C   0
#define CCV_C   1
#define SYV_C   2
#define B1V_C   3
#define B2V_C   4
#define INV_C   5
#define VD5_C   7
#define PVC_C   8
#define CCC_C   9
#define BAC_C   10  

#define LPCHANC        16

#include <stdint.h>
#include <comedilib.h>

    struct didata {
        uint32_t D0 : 1; //
        uint32_t D1 : 1; //
        uint32_t D2 : 1; //
        uint32_t D3 : 1; //
        uint32_t D4 : 1; //
        uint32_t D5 : 1; //
        uint32_t D6 : 1; //
        uint32_t D7 : 1; //
    };

    union dio_buf_type {
        uint32_t dio_buf;
        struct didata d;
    };

    typedef struct bmcdata {
        double pv_voltage, cc_voltage, input_voltage, b1_voltage, b2_voltage, system_voltage, logic_voltage;
        double pv_current, cc_current, battery_current;
        struct didata datain;
        union dio_buf_type dataout;
        int32_t adc_sample[32];
        int32_t dac_sample[32];
        int32_t utc;
    }
    bmctype;

    extern volatile struct bmcdata bmc;
    extern struct didata datain;
    extern struct dodata dataout;

    int init_daq(double, double, int);
    int init_dac(double, double, int);
    int init_dio(void);
    int adc_range(double, double);
    int dac_range(double, double);
    double get_adc_volts(int);
    int set_dac_volts(int, double);
    int set_dac_raw(int, lsampl_t);
    int get_dio_bit(int);
    int put_dio_bit(int, int);
    int set_dio_input(int);
    int set_dio_output(int);
    int get_data_sample(void);
    double lp_filter(double, int, int);
#ifdef __cplusplus
}
#endif

#endif /* DAQ_H */

#include <stdio.h> /* for printf() */
#include <unistd.h>
#include <stdbool.h>
#include <stdint.h>
#include <comedilib.h>
#include "daq.h"

int subdev_ai = 0; /* change this to your input subdevice */
int chan_ai = 0; /* change this to your channel */
int range_ai = 0; /* more on this later */
int aref_ai = AREF_GROUND; /* more on this later */
int maxdata_ai, ranges_ai, channels_ai;

int subdev_ao = 0; /* change this to your input subdevice */
int chan_ao = 0; /* change this to your channel */
int range_ao = 0; /* more on this later */
int aref_ao = AREF_GROUND; /* more on this later */
int maxdata_ao, ranges_ao, channels_ao;

int subdev_di = 0; /* change this to your input subdevice */
int chan_di = 0; /* change this to your channel */
int range_di = 0; /* more on this later */
int maxdata_di, ranges_di, channels_di, datain_di;

int subdev_do = 0; /* change this to your input subdevice */
int chan_do = 0; /* change this to your channel */
int range_do = 0; /* more on this later */
int maxdata_do, ranges_do, channels_do, datain_do;

int subdev_dio; /* change this to your input subdevice */
int aref_dio; /* more on this later */

comedi_t *it;
comedi_range *ad_range, *da_range;
bool ADC_OPEN = false, DIO_OPEN = false, ADC_ERROR = false, DEV_OPEN = false,
    DIO_ERROR = false, HAS_AO = false, DAC_ERROR = false;

int init_daq(double min_range, double max_range, int range_update)
{
    int i = 0;

    if (!DEV_OPEN) {
        it = comedi_open("/dev/comedi0");
        if (it == NULL) {
            comedi_perror("comedi_open");
            ADC_OPEN = false;
            DEV_OPEN = false;
            return -1;
        }
        DEV_OPEN = true;
    }

    subdev_ai = comedi_find_subdevice_by_type(it, COMEDI_SUBD_AI, subdev_ai);
    if (subdev_ai < 0) {
        return -2;
        ADC_OPEN = false;
    }


    subdev_ao = comedi_find_subdevice_by_type(it, COMEDI_SUBD_AO, subdev_ao);
    if (subdev_ao < 0) {
        HAS_AO = false;
    } else {
        HAS_AO = true;
    }

    printf("Subdev AI  %i ", subdev_ai);
    channels_ai = comedi_get_n_channels(it, subdev_ai);
    printf("Analog  Channels %i ", channels_ai);
    maxdata_ai = comedi_get_maxdata(it, subdev_ai, i);
    printf("Maxdata %i ", maxdata_ai);
    ranges_ai = comedi_get_n_ranges(it, subdev_ai, i);
    printf("Ranges %i ", ranges_ai);
    ad_range = comedi_get_range(it, subdev_ai, i, range_ai);
    if (range_update) {
        ad_range->min = min_range;
        ad_range->max = max_range;
    }
    printf(": ad_range .min = %.3f, max = %.3f\r\n", ad_range->min,
        ad_range->max);

    if (HAS_AO) {
        printf("Subdev AO  %i ", subdev_ao);
        channels_ao = comedi_get_n_channels(it, subdev_ao);
        printf("Analog  Channels %i ", channels_ao);
        maxdata_ao = comedi_get_maxdata(it, subdev_ao, i);
        printf("Maxdata %i ", maxdata_ao);
        ranges_ao = comedi_get_n_ranges(it, subdev_ao, i);
        printf("Ranges %i ", ranges_ao);
        da_range = comedi_get_range(it, subdev_ao, i, range_ao);
        printf(": da_range .min = %.3f, max = %.3f\r\n", da_range->min,
            da_range->max);
    }

    ADC_OPEN = true;
    comedi_set_global_oor_behavior(COMEDI_OOR_NUMBER);
    return 0;
}

int init_dac(double min_range, double max_range, int range_update)
{
    int i = 0;

    if (!DEV_OPEN) {
        it = comedi_open("/dev/comedi0");
        if (it == NULL) {
            comedi_perror("comedi_open");
            ADC_OPEN = false;
            DEV_OPEN = false;
            return -1;
        }
        DEV_OPEN = true;
    }

    subdev_ao = comedi_find_subdevice_by_type(it, COMEDI_SUBD_AO, subdev_ao);
    if (subdev_ao < 0) {
        HAS_AO = false;
    } else {
        HAS_AO = true;
    }

    if (HAS_AO) {
        printf("Subdev AO  %i ", subdev_ao);
        channels_ao = comedi_get_n_channels(it, subdev_ao);
        printf("Analog  Channels %i ", channels_ao);
        maxdata_ao = comedi_get_maxdata(it, subdev_ao, i);
        printf("Maxdata %i ", maxdata_ao);
        ranges_ao = comedi_get_n_ranges(it, subdev_ao, i);
        printf("Ranges %i ", ranges_ao);
        da_range = comedi_get_range(it, subdev_ao, i, range_ao);
        printf(": da_range .min = %.3f, max = %.3f\r\n", da_range->min,
            da_range->max);
    }

    comedi_set_global_oor_behavior(COMEDI_OOR_NUMBER);
    return 0;
}

int adc_range(double min_range, double max_range)
{
    if (ADC_OPEN) {
        ad_range->min = min_range;
        ad_range->max = max_range;
        return 0;
    } else {
        return -1;
    }
}

int dac_range(double min_range, double max_range)
{
    if (ADC_OPEN) {
        da_range->min = min_range;
        da_range->max = max_range;
        return 0;
    } else {
        return -1;
    }
}

int set_dac_volts(int chan, double voltage)
{
    lsampl_t data;
    int retval;

    data = comedi_from_phys(voltage, da_range, maxdata_ao);
    bmc.dac_sample[chan] = data;
    retval = comedi_data_write(it, subdev_ao, chan, range_ao, aref_ao, data);
    if (retval < 0) {
        comedi_perror("comedi_data_write in set_dac_volts");
        DAC_ERROR = true;
    }
    return retval;
}

int set_dac_raw(int chan, lsampl_t voltage)
{
    int retval;

    retval = comedi_data_write(it, subdev_ao, chan, range_ao, aref_ao, voltage);
    if (retval < 0) {
        comedi_perror("comedi_data_write in set_dac_raw");
        DAC_ERROR = true;
    }
    return retval;
}

double get_adc_volts(int chan)
{
    lsampl_t data[16];
    int retval;

    retval = comedi_data_read_n(it, subdev_ai, chan, range_ai, aref_ai, &data[0], 8);
    if (retval < 0) {
        comedi_perror("comedi_data_read in get_adc_volts");
        ADC_ERROR = true;
        return 0.0;
    }
    bmc.adc_sample[chan] = data[0];
    return comedi_to_phys(data[0], ad_range, maxdata_ai);
}

int set_dio_output(int chan)
{
    return comedi_dio_config(it,
        subdev_dio,
        chan,
        COMEDI_OUTPUT);
}

int set_dio_input(int chan)
{
    return comedi_dio_config(it,
        subdev_dio,
        chan,
        COMEDI_INPUT);
}

int get_dio_bit(int chan)
{
    lsampl_t data;
    int retval;

    retval = comedi_data_read(it, subdev_di, chan, range_di, aref_dio, &data);
    if (retval < 0) {
        comedi_perror("comedi_data_read in get_dio_bits");
        DIO_ERROR = true;
        return 0;
    }
    return data;
}

int put_dio_bit(int chan, int bit_data)
{
    lsampl_t data = bit_data;
    int retval;

    retval = comedi_data_write(it, subdev_do, chan, range_do, aref_dio, data);
    if (retval < 0) {
        comedi_perror("comedi_data_write in put_dio_bits");
        DIO_ERROR = true;
        return -1;
    }
    return 0;
}

int init_dio(void)
{
    int i = 0;

    if (!DEV_OPEN) {
        it = comedi_open("/dev/comedi0");
        if (it == NULL) {
            comedi_perror("comedi_open");
            DIO_OPEN = false;
            DEV_OPEN = false;
            return -1;
        }
        DEV_OPEN = true;
    }

    subdev_di = comedi_find_subdevice_by_type(it, COMEDI_SUBD_DI, subdev_di);
    if (subdev_di < 0) {
        return -1;
        DIO_OPEN = false;
    }
    subdev_do = comedi_find_subdevice_by_type(it, COMEDI_SUBD_DO, subdev_do);
    if (subdev_do < 0) {
        return -1;
        DIO_OPEN = false;
    }

    printf("Subdev DI  %i ", subdev_di);
    channels_di = comedi_get_n_channels(it, subdev_di);
    printf("Digital Channels %i ", channels_di);
    maxdata_di = comedi_get_maxdata(it, subdev_di, i);
    printf("Maxdata %i ", maxdata_di);
    ranges_di = comedi_get_n_ranges(it, subdev_di, i);
    printf("Ranges %i \r\n", ranges_di);

    printf("Subdev DO  %i ", subdev_do);
    channels_do = comedi_get_n_channels(it, subdev_do);
    printf("Digital Channels %i ", channels_do);
    maxdata_do = comedi_get_maxdata(it, subdev_do, i);
    printf("Maxdata %i ", maxdata_do);
    ranges_do = comedi_get_n_ranges(it, subdev_do, i);
    printf("Ranges %i \r\n", ranges_do);
    DIO_OPEN = true;
    return 0;
}

int get_data_sample(void)
{

    //    bmc.pv_voltage = get_adc_volts(PVV_C);
    //    bmc.cc_voltage = get_adc_volts(CCV_C);

    bmc.datain.D0 = get_dio_bit(0);
    put_dio_bit(0, bmc.dataout.d.D0);
    put_dio_bit(1, bmc.dataout.d.D1);
    put_dio_bit(2, bmc.dataout.d.D2);
    put_dio_bit(3, bmc.dataout.d.D3);
    put_dio_bit(4, bmc.dataout.d.D4);
    put_dio_bit(5, bmc.dataout.d.D5);
    put_dio_bit(6, bmc.dataout.d.D6);
    put_dio_bit(7, bmc.dataout.d.D7);
    return 0;
}

double lp_filter(double new, int bn, int slow) // low pass filter, slow rate of change for new, LPCHANC channels, slow/fast select (-1) to zero channel
{
    static double smooth[LPCHANC] = {0};
    double lp_speed, lp_x;

    if ((bn >= LPCHANC) || (bn < 0)) // check for proper array position
        return new;
    if (slow) {
        lp_speed = 0.033;
    } else {
        lp_speed = 0.125;
    }
    lp_x = ((smooth[bn]*100.0) + (((new * 100.0)-(smooth[bn]*100.0)) * lp_speed)) / 100.0;
    smooth[bn] = lp_x;
    if (slow == (-1)) { // reset and return zero
        lp_x = 0.0;
        smooth[bn] = 0.0;
    }
    return lp_x;
}
The connection scheme for k8055 shows an external input voltage of 5 to 30v. When I connect 9v the led power light doesn't even come on. It only comes on with the usb lead. You sound pretty clued up Mr Spook. There may be something on the board you have to do to connect in the external voltage? This was automatic on the Arduino UNO and NANO boards.
 

ericgibbs

Joined Jan 29, 2010
18,766
I have had nothing but problems with the k8055 board. Do you know of a good board for getting data in and out of a usb computer port.
hi den,
I use a Arduino Nano as a Serial to USB converter, it has the added advantage of being a 'smart' converter, in that the pins on the Nano can used to get and send data to external devices.

All you need to do, is to load a 'blank' sketch into the Nano for it to become a basic converter.

I still use Visual Basic 6 as program writer with Win 10 and the PC USB/Serial.

E
 

nsaspook

Joined Aug 27, 2009
13,079
The connection scheme for k8055 shows an external input voltage of 5 to 30v. When I connect 9v the led power light doesn't even come on. It only comes on with the usb lead. You sound pretty clued up Mr Spook. There may be something on the board you have to do to connect in the external voltage? This was automatic on the Arduino UNO and NANO boards.
Exactly what pins are you connecting this external input voltage? If it's SK2 or SK3 those are for the ADC input pots, not board power.
 

ericgibbs

Joined Jan 29, 2010
18,766
The schematic shows the power supply (clamp) leading to the ULN2803 chip. That is not a voltage regulator.
hi den,
If you mean the right side ULN.
That clamp connects to the Vext supply of the load you are driving with the ULN outputs, used if the load is inductive.

eg: if you are driving say 12Vdc relay coils, the relays would be powered by an external 12Vdc supply and the clamp pin would be connected to that 12Vdc supply.
E

ESP_ 299.png
 

Thread Starter

denison

Joined Oct 13, 2018
328
Exactly what pins are you connecting this external input voltage? If it's SK2 or SK3 those are for the ADC input pots, not board power.
The clamp and ground pin. Refer to Eric Gibbs post. I had thought that this connection was an alternate power supply to the usb port supply. Its not. It supplies power to a relay which can be turned on/off by a data out pin. With the usb port powering the circuit you are stuck with a maximum dac of 4.68v for code 255 and also the max current that can be supplied from the usb port.
 

Thread Starter

denison

Joined Oct 13, 2018
328
hi den,
I use a Arduino Nano as a Serial to USB converter, it has the added advantage of being a 'smart' converter, in that the pins on the Nano can used to get and send data to external devices.

All you need to do, is to load a 'blank' sketch into the Nano for it to become a basic converter.

I still use Visual Basic 6 as program writer with Win 10 and the PC USB/Serial.

E
That looks interesting Eric. I am using software called ChIDE with Win 10 as my program writer for the k8055 board. Not sure how I could use this software to connect to the pins on my Nano board. I would be using C or C++. Any ideas how I could reference the pins? You have used Visual Basic 6. I wanted simpler programming which I get with Ch.
Wouldn't you get an error message loading a blank sketch?
Would it help me if you give an example of your programming to connect to a Nano pin? I could then try it in C with ChIDE.
Thanks Eric.
 

Thread Starter

denison

Joined Oct 13, 2018
328
I get 5 volts on the updated version of the board but they are both obsolete. The updated version VM110Nwith a PIC18 is much faster. Linux has pretty good driver support for the Comedi DAQ system. I've written several drivers for it.
Supported Linux kernel drivers.
https://www.comedi.org/hardware.html#hw-kernel-org

https://www.comedi.org/

Is the VM110N the latest update of the Velleman? I know my K8055 is obsolete. You need an external power source so that you can get away from using the usb as a power source. My operating system is Win10 not Linux.
Does VM110N provide an external power source?
 

nsaspook

Joined Aug 27, 2009
13,079
Is the VM110N the latest update of the Velleman? I know my K8055 is obsolete. You need an external power source so that you can get away from using the usb as a power source. My operating system is Win10 not Linux.
Does VM110N provide an external power source?
The VM110 was the last update as it's also obsolete.

Why would you need external 5vdc power for the basic DAQ control functions of the board? You will always need a USB connection to operate the board. You could easily MOD a usb cable for external power while keeping the data connections.
 

ericgibbs

Joined Jan 29, 2010
18,766
hi den,
If you want to connect to an external RS232 type TX/RX serial data source into your PC USB port, write the Serial Event Sketch to the Nano. Set the Baud rate of the Sketch to the required value for the project.

E
 
Top