- Thu May 24, 2018 10:05 am
#199277
Hello
I'm trying to use both your products SX1509 Expander Breakout and HX711 Load cell amplifier.
My purpose is to read from several Load cells using the SX1509.
This is my hookup for 1 amplifier:
The connection is very simple:
arduino____SX1509____HX711
SCL------------SCL
SDA -----------SDA
GND---------- GND---------- GND
3.3V-----------3v3----------- VDD
5V------------------------------VCC
----------------- 0------------- CLK
----------------- 1------------- DAT
For Start, from your HX711.cpp liabrory i took the read function, and placed it into arduino code, to see if this is the only function that i need to read RAW data from the HX711, and it was right.
After finding the calibration factor and the offset i could translate the RAW data to real force/weight.
Then i adjusted it alittle bit and added it to your SX1509.cpp lieberary:
(ofcurse i declared on this function in the header file - SX1509.h)
I would appreciate if you could help me with that
Thanks
I'm trying to use both your products SX1509 Expander Breakout and HX711 Load cell amplifier.
My purpose is to read from several Load cells using the SX1509.
This is my hookup for 1 amplifier:
The connection is very simple:
arduino____SX1509____HX711
SCL------------SCL
SDA -----------SDA
GND---------- GND---------- GND
3.3V-----------3v3----------- VDD
5V------------------------------VCC
----------------- 0------------- CLK
----------------- 1------------- DAT
For Start, from your HX711.cpp liabrory i took the read function, and placed it into arduino code, to see if this is the only function that i need to read RAW data from the HX711, and it was right.
After finding the calibration factor and the offset i could translate the RAW data to real force/weight.
Then i adjusted it alittle bit and added it to your SX1509.cpp lieberary:
(ofcurse i declared on this function in the header file - SX1509.h)
long SX1509::read_my(byte DOUT, byte PD_SCK)
Code: Select all
Then i tried to use it like that:
long SX1509::read_my(byte DOUT, byte PD_SCK) {
// byte DOUT = 1;
// byte PD_SCK = 0;
byte GAIN = 1;
unsigned long value = 0;
uint8_t data[3] = { 0 };
uint8_t filler = 0x00;
// pulse the clock pin 24 times to read the data
data[2] = shiftIn(DOUT, PD_SCK, MSBFIRST);
data[1] = shiftIn(DOUT, PD_SCK, MSBFIRST);
data[0] = shiftIn(DOUT, PD_SCK, MSBFIRST);
// set the channel and the gain factor for the next reading using the clock pin
for (unsigned int i = 0; i < GAIN; i++) {
digitalWrite(PD_SCK, HIGH);
digitalWrite(PD_SCK, LOW);
}
// Replicate the most significant bit to pad out a 32-bit signed integer
if (data[2] & 0x80) {
filler = 0xFF;
} else {
filler = 0x00;
}
// Construct a 32-bit signed integer
value = ( static_cast<unsigned long>(filler) << 24
| static_cast<unsigned long>(data[2]) << 16
| static_cast<unsigned long>(data[1]) << 8
| static_cast<unsigned long>(data[0]) );
return static_cast<long>(value);
}
Code: Select all
Unfortunately the result that i'm getting is very different form the first attempt. And the values are jumping from 1 value to another, and it seems to be constant no matter what force i apply on the load cell.#include <Wire.h> // Include the I2C library (required)
#include <SparkFunSX1509.h> // Include SX1509 library
#define SX1509_Data 1
#define SX1509_CSK 0
const byte SX1509_ADDRESS = 0x3E; // SX1509 I2C address
SX1509 io; // Create an SX1509 object to be used throughout
void setup(){
Serial.begin(38400);
delay(10);
if (!io.begin(SX1509_ADDRESS))
Serial.println("Failed to communicate.");
else
Serial.println("SX1509 Alive");
delay(10);
io.pinMode(SX1509_Data, INPUT);
io.pinMode(SX1509_CSK, OUTPUT);
Serial.println("Starting:");
}
void loop() {
Serial.print("Reading: ");
long t1 = io.read_my(SX1509_Data, SX1509_CSK);
Serial.println(t1);
delay(100);
}
I would appreciate if you could help me with that
Thanks
You do not have the required permissions to view the files attached to this post.