Skip to content

Commit 46179b0

Browse files
authored
Add files via upload
1 parent 3c4580a commit 46179b0

1 file changed

Lines changed: 70 additions & 69 deletions

File tree

examples/test_LCs/test_LCs.ino

Lines changed: 70 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,70 @@
1-
/**
2-
* test_LCs.ino - Test Load Cell with AD7193
3-
* Author: Milos Petrasinovic <mpetrasinovic@pr-dc.com>
4-
* PR-DC, Republic of Serbia
5-
* info@pr-dc.com
6-
*
7-
* --------------------
8-
* Copyright (C) 2021 PR-DC <info@pr-dc.com>
9-
*
10-
* This file is part of PRDC_AD7193.
11-
*
12-
* PRDC_AD7193 is free software: you can redistribute it and/or modify
13-
* it under the terms of the GNU Lesser General Public License as
14-
* published by the Free Software Foundation, either version 3 of the
15-
* License, or (at your option) any later version.
16-
*
17-
* PRDC_AD7193 is distributed in the hope that it will be useful,
18-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20-
* GNU Lesser General Public License for more details.
21-
*
22-
* You should have received a copy of the GNU Lesser General Public License
23-
* along with PRDC_AD7193. If not, see <https://www.gnu.org/licenses/>.
24-
*
25-
*/
26-
27-
// Library
28-
// --------------------
29-
// PRDC AD7193
30-
// Author: PRDC
31-
#include <PRDC_AD7193.h>
32-
33-
// Define variables
34-
// --------------------
35-
uint32_t t0;
36-
37-
// SPI communications
38-
PRDC_AD7193 AD7193;
39-
40-
// setup function
41-
// --------------------
42-
void setup() {
43-
// Communication settings
44-
Serial.begin(115200);
45-
while(!Serial.available()){};
46-
47-
AD7193.setSPI(SPI);
48-
if(!AD7193.begin(PIN_SPI_SS, PIN_SPI_MISO)) {
49-
Serial.println(F("AD7193 initialization failed!"));
50-
} else {
51-
AD7193.printAllRegisters();
52-
AD7193.setClockMode(AD7193_CLK_EXT_MCLK2);
53-
AD7193.setRate(0x005);
54-
AD7193.setFilter(AD7193_MODE_SINC3);
55-
AD7193.enableNotchFilter(false);
56-
AD7193.enableChop(false);
57-
AD7193.rangeSetup(0, AD7193_CONF_GAIN_128); // bipolar, +-12.89 mV
58-
AD7193.channelSelect(AD7193_CH_1);
59-
}
60-
}
61-
62-
// loop function
63-
// --------------------
64-
void loop(){
65-
Serial.println(micros()-t0);
66-
t0 = micros();
67-
Serial.println(AD7193.singleConversion());
68-
Serial.println();
69-
}
1+
/**
2+
* test_LCs.ino - Test Load Cell with AD7193
3+
* Author: Milos Petrasinovic <mpetrasinovic@pr-dc.com>
4+
* PR-DC, Republic of Serbia
5+
* info@pr-dc.com
6+
*
7+
* --------------------
8+
* Copyright (C) 2021 PR-DC <info@pr-dc.com>
9+
*
10+
* This file is part of PRDC_AD7193.
11+
*
12+
* PRDC_AD7193 is free software: you can redistribute it and/or modify
13+
* it under the terms of the GNU Lesser General Public License as
14+
* published by the Free Software Foundation, either version 3 of the
15+
* License, or (at your option) any later version.
16+
*
17+
* PRDC_AD7193 is distributed in the hope that it will be useful,
18+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+
* GNU Lesser General Public License for more details.
21+
*
22+
* You should have received a copy of the GNU Lesser General Public License
23+
* along with PRDC_AD7193. If not, see <https://www.gnu.org/licenses/>.
24+
*
25+
*/
26+
27+
// Library
28+
// --------------------
29+
// PRDC AD7193
30+
// Author: PRDC
31+
#include <PRDC_AD7193.h>
32+
33+
// Define variables
34+
// --------------------
35+
uint32_t t0;
36+
37+
// SPI communications
38+
PRDC_AD7193 AD7193;
39+
40+
// setup function
41+
// --------------------
42+
void setup() {
43+
// Communication settings
44+
Serial.begin(115200);
45+
while(!Serial.available()){};
46+
47+
AD7193.setSPI(SPI);
48+
if(!AD7193.begin(PIN_SPI_SS, PIN_SPI_MISO)) {
49+
Serial.println(F("AD7193 initialization failed!"));
50+
} else {
51+
AD7193.printAllRegisters();
52+
AD7193.setClockMode(AD7193_CLK_EXT_MCLK2);
53+
AD7193.setRate(0x002);
54+
AD7193.setFilter(AD7193_MODE_SINC4);
55+
AD7193.enableNotchFilter(false);
56+
AD7193.enableChop(false);
57+
AD7193.enableBuffer(true);
58+
AD7193.rangeSetup(0, AD7193_CONF_GAIN_128);
59+
AD7193.channelSelect(AD7193_CH_0);
60+
}
61+
}
62+
63+
// loop function
64+
// --------------------
65+
void loop(){
66+
Serial.println(micros()-t0);
67+
t0 = micros();
68+
Serial.println(AD7193.singleConversion());
69+
Serial.println();
70+
}

0 commit comments

Comments
 (0)