0.2.0 HX711_MP

This commit is contained in:
Rob Tillaart 2024-03-03 10:22:22 +01:00
parent 5bd103d2dd
commit 6bdfb78357
10 changed files with 43 additions and 26 deletions

View File

@ -6,7 +6,7 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: arduino/arduino-lint-action@v1
with:
library-manager: update

View File

@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6

View File

@ -10,7 +10,7 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: json-syntax-check
uses: limitusus/json-syntax-check@v1
with:

View File

@ -5,11 +5,17 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
## [0.2.0] - 2024-03-02
- add fastProcessor option in **begin()** (Thanks to palmerr23)
- updated license
- updated GitHub/actions to v4
----
## [0.1.1] - 2023-11-04
- update readme.md
- minor edits
## [0.1.0] - 2023-03-10
- initial release
- first version derived from 0.3.5 https://github.com/RobTillaart/HX711

View File

@ -1,7 +1,7 @@
//
// FILE: HX711_MP.cpp
// AUTHOR: Rob Tillaart
// VERSION: 0.1.1
// VERSION: 0.2.0
// PURPOSE: Library for load cells for UNO
// URL: https://github.com/RobTillaart/HX711_MP
// URL: https://github.com/RobTillaart/HX711
@ -25,13 +25,16 @@ HX711_MP::HX711_MP(uint8_t size)
}
HX711_MP::~HX711_MP() {}
HX711_MP::~HX711_MP()
{
}
void HX711_MP::begin(uint8_t dataPin, uint8_t clockPin)
void HX711_MP::begin(uint8_t dataPin, uint8_t clockPin, bool fastProcessor )
{
_dataPin = dataPin;
_clockPin = clockPin;
_fastProcessor = fastProcessor;
pinMode(_dataPin, INPUT);
pinMode(_clockPin, OUTPUT);
@ -140,7 +143,11 @@ float HX711_MP::read()
{
// delayMicroSeconds(1) needed for fast processors?
digitalWrite(_clockPin, HIGH);
if (_fastProcessor)
delayMicroseconds(1);
digitalWrite(_clockPin, LOW);
if (_fastProcessor)
delayMicroseconds(1);
m--;
}
@ -380,12 +387,14 @@ uint8_t HX711_MP::_shiftIn()
while (mask > 0)
{
digitalWrite(clk, HIGH);
delayMicroseconds(1); // T2 >= 0.2 us
if(_fastProcessor) // T2 >= 0.2 us
delayMicroseconds(1);
if (digitalRead(data) == HIGH)
{
value |= mask;
}
digitalWrite(clk, LOW);
if(_fastProcessor)
delayMicroseconds(1); // keep duty cycle ~50%
mask >>= 1;
}

View File

@ -2,7 +2,7 @@
//
// FILE: HX711_MP.h
// AUTHOR: Rob Tillaart
// VERSION: 0.1.1
// VERSION: 0.2.0
// PURPOSE: Library for load cells for Arduino
// URL: https://github.com/RobTillaart/HX711_MP
// URL: https://github.com/RobTillaart/HX711
@ -14,7 +14,7 @@
#include "Arduino.h"
#define HX711_MP_LIB_VERSION (F("0.1.1"))
#define HX711_MP_LIB_VERSION (F("0.2.0"))
const uint8_t HX711_AVERAGE_MODE = 0x00;
@ -45,7 +45,7 @@ public:
~HX711_MP();
// fixed gain 128 for now
void begin(uint8_t dataPin, uint8_t clockPin);
void begin(uint8_t dataPin, uint8_t clockPin, bool fastProcessor = false);
void reset();
@ -191,6 +191,7 @@ private:
float _out[HX711_MP_MAX_SIZE];
uint8_t _size = HX711_MP_MAX_SIZE;
float _multiMap(float val);
bool _fastProcessor = false;
};

View File

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2019-2023 Rob Tillaart
Copyright (c) 2019-2024 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

View File

@ -90,7 +90,8 @@ is more math involved for converting raw data to weights.
Parameter sets the size of for the calibration arrays.
Allowed range for size is 2..10.
- **~HX711_MP()**
- **void begin(uint8_t dataPin, uint8_t clockPin)** sets a fixed gain 128 for now.
- **void begin(uint8_t dataPin, uint8_t clockPin, bool fastProcessor)** sets a fixed gain 128 for now.
The fastProcessor option adds a 1 uS delay for each clock half-cycle to keep the time greater than 200 nS.
- **void reset()** set internal state to start condition.
Reset also does a power down / up cycle.
It does not reset the calibration data.
@ -244,8 +245,8 @@ Colour scheme wires of two devices.
#### Temperature
Load cells do have a temperature related error. (see datasheet load cell)
This can be reduced by doing the calibration at the operational temperature
one uses for the measurements.
This can be reduced by doing the calibration and take the tare
at the operational temperature one uses for the measurements.
Another way to handle this is to add a good temperature sensor
(e.g. DS18B20, SHT85) and compensate for the temperature

View File

@ -15,7 +15,7 @@
"type": "git",
"url": "https://github.com/RobTillaart/HX711_MP"
},
"version": "0.1.1",
"version": "0.2.0",
"license": "MIT",
"frameworks": "*",
"platforms": "*",

View File

@ -1,5 +1,5 @@
name=HX711_MP
version=0.1.1
version=0.2.0
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Arduino library for HX711 load cell amplifier.