Skip to content

Commit 5d3938c

Browse files
committed
Update library version to 1.3.0 and add new I/O plugin headers for enhanced functionality.
Other features: * Hide the 2nd debug COM port * Access directly I/O variables in sketch * Read/write RTC clock * Watchdog (NB: VEDI SOTTO) * New partitioning scheme * Support NTP * Support update over Modbus TCP
1 parent a71af4d commit 5d3938c

File tree

10 files changed

+170
-2
lines changed

10 files changed

+170
-2
lines changed

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=AlPlc_Opta
2-
version=1.2.0
2+
version=1.3.0
33
author=Arduino
44
maintainer=Arduino <[email protected]>
55
sentence=Arduino IDE PLC runtime library for Arduino Opta

src/AlPlc_Opta.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#include <ArduinoRS485.h>
1313
#include <PortentaEthernet.h>
1414
#include <OptaBlue.h>
15+
#include <STM32H747_System.h>
16+
#include <Arduino_Portenta_OTA.h>
1517

1618
extern "C" void sysMbMRtu_SetPostDelay(uint16_t delay);
1719

@@ -22,10 +24,11 @@ extern uint8_t m_PLCSharedVarsInputBuf[];
2224
class AlPlc
2325
{
2426
public:
25-
AlPlc(int32_t sketchCrc);
27+
AlPlc(int32_t sketchCrc, bool debugMode = false);
2628
void Run();
2729
void ListFiles(bool resetPlc);
2830
void InitFileSystem();
31+
void MbTCP_EnablePLCRuntimeConn();
2932
};
3033

3134
#endif

src/IOPlugin.h

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#ifndef IOPLUGIN_H
2+
#define IOPLUGIN_H
3+
4+
/* local I/O */
5+
6+
#if defined( ARDUINO_PORTENTA_H7_M7 )
7+
8+
#include "ArduinoSpec/IODriver.h"
9+
10+
extern bool_t sysDigitalInputs[NUM_DIGITAL_INPUTS];
11+
extern bool_t sysDigitalOutputs[NUM_DIGITAL_OUTPUTS];
12+
13+
extern int32_t sysAnalogInputs[NUM_ANALOG_INPUTS];
14+
extern float sysAnalogOutputs[NUM_ANALOG_OUTPUTS];
15+
extern bool_t sysProgrammableDigitalIO[NUM_PROG_DIGITAL_IO];
16+
17+
extern SYS_TEMPPROBE_TYPE sysTempProbes[NUM_SYS_TEMP_PROBES];
18+
19+
extern sysEncoderInputType sysEncoders[NUM_SYS_ENCODERS];
20+
21+
#elif defined( ARDUINO_OPTA )
22+
23+
#include "IOPluginDefs.h"
24+
25+
extern uint16_t sysProgrammableInputs[NUM_PROG_INPUTS];
26+
extern bool_t sysRelayOutputs[NUM_RELAY_OUTPUTS];
27+
extern bool_t sysLEDOutputs[NUM_LED_OUTPUTS];
28+
extern bool_t sysButtonInputs[NUM_BUTTON_INPUTS];
29+
30+
typedef union
31+
{
32+
struct
33+
{
34+
uint16_t programmableInputs[OPTA_DIGITAL_IN_NUM]; // bool_t / uint16_t
35+
} digital; // 32 bytes
36+
37+
struct
38+
{
39+
ProgChannel_t analogInputs[OPTA_ANALOG_IN_NUM]; // float / uint16_t / bool_t
40+
} analog; // 32 bytes
41+
} ExpInput_t;
42+
43+
typedef union
44+
{
45+
struct
46+
{
47+
bool_t relayOutputs[OPTA_DIGITAL_OUT_NUM];
48+
} digital; // 8 bytes
49+
50+
struct
51+
{
52+
ProgChannel_t analogOutputs[OPTA_ANALOG_OUT_NUM]; // float / uint16_t
53+
PWM_t pwmOutputs[OPTA_PWM_OUT_NUM];
54+
bool_t ledOutputs[OPTA_LED_OUT_NUM];
55+
} analog; // 72 bytes
56+
} ExpOutput_t;
57+
58+
extern ExpInput_t sysExpInputs [MAX_OPTA_IOEXP];
59+
extern ExpOutput_t sysExpOutputs[MAX_OPTA_IOEXP];
60+
#endif
61+
62+
bool_t IOPlugin_GetDigitalInput(uint8_t id);
63+
bool_t IOPlugin_GetDigitalOutput(uint8_t id);
64+
bool_t IOPlugin_SetDigitalOutput(uint8_t id, bool_t value);
65+
int32_t IOPlugin_GetAnalogInput(uint8_t id);
66+
int32_t IOPlugin_GetAnalogOutput(uint8_t id);
67+
bool_t IOPlugin_SetAnalogOutput(uint8_t id, int32_t value);
68+
69+
#endif // IOPLUGIN_H

src/IOPluginDefs.h

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
#pragma once
2+
3+
// also defined in AlPlcMisrac.h ; howevere required here to let include this .h directly in the sketch
4+
typedef uint8_t bool_t;
5+
6+
#if defined( ARDUINO_PORTENTA_H7_M7 )
7+
8+
#define NUM_DIGITAL_INPUTS 8
9+
#define NUM_DIGITAL_OUTPUTS 8
10+
#define NUM_ANALOG_INPUTS 3 // DINT
11+
#define NUM_ANALOG_OUTPUTS 4 // REAL
12+
#define NUM_PROG_DIGITAL_IO 12
13+
#define NUM_SYS_TEMP_PROBES 3 // REAL
14+
#define NUM_SYS_ENCODERS 2 // DINT*3
15+
16+
#define IO_TOT_DIGITAL_OUTPUTS (NUM_DIGITAL_OUTPUTS + NUM_PROG_DIGITAL_IO)
17+
#define IO_TOT_DIGITAL_INPUTS NUM_DIGITAL_INPUTS
18+
#define IO_TOT_ANALOG_OUTPUTS NUM_ANALOG_OUTPUTS
19+
#define IO_TOT_ANALOG_INPUTS (NUM_ANALOG_INPUTS + NUM_SYS_TEMP_PROBES)
20+
21+
typedef struct _sysEncoderInputType
22+
{
23+
int currentState;
24+
int pulsesCount;
25+
int revolutionsCount;
26+
} sysEncoderInputType;
27+
28+
#elif defined( ARDUINO_OPTA )
29+
30+
// da Arduino_Opta_Blueprint\src
31+
// invece di includere OptaBlue.h che è la "radice" che tirerebbe dentro c++ include qui questo solo per numero i/o
32+
#include <DigitalCommonCfg.h>
33+
#include <AnalogCommonCfg.h>
34+
35+
// diciture "simili" a quelle di DigitalCommonCfg.h
36+
#define OPTA_ANALOG_IN_NUM OA_AN_CHANNELS_NUM // programmabile, fino a max 8
37+
#define OPTA_ANALOG_OUT_NUM OA_AN_CHANNELS_NUM // programmabile, fino a max 8
38+
#define OPTA_PWM_OUT_NUM OA_PWM_CHANNELS_NUM // 4 pwm
39+
#define OPTA_LED_OUT_NUM OA_LED_NUM
40+
41+
typedef struct
42+
{
43+
uint32_t period;
44+
uint32_t pulse;
45+
} PWM_t;
46+
47+
typedef union
48+
{
49+
float rtd;
50+
uint16_t an;
51+
bool_t dig;
52+
int32_t raw;
53+
} ProgChannel_t;
54+
55+
#define NUM_PROG_INPUTS 8
56+
#define NUM_RELAY_OUTPUTS 4
57+
#define NUM_LED_OUTPUTS 7
58+
#define NUM_BUTTON_INPUTS 1
59+
60+
// al momento minore di quello effettivamente supportato dalla libreria (OPTA_CONTROLLER_MAX_EXPANSION_NUM=10), concordato con Arduino
61+
#define MAX_OPTA_IOEXP 5
62+
typedef uint16_t ExpType_t;
63+
64+
#define IO_TOT_ANEXP_OUT (OPTA_ANALOG_OUT_NUM + OPTA_PWM_OUT_NUM * 2) // 16 out per exp
65+
66+
#define IO_TOT_DIGITAL_INPUTS (NUM_PROG_INPUTS + NUM_BUTTON_INPUTS + MAX_OPTA_IOEXP*OPTA_DIGITAL_IN_NUM)
67+
#define IO_TOT_DIGITAL_OUTPUTS (NUM_RELAY_OUTPUTS + NUM_LED_OUTPUTS + MAX_OPTA_IOEXP*OPTA_DIGITAL_OUT_NUM)
68+
// poichè su exp digitale i prog inputs si possono usare anche come analog e sono di più degli input della exp analogica, usa quelli
69+
#define IO_TOT_ANALOG_INPUTS (NUM_PROG_INPUTS + MAX_OPTA_IOEXP*OPTA_DIGITAL_IN_NUM)
70+
#define IO_TOT_ANALOG_OUTPUTS (MAX_OPTA_IOEXP*IO_TOT_ANEXP_OUT)
71+
72+
#endif
73+
74+
// GetDigitalInput
75+
#define IOPLUGIN_GETDIGITALINPUT_FN "IOPlugin_GetDigitalInput"
76+
typedef bool_t (* IOPlugin_GetDigitalInput_func)( uint8_t id );
77+
78+
// GetDigitalOutput
79+
#define IOPLUGIN_GETDIGITALOUTPUT_FN "IOPlugin_GetDigitalOutput"
80+
typedef bool_t (* IOPlugin_GetDigitalOutput_func)( uint8_t id );
81+
82+
// SetDigitalOutput
83+
#define IOPLUGIN_SETDIGITALOUTPUT_FN "IOPlugin_SetDigitalOutput"
84+
typedef bool_t (* IOPlugin_SetDigitalOutput_func)( uint8_t id, bool_t value );
85+
86+
// GetAnalogInput
87+
#define IOPLUGIN_GETANALOGINPUT_FN "IOPlugin_GetAnalogInput"
88+
typedef int32_t (* IOPlugin_GetAnalogInput_func)( uint8_t id );
89+
90+
// GetAnalogOutput
91+
#define IOPLUGIN_GETANALOGOUTPUT_FN "IOPlugin_GetAnalogOutput"
92+
typedef int32_t (* IOPlugin_GetAnalogOutput_func)( uint8_t id );
93+
94+
// SetAnalogOutput
95+
#define IOPLUGIN_SETANALOGOUTPUT_FN "IOPlugin_SetAnalogOutput"
96+
typedef bool_t (* IOPlugin_SetAnalogOutput_func)( uint8_t id, int32_t value );

src/cortex-m7/libAlIOPlugin.a

-36 Bytes
Binary file not shown.
-138 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

src/cortex-m7/libAlPlc.a

276 KB
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)