Code Monkey home page Code Monkey logo

daqhats's People

Contributors

jon-perreault avatar jsigren avatar nwright-mcc avatar nwright98 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

daqhats's Issues

MCC152 interrupt callback registration failed due to missing permission for GPIO modification/access

When trying to setup the interrupt handling for the MCC152 DIO-board (as described in one of the examples) the library failed to register the interrupt callback method.

The biggest problem for me was that I did not get any useful error messages as to why the registration failed. Luckily though, after a bit of investigation, I found the culprit and ultimately the solution:

Problem was, that the library did not have access to modify the GPIOs in '/sys/class/gpio'. By giving necessary permission with these two commands:

sudo chown root:gpio /sys/class/gpio/unexport /sys/class/gpio/export
sudo chmod -R 770 /sys/class/gpio

the interrupt handling worked perfectly fine.

Is there an FAQ section in the documentation that I can extend? Or is there an additional step in the installation/setup process of the library that's missing in the documentation or that I simply missed, which would've prevented this from happening?

Or maybe the permission could be granted at the end of the install.sh script. That way it's guaranteed to work for those who would have had the same problem.

Here's some additional information about my setup:
Board: MCC152
Language: Python
Raspberry Pi Model: 3 (B)
Raspberry Pi OS: Raspbian (a pretty much fresh install)
Daqhats library version: 1.4.0.3

Write time and date

Hi, I want to write the time (and date) into the first column. My problem is that the time is being written into the last column.
`#include "log_file.h"
#include <stdio.h>
#include <time.h>

FILE* log_file_ptr = NULL;

// Get the error message for the specified error code.
void get_path_and_filename(char* full_path, char* path, char* filename)
{
char* p;

int path_len = 0;

// Get the pointer to the last occurance of '/'.  This is the
// pointer to the end of the path part of the full path.
p = strrchr(full_path, '/');

// get the length of the path
path_len = p - full_path + 1;

// copy the path part of the full path
strncpy(path, full_path, path_len);

// copy the file name part of the full path
strcpy(filename, full_path+path_len);

return;

}

// Show the OpenFile dialog to allow the name of the log file to be chosen.
char* choose_log_file(GtkWidget parent_window, char default_path)
{
struct stat st;
char path[512] = {'\0'};
char filename[256] = {'\0'};
char* new_filename;
GtkWidget *dialog;
gint res;

// Get the path and filename.
get_path_and_filename(default_path, path, filename);

// Create the path if it does not already exist.
if (stat(path, &st) == -1)
{
    mkdir(path, 0700);
}

// Create the OpenFile dialog.
dialog = gtk_file_chooser_dialog_new ("Open File",
                                      (GtkWindow*)parent_window,
                                      GTK_FILE_CHOOSER_ACTION_SAVE,
                                      ("_Cancel"),
                                      GTK_RESPONSE_CANCEL,
                                      ("_Open"),
                                      GTK_RESPONSE_ACCEPT,
                                      NULL);

// Set the initial directory
gtk_file_chooser_set_current_folder ((GtkFileChooser*)dialog, path);

// Set the initial file name.
gtk_file_chooser_set_current_name((GtkFileChooser*)dialog, filename);

// Show the dialog.
res = gtk_dialog_run (GTK_DIALOG (dialog));
if (res == GTK_RESPONSE_ACCEPT)
{
    // get the selected file name path
    GtkFileChooser *chooser = GTK_FILE_CHOOSER (dialog);
    new_filename = gtk_file_chooser_get_filename (chooser);
}
else
{
    // Use the initial path if the selection has been canceled
    new_filename = default_path;
}

// Destroy the dialog.
gtk_widget_destroy (dialog);

// Return the path to the selected file.
return new_filename;

}

// Open the specified file for writing.
FILE* open_log_file (char* path)
{
struct stat st;
char directory[512] = {'\0'};
char filename[256] = {'\0'};;

// Get the path and file name.
get_path_and_filename(path, directory, filename);

// Create the path if it does not already exist.
if (stat(directory, &st) == -1)
{
    mkdir(directory, 0700);
}

// Open the log file for writing.
log_file_ptr = fopen(path, "w");

// Return the file pointer.
return log_file_ptr;

}

int init_log_file(FILE* log_file_ptr, uint8_t current_channel_mask)
{
int i = 0;
int chanMask = 0;
int channel = 0;
int write_status = 1;
int num_channels = 0;

chanMask = current_channel_mask;
channel = 0;

if (write_status <= 0)
{
	// exit if an error occurred.
	return write_status;
}

for (i = 0; i < MAX_118_CHANNELS; i++)
{
    // If this channel is in the scan,
    // print the channel number
    if (chanMask & 1)
    {
        //print channel
        write_status = fprintf(log_file_ptr, "\tChan %d ", i);
        if (write_status <= 0)
        {
            // Break if an error occurred.
            break;
        }
        num_channels++;
    }

    // Check next channel.
    channel++;
    chanMask >>= 1;
}
write_status = fprintf(log_file_ptr, "\n");
return write_status;

}

// Convert the numeric data to ASCII values, seperated by commas (CSV), and
// write the data using the specified file pointer.
int write_log_file(FILE* log_file_ptr, double* read_buf, int samplesPerChannel,
int numberOfChannels)
{

int i = 0;
int j = 0;
int write_status = 1;

char str[1000];
char buf[256];
int scan_start_index = 0;

strcpy(str, "");
// Write the data to the file.
for (i = 0; i < samplesPerChannel; i++)
{
    // Initialize the string to be written to the file.
    strcpy(str, "");

    // Write a sample for each channel in the scan.
    for (j = 0; j < numberOfChannels; j++)
    {
        // Convert the data sample to ASCII
        sprintf(buf,"%2.6lf\t", read_buf[scan_start_index+j]);


        // Add the data sample to the string to be written.
        strcat(str, buf);
    }

    // Write the ASCII scan data to the file.
    **time_t rawtime;
    struct tm * timeinfo;
    time ( &rawtime );
    timeinfo = localtime ( &rawtime );
    fprintf (log_file_ptr, "%s\t", asctime (timeinfo));**
    write_status = fprintf(log_file_ptr, "%s", str);
    if (write_status <= 0)
    {
        // Break if an error occurred.
        break;
    }

    // Get the index to the start of the next scan.
    scan_start_index += numberOfChannels;
}

// Flush the file to insure all data is written.
fflush(log_file_ptr);

// Return the error code.
return write_status;

}
`
So this is the code. I added some lines for the time printing. But how do I get it correctly done?
date

Can't select address of the stacked devices

Hi, I have stacked multiple DAQ HAT on a Raspberry Pi and everything is working fine except the query of available DAQ HAT devices. I am using "select_hat_device" function to determine the address of DAQ HATs. The function works perfectly when I have a single board i.e., MCC 118 on the Pi but if I use multiple boards then I get the following error:

Addr 0: Error: No HAT devices found

The devices are stacked in the following manner:
Address 0: MCC 118
Address 1: MCC 134
Address 2:: MCC 172

The jumpers are set and the data of the devices can be read if the addresses are passed explicitly e. g. address = 0 for MCC 118 and address = 1 for MCC 134.

Please do let me know if you need any other information.

Have a nice day

MCC172 ID SD and ID SC not available to access EEPROM

We have a Raspberry PI CM4 I/O board that doesn't have ID SD (pin27) and ID SC (pin28) available on the 40 pin GPIO header. Is it possible there's another way we can access the MCC172 EEPROM information, perhaps directly through a file on the PI? Any workarounds you could recommend?

Is the MCU programable via Atmel ICE

Hello,

I bought an MCC172 and it is working fine with the RPi, however I would like to program some firmware into the ATSAMG55J19 without the Rasperry Pi.

Ive been trying to flash some firmware using an ATMEL-ICE, but the device is not recognized by the debugger.

Is it possible to program the MCC172 via the pads on the back of the board? Or are the SWD pins disabled ?

Running program in Docker container can't get HAT devices.

When I package the Python program and its dependencies into a Docker container and run the Docker container. Although it shows that "Successfully installed daqhats-1.4.0.6" and the package can be imported in Python3.9 successfully, the HAT devices can't be obtained.

I have tried to open the serial port permission to the Docker container, using the flag --device /dev/ttyAMA0 and --privileged…… It's still not work and returns Addr 0: Error: No HAT devices found.

So is support for Docker added? Is there anything wrong with my operation? What should I do to realize the rapid deployment and transplantation of Python program based on `daqhats'?

Thank you very much!

hat_error_message is missing a case for undefined

There is an error in the source code for the lib.

hat_error_message(RESULT_UNDEFINED), will return the error message for RESULT_COMMS_FAILURE
There is a mismatch between the strings in the HAT_ERROR_MESSAGE array.

The Fix is to add another Case in hat_error_message(int result), and to increment the index in the default case.

IMO it would be better to put the undefined error message, as its own string. (and not in the array) that way, in the future, a missed index would at least return the undefined message which is slightly less wrong than what it does now. :)

libi2c-dev library conflict during installation.

I found that if you want to install the daqhats library you have to uninstall libi2c-dev, install MCC daqhats library, then reinstall libi2c-dev. If you try to install the MCC daqhats library with libi2c-dev installed there will be errors that prevent communication with the daqhat.

My other i2c hardware works fine after this process so far. I also ran the other i2c hardware in addition to running the daqhat at the same time.

Since others may run into this issue in the future I wanted to raise the issue so others can find the solution.

Insallation issue

I get as far as sudo ./install.sh

which gives,

sudo: ./install.sh: command not found

so I used sudo chmod a+x install.sh to make sure sudo was seeing the script as executable & then ran sudo ./install.sh

but this now give,

sudo: unable to execute ./install.sh: No such file or directory

then I tried sudo install.sh

which gives me,

`sudo: install.sh: command not found'

any ideas?

two channel synchronous sampling

I checked the document but did not find any doc related to the synchronous sampling in Python. Is it possible to do two channel synchronous sampling with just one MC118 board? What's the max possible sample rate for this situation? Thanks!!

Unequal sample numbers using multiple hats

Hi,

I'm using 2 x MCC172s so 4 channels.

I've amended your code to give 60,000 samples per channel at 60KHz & get told the actual sample rate is 51.2KHz (that's fine by the way)

Once the data is acquired I read it out via MQTT to a PC to inspect the data. Without fail the number of samples per channel is different and only the 2nd channel on the 2nd hat provides the full complement of 60,000 samples. Even though the sample counts from your code say that each channel does in fact have 60,000 samples stored.

For instance,

Total count:  154469
 
Hat 0:
Ch.0 count:  18752
Ch.1 count:  30220
 
Hat 1:
Ch.0 count:  45493
Ch.1 count:  60000

Any idea what's going on here?

Issues when downloading with Docker

While trying to use daqhats inside of a Docker container I receive the error 'Error: module 'daqhats has no attribute 'mcc118''. This occurs on a Raspberry Pi 3B+.

Timeout accessing a resource

Hi, i have purchased 4 MCC118 Hats and trying to read the inputs ( for the moment of 2 HATs ), using the examples in C. When I try program multi_hat_synchronous_scan. On the second hat i always get a result code -3 ( There was a timeout accessing a resource ) during the call of mcc118_a_in_scan_start.
Funny enough this does not happen all the time, but in abt 90% of all attempts.
Also the python version, aborts ( with message: IndexError: list index out of range ). When I read data from just one single HAT there are no issue ( does not matter which of the 4 installed HAT;s i choose).
What could be the issue ?

Best regards, Rene Reuscher

MCC 172 Recording

Can i recording music by MCC172 on Raspberry Pi?

I dont know what to do next. could you give me some advice?

Thank you

sample rate issue

Hi,
How can I ensure that if I set a 1000Hz sampling rate then mcc118 is emitting 1000Hz only to raspberry pi

Data-logger write multiple channles in diffferent columns

Hey,
I want to scan for example 3 or 4 channels with the C-Program "logger.c". But if I activate more than one channel, the values get written in one column. So there is:
Column 1:
Channel 1 Channel 2 Channel 3
1,75754 1,4548 1,54151
1,4844 1,5895 1,54651
... ... ...

But I wan to get:
Column1 Column2
Channel 1 Channel 2
1,54161 1,78974
1,55135 1,5654
... ....

So which files do I have to modify. I found some interesting spots in "log_file.c", but ehich parts do I have to modify?

MCC172 examples C data_logger

I can execute the example C "logger".
I output "10Hz" "sine wave" through a signal generator.
I can't see the X-axis units.
But I can see "logger.c line179 freq_val value" in the console. I print it on the console.

Please tell me what I might be doing wrong.
Thank you

image thumb png 40205df053bfd6cf7cc1f0ca1920f376

freq_val value
2022-11-11 102251

MCC134 ADC Init - confusing code

Reading through the code in mcc134_ad.c I am confused by something I am seeing:

    // check ID and device ready
    buffer[0] = CMD_RREG | REG_ID;
    buffer[1] = 2 - 1;  // count - 1
    buffer[2] = CMD_NOP;
    buffer[3] = CMD_NOP;
    if ((result = _mcc134_spi_transfer(address, buffer, NULL, 4)) !=
        RESULT_SUCCESS)
    {
        _release_board_lock(address);
        return result;
    }

    if ((buffer[2] & 0x0E) != 0x000)
    {
        // incorrect ID
        _release_board_lock(address);
        return RESULT_INVALID_DEVICE;
    }
    if ((buffer[3] & 0x40) != 0x00)
    {
        _release_board_lock(address);
        return RESULT_BUSY;
    }

Here 4 bytes are written to the ADC via SPI. No data is read. The subsequent code checks buffer[2] and buffer[3].
However, these checks are comparing 0x00 (CMD_NOP). What is the purpose of this?

The comment "Check ID and device ready" leads me to believe it's suppose to be reading data, and CMD_RREG implies that as well.

mcc118 hangs on a_in_scan_start and then returns HatError -3

I guess this issue corresponds to already closed one #14
In our case, after taking ~100 samples, the program hanged at <a_in_scan_start> function. Once restarted it quits with <daqhats.hats.HatError: Addr 0: Incorrect response -3.> (also thrown by the <a_in_scan_start> function).
Our python code is the following:

def scan(hat, channels, actual_scan_rate, samples_per_channel, read_request_size, timeout):
    options = OptionFlags.DEFAULT
    channel_mask = chan_list_to_mask(channels)
    try:
        logger.info("Starting scan")
        hat.a_in_scan_start(channel_mask, samples_per_channel, actual_scan_rate, options)
        result = _read_data_numpy(hat, channels, samples_per_channel, read_request_size, timeout)
        return result
    except (HatError, ValueError) as err:
        logger.error("Error during scan", exc_info=err)
        raise err
    finally:
        logger.info("Scan finished - cleaning...")
        hat.a_in_scan_stop()
        hat.a_in_scan_cleanup()

def _read_data_numpy(hat, channels, samples_per_channel, read_request_size, timeout):
    num_channels = len(channels)
    total_samples_read = 0
    result = numpy.array([])
    while total_samples_read < samples_per_channel:
        try:
            read_result = hat.a_in_scan_read_numpy(read_request_size, timeout)
        except (HatError, ValueError):
            raise
        if read_result.hardware_overrun:
            logger.error("Hardware overrun")
            break
        elif read_result.buffer_overrun:
            logger.error("Buffer overrun")
            break

        samples_read_per_channel = int(len(read_result.data) / num_channels)
        total_samples_read += samples_read_per_channel
        result = numpy.append(result, read_result.data)
    return result

We are taking scan every 60 seconds on 7 channels (0, 1, 2, 3, 4, 5, 6) reading 512 samples for each of them (both <actual_scan_rate>, <samples_per_channel>, <read_request_size> are equal to 512). The problem occurred on one of our five devices after switching to the new Raspberry Pi 4 and updating the daqhat software to 1.4.0.0 (however, I do not expect this might my the reason). The other four devices are working fine. All setups come with exactly the same configuration and are running the same program. Our previous installation (with Raspberry Pi 3 and daqhat v 1.1.0.2) used to work reliably for almost 2 years.

MCC152 dio_config_write_dict(item, value_dict) fails

Calls to the configuration write with a dictionary fail with the following traceback: "TypeError: byref() argument must be a ctypes instance, not _ctypes.PyCSimpleType".
I have verified that I can set and access configuration on a per-bit basis successfully.

Steps to reproduce:

  1. Instantiate a mcc152 type, ex. myHat = mcc152(0)
  2. Prepare a dictionary for bulk configuration, ex myConfig=dict(zip( [0,1,2],[1,1,0]))
  3. Call the function: myHat.dio_config_write_dict(DIOConfigItem.DIRECTION, myConfig)

Additional Information:
Platform: Debian 64-bit
Python: v3.9.2

Change the comma into a point

Hey,
I want to replace the comma in the values with a poin. For example I write 1,444 into a column. But I want to write 1.444.
SO in which file do I have to make changes and on which line?

MCC152 Default DIO state should be High-Z, not pull-up

The de-facto standard when a pin is non initialized, or configured as input, is high-Z. However, the MCC-152 defaults to pull-up (table 2 in the electrical specification). This causes it to apply a voltage to the circuit being monitored, any time dio_reset() is called, or any time the python scripts are not running. That could cause unexpected behavior on the circuit being monitored. It seems the default state of a DAQ input should not be to apply a voltage to the net being monitored, but to be as un-intrusive as possible.

Tips on installing daqhats in python venv

I'd like to develop inside a python 3 venv environment to prevent future broken dependencies on other libraries I am using with my RPi, however, I cannot seem to install daqhats in the environment. I successfully sudo installed to root, following instructions at https://mccdaq.github.io/daqhats/install.html, and everything works great in my home environment. With ~/daqhats/install.sh installed as root for python 3, and alias python=python3, I've tried the following within the virtual environment (venv) user:~/Projects/my_project $:

  1. sudo ~/daqhats/install.sh
  2. python ~/daqhats/setup.py install
  3. python ~/daqhats/setup.py build
  4. Re-performing the instructions at https://mccdaq.github.io/daqhats/install.html within the environment.

I still keep getting the following error:

from daqhats import mcc118, OptionFlags, HatIDs, HatError
ImportError: cannot import name 'mcc118'

Deleting 'mcc118' so that 'OptionFlags' is the first encountered item in the import raises a subsequent error, and so on down the line of imports. However, if I simply have import daqhats, no error is thrown until I also try to import from daqhats_utils.py, at which point ImportError: cannot import name... is thrown based on the imports at the head of this python script.

MCC 172 Can't open device, after X successful reads

Hi,

after multiple time recording loops with [1] We run into [2] After that the device won't start anymore [3] Only multiple reboots of the system does help and also updating the firmware [4].

I assume something is not really cleaned up properly? We encountered this problem only with this board so far.

Thanks,

[1]

...
def record(self):
   self.hat.a_in_scan_start(...)
   while not self.timeout.is_timeout:
      read_result = self.hat.a_in_scan_read(...)
   self.hat.a_in_scan_stop()
   self.hat.a_in_scan_cleanup()
   ...
   return frames   

[2]

rc[1990]: Traceback (most recent call last):
rc[1990]:   File "/rc/audio_sink/daq_hat.py", line 153, in _cleanup
rc[1990]:     self.hat.a_in_scan_stop()
rc[1990]:   File "/daqhats/mcc172.py", line 1153, in a_in_scan_stop
rc[1990]:     raise HatError(self._address, "Incorrect response.")
rc[1990]: daqhats.hats.HatError: Addr 0: Incorrect response.

[3]

Error while initializing DAQ Raspberry-Hat: Addr 0: Board not responding.

# AND if we try to list the board we get

$ pi@sounce:~ $ daqhats_list_boards
Found 1 board(s):

Address: 0
Type: MCC 172
Hardware version: 2
Name: MCC 172 IEPE HAT
Can't open device

[4]

$ pi@sounce:~ $ mcc172_firmware_update 0 MCC_172.fw 
The device at address 0 cannot be confirmed as an MCC 172.
Do you want to continue? Press Y to continue, any other key to exit. > y
Updating...
Finished
Checking device...
firmware version 1.01

$ pi@sounce:~ $ daqhats_list_boards
Found 1 board(s):

Address: 0
Type: MCC 172
Hardware version: 2
Name: MCC 172 IEPE HAT
Firmware version:   1.01

install scripts use quirky -D option for older coreutils versions

The various make files use the Linux install command to install the different files to the final locations. They use the -D option which is supposed to create intermediate directory levels in the destionation but can have some weird effects in older coreutils installations. It would be more compatible to first prepend the install command with an according

install -d $(INSTALL_DIR)

and then leave the -D option away from the following installation command. This makes the make scripts more compatible with different coreutils versions.

dash lib install error

"Could not find a version that satisfies the requirement install (from versions: )"
"No matching distribution found for install"

I get this when running:
pip install -Iv dash==0.30.0 dash-renderer==0.15.0 dash-html-components==0.13.2 dash-core-components==0.38.0

Crash when calling mcc118_open() after setlocale()

Hi,

I have a crash when I call mcc118_open() after setlocale().

#include <daqhats/daqhats.h>
#include <locale.h>
#include <stdio.h>

int main(int argc, char *argv[])
{
printf("locale at program start %s\n", setlocale(LC_ALL, NULL));

mcc118_open(0); // calling before setlocale() works
mcc118_close(0);

// That's what gtk_init() is doing according
// to the documentation of gtk_disable_setlocale()
setlocale (LC_ALL, "");
printf("locale after setlocale() %s\n", setlocale (LC_ALL, NULL));

mcc118_open(0); // calling after setlocale() segfaults
mcc118_close(0);

return 0;

}

The 2nd call of mcc118_open() crashes.

I have built libdaqhats with -O0 to get better backtraces:

#0 0x76f82d14 in _parse_factory_data (root=0x0, data=0x22a08) at mcc118.c:689
#1 0x76f83a88 in mcc118_open (address=0 '\000') at mcc118.c:1143
#2 0x000106f8 in main (argc=1, argv=0x7effefe4) at test.c:17

Crash happens in line
if ((root->type != cJSON_Object) ||

because root is NULL.

The crash doesn't happen anymore if I do
export LC_ALL=C in the console.

I have built the example like this
gcc -Wall -O0 -g test.c -ldaqhats

My locale is de_DE.UTF-8

Adding channels to data logger example

MCC172

I ran the logger.c example, it all compiled fine & I got 2 channels just fine.

I then amended the code to add 2 more channels as I have 2 hats on the Pi both with their own unique address,

#define MAX_CHANNELS 4

It compiles fine & the GTK GUI shows check boxes for all 4 channels but when I select either channel 3 or 4 I get the following pop up error,

Error: An incorrect parameter was passed to the function

It still works fine for channels 1 and 2

How do I add channels?

Dash Webserver Loading

I have successfully installed the mccdaq and dash. However, when launching the webserver with:

cd ~/daqhats/examples/python/mcc128/web_server ./web_server.py

and surfing to:

http://IP_ADRESS:8080

The webserver is stuck at "Loading...." and nothing shows up there.
Screenshot 2021-07-06 at 15 16 37

The ouput of the console is:
Screenshot 2021-07-06 at 15 23 38

While from terminal I got:
Screenshot 2021-07-06 at 15 24 33

What I'm doing wrong?

Issue with mcc118 Error -6

Hello all!
After a while pooling all 8 channels, using mcc118_a_in_read, my application stops reading the hat with error -6 A needed resource was not available. Pooling interval is one second and always stop working after 505 seconds!
I'm using the last version of the library, QT5.12.3, C++
Any help?

Support MCC 172 and MyPI setup

Hello there,
I'm trying your DAQ HAT on MyPI with CM 3B+.
After installation (sudo ./install.sh), I have 0 boards found.

sudo daqhats_read_eeproms
Reading...
Found EEPROM at address 0
Done

sudo daqhats_list_boards
0 boards found

I also tried to update fw:

mcc172_firmware_update 0 ~/daqhats/tools/MCC_172.fw
Warning - address 0 using factory EEPROM default values
Checking existing version...
Device firmware version 1.01
Do you want to continue? Press Y to continue, any other key to exit. > y
Updating...

Finished
Checking device...
Warning - address 0 using factory EEPROM default values
firmware version 1.01

Something caught up my attention: "Warning - address 0 using factory EEPROM default values"
Is it possible MyPI raspberry version have something different?
What can I do? I tried 2 boards... same result.

Best regards,
Thanks

Web server example Import Error

After pip install dash dash-renderer dash-html-components dash-core-components and running $ ./web_server.py or $ python web_server.py I get ImportError: cannot import name Event from dash.dependencies. After reading that the Event system was removed (see https://community.plot.ly/t/why-cant-i-import-the-event-dash-dependency/19288), I commented it out in the import statement and naturally got NameError: name 'Event' is not defined on line 389 of web_server.py with no import error. Potential guidance on a fix is detailed here: https://community.plot.ly/t/dash-events-button/19791/3?u=nedned

chan_string is too small line 214 in daqhats_utils.h

Hi,

I guess that chan_string is too small line 214 in daqhats_utils.h as it is reported during compilation:
./../daqhats_utils.h: In function ‘convert_chan_mask_to_string’: ../../daqhats_utils.h:225:35: warning: ‘%d’ directive writing between 1 and 10 bytes into a region of size 8 [-Wformat-overflow=] 225 | sprintf(chan_string, "%d, ", i); | ^~ ../../daqhats_utils.h:225:34: note: directive argument in the range [0, 2147483647] 225 | sprintf(chan_string, "%d, ", i); | ^~~~~~ ../../daqhats_utils.h:225:13: note: ‘sprintf’ output between 4 and 13 bytes into a destination of size 8 225 | sprintf(chan_string, "%d, ", i); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Support Ubuntu Server 20.04 LTS for raspberry pi 4B+

Hi @nwright98 @nwright-mcc @jperreault-mcc @jsigren !

Recently in my spare time I have played with the MCC128 on Ubuntu Server 20.04 LTS for raspberry pi 4B+ and made the daqhats build on it. Also, the data_logger example builds and GUI can show up. Since current master branch have some linking and dependancy issues on Ubuntu 20.04, I've prepared a prototype https://github.com/MrXinWang/daqhats/tree/rasp_pi_4b_ubuntu_20_04 and hope to contribute this prototype to upstream here.

Since I am not sure if you accept PRs here, please feel free to review the code and pick the top 3 commits to the master branch. Thanks!

MCC 172 DAQ HAT cannot be detected

Hi I have encountered a problem that DAQ HAT cannot be detected on the raspberry pi system. I have followed the installation procedure and there was no problem from step 1-7. However when I run the command 'daqhats_list_boards', it shows 0 board detected. The MCC DAQ HAT manager I installed also could not detect the device.

The DAQ HAT should have be installed correctly as the green light on the board is on(photo attached). Does anyone knows how to solve this problem? Thank you so much!
1
2
3

Bug with Continuous scanning with external clock

There appears to be a small bug when using hats in a synchronous setup with CLK lines connected, PY libraries

Whilst a master can be set to continuous scanning (in which the buffer size is irrelevant - assuming data is read quickly enough) this does not carry over to adjacent devices set to EXTCLOCK.

EXTCLOCK devices seem to be limited to a finite scan set to the buffer size limit regardless of data in the buffer, and will halt at this limit regardless. This behavior is present in the example file, changing the Options to continuous rather than trigger, the scan is halted at 10000 samples due to the state of the EXTCLOCK device

Unable to figure out a neat workaround for this other than a continuous check and restart.

mcc172 continuous acquisition

have made a script for continuous acquisition on mcc172 and saving to hard disk. the saving part is in a separate thread and acq thread passes the data through queue. script works fine for 4 days (1 new file per minute giving 5609 files).

the acquisition thread would throw out buffer overflow at around 4 days for 2 channels. and roughly 2 days for 4 channels (2 boards).

is this due to a counter integer overflow internally in the driver?

part of the code for acq thread is as follows:

while True:

    read_result = hats[0].a_in_scan_read(read_request_size, timeout)
    #read_result_2 = hats[1].a_in_scan_read(read_request_size, timeout)

    # Check for an overrun error
    if read_result.hardware_overrun :
        print('\n\nHardware overrun\n')
        break
    elif read_result.buffer_overrun:
        print('\n\nBuffer overrun\n')
        break
    q.put([read_result.data]) # pass data to saving thread

read request size is set at 25600, sample rate is also 25600
the queue for saving thread is unlikely to overrun as the file name being saved is according to the time, the files being saved follows the minute mark to the time very well; i.e. the second on the file name always matches.

Testing with Valgrind

Hi,

when I run this simple example...
`
#include <daqhats/daqhats.h>

int main(void)
{
int error;
error = mcc118_open(0);
if (error == 0)
{
mcc118_close(0);
}
return 0;
}
`
... under Valgrind I get some errors:

pi@raspberrypi:~ $ valgrind --tool=memcheck --track-origins=yes ./a.out
==1330== Memcheck, a memory error detector
==1330== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==1330== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==1330== Command: ./a.out
==1330==
==1330== Invalid read of size 1
==1330== at 0x484B200: strlen (vg_replace_strmem.c:458)
==1330== by 0x489A72B: cJSON_ParseWithOpts (cJSON.c:1008)
==1330== by 0x48950EF: mcc118_open (mcc118.c:1142)
==1330== by 0x10637: main (in /home/pi/a.out)
==1330== Address 0x4b163fa is 0 bytes after a block of size 530 alloc'd
==1330== at 0x4847568: malloc (vg_replace_malloc.c:299)
==1330== by 0x489513F: mcc118_open (mcc118.c:1104)
==1330== by 0x10637: main (in /home/pi/a.out)
==1330==
==1330== Conditional jump or move depends on uninitialised value(s)
==1330== at 0x4894B5C: _spi_transfer (mcc118.c:508)
==1330== by 0x4894FF3: mcc118_open (mcc118.c:1172)
==1330== by 0x10637: main (in /home/pi/a.out)
==1330== Uninitialised value was created by a heap allocation
==1330== at 0x4847568: malloc (vg_replace_malloc.c:299)
==1330== by 0x4894983: _spi_transfer (mcc118.c:397)
==1330== by 0x4894FF3: mcc118_open (mcc118.c:1172)
==1330== by 0x10637: main (in /home/pi/a.out)
==1330==
==1330== Conditional jump or move depends on uninitialised value(s)
==1330== at 0x4894C70: _parse_buffer (mcc118.c:272)
==1330== by 0x4894C70: _spi_transfer (mcc118.c:544)
==1330== by 0x4894FF3: mcc118_open (mcc118.c:1172)
==1330== by 0x10637: main (in /home/pi/a.out)
==1330== Uninitialised value was created by a heap allocation
==1330== at 0x4847568: malloc (vg_replace_malloc.c:299)
==1330== by 0x4894983: _spi_transfer (mcc118.c:397)
==1330== by 0x4894FF3: mcc118_open (mcc118.c:1172)
==1330== by 0x10637: main (in /home/pi/a.out)
==1330==
==1330== Conditional jump or move depends on uninitialised value(s)
==1330== at 0x4894CF4: _parse_buffer (mcc118.c:292)
==1330== by 0x4894CF4: _spi_transfer (mcc118.c:544)
==1330== by 0x4894FF3: mcc118_open (mcc118.c:1172)
==1330== by 0x10637: main (in /home/pi/a.out)
==1330== Uninitialised value was created by a heap allocation
==1330== at 0x4847568: malloc (vg_replace_malloc.c:299)
==1330== by 0x4894983: _spi_transfer (mcc118.c:397)
==1330== by 0x4894FF3: mcc118_open (mcc118.c:1172)
==1330== by 0x10637: main (in /home/pi/a.out)
==1330==
==1330== Conditional jump or move depends on uninitialised value(s)
==1330== at 0x4894D1C: _parse_buffer (mcc118.c:307)
==1330== by 0x4894D1C: _spi_transfer (mcc118.c:544)
==1330== by 0x4894FF3: mcc118_open (mcc118.c:1172)
==1330== by 0x10637: main (in /home/pi/a.out)
==1330== Uninitialised value was created by a heap allocation
==1330== at 0x4847568: malloc (vg_replace_malloc.c:299)
==1330== by 0x4894983: _spi_transfer (mcc118.c:397)
==1330== by 0x4894FF3: mcc118_open (mcc118.c:1172)
==1330== by 0x10637: main (in /home/pi/a.out)
==1330==
==1330== Conditional jump or move depends on uninitialised value(s)
==1330== at 0x4894D34: _parse_buffer (mcc118.c:307)
==1330== by 0x4894D34: _spi_transfer (mcc118.c:544)
==1330== by 0x4894FF3: mcc118_open (mcc118.c:1172)
==1330== by 0x10637: main (in /home/pi/a.out)
==1330== Uninitialised value was created by a heap allocation
==1330== at 0x4847568: malloc (vg_replace_malloc.c:299)
==1330== by 0x4894983: _spi_transfer (mcc118.c:397)
==1330== by 0x4894FF3: mcc118_open (mcc118.c:1172)
==1330== by 0x10637: main (in /home/pi/a.out)
==1330==
==1330== Conditional jump or move depends on uninitialised value(s)
==1330== at 0x4894D64: _spi_transfer (mcc118.c:569)
==1330== by 0x4894FF3: mcc118_open (mcc118.c:1172)
==1330== by 0x10637: main (in /home/pi/a.out)
==1330== Uninitialised value was created by a heap allocation
==1330== at 0x4847568: malloc (vg_replace_malloc.c:299)
==1330== by 0x4894983: _spi_transfer (mcc118.c:397)
==1330== by 0x4894FF3: mcc118_open (mcc118.c:1172)
==1330== by 0x10637: main (in /home/pi/a.out)
==1330==
==1330== Conditional jump or move depends on uninitialised value(s)
==1330== at 0x4894DE0: _spi_transfer (mcc118.c:572)
==1330== by 0x4894FF3: mcc118_open (mcc118.c:1172)
==1330== by 0x10637: main (in /home/pi/a.out)
==1330== Uninitialised value was created by a heap allocation
==1330== at 0x4847568: malloc (vg_replace_malloc.c:299)
==1330== by 0x4894983: _spi_transfer (mcc118.c:397)
==1330== by 0x4894FF3: mcc118_open (mcc118.c:1172)
==1330== by 0x10637: main (in /home/pi/a.out)
==1330==
==1330== Use of uninitialised value of size 4
==1330== at 0x4894DE0: _spi_transfer (mcc118.c:572)
==1330== by 0x4894FF3: mcc118_open (mcc118.c:1172)
==1330== by 0x10637: main (in /home/pi/a.out)
==1330== Uninitialised value was created by a heap allocation
==1330== at 0x4847568: malloc (vg_replace_malloc.c:299)
==1330== by 0x4894983: _spi_transfer (mcc118.c:397)
==1330== by 0x4894FF3: mcc118_open (mcc118.c:1172)
==1330== by 0x10637: main (in /home/pi/a.out)
==1330==
==1330== Conditional jump or move depends on uninitialised value(s)
==1330== at 0x4895020: mcc118_open (mcc118.c:1179)
==1330== by 0x10637: main (in /home/pi/a.out)
==1330== Uninitialised value was created by a heap allocation
==1330== at 0x4847568: malloc (vg_replace_malloc.c:299)
==1330== by 0x4894983: _spi_transfer (mcc118.c:397)
==1330== by 0x4894FF3: mcc118_open (mcc118.c:1172)
==1330== by 0x10637: main (in /home/pi/a.out)
==1330==
==1330==
==1330== HEAP SUMMARY:
==1330== in use at exit: 0 bytes in 0 blocks
==1330== total heap usage: 36 allocs, 36 frees, 6,135 bytes allocated
==1330==
==1330== All heap blocks were freed -- no leaks are possible
==1330==
==1330== For counts of detected and suppressed errors, rerun with: -v
==1330== ERROR SUMMARY: 15 errors from 10 contexts (suppressed: 6 from 3)

Would you please check?

phantom voltage spikes in buffer mcc118

I'm currently trying to run a continuous scan on the mcc118, but I'm getting random voltage spikes. I'm sampling at 1kHz and reading in a buffer of 10 samples across 4 channels. When I use board.a_in_read(channel) to read at the same frequency, however, I no longer see these spikes, which leads me to believe it's a buffer issue. I've attached two snippets of code; the first shows these spikes, the second does not. The image shows the data (downsampled to 100Hz) with the spikes. Does anybody have any suggestions for how I can address this issue? Am I doing something wrong here?

raspberry pi 4
daqhats 1.4.0.4
raspberry pi os 5.15.32

options = OptionFlags.CONTINUOUS
scan_rate = 1000
board = None

for entry in board_list:
  if entry.id == HatIDs.MCC_118:
      print("Board {}: MCC 118".format(entry.address))
      board = mcc118(entry.address)

board.a_in_scan_start(chan_mask, 0, scan_rate, options)
actual_scan_rate = board.a_in_scan_actual_rate(4, scan_rate)
timeout = -1

time.sleep(.3)

while (time.time() - stop_time < total_time):
      
    read_result = board.a_in_scan_read(10, timeout)
while(time.time() - stop_time < total_time):
   if (time.time() - time1000 > 0.001):
      time1000 = time.time()
      for channel in range(4):
          value[channel][i] = board.a_in_read(channel)
          i += 1

image

Hardware overruns?

7 x MCC172 Raspberry Pi 3 B+

I'm collecting data at 25.6KHz on all 14 channels & its been running fine for days but today I cant get past 10 seconds acquistition before it throws a "Hardware overrun" error. After I've loaded all the channel data into a buffer & then send that buffer via WiFi using MQTT. So roughly a packet/second.

Reading more DAQ HATs than are Present

I'm using some of the sample Python code to understand how to read data from MCC 134 and 152 HATs and when I run the hat_list function I get back that Board0, Board1, and Board2 are connected when I only have two HATs connected. After that I'm trying to read data from both boards and I get the following result.

Board0:
Board1:
Board2:
Board 323: MCC 134
Ch 0: 23.582
Ch 1: -9999.000
Ch 2: -9999.000
Ch 3: -9999.000
Board 323: MCC 134
Ch 0: -127.341
Ch 1: -127.406
Ch 2: -127.363
Ch 3: -127.383
Board 324: MCC 152
Traceback (most recent call last):
File "/home/pi/daqhats/mcc134test.py", line 32, in
board = mcc152(entry.address)
File "/home/pi/daqhats/daqhats/mcc152.py", line 141, in init
raise HatError(self._address, "Board not responding.")
daqhats.hats.HatError: Addr 2: Board not responding.

Here is the Python code I'm using. Any helped would be appreciated.

//!/usr/bin/env python
import sys
from daqhats import hat_list, HatIDs, mcc134,mcc152

get hat list of MCC daqhat boards

board_list = hat_list(filter_by_id = HatIDs.ANY)
for entry in board_list:
print("Board{}: ".format(entry.address))
if not board_list:
print("No boards found")
sys.exit()

Read and display every channel

for entry in board_list:
if entry.id == HatIDs.MCC_134:
print("Board {}: MCC 134".format(entry.id))
board = mcc134(entry.address)
for channel in range(board.info().NUM_AI_CHANNELS):
board.tc_type_write(channel,1)
value = board.t_in_read(channel)
print("Ch {0}: {1:.3f}".format(channel, value))
elif entry.id == HatIDs.MCC_152:
print("Board {}: MCC 152".format(entry.id))
board = mcc152(entry.address)
for channel in range(board.info().NUM_AI_CHANNELS):
value = board.a_in_read(channel)
print("Ch {0}: {1:.3f}".format(channel, value))

Unable to Compile/Run Data Logger Example

I am unable to run this example when using the command window or Geany. When using Geany, I receive a number of errors like:

logger.c:103.5: error: 'for' loop initial declarations are only allowed in C99 or C11 mode

I am able to run the continuous example though

Running MCC 128 with a BananaPi M2 Zero

I am trying to run a single MCC 128 board with a BananaPi M2 Zero running Armbian 23.05.0-trunk Bookworm.

It seems like some aspects of the installation process are specific to Rasbian and I was wondering if you have a similar installation script for Armbian. Alternatively if you could help me understand some of the steps in the installation file so I can find the equivalent in Armbian.

For example, the installation script uses rasp-config to activate SPI I2C communication. Instead I activated it by adding the following lines to /boot/armbianEnv.txt :

overlays=spi-spidev
param_spidev_spi_bus=0
overlays=i2c0

However, I am still unable to fully compile all the files during installation. Currently the compiler is stuck because it is not able to import bcm_host.h. This seems to be a library libraspberrypi-dev raspberrypi-kernel-headers.

Thank you very much for the help and let me know if there is any more information you might need from me.
All the best.

cannot import errors

Hi,

I am getting cannot import OptionFlags error when I try to run ./continuous_scan.py

HatError -3 After One to Two Thousand Finite Samples

I want to take a one second long finite sample every few seconds for several days. The problem is that everything runs as expected for several hours until the program just quits on HatError -3. My relevant python code is as follows:

#start background acquisition into buffer
def acquire_data():
	channels = [0, 1, 2, 3]
	channel_mask = chan_list_to_mask(channels)
	num_channels = len(channels)
	#make sure samples and scan_rate match
	samples = 12000 # this ensures 1 Hz resolution in Fourier space
	scan_rate = 12000.0
	options = OptionFlags.DEFAULT
	hat.a_in_scan_start(channel_mask,
		samples,
		scan_rate,
		options)
	#read and store data
	read_values = hat.a_in_scan_read_numpy(samples, 1).data
	read_values = np.reshape(read_values, (-1, 4))
	hat.a_in_scan_cleanup()
        # only take channel 0, may want others in the future
	get_thd(read_values[:,0], num_channels, samples, scan_rate)

This function is called and looped via:

if __name__ == '__main__':
	acquire_data()
	while True:
		time.sleep(3)
		acquire_data()

The error is:

Traceback (most recent call last):
  File "THD_DAQ.py", line 100, in <module>
    acquire_data()
  File "THD_DAQ.py", line 88, in acquire_data
    options)
  File "/home/pi/Projects/THD/thd_env/lib/python3.7/site-packages/daqhats/mcc118.py", line 547, in a_in_scan_start
    result))
daqhats.hats.HatError: Addr 0: Incorrect response -3.

Tracing these errors from line 547 in mcc118.py leads to the daqhats/lib/mcc118.c. From there, my best guess is that _spi_transfer function is returning a value which is not RESULT_SUCCESS to the 'result' variable in mcc118_a_in_scan_start on line 1707. The _spi_transfer function has many possible return values other than RESULT_SUCCESS, is there a way I can print or see this value for debugging reasons?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.