7 years, 5 months ago.

HelloWorld_PLC01A1

Would you please extend HelloWorld_PLC01A1 to show how to execute logic in the STM32F4 uC based on PLC inputs before updating the PLC outputs?

1 Answer

7 years, 4 months ago.

Kaled,

ST is the maintainer/creator of that repository, but I had a look at the HelloWorld program as well as the library. Starting at line 80 of the main file:

void SsrelayHandler(X_NUCLEO_PLC01A1 &plc)
{
  /* Set outputArray as DigInpArray RxBuffer */
  outputArray[1] = plc.signalMirror(inputArray[1]);
  
  /* Uncomment the relevant function as required */                                                       
  //outputArray[1] = plc.signalMirror(0xFF);
  //outputArray[1] = plc.outputFreeze(0xFF,5000);
  //outputArray[1] = plc.outputRegroup(0xFF);
  //Ch_On = plc.inputSum(&outputArray[1],0xFF);
  //outputArray[1] = plc.setOutput(0xFF);
  //outputArray[1] = plc.inputsAND(0xFF,0x0F);
  //outputArray[1] = plc.inputsOR(0xF0,0x0F);
  //outputArray[1] = plc.inputsNOT(0x00);
  //outputArray[1] = plc.inputsXOR(0xFF,0x00);
  
  /* Parity bits calculation */
  plc.outputParityBits(outputArray);
 
  /* Send output information to solid state relay */
  plc.plcOutput().Ssrelay_SetOutput(outputArray);
}

On line 4 of the above excerpt, you can see that the output array is being set according to an element in the input array, where line 21 uses that array to produce output. At that point, you have access to the input array, and you could write code before line 4 to operate on those inputs before setting the data in the output array. It looks like some of the function calls in the following lines are also operating on the output array. I would suggest looking at the library documentation for a full description of available functions. Here is a link to the library page: https://developer.mbed.org/teams/ST/code/X_NUCLEO_PLC01A1/

Accepted Answer