• Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. Giamba
    G
    • Profile
    • Following 0
    • Followers 0
    • Topics 8
    • Posts 47
    • Best 3
    • Controversial 0
    • Groups 0

    Giamba

    @Giamba

    3
    Reputation
    870
    Profile views
    47
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    Giamba Unfollow Follow

    Best posts made by Giamba

    • RE: Decode api.cgi vars

      Hi, thanks for the job.
      I found functions in UserJS that do the job:

      • parseRealFromHex
      • parseIntFromHex
      • parseValueFromHash
        ...
        Now I have to find how to provide the type to decode in the right way.
        I have to look in html5_shark.xsl to modify it

      Thanks

      posted in Mervis
      G
      Giamba
    • RE: AI extension

      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

      posted in UniPi 1Wire Extension Modules (official)
      G
      Giamba
    • RE: Debugging mode probleme

      Got it!
      Each fdb programme must have an entry in PLC Tasks.

      posted in Mervis
      G
      Giamba

    Latest posts made by Giamba

    • RE: Push button relay toggle

      0_1545042847414_mervis.png

      posted in Mervis
      G
      Giamba
    • RE: Access to variables from another PLC

      Hi CKB.
      Yes it's ok for me now. Tested with example and with my project.

      posted in Mervis
      G
      Giamba
    • RE: Access to variables from another PLC

      Hi, this is the SSCP Server log. Can U tell me how is managed the login on the RT (maybe cookie with wrong acl) and if the sscp connection have to be permanant keep-alive because it seems to reconnect on each request.

      [10.05 09:16:44.863]      TSvr12346: New connection on port 12346 (remote 192.168.1.55:48494)
      [10.05 09:16:44.883] <->  TSvr12346: Assigned client context no. 0
      [10.05 09:16:46.909] <->  TSvr12346: Unassigned client context no. 0
      [10.05 09:16:46.914]      TSvr12346: New connection on port 12346 (remote 192.168.1.55:48496)
      [10.05 09:16:46.919] <->  TSvr12346: Assigned client context no. 0
      [10.05 09:16:48.959] <->  TSvr12346: Unassigned client context no. 0
      [10.05 09:16:48.965]      TSvr12346: New connection on port 12346 (remote 192.168.1.55:48498)
      [10.05 09:16:48.970] <->  TSvr12346: Assigned client context no. 0
      [10.05 09:16:51.010] <->  TSvr12346: Unassigned client context no. 0
      [10.05 09:16:51.015]      TSvr12346: New connection on port 12346 (remote 192.168.1.55:48500)
      [10.05 09:16:51.020] <->  TSvr12346: Assigned client context no. 0
      [10.05 09:16:53.060] <->  TSvr12346: Unassigned client context no. 0
      [10.05 09:16:53.066]      TSvr12346: New connection on port 12346 (remote 192.168.1.55:48502)
      [10.05 09:16:53.085] <->  TSvr12346: Assigned client context no. 0
      [10.05 09:16:55.111] <->  TSvr12346: Unassigned client context no. 0
      [10.05 09:16:55.116]      TSvr12346: New connection on port 12346 (remote 192.168.1.55:48504)
      [10.05 09:16:55.121] <->  TSvr12346: Assigned client context no. 0
      
      posted in Mervis
      G
      Giamba
    • RE: Tool Tips in HMI pannel...

      Hi!
      It's purely Javascript and DOM.
      If you have knowledge in this, you can take a look at http://www.voicerss.org/ which translates the text that you pass to in audio. With Javascript, you fetch all the elements of the DOM until you find those where you set an attribute (data-my-text-to-read) to define it's hhover event. Methode for all recents browsers.
      You can edit the sources of the HMI web pages in the web directory of your project directory.
      Hope that's help.

      posted in Mervis
      G
      Giamba
    • RE: Access to variables from another PLC

      Up @tomas_hora

      posted in Mervis
      G
      Giamba
    • RE: Access to variables from another PLC

      As seen in https://kb.mervis.info/lib/exe/fetch.php/cs:mervis-ide:sharkprotocolspecification_user_2017_05_30.pdf,
      In port monitor:
      On receiving:

      • 01 SSCP address
      • C5 00 Read variables directly error
      • 00 04 Data length
      • 00 00 01 14 NotLogged

      So I have a resonse, credentials seems too be wrong, but I have admin - rw on PLC configuration and SSCP Device.
      Do you have an explanation ?

      posted in Mervis
      G
      Giamba
    • RE: Access to variables from another PLC

      Hi,
      I test lots of configurations and doesn't work yet.
      This is what I have in mervis:
      !0_1525599211705_Mervis com.JPG
      And netstat command:
      0_1525599296587_tcp connexion.JPG
      So, plz, can U tell me what's wrong ?

      posted in Mervis
      G
      Giamba
    • RE: Access to variables from another PLC

      hi @CKB, @tomas_hora ,
      Same problem for me, did you find the solution ?
      Thanks.

      posted in Mervis
      G
      Giamba
    • RE: 1 Wire problems

      Hi @tomas_hora,

      So this is the chart I get of few hours with some unusual peaks and a unfortunate no signal blackout at the end for a couple of minutes.

      Could you please provide me a chart that shows on a long term basis multiple 1wire sensors curves to make sure that the product (sensors and hub) you sold on you website are reliable.
      Thanks in advance.

      0_1510526864647_temp chart.png

      posted in Mervis
      G
      Giamba
    • RE: 1 Wire problems

      Hi,
      Ok, now my one wire network is working for a few minutes.
      I have put 4+5 together, 3+8 and 6+7, but I have inserted a 150ohm resistor to the data pin of each branch, one branch for one sensor in the middle (1.5m) and one for the star "branch" to the end at 3m.
      According to the specification, 150ohm resistor is not suposed to work for the DS2482-X but it's actualy the only way I found to make it works (for a few minutes) whereas without resistor no sensor is found.

      Is there a way to modify the DS2482-x configuration register to test diferent PullUp options ?

      So the 1 wire is very important for me, it controls solar heating panels and boiler, without this working it's realy a problem.

      Thanks to help me to get it working.

      posted in Mervis
      G
      Giamba