mendesgeo
Hello, is it possible to access variables of PLC memory instead of discrete and analog outputs and inputs?
The only way I got to make arduino "do something different" is when i modified its firmware to allow specifics analog outputs to serve as another porpoise different than to write pwm.
  • For instance: if an 1 is write to %QW1.0, it causes the value in %QW1.1 to be sent trough I2C/Software serial/SPI/ETC and %QW1.0 is cleared) 
If this could be made directly by memory access, it could get more intuitive to control.

Could I try to include the code below in glue_generator.cpp (glueVar function), rebuild everthing and (with proper modifications in host and arduino side I/O structures) get it working when writting to a variable named %MQ0.0 ?


else if (varName[2] == 'M')
  {
      switch (varName[3])
    {
      case 'I':
        glueVars << "\tusint_input[" << pos1 << "][" << pos2 << "] = " << varName << ";\r\n"; //input uint memory register
        break;
      case 'Q':
        glueVars << "\tusint_output[" << pos1 << "][" << pos2 << "] = " << varName << ";\r\n"; //output uint memory register
        break;
    }
    
  }


If this can be possible, we could have easy access to any peripheral of arduino or custom interaction.

Also, as we normally have just Holding and input register access trough ModBus, its gonna be possible to read memory variables by some mean using this protocol (to show them in a supervisory for instance)?.

Thank you.
Quote 0 0
thiagoralves
I'm modifying the modbus code to support memory and some other things that were missing. I've been working on that during the last days. Basically with the update you will be able to write to some specific holding registers that will be links to OpenPLC internal memory. You will even be able to read and write floats and doubles to the registers. Part of the modification is what you did on the gluevars file, however that alone is not enough. You need to modify the Modbus code as well. I'm finishing it, so if you wait just a little bit longer you will have the finished code in your hands [smile]

However, the memory is internal to the OpenPLC, which means it doesn't get transmitted to the Arduino board. The only thing the Arduino receives is the information about physical IO. It is blind about the OpenPLC's internal memory.

Perhaps the right way to do it would be to create extra IOs to transmit the information you want (like we discussed before) to the Arduino board. Then the OpenPLC would be simply writing and reading from IO and the Arduino firmware would be doing the hard work depending on which IO was requested.
Quote 0 0
thiagoralves
I updated the code. Check the News & Announcements section for more details! [smile]
Quote 0 0
mendesgeo
Thank you very much! I'm testing it with serial baudrate of 1Mhz through arduino [smile]
Quote 0 0
thiagoralves
Nice! Is it working well? I don't remember to have added support for baud rates higher than 115200 on my Arduino driver code running on the host
Quote 0 0
mendesgeo
I edited hardware layer code. I changed 115200 values for 1000000 and added a new Constant called B1000000 in a switch case (don't remember the function name).

In rasp, I edited a config parameter to allow this baudrate to communicate to arduino, which is very good as it is the maximum baud possible with 0.0% of error.
Thanks you for the updates, i tested with scadaBr and seems very sólid. I can now include crc16 in hardware layers to ensure no problem at all at this baudrate.
Quote 0 0