Jump to content
  • 0

Please help: MCC USB-1808X Analog Input Readings Odd Behaviour


Henry Walker

Question

I require my MCC USB-1808X to sample hydrophone readings of a 25kHz pinger at a sampling frequency of 200kHz. The pinger sends out a pulse every 2 seconds or so.

I have a dedicated PCB connected to four TC4013 hydrophones from Teledyne Marine to amplify their outputs. The schematic of each channel is attached below, with vGND1 and vGND2 held at ~+2.5V.image.png.58d47e225fd648473682ae1488be1a92.png

The PCB itself works, as I have verified using an oscilloscope directly at the analog input of the DAQ device (shown below), although the magnitude is slightly smaller than desired and there's quite a fair bit of reflected waves picked up too (also shown below).

image.thumb.png.1fe2bcbeee32b3c6597c89f5cf9733d0.pngimage.thumb.png.76eeec6a1e1606b960426659cdf79fa6.png

However, oddly enough, when I record the DAQ readings, all I acquire is noise centred around the DC offset. This is not true, however, when I use a signal generator (also offset to +2.5V), which results in very nice readings. The readings from the channels that are connected to the PCB are in the first three columns, and the green column is the recorded readings of the DAQ channel reading directly from the signal generator. I recorded the data for ~10s (so that I don't just miss out on the pinger's pings) and the readings are generally similar to this.

image.png.5a01e064cd5a42cd004b7805548b89c1.png

I have attached below my C code for recording this, which is a modified version of the AInScan.c example from the MCC ULDAQ GitHub repository https://github.com/mccdaq/uldaq (via running ./AInScan > AInScan.csv):

#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <time.h>

#include "uldaq.h"
#include "utility.h"

#define MAX_DEV_COUNT           100
#define MAX_STR_LENGTH          64
#define MAX_SCAN_OPTIONS_LENGTH 256

int main(void)
{
	int descriptorIndex = 0;
	DaqDeviceDescriptor devDescriptors[MAX_DEV_COUNT];
	DaqDeviceInterface interfaceType = ANY_IFC;
	DaqDeviceHandle daqDeviceHandle = 0;
	unsigned int numDevs = MAX_DEV_COUNT;

	// set some variables that are used to acquire data
	int lowChan = 0;
	int highChan = 3;
	AiInputMode inputMode = AI_SINGLE_ENDED;
	Range range = UNI5VOLTS;
	int samplesPerChannel = 200000;
	double rate = 200000;
	ScanOption scanOptions = (ScanOption) (SO_CONTINUOUS);
	AInScanFlag flags = AINSCAN_FF_DEFAULT;

	int index = 0;

	int chanCount = highChan - lowChan + 1;
	double* buffer = NULL;
	UlError err = ERR_NO_ERROR;

	double prevLastFour[4] = { 0, 0, 0, 0 };

	int i = 0;

	goto boot;

boot:
	err = ulGetDaqDeviceInventory(interfaceType, devDescriptors, &numDevs);

	// verify at least one DAQ device is detected
	if (numDevs == 0) {
		printf("No DAQ device is detected\n");
		goto error;
	}

	// get a handle to the DAQ device associated with the first descriptor
	daqDeviceHandle = ulCreateDaqDevice(devDescriptors[descriptorIndex]);

	if (daqDeviceHandle == 0) {
		printf("\nUnable to create a handle to the specified DAQ device\n");
		goto error;
	}

	// printf("\nConnecting to %s...\n", devDescriptors[descriptorIndex].devString);

	// establish a connection to the DAQ device
	err = ulConnectDaqDevice(daqDeviceHandle);

	if (err != ERR_NO_ERROR)
		goto error;

	goto acquisition;

acquisition:
	// allocate a buffer to receive the data
	buffer = (double*) malloc(chanCount * samplesPerChannel * sizeof(double));
	double* lastFour = buffer + chanCount * samplesPerChannel - 4;

	for (i = 0; i < 4; i++) {
		prevLastFour[i] = lastFour[i];
	}

	// start the acquisition
	err = ulAInScan(
		daqDeviceHandle, lowChan, highChan, inputMode, range, samplesPerChannel, &rate, scanOptions, flags, buffer
	);

	// printf("Scan started\n");

	if (err == ERR_NO_ERROR) {
		ScanStatus status;
		TransferStatus transferStatus;

		// get the initial status of the acquisition
		ulAInScanStatus(daqDeviceHandle, &status, &transferStatus);

		int loopCount = 0;
		while (status == SS_RUNNING && !enter_press())
		// while(status == SS_RUNNING && !enter_press() && loopCount < maxLoop) // for debugging purposes
		{
			// get the current status of the acquisition
			err = ulAInScanStatus(daqDeviceHandle, &status, &transferStatus);

			if (err == ERR_OVERRUN) // restarts the acquisition if an overrun error occurs
			{
				printf("FIFO overrun\n");
				err = ulAInScanStop(daqDeviceHandle);

				goto acquisition;
			}
			else if (err != ERR_NO_ERROR) {
				goto error;
			}

			if ((prevLastFour[0] != lastFour[0]) || (prevLastFour[1] != lastFour[1]) ||
			    (prevLastFour[2] != lastFour[2]) || (prevLastFour[3] != lastFour[3]))
			{
				// TODO: send data to MUSIC

				for (i = 0; i < 4; i++) {
					prevLastFour[i] = lastFour[i];
				}

			for (int j = 0; j < samplesPerChannel; j++) {
				for (i = 0; i < chanCount; i++) {
					printf("%f", buffer[i + chanCount * j]);
					if (i != 3) {
						printf(", ");
					}
					else {
						printf("\n");
					}
				}
			}

			// usleep(100);

			loopCount = loopCount + 1;
			// printf("Looped %d times \n", loopCount);

			if (loopCount == 10) {
				return 0;
			}
		}
		}
	}

error:
	// release the scan buffer
	if (buffer)
		free(buffer);

	// disconnect the DAQ device
	ulDisconnectDaqDevice(daqDeviceHandle);

	if (err != ERR_NO_ERROR) {
		char errMsg[ERR_MSG_LEN];
		ulGetErrMsg(err, errMsg);
		printf("Error Code: %d \n", err);
		printf("Error Message: %s \n", errMsg);
	}

	printf("Restarting... \n");
	goto boot;
}

I would greatly appreciate any assistance or insight into this as I am at my wit's end trying to solve this issue.

Edited by Henry Walker
Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

Hello @Henry Walker.

Keep the source impedances to the USB-1808X as low as possible (<100 Ohm). If your signal has a high impedance, consider using a buffer circuit between the signal and the USB-1808X.  Signal generators typically have a low output impedance and the data in your post shows the comparison of using a low impedance vs. high impedance source.

Also, verify the ground connections between your PCB and the USB-1808X; avoid creating ground loops that will create noise.

Regards,

Fausto

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...