nucleo f767zi 3.0 demo board

14
1 Nucleo F767ZI 3p0 demo board NUCLEO F767ZI 3.0 DEMO BOARD 1. Quickstart ................................................................................................................................ 2 1.1 Connect LogicLab using USB-Serial ................................................................................. 2 1.2 Connect LogicLab using Ethernet connection ................................................................... 3 1.3 Configure Ethernet with SoftTune..................................................................................... 5 1.4 Using SoftScope ............................................................................................................... 6 2. Peripheral connection .............................................................................................................. 8 3. Firmware upgrade ................................................................................................................... 9 4. Nucleo firmware and Plugin development ............................................................................. 10 4.1 IOPluginLib user sample plugin ...................................................................................... 10 4.1.1 Project settings......................................................................................................... 11 4.1.2 IOPlugin interface description.................................................................................. 11 4.2 Add plugin to main firmware .......................................................................................... 14

Upload: others

Post on 05-Dec-2021

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: NUCLEO F767ZI 3.0 DEMO BOARD

1 Nucleo F767ZI 3p0 demo board

NUCLEO F767ZI 3.0 DEMO BOARD

1. Quickstart ................................................................................................................................ 2

1.1 Connect LogicLab using USB-Serial ................................................................................. 2

1.2 Connect LogicLab using Ethernet connection ................................................................... 3

1.3 Configure Ethernet with SoftTune ..................................................................................... 5

1.4 Using SoftScope ............................................................................................................... 6

2. Peripheral connection .............................................................................................................. 8

3. Firmware upgrade ................................................................................................................... 9

4. Nucleo firmware and Plugin development ............................................................................. 10

4.1 IOPluginLib user sample plugin ...................................................................................... 10

4.1.1 Project settings ......................................................................................................... 11

4.1.2 IOPlugin interface description .................................................................................. 11

4.2 Add plugin to main firmware .......................................................................................... 14

Page 2: NUCLEO F767ZI 3.0 DEMO BOARD

2 Nucleo F767ZI 3p0 demo board

1. QUICKSTART

1.1 CONNECT LOGICLAB USING USB-SERIAL

It is possible to connect to Nucleo board via USB-Serial connection.

• Connect USB cable into CN1 connector.

• Open LogicLab

• Create new Nucleo_F767ZI_3p0 project

• LogicLab main menu On-line → Set up communication…

• Select “Modbus” protocol → Activate

• Properties

• Configure in this way:

N.B: Specify the USB virtual COM port as recognized by your system

• Click Ok

• On-line → Connect

• In the right-lower corner you should see [CONNECTED]

Page 3: NUCLEO F767ZI 3.0 DEMO BOARD

3 Nucleo F767ZI 3p0 demo board

1.2 CONNECT LOGICLAB USING ETHERNET CONNECTION

It is possible to connect to Nucleo board via Ethernet.

Network scan

By default IP address is assigned to Nucleo by DHCP

• Connect to Ethernet LAN plugging cable into CN14 connector.

• Open LogicLab

• Click “Scan Network…” button

• If Nucleo board can be recognized you should see in this way

N.B: in this case no DHCP server is available, so you should configure static IP address

Configure static IP address

If no DHCP server is available on the network 169.254.x.y address is assigned to Nucleo.

In this case you should modify IP address to set it to static.

• Click on this button to assign a static IP address to Nucleo board

• Enter static IP address in the dialog then press OK

Page 4: NUCLEO F767ZI 3.0 DEMO BOARD

4 Nucleo F767ZI 3p0 demo board

• If address can be changed on the target this dialog appears:

• Reboot target

• Perform network scan again

• Now you will see Nucleo board with the configured IP address

Create new project

• Click on this button

• Enter project name in the dialog

• A new nucleo project will be created (with the right communication settings)

• On-line → Connect

• In the right-lower corner you should see [CONNECTED] in green

Page 5: NUCLEO F767ZI 3.0 DEMO BOARD

5 Nucleo F767ZI 3p0 demo board

1.3 CONFIGURE ETHERNET WITH SOFTTUNE

It is also possible to configure Nucleo board ethernet settings from SoftTune commissioning tool

• Connect USB cable into CN1 connector.

• Open SoftTune

• Create new Nucleo_F767ZI_3p0 project

• Target → Communication settings

• Select “Modbus” protocol → Activate

• Properties

• Configure in this way:

N.B: Specify the USB virtual COM port as recognized by your system

• Click Ok

• Click connection icon

• You should see [CONNECTED]

• On the parameters tree select this menu:

• All Parameters → Communication →Configure TCP IP address

• Specify desired IP address (write parameters into target)

• Save parameters and reboot

Page 6: NUCLEO F767ZI 3.0 DEMO BOARD

6 Nucleo F767ZI 3p0 demo board

• Target → Save parameters

• Target → Device reboot

• Connect LogicLab to target via Ethernet (see 1.2 Ethernet connection)

1.4 USING SOFTSCOPE

SoftScope is now supported by Nucleo (from Nucleo 2p0 20210224 firmware release version). This tool can be used to make real time acquisitions of PLC symbols.

Using SoftScope with Nucleo board requires dedicated Modbus TCP connection that must be configured with “Use dedicated server for this connection”.

Modbus RTU connection via USB port is not supported.

Check LogicLab project communication settings first of all.

• On-line → Set up communication

• Select MobusTCP protocol then click on Activate

• Click on Properties button

• Enter your settings and be sure “Use dedicated server for this connection” option is checked.

Now it is possible to launch SoftScope from LogicLab project in this way

• Main menu Tools Open with SoftScope

Page 7: NUCLEO F767ZI 3.0 DEMO BOARD

7 Nucleo F767ZI 3p0 demo board

• SoftScope is shown with the available PLC symbols that you can drag&drop on the graph and then acquire.

Page 8: NUCLEO F767ZI 3.0 DEMO BOARD

8 Nucleo F767ZI 3p0 demo board

2. PERIPHERAL CONNECTION

Peripheral Connector Description What’s for

Ethernet CN14 RJ45 port Modbus TCP slave

USB CN1 USB-RS232 virtual port

Modbus RTU slave

GPIO – Out CN12 – Pin 11 (PA5) GPIO digital output pin

I/O

GPIO – Out CN12 – Pin 13 (PA6) GPIO digital output pin

GPIO – In CN12 – Pin 23 (PA8) GPIO digital input pin

GPIO – In CN12 – Pin 21 (PA9) GPIO digital input

pin

CAN Rx CN11 – Pin 57 (PD0) CAN Rx signal CAN Open master

CAN Tx CN11 – Pin 55 (PD1) CAN Tx signal

USART 1 RX CN12 – Pin 26 (PB15) RS485 Rx signal

Modbus RTU master USART 1 TX CN12 – Pin 28 (PB14) RS485 Tx signal

USART 1 DE CN12 – Pin 12 (PA12) RS485 Direction enable signal

Page 9: NUCLEO F767ZI 3.0 DEMO BOARD

9 Nucleo F767ZI 3p0 demo board

3. FIRMWARE UPGRADE

This is the procedure to prepare Nucleo F767ZI demo board to run Axel PLC.

N.B: all data on the flash will be erased, license key will be erased too. If target has been already licensed please be sure to have license key available. You can read it from target

using SoftTune before to proceed with target upgrade.

• Download “STM32 ST-LINK Utility” application from ST official website

https://www.st.com/en/development-tools/stsw-link004.html#get-software

• Connect Nucleo F767ZI demo board to PC using USB (CN1 connector)

• Launch “STM32 ST-LINK Utility”

o Connect to target

“Target” → “Connect”

o Erase flash

“Target” → “Erase chip”

o Prepare download

▪ “Target” → “Program & Verify”

▪ Select firmware file from Axel Suite install folder

Es: “C:\Program Files (x86)\Axel PC

Tools\Catalog\Nucleo_F767ZI_3p0\Firmware\NUCLEO_STM32F767ZI_RTOS_3p0.bi

n”

o Upgrade firmware

▪ Click “Start”

Page 10: NUCLEO F767ZI 3.0 DEMO BOARD

10 Nucleo F767ZI 3p0 demo board

4. NUCLEO FIRMWARE AND PLUGIN DEVELOPMENT

With Nucleo F767ZI 3.0 demo is possible to write a user plugin to add custom functionalities to default implementation.

Plugin development allows the user to add:

• embedded functions

• datablocks

• callback related to events

User can develop a plugin library project with its own implementation and run it together with the already available firmware core functions.

Nucleo firmware source demo project is available for STM32 F767ZI demo board.

Firmware source consist of four project:

• NUCLEO_STM32F767ZI_RTOS – main project

o Contains .ioc project file for ST code generation

o Main PLC porting feature

o Database

o Modbus TCP slave communication stack

o TCP scan support for target identification

• COPMLib – lib project

o The CANopen master project

• ModbusRTULib – lib project

o The Modbus RTU master/slave project

• ModbusTCPMasterLib – lib project

o The Modbus TCP master project

• SoftScopeLib – lib project

o The SoftScope real time oscilloscope project

• SymbolsServerLib – lib project

o Symbols server for LLSymbols client

• IOPluginLib – lib project

o IO Plugin sample project

IOPluginLib is here described in details as explanation on how it is possible to add plugins to your project.

4.1 IOPLUGINLIB USER SAMPLE PLUGIN

IOPluginLib is provided as sample plugin for Nucleo demo board to show how to do a plugin with custom user functionalities.

• This plugin is used to manage 4 GPIOs: 2 inputs + 2 outputs in this way

• GPIO configuration set at startup

• I/O datablocks are published to LogicLab

• Inputs are read each time the task Fast is executed by system (using callback event)

Page 11: NUCLEO F767ZI 3.0 DEMO BOARD

11 Nucleo F767ZI 3p0 demo board

• Outputs are written each time the task Fast is executed by system (using callback event)

4.1.1 PROJECT SETTINGS

• Sample project has been created using STM32 Cube IDE 3.0.0 as C static library empty project for STM32 F767ZITx target.

• These include paths have then been added to access system and driver functions.

Project properties →C++ Build →Tool Settings. MCU GCC Compiler →Include paths

"${workspace_loc:/NUCLEO_STM32F767ZI_RTOS/Drivers/CMSIS/Device/ST/STM32F7xx/Include}"

"${workspace_loc:/NUCLEO_STM32F767ZI_RTOS/Drivers/CMSIS/Include}"

"${workspace_loc:/NUCLEO_STM32F767ZI_RTOS/Drivers/STM32F7xx_HAL_Driver/Inc}"

"${workspace_loc:/NUCLEO_STM32F767ZI_RTOS/Drivers/STM32F7xx_HAL_Driver/Inc/Legacy}"

"${workspace_loc:/NUCLEO_STM32F767ZI_RTOS/Inc}"

"${workspace_loc:/NUCLEO_STM32F767ZI_RTOS}"

"${workspace_loc:/NUCLEO_STM32F767ZI_RTOS/Src}"

• In addition, if RTOS is required by your plugin add this includes:

"${workspace_loc:/NUCLEO_STM32F767ZI_RTOS/Middlewares/Third_Party/FreeRTOS/Source/include}"

"${workspace_loc:/NUCLEO_STM32F767ZI_RTOS/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS

_V2}"

"${workspace_loc:/NUCLEO_STM32F767ZI_RTOS/Middlewares/Third_Party/FreeRTOS/Source/portable/G

CC/ARM_CM7/r0p1}"

• These project defines have been defined to use the same micro and AlPlcRuntime defines of the main project. MCU GCC Compiler →Preprocessor

STM32F767xx, USE_HAL_DRIVER, ALPLC_C_GCCARM, ALPLC_P_ARM_THUMB2VFP2, USE_STDINT_FOR_MISRA_C

4.1.2 IOPLUGIN INTERFACE DESCRIPTION

IOPlugin public interface

IOPluginLib.h is the header plugin interface that public IOPlugin_Init function used by firmware core to link this plugin.

void IOPlugin_Init(void);

IOPluginLib.c provides the implementation of the plugin interface

IOPlugin_Init function

void IOPlugin_Init()

{

MX_GPIO_Init();

/* mandatory to force plugin interface allocation */

ALPLC_PLUGIN_ADD( IOPlugin )

Page 12: NUCLEO F767ZI 3.0 DEMO BOARD

12 Nucleo F767ZI 3p0 demo board

}

This function must be called before AlPlcInit() function.

In Nucleo it is called in PluginsManager.c file under IOPLUGIN define.

IOPlugin is the unique name of the plugin. This name must be same in all macro declaration of the plugin.

Plugin interface is defined in this c source and here described in details:

Embedded functions table

ALPLC_FUNCTIONS_TABLE_INI( IOPlugin ) // start table definition

ALFCNREC_FUNC( TestFunc ) // function to publish

ALPLC_FUNCTIONS_TABLE_END // end table definition

Even if no functions are published definition is mandatory.

To publish functions add between ALPLC_FUNCTIONS_TABLE_INI and ALPLC_FUNCTIONS_TABLE_END macro a series of ALFCNREC_FUNC records indicating the function to call. Functions will be published to LogicLab with the same name of the C code function name.

Datablocks table

ALPLC_DATABLOCKS_TABLE_INI( IOPlugin ) // start table definition

ALDBREC_INPUT( 0, m_sysDigitalInputs, sizeof(m_sysDigitalInputs[0]), DBRW_R )

ALDBREC_OUTPUT( 0, m_sysDigitalOutputs, sizeof(m_sysDigitalOutputs[0]), DBRW_RW )

ALPLC_DATABLOCKS_TABLE_END // end table definition

Datablock table definition is mandatory, starts with ALPLC_DATABLOCKS_TABLE_INI and

terminate with ALPLC_DATABLOCKS_TABLE_END.

In this case two datablocks have been added using macro:

ALDBREC_INPUT to publish the digital inputs datablock as DBTY_INP datablock with index

0.

ALDBREC_OUTPUT to publish the digital outputs datablock as DBTY_OUT datablock with index 0.

With this kind of definition the whole array is published.

It is possible to use ALDBREC_MEMO macro to add memo datablocks with default settings or ALDBREC_EX macro to specify each setting.

Callback data definition

ALCBKREC_DATA(OnBeforeTaskFast)

Page 13: NUCLEO F767ZI 3.0 DEMO BOARD

13 Nucleo F767ZI 3p0 demo board

Some callback types (high priority callbacks) require additional definition to provide memory to AlPlcRuntime in order to manage properly callbacks.

This is the case of ALCBKREC_ON_BEFORE_PLC_TASK_IO that is used to call

OnBeforeTaskFast.function. ALCBKREC_DATA definition is used for this.

See AlPlcUserPlugin.h the list of callbacks that requires this definition. If no definition is provided compile error is given.

Callback table definition

ALPLC_CALLBACKS_TABLE_INI( IOPlugin ) // start table definition

ALCBKREC_ON_BEFORE_PLC_TASK_IO(OnBeforeTaskFast)

ALPLC_CALLBACKS_TABLE_END // end table definition

Callbacks table definition is mandatory, starts with ALPLC_DATABLOCKS_TABLE_INI and terminate with ALPLC_DATABLOCKS_TABLE_END.

In IOPlugin the only callback associated is the OnBeforeTaskFast function associated to the on before plc task IO event (that is raised periodically in task fast).

Internal functions definition

ALPLC_INTERNAL_FUNCTIONS_TABLE_INI( IOPlugin ) // start table definition

ALFCNREC_INTERNAL_FUNC( IOPlugin_GetDigitalInput )

ALFCNREC_INTERNAL_FUNC( IOPlugin_GetDigitalOutput )

ALFCNREC_INTERNAL_FUNC( IOPlugin_SetDigitalOutput )

ALPLC_INTERNAL_FUNCTIONS_TABLE_END

Internal function table definition is mandatory, starts with

ALPLC_INTERNAL_FUNCTIONS_TABLE_INI and terminate with ALPLC_INTERNAL_FUNCTIONS_TABLE_END.

It is possible to specify in this section functions that can be called by other plugins or firmware code by “name” using AlPlc_GetFunctionAddr avoiding direct dipendencies

Plugin definition

ALPLC_PLUGIN_DEFINITION( IOPlugin )

This is the definition of the plugin. This definition is mandatory.

Full documentation

Other documentation is available in SP05012-PLCIecDriver.pdf, section 4.11 User Plugins

Page 14: NUCLEO F767ZI 3.0 DEMO BOARD

14 Nucleo F767ZI 3p0 demo board

4.2 ADD PLUGIN TO MAIN FIRMWARE

If you want to create a new plugin you should start creating a library project (as explained in 4.1.1 Project settings), you should provide the plugin definition as explained in the sample project. See 4.3 User plugin definition for more information.

Once you got your plugin library you can link it from main Nucleo firmware project.

• Project properties →C++ Build →Tool Settings. MCU GCC Linker →Libraries

Libraries box: Add your plugin library here

• Project properties →C++ Build →Tool Settings. MCU GCC Linker →Libraries

Libraries search path box: Add the path of the plugin library

• In PluginsManager.c #include the file “yourPluginLib.h” where the init function is declared.

The init function is the function that call the ALPLC_PLUGIN_ADD function.

In the IOPluginLib sample is the IOPlugin_Init function.

• In PluginsManager.c go to PluginsInit function and add the init function call here.