AI extension



  • I need more analog input.
    Is there no AI extension in the web shop


  • administrators

    Good morning,

    we are going to sell new product with analog inputs soon (4x Analog input module. 0-10V)
    It has full compatibility with Neuron product line. For UniPi 1.1 users, there is converter to connect extension module.

    BR
    Adam Skorpik



  • Ok thanks for the quick response
    How far in the future before it is available in the web shop



  • @skorp
    Can you please elaborate, will this new product be similar form factor as Neuron ( Din rail mountable) or is it just another extension board?

    Are there any plans to release versions of Neuron with additional Analog I/O?


  • administrators

    Hello,

    The case will be the same for the extensions for neuron as well as for the neuron itself.

    First of all we will release the extensions and later also probably some variations with more analog i/o but cannot guarantee.



  • Hi,
    following up to the discussion above is there an update on the release date of AI extension boards?

    Regards
    CKB


  • administrators



  • Hello,
    my system architecture is several Unpi's 1.1 with a stack of extension PCBs (relay + AO).
    Is there no AI board like in the design of the relay extension boards?
    If no, can you give me a link to the converter for I²C to Modbus?

    Thanks


  • administrators

    @CKB We do not plan to make an AI extension for the first generation right now. Converting I2C to modbus is not possible



  • Hi,
    I Think you can make a programm that reads value from i2c and send them to modbus.
    I create one that read value from zmq and send to modbus.
    You have to find and install modbus library.
    Then you have to create modbus channel in IDE, connect to the right port, and parse values.
    So, to you to read value from i2c.
    My code here:

    #include <stdio.h>
    #include <unistd.h>
    #include <string.h>
    #include <stdlib.h>
    #include <errno.h>
    
    #include <modbus.h>
    #include <zmq.h>
    #include "zhelpers.h"
    
    int arrondi(float nombre) {
      return nombre + 0.5;
    }
    
    
    int main()
    {
        int socket;
        modbus_t *ctx;
        modbus_mapping_t *mb_mapping;
        
        int keepRunning;
        
        int rc;
        
        char src[sizeof("WMR200_USB")];
        char pressure[sizeof("0000.0")];
        char humid0[sizeof("000.0")];
        char humid1[sizeof("000.0")];
        char temp0[sizeof("-000.0")];
        char temp1[sizeof("-000.0")];
        char windGust[sizeof("000.0")];
        char windAvg[sizeof("000.0")];
        char windDir[sizeof("000.0")];
    
        char zmq_msg[100];
        
    
        printf("Start WView WMR200 ZMQ/Modbus gateway\r\n");
        fflush(stdout);
        
        keepRunning = 1;
        while(keepRunning == 1) {
            printf("Waiting for TCP connection...\r\n");
            fflush(stdout);
            ctx = modbus_new_tcp("127.0.0.1", 1502);
            socket = modbus_tcp_listen(ctx, 1);
            modbus_tcp_accept(ctx, &socket);
            printf("TCP connection started!\r\n");
            fflush(stdout);
    
    
            mb_mapping = modbus_mapping_new(1000, 1000,
                                            1000, 1000);
    
            mb_mapping->tab_registers[0] = 0; //pressure
            mb_mapping->tab_registers[1] = 0; //temp sensor 0 temp  (station temp)
            mb_mapping->tab_registers[2] = 0; //temp sensor 0 humid
            mb_mapping->tab_registers[4] = 0; ///temp sensor 1 temp (out temp)
            mb_mapping->tab_registers[5] = 0; //temp sensor 1 humid
            mb_mapping->tab_registers[7] = 0; //wind gust
            mb_mapping->tab_registers[8] = 0; //wind avg
            mb_mapping->tab_registers[9] = 0; //wind dir
    
    
            if (mb_mapping == NULL) {
                fprintf(stderr, "Failed to allocate the mapping: %s\r\n",
                        modbus_strerror(errno));
                modbus_free(ctx);
                return -1;
            }
    
            void *context = zmq_ctx_new ();
            void *subscriber = zmq_socket (context, ZMQ_PULL);
            rc = zmq_bind (subscriber, "tcp://*:5560");
            assert(rc == 0);
    
    
            while(1) {
                memset(zmq_msg, 0, sizeof(zmq_msg));
                int size = zmq_recv (subscriber, zmq_msg, 2048, ZMQ_DONTWAIT);
                if (size != -1) {
                    //  Process task
    
                    //printf("%s\n\r", zmq_msg);
                    fflush(stdout);
                    sscanf (zmq_msg, "%s %s %s %s %s %s %s %s %s",src, pressure, temp0, humid0, temp1, humid1, windGust, windAvg, windDir);
                    printf("WMR200 Modbus Gateway from ZMQ: topic=%s pressure=%s temp0=%s humid0=%s temp1=%s humid1=%s winGust=%s windAvg=%s windDir=%s\r\n", src, pressure, temp0, humid0, temp1, humid1, windGust, windAvg, windDir);
                    fflush(stdout);
                    if (strcmp(src, "WMR200_USB") ==0){
                        mb_mapping->tab_registers[0] = arrondi(atof(pressure)); //pressure
                        mb_mapping->tab_registers[1] = arrondi(atof(temp0)*10); //temp sensor 0 temp  (station temp)
                        mb_mapping->tab_registers[2] = arrondi(atof(humid0)*10); //temp sensor 0 humid
                        mb_mapping->tab_registers[3] = arrondi(atof(temp1)*10); ///temp sensor 1 temp (out temp)
                        mb_mapping->tab_registers[4] = arrondi(atof(humid1)*10); //temp sensor 1 humid
                        mb_mapping->tab_registers[5] = arrondi(atof(windGust)*10); //wind gust
                        mb_mapping->tab_registers[6] = arrondi(atof(windAvg)*10); //wind avg
                        mb_mapping->tab_registers[7] = arrondi(atof(windDir)*10); //wind dir
                    }
                }
    
                uint8_t query[MODBUS_TCP_MAX_ADU_LENGTH];
                rc = modbus_receive(ctx, query);
                if (rc >= 0) {
                    //printf("Replying to request.\r\n");
                    modbus_reply(ctx, query, rc, mb_mapping);
                    //fflush(stdout);
                } else {
                    printf("Quit the loop: %s\r\n", modbus_strerror(errno));
                    fflush(stdout);
                    zmq_close (subscriber);
                    zmq_ctx_destroy (context);
                    modbus_mapping_free(mb_mapping);
                    close(socket);
                    modbus_free(ctx);
                    break;
                }
            }   
        }
        return 0;
    }
    

    Tell me if you need more help.
    Giamba