Skip to content

Commit 7661eee

Browse files
committed
2021-01-29
1 parent 7286182 commit 7661eee

File tree

1,414 files changed

+61325
-4631
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,414 files changed

+61325
-4631
lines changed

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
# MIT License
33

4-
Copyright (c) 2010-2020 Rob Tillaart
4+
Copyright (c) 2010-2021 Rob Tillaart
55

66
Permission is hereby granted, free of charge, to any person obtaining a copy
77
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,52 @@
11
# Arduino libraries
22

3-
**NOTE** these libraries will all get their own repo, so this repository
4-
does not have the latest version of all libs anymore. That said I will update
5-
this bulk repo on request or if time permit.
3+
**NOTE** these libraries all have their own repo under https://github.com/RobTillaart?tab=repositories
4+
5+
So this repository does not have the latest version of all libs anymore.
6+
That said I will update this bulk repo on request or if time permit.
67

78

89
### Introduction
10+
911
This repository contains several Arduino libraries I have written to be used in applications.
1012
Most of them include example code how the libraries can be used.
1113
Furthermore this repository contains a few stand alone applications.
1214

1315

1416
### Questions
17+
1518
For questions about the usage of the libraries, please post a question on the Arduino
1619
forum at http://forum.arduino.cc/
1720

21+
1822
### Bugs and issues
23+
1924
**Please check if the library has its own repo first and fill an issue there**
2025

21-
For bugs in the libraries, please fill in an issue in Github as that makes it
22-
far easier to track them. If possible provide a minimal code snippet that exposes
23-
the bug. Also proposals for solutions are welcome.
26+
For bugs in the libraries, please fill in an issue in Github as that makes it far easier to track them.
27+
If possible provide a minimal code snippet that exposes the bug.
28+
Add information about platform used and version etc.
29+
Also proposals for solutions are welcome.
30+
31+
Other issues are not directly bugs but still problematic.
32+
E.g. if a library is too slow for your application that is an serious issue, not a bug.
33+
Please fill in an issue and provide as much details about your requirements.
34+
Maybe I can help to fix it.
2435

25-
Issues are not bugs but still possible problematic. E.g. if a library is too slow
26-
for your application that is an issue, not a bug. Please fill in an issue and provide
27-
as much details about your requirements.
2836

2937
### Improvements and changes
30-
For improvements and changes, please provide a pull request. I will try to follow up on them
31-
asap but it can take quite some time. Please try to be generic in your improvements and try to
32-
see "over the needs of your own application".
38+
39+
For improvements and changes, please provide a pull request.
40+
I will try to follow up on them asap but it can take quite some time.
41+
Please try to be generic in your improvements and try to see "over the needs of your own application".
42+
43+
There is no guarantee that pull requests will be honored.
44+
In such case feel free to start your own modified library from a fork.
45+
3346

3447
### License and Warranty
35-
I appreciate if you give credits when appropriate, and if you want to donate, please
36-
donate to charity like "doctors without borders".
48+
49+
I appreciate if you give credits when appropriate.
3750

3851
Please check the file LICENSE.md for the details.
3952

libraries/ACS712/.arduino-ci.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
compile:
2+
# Choosing to run compilation tests on 2 different Arduino platforms
3+
platforms:
4+
- uno
5+
- leonardo
6+
- due
7+
- zero
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
name: Arduino CI
3+
4+
on: [push, pull_request]
5+
6+
jobs:
7+
arduino_ci:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v2
12+
- uses: Arduino-CI/action@master
13+
# Arduino-CI/[email protected]

libraries/ACS712/ACS712.cpp

Lines changed: 42 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,68 @@
11
//
22
// FILE: ACS712.cpp
33
// AUTHOR: Rob Tillaart, Pete Thompson
4-
// VERSION: 0.2.0
4+
// VERSION: 0.2.1
55
// DATE: 2020-08-02
66
// PURPOSE: ACS712 library - current measurement
77
//
88
// HISTORY:
99
// 0.1.0 2020-03-17 initial version
1010
// 0.1.1 2020-03-18 first release version
11-
// 0.1.2 2020-03-21 automatic formfactor test
11+
// 0.1.2 2020-03-21 automatic formfactor test
1212
// 0.1.3 2020-05-27 fix library.json
1313
// 0.1.4 2020-08-02 Allow for faster processors
1414
// 0.2.0 2020-08-02 Add autoMidPoint
15+
// 0.2.1 2020-12-06 Add arduino-CI + readme + unittest + refactor
1516

1617
#include "ACS712.h"
1718

1819
ACS712::ACS712(uint8_t analogPin, float volts, uint16_t maxADC, uint8_t mVperA)
1920
{
20-
_pin = analogPin;
21-
// 1x 1000 for V -> mV
22-
_mVpstep = 1000.0 * volts / maxADC;
23-
_mVperAmpere = mVperA;
24-
_formFactor = 0.70710678119; // 0.5 * sqrt(2); TODO: should be smaller in practice 0.5 ?
25-
_midPoint = maxADC / 2;
26-
_noisemV = 21; // Noise is 21mV according to datasheet
21+
_pin = analogPin;
22+
_mVpstep = 1000.0 * volts / maxADC; // 1x 1000 for V -> mV
23+
_mVperAmpere = mVperA;
24+
_formFactor = 0.70710678119; // 0.5 * sqrt(2); TODO: should be smaller in practice 0.5 ?
25+
_midPoint = maxADC / 2;
26+
_noisemV = 21; // Noise is 21mV according to datasheet
2727
}
2828

2929
int ACS712::mA_AC(uint8_t freq)
3030
{
31-
uint32_t start = micros();
32-
uint16_t period = ((freq == 60) ? 16670 : 20000);
33-
uint16_t samples = 0;
34-
uint16_t zeros = 0;
35-
int _min, _max;
36-
_min = _max = analogRead(_pin);
37-
while (micros() - start < period) // UNO ~180 samples...
38-
{
39-
samples++;
40-
int val = analogRead(_pin);
41-
if (val < _min) _min = val;
42-
if (val > _max) _max = val;
43-
if (abs(val - _midPoint) <= (_noisemV/_mVpstep)) zeros++;
44-
}
45-
int p2p = (_max - _min);
31+
uint32_t start = micros();
32+
uint16_t period = ((freq == 60) ? 16670 : 20000);
33+
uint16_t samples = 0;
34+
uint16_t zeros = 0;
35+
36+
int _min, _max;
37+
_min = _max = analogRead(_pin);
38+
39+
while (micros() - start < period) // UNO ~180 samples...
40+
{
41+
samples++;
42+
int val = analogRead(_pin);
43+
if (val < _min) _min = val;
44+
if (val > _max) _max = val;
45+
if (abs(val - _midPoint) <= (_noisemV/_mVpstep)) zeros++;
46+
}
47+
int point2point = (_max - _min);
4648

47-
// automatic determine _formFactor / crest factor
48-
float D = 0;
49-
float FF = 0;
50-
if (zeros > samples * 0.025)
51-
{
52-
D = 1.0 - (1.0 * zeros) / samples; // % SAMPLES NONE ZERO
53-
FF = sqrt(D) * 0.5 * sqrt(2); // ASSUME NON ZERO PART ~ SINUS
54-
}
55-
else // # zeros is small => D --> 1 --> sqrt(D) --> 1
56-
{
57-
FF = 0.5 * sqrt(2);
58-
}
59-
_formFactor = FF;
49+
// automatic determine _formFactor / crest factor
50+
float D = 0;
51+
float FF = 0;
52+
if (zeros > samples * 0.025)
53+
{
54+
D = 1.0 - (1.0 * zeros) / samples; // % SAMPLES NONE ZERO
55+
FF = sqrt(D) * 0.5 * sqrt(2); // ASSUME NON ZERO PART ~ SINUS
56+
}
57+
else // # zeros is small => D --> 1 --> sqrt(D) --> 1
58+
{
59+
FF = 0.5 * sqrt(2);
60+
}
61+
_formFactor = FF;
6062

61-
// math could be partially precalculated: C = 1000.0 * 0.5 * _mVpstep / _mVperAmpere;
62-
// rounding?
63-
return 1000.0 * 0.5 * p2p * _mVpstep * _formFactor / _mVperAmpere;
63+
// math could be partially precalculated: C = 1000.0 * 0.5 * _mVpstep / _mVperAmpere;
64+
// rounding?
65+
return 1000.0 * 0.5 * point2point * _mVpstep * _formFactor / _mVperAmpere;
6466
}
6567

6668
int ACS712::mA_DC()

libraries/ACS712/ACS712.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// FILE: ACS712.h
44
// AUTHOR: Rob Tillaart
5-
// VERSION: 0.2.0
5+
// VERSION: 0.2.1
66
// DATE: 2020-08-02
77
// PURPOSE: ACS712 library - current measurement
88
//
@@ -11,7 +11,7 @@
1111

1212
#include "Arduino.h"
1313

14-
#define ACS712_LIB_VERSION "0.1.3"
14+
#define ACS712_LIB_VERSION "0.2.1"
1515

1616

1717
class ACS712
@@ -37,7 +37,7 @@ class ACS712
3737
int mA_DC();
3838

3939
// midpoint ADC for DC only
40-
inline void setMidPoint(uint16_t mp) { _midPoint = mp; };
40+
inline void setMidPoint(uint16_t mp) { _midPoint = mp; };
4141
inline uint16_t getMidPoint() { return _midPoint; };
4242
inline void incMidPoint() { _midPoint++; };
4343
inline void decMidPoint() { _midPoint--; };
@@ -58,8 +58,8 @@ class ACS712
5858

5959
private:
6060
uint8_t _pin;
61-
float _mVpstep; // millivolt per step
62-
float _formFactor; // P2P -> RMS
61+
float _mVpstep; // millivolt per step
62+
float _formFactor; // point2point -> RMS
6363
uint8_t _mVperAmpere;
6464
uint16_t _midPoint;
6565
uint8_t _noisemV;

libraries/ACS712/LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2020 Rob Tillaart
3+
Copyright (c) 2020-2021 Rob Tillaart
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

libraries/ACS712/keywords.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Syntax Coloring Map For ACS712
2+
3+
# Datatypes (KEYWORD1)
4+
ACS712 KEYWORD1
5+
6+
# Methods and Functions (KEYWORD2)
7+
mA_AC KEYWORD2
8+
mA_DC KEYWORD2
9+
setMidPoint KEYWORD2
10+
getMidPoint KEYWORD2
11+
incMidPoint KEYWORD2
12+
decMidPoint KEYWORD2
13+
setFormFactor KEYWORD2
14+
getFormFactor KEYWORD2
15+
setNoisemV KEYWORD2
16+
getNoisemV KEYWORD2
17+
setmVperAmp KEYWORD2
18+
getmVperAmp KEYWORD2
19+
20+
21+
# Constants (LITERAL1)
22+
ACS712_LIB_VERSION LITERAL1
23+

libraries/ACS712/library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"type": "git",
2222
"url": "https://github.com/RobTillaart/ACS712"
2323
},
24-
"version":"0.2.0",
24+
"version":"0.2.1",
2525
"frameworks": "arduino",
2626
"platforms": "*"
2727
}

libraries/ACS712/library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=ACS712
2-
version=0.2.0
2+
version=0.2.1
33
author=Rob Tillaart <[email protected]>, Pete Thompson <[email protected]>
44
maintainer=Rob Tillaart <[email protected]>
55
sentence=ACS712 library for Arduino.

0 commit comments

Comments
 (0)