Skip to content

Commit

Permalink
update readme.md (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
RobTillaart authored Dec 9, 2021
1 parent debc1b3 commit 81e2f57
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 18 deletions.
3 changes: 2 additions & 1 deletion ACS712.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// FILE: ACS712.cpp
// AUTHOR: Rob Tillaart, Pete Thompson
// VERSION: 0.2.5
// VERSION: 0.2.6
// DATE: 2020-08-02
// PURPOSE: ACS712 library - current measurement
//
Expand All @@ -18,6 +18,7 @@
// updated build CI, readme.md
// 0.2.4 2021-11-22 add experimental detectFrequency()
// 0.2.5 2021-12-03 add timeout to detectFrequency()
// 0.2.6 2021-12-09 update readme.md + license


#include "ACS712.h"
Expand Down
4 changes: 2 additions & 2 deletions ACS712.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// FILE: ACS712.h
// AUTHOR: Rob Tillaart, Pete Thompson
// VERSION: 0.2.5
// VERSION: 0.2.6
// DATE: 2020-08-02
// PURPOSE: ACS712 library - current measurement
//
Expand All @@ -12,7 +12,7 @@

#include "Arduino.h"

#define ACS712_LIB_VERSION (F("0.2.5"))
#define ACS712_LIB_VERSION (F("0.2.6"))


// ACS712_FF_SINUS == 1.0/sqrt(2) == 0.5 * sqrt(2)
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020-2021 Rob Tillaart
Copyright (c) 2020-2022 Rob Tillaart

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

# ACS712

Library for the ACS712 Current Sensor - 5A, 20A, 30A
Library for the ACS712 Current Sensor - 5A, 20A, 30A.


## Description
Expand All @@ -22,13 +22,14 @@ There are 2 core functions:
- **int mA_AC(float freq = 50)** The frequency can be set to typically 50 or 60 Hz
however other values e.g. 50.1 or 40 or 123.456 are possible.

To measure DC current a single **analogRead()** with some conversion maths is sufficient to get
To measure DC current a single **analogRead()** with conversion maths is sufficient to get
a value. To stabilize the signal **analogRead()** is called twice.

To measure AC current **a blocking loop for 20 milliseconds** is run to determine the
peak to peak value which is converted to the RMS value. To convert the peak2peak
value to RMS one need the so called crest or form factor. This factor depends heavily
on the signal form. For a perfect sinus the value is sqrt(2)/2 == 1/sqrt(2).
See Form factor below.


## Interface
Expand All @@ -41,7 +42,7 @@ It defaults a 20 A type sensor, which is defined by the default value of mVperA.
Since version 0.2.2 frequencies other integer values than 50 and 60 are supported, the lower the frequency,
the longer the blocking period.
Since version 0.2.3 floating point frequencies are supported to tune optimally.
- **int mA_DC()** blocks < 1 ms as it just needs one **analogRead()**.
- **int mA_DC()** blocks < 1 ms (Arduino UNO) as it just needs one **analogRead()**.


| type sensor | mVperA | LSB 5V-10bit |
Expand Down Expand Up @@ -69,7 +70,7 @@ Also known as crest factor; affects AC signals only.
- **void setFormFactor(float ff = ACS712_FF_SINUS)** manually sets form factor, must be between 0.0 and 1.0
- **float getFormFactor()** returns current form factor.

The library has a number of predefined form factors
The library has a number of predefined form factors:

| definition | value | approx | notes |
|:---------------------|:--------------|:------:|:--------|
Expand All @@ -79,21 +80,22 @@ The library has a number of predefined form factors
| | | | |

It is important to measure the current with a calibrated multimeter
and determine / verify the form factor of the signal. This can help
to improve the quality of your measurements.
and determine / verify the form factor of the signal.
This can help to improve the quality of your measurements.


#### Noise

Default = 21 mV.

- **void setNoisemV(uint8_t noisemV = 21)** set noise level, is used to determine zero level e.g. in AC measurements.
- **void setNoisemV(uint8_t noisemV = 21)** set noise level,
is used to determine zero level e.g. in AC measurements.
- **uint8_t getNoisemV()** returns the set value.


#### mV per Ampere

Both for AC and DC. Is defined in the constructor and depends on
Both for AC and DC. Is defined in the constructor and depends on sensor used.

- **void setmVperAmp(uint8_t mva)** sets the milliVolt per Ampere measured.
- **uint8_t getmVperAmp()** returns the set value.
Expand All @@ -117,8 +119,6 @@ to adjust. Testing with my UNO I got a factor 0.9986.

Current version is not performance optimized.

Current version of detectFrequency can block forever. The second part has no timeout guard.


## Test

Expand Down Expand Up @@ -148,7 +148,7 @@ The examples show the basic working of the functions.

- mA_AC blocks 20 ms so might affect task scheduling on a ESP32.
This needs to be investigated. Probably need a separate thread that wakes up when new analogRead is available.
**detectFrequency** also blocks pretty long.
- **detectFrequency** also blocks pretty long.
- int point2point(float freq) function for AC. Is part of mA_AC() already.
Needs extra global variables, which are slower than local ones
Or just cache the last p2p value?
Expand Down
6 changes: 5 additions & 1 deletion keywords.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Syntax Coloring Map For ACS712
# Syntax Colouring Map For ACS712

# Data types (KEYWORD1)
ACS712 KEYWORD1
Expand All @@ -21,6 +21,10 @@ getNoisemV KEYWORD2
setmVperAmp KEYWORD2
getmVperAmp KEYWORD2

detectFrequency KEYWORD2
setMicrosAdjust KEYWORD2
getMicrosAdjust KEYWORD2


# Constants (LITERAL1)
ACS712_LIB_VERSION LITERAL1
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"type": "git",
"url": "https://github.com/RobTillaart/ACS712.git"
},
"version": "0.2.5",
"version": "0.2.6",
"license": "MIT",
"frameworks": "arduino",
"platforms": "*",
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=ACS712
version=0.2.5
version=0.2.6
author=Rob Tillaart <[email protected]>, Pete Thompson <[email protected]>
maintainer=Rob Tillaart <[email protected]>
sentence=ACS712 library for Arduino.
Expand Down

0 comments on commit 81e2f57

Please sign in to comment.