An example of usage of the X-NUCLEO-PLC01A1 Programmable Logic Controller Expansion Board.
Dependencies: X_NUCLEO_PLC01A1
PLC with the X-NUCLEO-PLC01A1 Expansion Board
This application provides a simple example of usage of the X-NUCLEO-PLC01A1 Programmable Logic Controller Expansion Board.
It shows how to use one PLC connected to the board, driving the status of each output channels according to the status of each input channels.
Diff: main.cpp
- Revision:
- 5:321e4e37ba1c
- Parent:
- 4:17b45bcd5b40
- Child:
- 6:afd63b2b2d1a
--- a/main.cpp Tue Feb 23 13:00:04 2016 +0000 +++ b/main.cpp Wed Feb 24 10:54:02 2016 +0000 @@ -67,7 +67,7 @@ * @param None * @retval None */ -void DigitalInputArrayHandler(PLC &plc) +void DigitalInputArrayHandler(X_NUCLEO_PLC01A1 &plc) { plc.plcInput().DigInpArray_GetInput(inputArray); } @@ -77,7 +77,7 @@ * @param None * @retval None */ -void SsrelayHandler(PLC &plc) +void SsrelayHandler(X_NUCLEO_PLC01A1 &plc) { /* Set outputArray as DigInpArray RxBuffer */ outputArray[1] = plc.signalMirror(inputArray[1]); @@ -118,8 +118,8 @@ SPI spi(X_NUCLEO_PLC01A1_PIN_SPI_MOSI, X_NUCLEO_PLC01A1_PIN_SPI_MISO, X_NUCLEO_PLC01A1_PIN_SPI_SCLK); setup(spi, X_NUCLEO_PLC01A1_PIN_SPI_BITS); - /* Initializing PLC IO Channels Component. */ - PLC plc(X_NUCLEO_PLC01A1_PIN_SPI_CS1, X_NUCLEO_PLC01A1_PIN_SPI_CS2, X_NUCLEO_PLC01A1_PIN_OUT_EN, spi); + /* Initializing X_NUCLEO_PLC01A1 IO Channels Component. */ + X_NUCLEO_PLC01A1 plc(X_NUCLEO_PLC01A1_PIN_SPI_CS1, X_NUCLEO_PLC01A1_PIN_SPI_CS2, X_NUCLEO_PLC01A1_PIN_OUT_EN, spi); while(1) { plc.plcInput().SetReadStatus(1);