REXYGEN Community Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Login
    1. Home
    2. belgacom
    3. Posts
    B
    • Profile
    • Following 0
    • Followers 0
    • Topics 3
    • Posts 14
    • Best 1
    • Controversial 0
    • Groups 0

    Posts made by belgacom

    • RE: Memory through 2 different lvl

      @jan-reitinger Hello Jan, thank you for your answers.

      As I have done some test yesterday, I come with another question.
      As you can see on my printscreen, I have 3 Rexlang in one task, these task is doing reading on probes.
      1 Rexlang per probes, as I only want to read values on the probe every 30 sec, I change the tick and ntick inside the EXEC.
      My problem is that I would like to have also manual action in this task. ( turn on/off, output ) as I have change the scan time of this task, the manual action as a long delay before the change.

      Therefore I tried to put back the original values of the scan time in the EXEC. ( 0.05 / 10 lvl0 ) As soon as I put these values, it's like if I'm killing the rexcore in my raspeberry pi. A lot of trouble to connect, no more possible to go in live watch, etc...
      My question is: is it possible that the fact that I have 3 rexlang in 1 task, with ( 0.05 *10 ) scan time, could kill the "CPU" ?
      Do I have to manage the Hold of the Rexlang, to only do measurement when I need it ?

      Hope my explanation is clear.
      Arnaud

      posted in REXYGEN Studio
      B
      belgacom
    • Memory through 2 different lvl

      Hello everybody,

      I would like to know how I can use an internal memory status through 2 different level of the EXEC block.
      I tried with GOTO and FROM, but it doens't seems to work.

      Thank you for you help.

      c5236700-bc19-4b46-bee9-9e825919d0bb-image.png

      posted in REXYGEN Studio
      B
      belgacom
    • RE: I2C EZO component

      @reitinge

      Everything works fine !
      Thank you.

      posted in Communication (RS232
      B
      belgacom
    • RE: I2C EZO component

      @reitinge

      Hi.

      I had time to dig a littl bit, and I find solution to do the write and read in 1 rexlang.
      After that no more issue with alarm and I'm able to trace " message"

      It works fine.
      But still I don't understand how to display the value of "message" in the HMI designer.

      trace.jpg

      I tried with standard display and string display.
      I would like also to trend the ASCII value ( 3.xxxx)
      Can you give me a hand on this ?

      Thx.

      Arnaud.

      my code :

      /[5]*************************************
      *

      • REXLANG - Reading data from MCP3422 AD converter via I2C

      *************************************************************/

      string parameter(0) i2c_dev; // the I2C bus is defined by the p0 parameter

      //assigning variables to outputs, these variables are WRITE-ONLY
      long output(0) adc_value;
      long output(1) adc_value1;
      long output(2) adc_value2;
      long output(3) adc_value3;
      long output(4) adc_value4;
      long output(5) adc_value5;
      long output(6) adc_value6;
      long output(7) message;
      string output(8) message;

      //declaration of variables
      long i2c_bufTx[4]; //buffer for transmitting data
      long i2c_bufRx[7]; //buffer for receiving data
      long i2c_bus_handle;
      long i2c_chip_address;
      long i2c_write_count;
      long i2c_read_count;
      long i2c_ret_fun;
      int i;
      char message[5];

      //the init procedure is executed once when the REXLANG function block initializes
      int init(void)
      {
      i2c_bus_handle = OpenI2C(i2c_dev); // open I2C bus
      Trace(1,i2c_bus_handle);

      i2c_chip_address = 0x63; // 7-bit address of the I2C device

      return 0;
      

      }

      //the main procedure is executed once in each sampling period
      long main(void)
      {
      //i2c_bufTx[0] = 0x46;
      //i2c_bufTx[1] = 0x69;
      //i2c_bufTx[2] = 0x6E;
      //i2c_bufTx[3] = 0x64;

      i2c_bufTx[0] = 0x52;

      // i2c_bufTx[0] = 0x53;
      //i2c_bufTx[1] = 0x6C;
      //i2c_bufTx[2] = 0x65;
      //i2c_bufTx[3] = 0x65;
      //i2c_bufTx[4] = 0x70;

      i2c_write_count = 1;
      i2c_read_count = 0;

      //Sending data via I2C
      i2c_ret_fun = I2C(i2c_bus_handle, i2c_chip_address, i2c_bufTx, i2c_write_count, i2c_bufRx, i2c_read_count);

      Suspend (3);
      i2c_write_count = 0;
      i2c_read_count = 7;

      i2c_ret_fun = I2C(i2c_bus_handle, i2c_chip_address, i2c_bufTx, i2c_write_count, i2c_bufRx, i2c_read_count);

      adc_value = (i2c_bufRx[0]);
      adc_value1 = (i2c_bufRx[1]);
      adc_value2 = (i2c_bufRx[2]);
      adc_value3 = (i2c_bufRx[3]);
      adc_value4 = (i2c_bufRx[4]);
      adc_value5 = (i2c_bufRx[5]);

      for (i=1; i<6; i++)
      message[i-1] = i2c_bufRx[i];
      Trace(1,message);

      return 0;
      }

      //the exit procedure is executed once when the task is correctly terminated
      // (system shutdown, downloading new control algorithm, etc.)
      long exit(void)
      {
      if(i2c_bus_handle>=0) Close(i2c_bus_handle); // close I2C bus
      return 0;
      }

      posted in Communication (RS232
      B
      belgacom
    • RE: I2C EZO component

      @reitinge

      Hello, Happy new year. Hope you are going .
      I tried to use trace with you code up here, but even if the block is returning the correct value of my Ezo components,
      I have an 508 error.

      errore 508 .jpg
      therefore no trace is seen in the log . any idea why 508 error ?

      Anyway even if I hand write 5 values into message[5], how after do I see it on the HMI page.
      If I use a declaration of output like :

      long output(x) message; or string output(x) I can't manage to see values in message.
      How do I proceed ?

      thx

      Arnaud

      posted in Communication (RS232
      B
      belgacom
    • RE: I2C EZO component

      @reitinge

      Hello, Happy new year. Thanks for your help and sorry for the time lost for my com issue. I was targeting Localhost and not my Pi. Except the fact that command need to be send in Hex and not in Dec, your code works find.

      I'm able to send command and read values back.
      Thanks a lot.

      I still have a couple of question for you :

      1. now I have the reading of my probe in bufRx [1] to [5] in DEC. and I need to convert it in ASCII. (51 46 56 57 54 = 3.896 )
        Is there a function for that, in Rexlang or another FB to use ?

      2. Between a write and a read, I have for example 900ms to wait . So currently I have done 2 Rexlang, 1 to write, 1 to read.
        And I use a timer between both FB. Is there a way to do it directly in Rexlang, or do I have to continue to use 2 block ?
        I didn't find answer in the doc.

      Have a good day.

      Arnaud.

      posted in Communication (RS232
      B
      belgacom
    • RE: I2C EZO component

      @reitinge

      I do have a negative result with the trace function .

      here is a print screen of the log and the current BF code :

      trace .jpg

      What could be the error to have the trace at -106.

      Arnaud

      posted in Communication (RS232
      B
      belgacom
    • RE: I2C EZO component

      @reitinge

      Hello again thx for your time.

      When I try to add trace function, I have an error in the during compiling : function 'trace' is not declared ?
      The example that you attach in your response, is when you request data from device. ( so we read data )

      But if I want to write I have this data :

      send.jpg

      So Do I have to generate an array of 5 and send Start, I2c address, write, "the wanted function", stop ?
      And easy test for me is to make a led blinking on the EZo chip :

      find.jpg

      If I understand their example, I need to WRITE find in the EZO and there is no returns values because it's making a led blinking.
      The example with ascii code return, is when I do a reading of the probe for example.
      My question is if I write Find, Do I have to send ( write; find ) And I alerady have the start, with open I2c and adresse, and stop or do I have to send all data ?

      Hope I'm enough clear ?

      Arnaud.

      posted in Communication (RS232
      B
      belgacom
    • RE: Python FB

      Hello reitinge,

      Here is the requested log :

      system log.jpg

      Thanks for the help.

      Arnaud.

      posted in REXYGEN Studio
      B
      belgacom
    • Python FB

      Hello,

      I would like to use Python FB for a test, but as soon as I try to download to my Pi, as i an error.

      error: Rexygen Module Error - some driver or block is not installed or licensed on target device. ( code-108 )
      I did follow instruction of Python block.

      I have done the apt install rex-pythonblkt and even the python3-numpy python3-opencv.
      But in all case I have this error.

      Someone can give me a hint ?
      Arnaud

      posted in REXYGEN Studio
      B
      belgacom
    • RE: I2C EZO component

      Hello again everybody.

      I just received my I2c components, and I'm really lost to understand how adapt the i2c example for my hardware.
      I have understand the line of the rexlang MCP3422 ADC, with i2c handle, adress, ect. But I I don't understand the communication itself.

      I have as example for my hardware :

      4.jpg 3.jpg 2.jpg 1.jpg

      With these information I don't understand how I need to adapt the rexlang function made for MCP3422 to match the EZO read/write.

      If I understand well, I would say that :

      Start is : Open I2C;
      I2C adress: is 0x63;
      after I don't know how to code the Read or Write function.
      In the example of MCP3422, the variable are 2 array [3] for bufTx and bufRx;
      and we put 0x88 ( I understand why with the explanation) in the bufTx[0]
      and there is a write count of 1 and read of 2.
      I think it's this part that I need to adapt ?

      And stop is close I2C.

      Does anyone can help me to understand how to modify the code of an I2C example to match my hardware.
      It would be a nice Christmas present for me 😉

      Thanks.

      Arnaud.

      posted in Communication (RS232
      B
      belgacom
    • RE: I2C EZO component

      @reitinge Hello thank you for your time

      I appreciate . I'll have a look at these example.
      Thx again.

      Arnaud

      posted in Communication (RS232
      B
      belgacom
    • I2C EZO component

      HI Everybody,

      I'm new with Rexygen, but I'm really surprise with the amount of possibilities, it's really amazing.
      I have already done some I/O simulation, and everything works perfectly.

      My project with Rexagen would be to integrate Ph / ORP /etc probes into my swimming pole management.
      To do that I'll add EZO I2C components ( https://www.whiteboxes.ch/shop/ezo-ph-circuit/) on the GPIO of my raspberry.
      I'm not familiar on how I can manage I2C data with rexygen.

      Is someone can guide on how to proceed ?

      Arnaud

      posted in Communication (RS232
      B
      belgacom