Calificación:
  • 0 voto(s) - 0 Media
  • 1
  • 2
  • 3
  • 4
  • 5
CONSULTA error compilando para tarjeta arduino uno
#1
cordial saludo a todos

soy nuevo en programación con arduino, y deseo hacer un programa para trabajar con unas celdas de carga y sus amplificadore HX711, verifico todo el codigo a continuacion y me sale : Error complilando para tarjeta arduino uno.
Quisera por favor si alguien pudiese ayudarme a encontrar el error, o explicarme a que se debe este

gracias

//HX711-multi.h
#ifndef HX711_MULTI_h
#define HX711_MULTI_h
#if ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
class HX711MULTI {
private:
byte PD_SCK; // Power Down and Serial Clock Input Pin
byte COUNT; // The number of channels to read
byte *DOUT; // Serial Data Output Pin
byte GAIN; // Amplification Factor
bool debugEnabled; // print debug messages?
long *OFFSETS; // used for tare weight
// Array of values used to convert the integer digital data to weight (in grams, ounces,etc.)
float *SCALES;
public:
// define clock and data pin, channel, and gain factor
// channel selection is made by passing the appropriate gain: 128 or 64 for channel A, 32 for channel B
// count: the number of channels
// dout: an array of pin numbers, of length 'count', one entry per channel
HX711MULTI(int count, byte *dout, byte pd_sck, byte gain = 128);
virtual ~HX711MULTI();
// returns the number of channels
byte get_count();
// check if HX711 is ready
// from the datasheet: When output data is not ready for retrieval, digital output pin DOUT is high. Serial clock
// input PD_SCK should be low. When DOUT goes to low, it indicates data is ready for retrieval.
bool is_ready();
// set the gain factor; takes effect only after a call to read()
// channel A can be set for a 128 or 64 gain; channel B has a fixed 32 gain
// depending on the parameter, the channel is also set to either A or B
void set_gain(byte gain = 128);
// waits for the chip to be ready and returns a reading
void read(long *result = NULL);
// same as read, but does not offset the values according to the tare
void readRaw(long *result = NULL);
// set the OFFSET value for tare weight
// times: how many times to read the tare value
// returns true iff the offsets have been reset for the scale during this call.
// tolerance: the maximum deviation of samples, above which to reject the attempt to tare. (if set to 0, ignored)
bool tare(byte times = 10, uint16_t tolerance = 0);
// puts the chip into power down mode
void power_down();
// wakes up the chip after power down mode
void power_up();
void setDebugEnable(bool debugEnable = true);
/* NEW FEATURES BELOW */
// Method to return the array of SCALES values
float* get_scales();
// Method to set the array of SCALES values
void set_scales(float *_scales);
// Method to actually get the weight data (does not return it, but changes the parameter passed by reference)
void get_units(double *result = NULL);
/* END OF NEW FEATURES */
};
#endif /* end HX711_MULTI_h */

#include <Arduino.h>
#include <HX711-multi.h>
HX711MULTI::HX711MULTI(int count, byte *dout, byte pd_sck, byte gain) {
PD_SCK = pd_sck;
DOUT = dout;
COUNT = count;
debugEnabled = false;
pinMode(PD_SCK, OUTPUT);
for (int i=0; i<count; i++) {
pinMode(DOUT[i], INPUT);
}
set_gain(gain);
OFFSETS = (long *) malloc(COUNT*sizeof(long));
// Allocate memory space for the SCALES array when creating a new HX711MULTI object
SCALES = (float *) malloc(COUNT*sizeof(float));
for (int i=0; i<COUNT; ++i) {
OFFSETS[i] = 0;
// Initialize the SCALES array with 1's to avoid dividing by 0
SCALES[i] = 1.0;
}
}
HX711MULTI::~HX711MULTI() {
free(OFFSETS);
// Recover the memory space allocated earlier when deleting the object
free(SCALES);
}
bool HX711MULTI::is_ready() {
bool result = true;
for (int i = 0; i<COUNT; ++i) {
if (digitalRead(DOUT[i]) == HIGH) {
result = false;
}
}
return result;
}
void HX711MULTI:Confundidoet_gain(byte gain) {
switch (gain) {
case 128: // channel A, gain factor 128
GAIN = 1;
break;
case 64: // channel A, gain factor 64
GAIN = 3;
break;
case 32: // channel B, gain factor 32
GAIN = 2;
break;
}
digitalWrite(PD_SCK, LOW);
read(); // a read is needed to get gain setting to come into effect.
}
byte HX711MULTI::get_count() {
return COUNT;
}
bool HX711MULTI::tare(byte times, uint16_t tolerance) {
int i,j;
long values[COUNT];
long minValues[COUNT];
long maxValues[COUNT];
for (i=0; i<COUNT; ++i) {
minValues[i]=0x7FFFFFFF;
maxValues[i]=0x80000000;
}
for (i=0; i<times; ++i) {
readRaw(values);
for (j=0; j<COUNT; ++j) {
if (values[j]<minValues[j]) {
minValues[j]=values[j];
}
if (values[j]>maxValues[j]) {
maxValues[j]=values[j];
}
}
}
if (tolerance!=0 && times>1) {
for (i=0; i<COUNT; ++i) {
if (abs(maxValues[i]-minValues[i])>tolerance) {
// one of the cells fluctuated more than the allowed tolerance, reject tare attempt;
if (debugEnabled) {
Serial.print("Rejecting tare: (");
Serial.print(i);
Serial.print(") ");
Serial.println(abs(maxValues[i]-
minValues[i]));
}
return false;
}
}
}
// set the offsets
for (i=0; i<COUNT; ++i) {
OFFSETS[i] = values[i];
}
return true;
}
// reads from all cahnnels and sets the values into the passed long array pointer (which must have at least 'count' cells allocated)
// if you are only reading to toggle the line, and not to get values (such as in the case of setting gains) you can pass NULL.
void HX711MULTI::read(long *result) {
readRaw(result);
// Datasheet indicates the value is returned as a two's complement value, so 'stretch' the 24th bit to fit into 32 bits.
if (NULL!=result) {
for (int j = 0; j < COUNT; ++j) {
result[j] -= OFFSETS[j];
}
}
}
void HX711MULTI::readRaw(long *result) {
int i,j;
// wait for all the chips to become ready
while (!is_ready());
// pulse the clock pin 24 times to read the data
for (i = 0; i < 24; ++i) {
digitalWrite(PD_SCK, HIGH);
if (NULL!=result) {
for (j = 0; j < COUNT; ++j) {
bitWrite(result[j], 23-i, digitalRead(DOUT[j]));
}
}
digitalWrite(PD_SCK, LOW);
}
// set the channel and the gain factor for the next reading using the clock pin
for (i = 0; i < GAIN; ++i) {
digitalWrite(PD_SCK, HIGH);
digitalWrite(PD_SCK, LOW);
}
// Datasheet indicates the value is returned as a two's complement value, so 'stretch' the 24th bit to fit into 32 bits.
if (NULL!=result) {
for (j = 0; j < COUNT; ++j) {
if ( ( result[j] & 0x00800000 ) ) {result[j] |= 0xFF000000;

else {
result[j] &= 0x00FFFFFF; // required in lieu of re-setting the value to zero before shifting bits in.
}
}
}
}
void HX711MULTI:ConfundidoetDebugEnable(bool debugEnable) {
debugEnabled = debugEnable;
}
void HX711MULTI::power_down() {
digitalWrite(PD_SCK, LOW);
digitalWrite(PD_SCK, HIGH);
}
void HX711MULTI::power_up() {
digitalWrite(PD_SCK, LOW);
}
float* HX711MULTI::get_scales() {
// Just return the SCALES array (property of the object)
return SCALES;
}
void HX711MULTI:Confundidoet_scales(float *_scales) {
// Just set the SCALES object property with the array parameter
SCALES = _scales;
}
void HX711MULTI::get_units(double *result) {
// Use the library's built-in read() method to obtain the weight as an integer value and save it in a temporary array
long int rawResult[COUNT];
read(rawResult);
// Convert each value of the temporary array to weight data using the SCALES property and save it to the result array passed by reference
for (int i = 0; i < COUNT; ++i) {
result[i] = ((double) rawResult[i]) / SCALES[i];
}
}
// arduino_get_data_def.ino
#include "HX711-multi.h"
#define CLK A0 // clock pin to the load cell
#define N 3 // # of channels
#define DOUT1 A1 // data pin to the 1st load cell lift 1
#define DOUT2 A2 // data pin to the 2nd load cell lift 2
#define DOUT3 A3 // data pin to the 3rd load cell drag
#define TARE_TIMEOUT_SECONDS 4
// INSERT THE VALUES CORRESPONDING TO YOUR MODEL
// Inputs
double x01 = 0.02; // distance between the leading edge and the first load cell [m]
double v = 10; // speed of the wind [m/s]
double rho = 1.225; // density [kg/m^3]
double S = 0.04; // wing surface [m^2]
double C = 0.2; // chord length [m]
//CALLIBRATION OF THE BALANCE
// To re-calibrate the balance (if a load cell is replaced or one of the existing changes its behavior) write a 1.0 in the corresponding cell of measurements[]
// vector and tare the balance (this can be done sending any character to the Arduino through Serial Monitor).
// Then read the value of 'WEIGHT DATA BELOW' corresponding to the load cell at the program when a known weight is placed at the load cell.
// Substitute the 1.0 by (value obtained)/(known weight [g]).
float measurements[N] = {(-10000/21.2), -8600/21.2, 40750/21.2}; // measured SCALES parameters
// MAIN CODE, DO NOT SAVE THE CHANGES MADE HERE
// Init
byte DOUTS[N] = {DOUT1, DOUT2, DOUT3};
long int results[N];
double weights[N];
double go = 9.80662;
double lift;
double drag;
double Mle;
double F1;
double F2;
double x02 = 0.041;
double x12 = x01 + x02;
double xcp;
double Cl;
double Cd;
double Cm;
HX711MULTI scales(N, DOUTS, CLK);
void setup() {
Serial.begin(115200);
Serial.flush();
tare();
scales.set_scales(measurements);
}
void tare() {
bool tareSuccessful = false;
unsigned long tareStartTime = millis();
while (!tareSuccessful && millis() < (tareStartTime + TARE_TIMEOUT_SECONDS
* 1000)) {
tareSuccessful = scales.tare(20, 10000); //reject 'tare' if still ringing
}
}
// void sendRawData() {
// scales.read(results);
// for (int i = 0; i < scales.get_count(); ++i) {
// Serial.print(-results[i]);
// Serial.print((i != scales.get_count() - 1) ? "\t" : "\n");
// }
// delay(1000);
//}
void sendWeightData() {
scales.get_units(weights);
for (int i = 0; i < scales.get_count(); ++i) {
Serial.print(-weights[i]);
Serial.print((i != scales.get_count() - 1) ? "\t" : "\n");
}
delay(1000);
}
void loop() {
// Serial.println("RAW DATA BELOW");
// sendRawData(); // this is for sending raw data, for where everything else is done in processing
// Serial.println();
Serial.println("WEIGHT DATA BELOW");
sendWeightData();
Serial.println();
//calculate forces in N
F1 = weights[0]*go/1000; //[N]
F2 = weights[1]*go/1000; //[N]
lift = F1 + F2;
drag = (weights[2])*go/1000; //[N]
Mle = x01 * F1 + x02 *F2; // [Nm]
xcp = (x02 * F2 + x01 * F2) / (F1 + F2)*1000;
//aerodynamic coefficients
Cl = (lift*2)/(rho*v*v*S);
Cd = (drag*2)/(rho*v*v*S);
Cm = (Mle*2)/(rho*v*v*S*C);
Serial.print("lift = ");
Serial.print(lift);
Serial.println(" [N]");
Serial.print("drag = ");
Serial.print(drag);
Serial.println(" [N]"); // REPRESENT IT IN MILINEWTONS FOR MORE PRECISSION
Serial.print("momentum at the leading edge = ");
Serial.print(Mle);
Serial.println(" [Nm]");
Serial.print("position of the centre of pressure: ");
Serial.print(xcp);
Serial.println(" [mm]");
Serial.println();
Serial.println("Aerodynamic coefficients");
Serial.print("Cl = ");
Serial.println(Cl);
Serial.print("Cd = ");
Serial.println(Cd);
Serial.print("Cm = ");
Serial.println(Cm);
Serial.println();
// On serial data (any data), re-tare
if (Serial.available() > 0) {
while (Serial.available()) {
Serial.read();
}
tare();
}
}
Citar


[-]
Respuesta rápida
Mensaje
Escribe tu respuesta a este mensaje aquí.

Verificación de la imagen
Escribe el texto que aparece en la imagen, en el campo que está abajo. Este proceso se usa para evitar mensajes automáticos.
Verificación de la imagen
(no distingue MAYÚSC/minúsc)

Temas similares...
Tema Autor Respuestas Vistas Último mensaje
  CONSULTA AYUDA ERROR LASERGRBL pedrovelandia 0 40 01-07-2020, 05:24 PM
Último mensaje: pedrovelandia
  CONSULTA AYUDA ERROR LASERGRBL pedrovelandia 0 31 01-07-2020, 05:23 PM
Último mensaje: pedrovelandia
  CONSULTA AYUDA ERROR LASERGRBL pedrovelandia 0 25 01-07-2020, 05:22 PM
Último mensaje: pedrovelandia
  CONSULTA Error compiladopara la tarjeta Arduino/Genuino Uno RobbieW21 3 393 19-04-2020, 10:55 PM
Último mensaje: JLSiles79
  DUDA Error de mi anycubicb photón Escultor digital 0 312 31-10-2019, 06:00 PM
Último mensaje: Escultor digital