7
7
from the interface RX channel.
8
8
9
9
Circuit:
10
- - Portenta H7
11
- - Machine Control
12
- - A Slave device with RS232 interface
13
- - Connect TXN to RXD Slave RS232 channel
14
- - Connect RSXN to TXD Slave RS232 channel
10
+ - Arduino Portenta Machine Control (PMC)
11
+ - Device with RS232 interface
12
+ - Connect PMC TXN to RS232 Device RXD
13
+ - Connect PMC RXP to RS232 Device TXD
14
+ - Connect PMC GND to RS232 Device GND
15
15
16
16
*/
17
17
18
- #include " Arduino_MachineControl.h"
18
+ #include < Arduino_MachineControl.h>
19
19
20
20
using namespace machinecontrol ;
21
21
@@ -39,15 +39,18 @@ void setup()
39
39
comm_protocols.init ();
40
40
41
41
// RS485/RS232 default config is:
42
+ // - RS485/RS232 system disabled
42
43
// - RS485 mode
43
44
// - Half Duplex
44
45
// - No A/B and Y/Z 120 Ohm termination enabled
45
46
46
47
// Enable the RS485/RS232 system
47
- comm_protocols.rs485Enable (false );
48
+ comm_protocols.rs485Enable (true );
49
+ // Enable the RS232 mode
50
+ comm_protocols.rs485ModeRS232 (true );
48
51
49
- // Specify baudrate, and preamble and postamble times for RS485 communication
50
- comm_protocols.rs485 .begin (115200 , 0 , 500 );
52
+ // Specify baudrate for RS232 communication
53
+ comm_protocols.rs485 .begin (115200 );
51
54
// Start in receive mode
52
55
comm_protocols.rs485 .receive ();
53
56
@@ -60,14 +63,21 @@ void loop()
60
63
Serial.write (comm_protocols.rs485 .read ());
61
64
62
65
if (millis () > sendNow) {
66
+ String log = " [" ;
67
+ log += sendNow;
68
+ log += " ] " ;
69
+
70
+ String msg = " hello " ;
71
+ msg += counter++;
72
+
73
+ log += msg;
74
+ Serial.println (log);
75
+
63
76
// Disable receive mode before transmission
64
77
comm_protocols.rs485 .noReceive ();
65
78
66
79
comm_protocols.rs485 .beginTransmission ();
67
-
68
- comm_protocols.rs485 .print (" hello " );
69
- comm_protocols.rs485 .println (counter++);
70
-
80
+ comm_protocols.rs485 .println (msg);
71
81
comm_protocols.rs485 .endTransmission ();
72
82
73
83
// Re-enable receive mode after transmission
0 commit comments