Skip to content
This repository was archived by the owner on Feb 28, 2024. It is now read-only.

Commit 72f0840

Browse files
authored
Modified all the examples to support the PCB v3.0
Modified all the examples to support the PCB v3.0 Update examples/Analog_input/Analog_input_NTC/Analog_input_NTC.ino
1 parent c66f3bc commit 72f0840

File tree

16 files changed

+387
-178
lines changed

16 files changed

+387
-178
lines changed

examples/Analog_Out/Analog_Out.ino

-4
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@
1010
- Portenta H7
1111
- Machine Control
1212
13-
created 17 November 2020
14-
by Riccardo Rizzo
15-
modified 09 December 2020
16-
by Silvio Navaretti
1713
This example code is in the public domain.
1814
*/
1915

examples/Analog_input/Analog_input_0_10V/Analog_input_0_10V.ino

+7-11
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*
2-
Automation Carrier - Analog in 0 - 10 V Example
2+
Machine Control - Analog in 0 - 10 V Example
33
44
This example provides the voltage value acquired by the
5-
Automation Carrier. For each channel of the ANALOG IN connector,
5+
Machine Control. For each channel of the ANALOG IN connector,
66
there is a resistor divider made by a 100k and 39k,
77
the input voltage is divided by a ratio of 0.28.
88
Maximum input voltage is 10V.
@@ -11,20 +11,16 @@
1111
1212
The circuit:
1313
- Portenta H7
14-
- Automation Carrier
14+
- Machine Control
1515
16-
created 18 September 2020
17-
by Silvio Navaretti
18-
modified 30 September 2020
19-
by Riccardo Rizzo
2016
This example code is in the public domain.
2117
*/
2218
#include <AutomationCarrier.h>
2319

2420
using namespace automation;
2521

2622
float res_divider = 0.28057;
27-
float reference = 3.3;
23+
float reference = 3;
2824

2925
void setup() {
3026
analogReadResolution(16);
@@ -36,19 +32,19 @@ void setup() {
3632
void loop() {
3733
float raw_voltage_ch0 = analog_in.read(0);
3834
float voltage_ch0 = (raw_voltage_ch0 * reference) / 65535 / res_divider;
39-
Serial.print("Voltage ch0: ");
35+
Serial.print("Voltage CH0: ");
4036
Serial.print(voltage_ch0, 3);
4137
Serial.println("V");
4238

4339
float raw_voltage_ch1 = analog_in.read(1);
4440
float voltage_ch1 = (raw_voltage_ch1 * reference) / 65535 / res_divider;
45-
Serial.print("Voltage ch1: ");
41+
Serial.print("Voltage CH1: ");
4642
Serial.print(voltage_ch1, 3);
4743
Serial.println("V");
4844

4945
float raw_voltage_ch2 = analog_in.read(2);
5046
float voltage_ch2 = (raw_voltage_ch2 * reference) / 65535 / res_divider;
51-
Serial.print("Voltage ch2: ");
47+
Serial.print("Voltage CH2: ");
5248
Serial.print(voltage_ch2, 3);
5349
Serial.println("V");
5450
Serial.println();

examples/Analog_input/Analog_input_4_20mA/Analog_input_4_20mA.ino

+9-11
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,15 @@
1313
- Portenta H7
1414
- Automation Carrier
1515
16-
created 18 September 2020
17-
by Silvio Navaretti
18-
modified 30 September 2020
19-
by Riccardo Rizzo
2016
This example code is in the public domain.
2117
*/
2218
#include <AutomationCarrier.h>
2319

2420
using namespace automation;
2521

26-
float reference = 3.3;
22+
#define SENSE_RES 120
23+
24+
float reference = 3;
2725

2826
void setup() {
2927
analogReadResolution(16);
@@ -35,21 +33,21 @@ void setup() {
3533
void loop() {
3634
float raw_voltage_ch0 = analog_in.read(0);
3735
float voltage_ch0 = (raw_voltage_ch0 * reference) / 65535;
38-
float current_ch0 = voltage_ch0 / 120 * 1000;
39-
Serial.print("Measured Current ch0: ");
36+
float current_ch0 = (voltage_ch0 / SENSE_RES) * 1000;
37+
Serial.print("Measured Current CH0: ");
4038
Serial.print(current_ch0);
4139
Serial.println("mA");
4240

4341
float raw_voltage_ch1 = analog_in.read(1);
4442
float voltage_ch1 = (raw_voltage_ch1 * reference) / 65535;
45-
float current_ch1 = voltage_ch1 / 120 * 1000;
46-
Serial.print("Measured Current ch1: ");
43+
float current_ch1 = (voltage_ch1 / SENSE_RES) * 1000;
44+
Serial.print("Measured Current CH1: ");
4745
Serial.print(current_ch1);
4846
Serial.println("mA");
4947
float raw_voltage_ch2 = analog_in.read(2);
5048
float voltage_ch2 = (raw_voltage_ch2 * reference) / 65535;
51-
float current_ch2 = voltage_ch2 / 120 * 1000;
52-
Serial.print("Measured Current ch2: ");
49+
float current_ch2 = (voltage_ch2 / SENSE_RES) * 1000;
50+
Serial.print("Measured Current CH2: ");
5351
Serial.print(current_ch2);
5452
Serial.println("mA");
5553

examples/Analog_input/Analog_input_NTC/Analog_input_NTC.ino

+23-20
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,16 @@
1818
- Portenta H7
1919
- Automation Carrier
2020
21-
created 18 September 2020
22-
by Silvio Navaretti
23-
modified 30 September 2020
24-
by Riccardo Rizzo
2521
This example code is in the public domain.
2622
*/
2723
#include <AutomationCarrier.h>
2824

2925
using namespace automation;
3026

31-
float reference = 3.3;
27+
#define REFERENCE_RES 100000
28+
29+
float reference = 3;
30+
float lowest_voltage = 2.7;
3231

3332
void setup() {
3433
analogReadResolution(16);
@@ -41,38 +40,42 @@ void loop() {
4140
float raw_voltage_ch0 = analog_in.read(0);
4241
float voltage_ch0 = (raw_voltage_ch0 * reference) / 65535;
4342
float resistance_ch0;
44-
if (voltage_ch0 < 3) {
45-
resistance_ch0 = ((-100000) * voltage_ch0) / (voltage_ch0 - 3);
43+
Serial.print("Resistance CH0: ");
44+
if (voltage_ch0 < lowest_voltage) {
45+
resistance_ch0 = ((-REFERENCE_RES) * voltage_ch0) / (voltage_ch0 - reference);
46+
Serial.print(resistance_ch0);
47+
Serial.println(" ohm");
4648
} else {
4749
resistance_ch0 = -1;
50+
Serial.println("NaN");
4851
}
49-
Serial.print("Resistance ch0: ");
50-
Serial.print(resistance_ch0);
51-
Serial.println(" ohm");
5252

5353
float raw_voltage_ch1 = analog_in.read(1);
5454
float voltage_ch1 = (raw_voltage_ch1 * reference) / 65535;
5555
float resistance_ch1;
56-
if (voltage_ch1 < 3) {
57-
resistance_ch1 = ((-100000) * voltage_ch1) / (voltage_ch1 - 3);
56+
Serial.print("Resistance CH1: ");
57+
if (voltage_ch1 < lowest_voltage) {
58+
resistance_ch1 = ((-REFERENCE_RES) * voltage_ch1) / (voltage_ch1 - reference);
59+
Serial.print(resistance_ch1);
60+
Serial.println(" ohm");
5861
} else {
5962
resistance_ch1 = -1;
63+
Serial.println("NaN");
6064
}
61-
Serial.print("Resistance ch1: ");
62-
Serial.print(resistance_ch1);
63-
Serial.println(" ohm");
6465

6566
float raw_voltage_ch2 = analog_in.read(2);
6667
float voltage_ch2 = (raw_voltage_ch2 * reference) / 65535;
6768
float resistance_ch2;
68-
if (voltage_ch2 < 3) {
69-
resistance_ch2 = ((-100000) * voltage_ch2) / (voltage_ch2 - 3);
69+
Serial.print("Resistance CH2: ");
70+
if (voltage_ch2 < lowest_voltage) {
71+
resistance_ch2 = ((-REFERENCE_RES) * voltage_ch2) / (voltage_ch2 - reference);
72+
Serial.print(resistance_ch2);
73+
Serial.println(" ohm");
7074
} else {
7175
resistance_ch2 = -1;
76+
Serial.println("NaN");
7277
}
73-
Serial.print("Scaled ch2: ");
74-
Serial.print(resistance_ch2);
75-
Serial.println(" ohm");
78+
7679
Serial.println();
7780
delay(250);
7881
}

examples/CAN/ReadCan/ReadCan.ino

-5
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@
88
- Portenta H7
99
- Automation Carrier
1010
11-
12-
created 25 August 2020
13-
by Silvio Navaretti
14-
modified 4 November 2020
15-
by Riccardo Rizzo
1611
*/
1712
#include <AutomationCarrier.h>
1813
#include <CAN.h>

examples/CAN/WriteCan/WriteCan.ino

-5
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@
88
- Portenta H7
99
- Automation Carrier
1010
11-
12-
created 25 August 2020
13-
by Silvio Navaretti
14-
modified 4 November 2020
15-
by Riccardo Rizzo
1611
*/
1712
#include <AutomationCarrier.h>
1813
#include <CAN.h>

examples/Digital_input/Digital_input.ino

-66
This file was deleted.

examples/Digital_output/Digital_output.ino

+2-8
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,6 @@
2424
- Portenta H7
2525
- Automation Carrier
2626
27-
created 25 August 2020
28-
by Silvio Navaretti
29-
modified 29 September 2020
30-
by Riccardo Rizzo
31-
modified 6 October 2020
32-
by Silvio Navaretti
3327
This example code is in the public domain.
3428
*/
3529

@@ -43,11 +37,11 @@ void setup() {
4337
while (!Serial);
4438

4539
//Set over current behavior of all channels to latch mode:
46-
digital_programmables.setLatch();
40+
digital_outputs.setLatch();
4741

4842
// Uncomment this line to set over current behavior of all
4943
// channels to auto retry mode instead of latch mode:
50-
// digital_programmables.setRetry();
44+
//digital_outputs.setRetry();
5145

5246
//At startup set all channels to OPEN
5347
digital_outputs.setAll(0);

0 commit comments

Comments
 (0)