eyasu
Hi all,

I think the maximum number of output pins in OpenPLC are limited to 16. I tried to declare more than 16 output pins on the Arduino firmware, e.g., declaring some of the analog input pins as digital output pins, but those beyond 16, i.e., > QX1.7, are not working. Could you please point me where to change it if it is already fixed somewhere on the OpenPLC implementation? I couldn't find it on the hardware layer implementation. 

Thanks.
Reply 0 0
thiagoralves
One of the first things declared on the arduino firmware is the struct responsible for I/O:

struct OPLC_input
{
  uint8_t digital[4];
  uint16_t analog[16];
};
struct OPLC_output
{
  uint8_t digital[2];
  uint16_t analog[12];
};

As you can see, there are two structs, one holding the values for the inputs and the other for the outputs. The size for the digital output is 2x8bits = 16 (uint8_t digital[2]). If you declare more than 16 output pins, they will be outside of the array size, and therefore will never be used. If you increase digital[2] to be digital[3] for example, you'll have 8 more digital outputs. There is a similar structure on the arduino hardware_layer.cpp file for the OpenPLC host as well. If you change the size of the struct in the Arduino firmware, you'll have to change the OpenPLC host hardware_layer.cpp file as well. They must have exactly the same size, or the communication will not work!

Also, keep in mind that if the analog pins are used as analog inputs, they can't be used as normal digital outputs, which means that you'll need to remove them from pinMask_AIN[] vector while adding to pinMask_DOUT[].
Reply 1 0
eyasu
Thank you very much for the prompt response!
Reply 0 0
Reply