Library to handle the X-NUCLEO-PLC01A1 Programmable Logic Controller Expansion Board based on the VNI8200XP (solid state relay) and CLT01-38SQ7 (octal digital termination array) components.

Dependents:   HelloWorld_PLC01A1

Programmable Logic Controller Library

Library to handle the X-NUCLEO-PLC01A1 Programmable Logic Controller Expansion Board based on the VNI8200XP (solid state relay) and CLT01-38SQ7 (octal digital termination array) components.

Information

For further details on VNI8200XP (Octal high side smart power solid state relay with serial/parallel selectable interface on chip) please refer to ST's web site.

For further details on CLT01-38SQ7 (High speed digital input current limiter) please refer to ST's web site.

SPI configuration

Pin D3 and D13 providing the SPI serial clock are short-circuited in the X-NUCLEO-PLC01A1 Expansion Board.

Please be aware that you may not drive the base board LED if it is connected to pin D13 (as it happens on STM32 Nucleo boards) or D3, otherwise you will get a conflict.

Platform compatibility

  • STM32 NUCLEO boards have been tested with the default configuration provided by the HelloWorld_PLC01A1 example.

return DSPI_HAL_ReadData(spi_address[obj->instance]);

X-NUCLEO-PLC01A1 board powering and startup

The following steps must be followed to run the X-NUCLEO-PLC01A1:

  1. Plug the X-NUCLEO-PLC01A1 onto a base board
  2. Connect the base board to a PC via a standard Type A / mini (or micro) B USB cable
  3. Download the firmware on the MCU hosted on the base board
  4. Supply 24 V to the X-NUCLEO-PLC01A1 board through the J8 connector
  5. The HelloWorld_PLC01A1 demonstration firmware is ready to run: connect any of the 8 inputs on the J8 connector to see the corresponding output on the J10 connector capable of driving a load (i.e. short-circuit input “x” with the 24 V and connect the corresponding output “x” to a load).
Committer:
apalmieri
Date:
Mon Jul 12 10:09:44 2021 +0000
Revision:
7:5d4336d0e372
Parent:
5:0845d4141a01
Update to mbed-os 6 (mbed-os-6.12.0)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Davidroid 5:0845d4141a01 1 /**
Davidroid 5:0845d4141a01 2 ******************************************************************************
Davidroid 5:0845d4141a01 3 * @file XNucleoPLC01A1.h
Davidroid 5:0845d4141a01 4 * @author AST/CL
Davidroid 5:0845d4141a01 5 * @version V1.1.0
Davidroid 5:0845d4141a01 6 * @date February 23rd, 2016
Davidroid 5:0845d4141a01 7 * @brief Class header file for the X_NUCLEO_PLC01A1 expansion board.
Davidroid 5:0845d4141a01 8 ******************************************************************************
Davidroid 5:0845d4141a01 9 * @attention
Davidroid 5:0845d4141a01 10 *
Davidroid 5:0845d4141a01 11 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
Davidroid 5:0845d4141a01 12 *
Davidroid 5:0845d4141a01 13 * Redistribution and use in source and binary forms, with or without modification,
Davidroid 5:0845d4141a01 14 * are permitted provided that the following conditions are met:
Davidroid 5:0845d4141a01 15 * 1. Redistributions of source code must retain the above copyright notice,
Davidroid 5:0845d4141a01 16 * this list of conditions and the following disclaimer.
Davidroid 5:0845d4141a01 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
Davidroid 5:0845d4141a01 18 * this list of conditions and the following disclaimer in the documentation
Davidroid 5:0845d4141a01 19 * and/or other materials provided with the distribution.
Davidroid 5:0845d4141a01 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
Davidroid 5:0845d4141a01 21 * may be used to endorse or promote products derived from this software
Davidroid 5:0845d4141a01 22 * without specific prior written permission.
Davidroid 5:0845d4141a01 23 *
Davidroid 5:0845d4141a01 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Davidroid 5:0845d4141a01 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Davidroid 5:0845d4141a01 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Davidroid 5:0845d4141a01 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
Davidroid 5:0845d4141a01 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Davidroid 5:0845d4141a01 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Davidroid 5:0845d4141a01 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Davidroid 5:0845d4141a01 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Davidroid 5:0845d4141a01 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Davidroid 5:0845d4141a01 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Davidroid 5:0845d4141a01 34 *
Davidroid 5:0845d4141a01 35 ******************************************************************************
Davidroid 5:0845d4141a01 36 */
Davidroid 5:0845d4141a01 37
Davidroid 5:0845d4141a01 38
Davidroid 5:0845d4141a01 39 /* Define to prevent recursive inclusion -------------------------------------*/
Davidroid 5:0845d4141a01 40
Davidroid 5:0845d4141a01 41 #ifndef __X_NUCLEO_PLC01A1_CLASS_H
Davidroid 5:0845d4141a01 42 #define __X_NUCLEO_PLC01A1_CLASS_H
Davidroid 5:0845d4141a01 43
Davidroid 5:0845d4141a01 44
Davidroid 5:0845d4141a01 45 /* Includes ------------------------------------------------------------------*/
Davidroid 5:0845d4141a01 46
Davidroid 5:0845d4141a01 47 /* ACTION 1 ------------------------------------------------------------------*
Davidroid 5:0845d4141a01 48 * Include here platform specific header files. *
Davidroid 5:0845d4141a01 49 *----------------------------------------------------------------------------*/
Davidroid 5:0845d4141a01 50 #include "mbed.h"
Davidroid 5:0845d4141a01 51 /* ACTION 2 ------------------------------------------------------------------*
Davidroid 5:0845d4141a01 52 * Include here expansion board configuration's header files. *
Davidroid 5:0845d4141a01 53 *----------------------------------------------------------------------------*/
Davidroid 5:0845d4141a01 54 #include "x_nucleo_plc01a1_config.h"
Davidroid 5:0845d4141a01 55 /* ACTION 3 ------------------------------------------------------------------*
Davidroid 5:0845d4141a01 56 * Include here expansion board's components' header files. *
Davidroid 5:0845d4141a01 57 * *
Davidroid 5:0845d4141a01 58 * Example: *
Davidroid 5:0845d4141a01 59 * #include "COMPONENT_1.h" *
Davidroid 5:0845d4141a01 60 * #include "COMPONENT_2.h" *
Davidroid 5:0845d4141a01 61 *----------------------------------------------------------------------------*/
Davidroid 5:0845d4141a01 62 #include "CLT01_38S.h"
Davidroid 5:0845d4141a01 63 #include "VNI8200XP.h"
Davidroid 5:0845d4141a01 64
Davidroid 5:0845d4141a01 65
Davidroid 5:0845d4141a01 66 /* Classes ------------------------------------------------------------------*/
Davidroid 5:0845d4141a01 67
Davidroid 5:0845d4141a01 68 class XNucleoPLC01A1
Davidroid 5:0845d4141a01 69 {
Davidroid 5:0845d4141a01 70 public:
Davidroid 5:0845d4141a01 71
Davidroid 5:0845d4141a01 72 /*** Constructor and Destructor Methods ***/
Davidroid 5:0845d4141a01 73
Davidroid 5:0845d4141a01 74 /**
Davidroid 5:0845d4141a01 75 * @brief Constructor.
Davidroid 5:0845d4141a01 76 * @param input_ssel pin name of the SSEL pin of the SPI device to be used for communication with Input Channels component
Davidroid 5:0845d4141a01 77 * @param output_ssel pin name of the SSEL pin of the SPI device to be used for communication with Output Channels component
Davidroid 5:0845d4141a01 78 * @param spi SPI device to be used for communication.
Davidroid 5:0845d4141a01 79 */
Davidroid 5:0845d4141a01 80 XNucleoPLC01A1(PinName input_ssel, PinName output_ssel, PinName out_en, SPI &spi) : plcIn(input_ssel, spi), plcOut(out_en, output_ssel, spi), freezeTo(false), attached(false)
Davidroid 5:0845d4141a01 81 {
Davidroid 5:0845d4141a01 82 if (plcIn.init() != COMPONENT_OK)
Davidroid 5:0845d4141a01 83 exit(EXIT_FAILURE);
Davidroid 5:0845d4141a01 84
Davidroid 5:0845d4141a01 85 if (plcOut.init() != COMPONENT_OK)
Davidroid 5:0845d4141a01 86 exit(EXIT_FAILURE);
Davidroid 5:0845d4141a01 87
Davidroid 5:0845d4141a01 88 outBuff[0] = 0;
Davidroid 5:0845d4141a01 89 outBuff[1] = 0;
Davidroid 5:0845d4141a01 90 }
Davidroid 5:0845d4141a01 91
Davidroid 5:0845d4141a01 92 /**
Davidroid 5:0845d4141a01 93 * @brief Destructor.
Davidroid 5:0845d4141a01 94 */
Davidroid 5:0845d4141a01 95 virtual ~XNucleoPLC01A1(void) {}
Davidroid 5:0845d4141a01 96
Davidroid 5:0845d4141a01 97 /*
Davidroid 5:0845d4141a01 98 * Accessors to PLC input channels component. Please refer to "PLCInput.h".
Davidroid 5:0845d4141a01 99 * All PLCInput related unctionality requires going through this accessor.
Davidroid 5:0845d4141a01 100 */
Davidroid 5:0845d4141a01 101 const PLCInput& plc_input() const {
Davidroid 5:0845d4141a01 102 return plcIn;
Davidroid 5:0845d4141a01 103 }
Davidroid 5:0845d4141a01 104 PLCInput& plc_input() {
Davidroid 5:0845d4141a01 105 return plcIn;
Davidroid 5:0845d4141a01 106 }
Davidroid 5:0845d4141a01 107
Davidroid 5:0845d4141a01 108 /*
Davidroid 5:0845d4141a01 109 * Accessors to PLC output channels component. Please refer to "PLCOutput.h".
Davidroid 5:0845d4141a01 110 * All PLCOutput related functionality requires going through this accessor.
Davidroid 5:0845d4141a01 111 */
Davidroid 5:0845d4141a01 112 const PLCOutput& plc_output() const {
Davidroid 5:0845d4141a01 113 return plcOut;
Davidroid 5:0845d4141a01 114 }
Davidroid 5:0845d4141a01 115 PLCOutput& plc_output() {
Davidroid 5:0845d4141a01 116 return plcOut;
Davidroid 5:0845d4141a01 117 }
Davidroid 5:0845d4141a01 118
Davidroid 5:0845d4141a01 119 /*
Davidroid 5:0845d4141a01 120 * @brief Mirrors input data
Davidroid 5:0845d4141a01 121 * @param Input channel state buffer
Davidroid 5:0845d4141a01 122 * @retval Input buffer state
Davidroid 5:0845d4141a01 123 */
Davidroid 5:0845d4141a01 124 uint8_t signal_mirror(uint8_t In_Array);
Davidroid 5:0845d4141a01 125
Davidroid 5:0845d4141a01 126 /*
Davidroid 5:0845d4141a01 127 * @brief Freeze selected output for a given time
Davidroid 5:0845d4141a01 128 * @param Output channels to be freezed
Davidroid 5:0845d4141a01 129 * @param Duration of freeze
Davidroid 5:0845d4141a01 130 * @retval Output value
Davidroid 5:0845d4141a01 131 */
Davidroid 5:0845d4141a01 132 uint8_t output_freeze(uint8_t N_Channel, uint16_t msec);
Davidroid 5:0845d4141a01 133
Davidroid 5:0845d4141a01 134 /*
Davidroid 5:0845d4141a01 135 * @brief Regroup output buffer according to out_Array
Davidroid 5:0845d4141a01 136 * @param Regroup array
Davidroid 5:0845d4141a01 137 * @retval Value
Davidroid 5:0845d4141a01 138 */
Davidroid 5:0845d4141a01 139 uint8_t output_regroup(uint8_t Out_Array);
Davidroid 5:0845d4141a01 140
Davidroid 5:0845d4141a01 141 /*
Davidroid 5:0845d4141a01 142 * @brief Sum all the inputs at high state
Davidroid 5:0845d4141a01 143 * @param Input channel state data
Davidroid 5:0845d4141a01 144 * @retval Value corresponding to the sum of inputs at high
Davidroid 5:0845d4141a01 145 */
Davidroid 5:0845d4141a01 146 uint8_t input_sum(uint8_t* Buffer, uint8_t In_Array);
Davidroid 5:0845d4141a01 147
Davidroid 5:0845d4141a01 148 /*
Davidroid 5:0845d4141a01 149 * @brief Set the output channels on/off
Davidroid 5:0845d4141a01 150 * @param Output to set
Davidroid 5:0845d4141a01 151 * @retval Output value
Davidroid 5:0845d4141a01 152 */
Davidroid 5:0845d4141a01 153 uint8_t set_output(uint8_t Out_Array);
Davidroid 5:0845d4141a01 154
Davidroid 5:0845d4141a01 155 /*
Davidroid 5:0845d4141a01 156 * @brief AND Inputs for selected output channels
Davidroid 5:0845d4141a01 157 * @param Input channels state
Davidroid 5:0845d4141a01 158 * @param Outputs to be AND with inputs
Davidroid 5:0845d4141a01 159 * @retval Result of AND operation
Davidroid 5:0845d4141a01 160 */
Davidroid 5:0845d4141a01 161 uint8_t inputs_and(uint8_t In_Array, uint8_t Out_Channel);
Davidroid 5:0845d4141a01 162
Davidroid 5:0845d4141a01 163 /*
Davidroid 5:0845d4141a01 164 * @brief OR Inputs for selected output channels
Davidroid 5:0845d4141a01 165 * @param Input channels state
Davidroid 5:0845d4141a01 166 * @param Outputs to be OR with inputs
Davidroid 5:0845d4141a01 167 * @retval Result of OR operation
Davidroid 5:0845d4141a01 168 */
Davidroid 5:0845d4141a01 169 uint8_t inputs_or(uint8_t In_Array, uint8_t Out_Channel);
Davidroid 5:0845d4141a01 170
Davidroid 5:0845d4141a01 171 /*
Davidroid 5:0845d4141a01 172 * @brief NOT Inputs
Davidroid 5:0845d4141a01 173 * @param Input channels state
Davidroid 5:0845d4141a01 174 * @retval Result of OR operation
Davidroid 5:0845d4141a01 175 */
Davidroid 5:0845d4141a01 176 uint8_t inputs_not(uint8_t In_Array);
Davidroid 5:0845d4141a01 177
Davidroid 5:0845d4141a01 178 /*
Davidroid 5:0845d4141a01 179 * @brief XOR Inputs for selected output channels
Davidroid 5:0845d4141a01 180 * @param Input channels state
Davidroid 5:0845d4141a01 181 * @param Outputs to be XOR with inputs
Davidroid 5:0845d4141a01 182 * @retval Result of XOR operation
Davidroid 5:0845d4141a01 183 */
Davidroid 5:0845d4141a01 184 uint8_t inputs_xor(uint8_t In_Array, uint8_t Out_Channel);
Davidroid 5:0845d4141a01 185
Davidroid 5:0845d4141a01 186 /*
Davidroid 5:0845d4141a01 187 * @brief Calculate and set parity bits for Ssrelay transmission
Davidroid 5:0845d4141a01 188 * @param Output value buffer
Davidroid 5:0845d4141a01 189 * @retval None
Davidroid 5:0845d4141a01 190 */
Davidroid 5:0845d4141a01 191 void output_parity_bits(uint8_t* Buffer);
Davidroid 5:0845d4141a01 192
Davidroid 5:0845d4141a01 193 /*
Davidroid 5:0845d4141a01 194 * @brief Toggle selected output for given frequency
Davidroid 5:0845d4141a01 195 * @param Output channels to be toggled
Davidroid 5:0845d4141a01 196 * @retval None
Davidroid 5:0845d4141a01 197 */
Davidroid 5:0845d4141a01 198 void output_cycling(void);
Davidroid 5:0845d4141a01 199
Davidroid 5:0845d4141a01 200 protected:
Davidroid 5:0845d4141a01 201 void handle_freeze_to(void);
Davidroid 5:0845d4141a01 202 void toggle_output(void);
Davidroid 5:0845d4141a01 203
Davidroid 5:0845d4141a01 204 CLT01_38S plcIn;
Davidroid 5:0845d4141a01 205 VNI8200XP plcOut;
Davidroid 5:0845d4141a01 206
Davidroid 5:0845d4141a01 207 Timeout timeout;
Davidroid 5:0845d4141a01 208 bool freezeTo;
Davidroid 5:0845d4141a01 209 bool attached;
Davidroid 5:0845d4141a01 210
Davidroid 5:0845d4141a01 211 Ticker ticker;
Davidroid 5:0845d4141a01 212 uint8_t outBuff[2];
Davidroid 5:0845d4141a01 213 };
Davidroid 5:0845d4141a01 214
Davidroid 5:0845d4141a01 215 #endif /* __X_NUCLEO_PLC01A1_CLASS_H */
Davidroid 5:0845d4141a01 216
Davidroid 5:0845d4141a01 217 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/