Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Potrebna pomoc oko sklapanja sms vage ARDUINO

[es] :: Elektronika :: Mikrokontroleri :: Potrebna pomoc oko sklapanja sms vage ARDUINO

[ Pregleda: 2732 | Odgovora: 11 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

anon300486

Član broj: 300486
Poruke: 17
62.193.159.*



Profil

icon Potrebna pomoc oko sklapanja sms vage ARDUINO20.09.2018. u 08:13 - pre 67 meseci
Od kompnenata imam
Arduino wavget uno r3 , senzor tezine analogni od 120 kg , HX 711 modul on bi trebao da sluzi za pretvaranje analognog napona u digitalni , u sim 900 c 84 GSM Shild za arduino . Povezao sam sve vodjen trebalo mi je malo vremena da uopste pustim ovaj wavget uno r3 u rad uopste zato sto su mu potrebni posebni drajveri za rad.
Hocu prvo da napravim bar vagu tjst senzor tezine da pustim u rad . Ali mi nikako ne ide za rukom . Povezao sam sve i vodjen ovim tutorijalom sa youtuba
https://www.youtube.com/watch?v=nGUpzwEa4vg
iskopirao kod ali stalno dobijam ocitanu vrednost 0 . Molim vas ako neko se razume u arduino ili ima neka slicna tema nek me navede na odgovor . Pozdrav . u produzetku teksta cu uraditi copy paste koda koji sam pustio na arduino za tezinu .

glavni kod


#include "HX711.h"

HX711 cell(3, 2);

void setup() {
Serial.begin(9600);
}

long val = 0;
float count = 0;

void loop() {
count = count + 1;

// Use only one of these
//val = ((count-1)/count) * val + (1/count) * cell.read(); // take long term average
//val = 0.5 * val + 0.5 * cell.read(); // take recent average
val = cell.read(); // most recent reading

Serial.println( val );
}


KOD HX711.cpp

//#include <Arduino.h>
#include "HX711.h"

HX711::HX711(byte dout, byte pd_sck, byte gain) {
PD_SCK = pd_sck;
DOUT = dout;

pinMode(PD_SCK, OUTPUT);
pinMode(DOUT, INPUT);

set_gain(gain);
}

HX711::~HX711() {

}

bool HX711::is_ready() {
return digitalRead(DOUT) == LOW;
}

void HX711::set_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();
}

long HX711::read() {
// wait for the chip to become ready
while (!is_ready());

byte data[3];

// pulse the clock pin 24 times to read the data
for (byte j = 3; j--;) {
for (char i = 8; i--;) {
digitalWrite(PD_SCK, HIGH);
bitWrite(data[j], i, digitalRead(DOUT));
digitalWrite(PD_SCK, LOW);
}
}

// set the channel and the gain factor for the next reading using the clock pin
for (int i = 0; i < GAIN; i++) {
digitalWrite(PD_SCK, HIGH);
digitalWrite(PD_SCK, LOW);
}

data[2] ^= 0x80;

return ((uint32_t) data[2] << 16) | ((uint32_t) data[1] << 8) | (uint32_t) data[0];
}

long HX711::read_average(byte times) {
long sum = 0;
for (byte i = 0; i < times; i++) {
sum += read();
}
return sum / times;
}

double HX711::get_value(byte times) {
return read_average(times) - OFFSET;
}

float HX711::get_units(byte times) {
return get_value(times) / SCALE;
}

void HX711::tare(byte times) {
double sum = read_average(times);
set_offset(sum);
}

void HX711::set_scale(float scale) {
SCALE = scale;
}

void HX711::set_offset(long offset) {
OFFSET = offset;
}

void HX711::power_down() {
digitalWrite(PD_SCK, LOW);
digitalWrite(PD_SCK, HIGH);
}

void HX711::power_up() {
digitalWrite(PD_SCK, LOW);
}

KOD HX711.h

#ifndef HX711_h
#define HX711_h

#if ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif

class HX711
{
private:
byte PD_SCK; // Power Down and Serial Clock Input Pin
byte DOUT; // Serial Data Output Pin
byte GAIN; // amplification factor
long OFFSET; // used for tare weight
float SCALE; // used to return weight in grams, kg, ounces, whatever

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
// gain: 128 or 64 for channel A; channel B works with 32 gain factor only
HX711(byte dout, byte pd_sck, byte gain = 128);

virtual ~HX711();

// 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
long read();

// returns an average reading; times = how many times to read
long read_average(byte times = 10);

// returns (read_average() - OFFSET), that is the current value without the tare weight; times = how many readings to do
double get_value(byte times = 1);

// returns get_value() divided by SCALE, that is the raw value divided by a value obtained via calibration
// times = how many readings to do
float get_units(byte times = 1);

// set the OFFSET value for tare weight; times = how many times to read the tare value
void tare(byte times = 10);

// set the SCALE value; this value is used to convert the raw data to "human readable" data (measure units)
void set_scale(float scale = 1.f);

// set OFFSET, the value that's subtracted from the actual reading (tare weight)
void set_offset(long offset = 0);

// puts the chip into power down mode
void power_down();

// wakes up the chip after power down mode
void power_up();
};

#endif /* HX711_h */
 
Odgovor na temu

eembedded
student
novi sad

Član broj: 338914
Poruke: 49
*.dynamic.isp.telekom.rs.



+8 Profil

icon Re: Potrebna pomoc oko sklapanja sms vage ARDUINO20.09.2018. u 08:27 - pre 67 meseci
"HX711.h" da li si skinuo ovaj lib ?
 
Odgovor na temu

anon300486

Član broj: 300486
Poruke: 17
62.193.159.*



Profil

icon Re: Potrebna pomoc oko sklapanja sms vage ARDUINO20.09.2018. u 08:36 - pre 67 meseci
Pustio sam i kod te biblioteke u ovoj mojoj prvoj poruci imam skinuto
 
Odgovor na temu

gobs
Goran Surtov
ing. odrzavanje ,
K.Dubica

Član broj: 162343
Poruke: 51
89.111.232.*



+2 Profil

icon Re: Potrebna pomoc oko sklapanja sms vage ARDUINO20.09.2018. u 09:42 - pre 67 meseci
Ovo je kod iz primjera koji dođe sa bibliotekom , radi iz prve na Arduino Nano.
Izmjena: dodao sam i biblioteku sa primjerima.
Code:

#include "HX711.h"

// HX711.DOUT    - pin #A1
// HX711.PD_SCK    - pin #A0

HX711 scale(A1, A0);        // parameter "gain" is ommited; the default value 128 is used by the library

void setup() {
  Serial.begin(38400);
  Serial.println("HX711 Demo");

  Serial.println("Before setting up the scale:");
  Serial.print("read: \t\t");
  Serial.println(scale.read());            // print a raw reading from the ADC

  Serial.print("read average: \t\t");
  Serial.println(scale.read_average(20));      // print the average of 20 readings from the ADC

  Serial.print("get value: \t\t");
  Serial.println(scale.get_value(5));        // print the average of 5 readings from the ADC minus the tare weight (not set yet)

  Serial.print("get units: \t\t");
  Serial.println(scale.get_units(5), 1);    // print the average of 5 readings from the ADC minus tare weight (not set) divided 
                        // by the SCALE parameter (not set yet)  

  scale.set_scale(2280.f);                      // this value is obtained by calibrating the scale with known weights; see the README for details
  scale.tare();                        // reset the scale to 0

  Serial.println("After setting up the scale:");

  Serial.print("read: \t\t");
  Serial.println(scale.read());                 // print a raw reading from the ADC

  Serial.print("read average: \t\t");
  Serial.println(scale.read_average(20));       // print the average of 20 readings from the ADC

  Serial.print("get value: \t\t");
  Serial.println(scale.get_value(5));        // print the average of 5 readings from the ADC minus the tare weight, set with tare()

  Serial.print("get units: \t\t");
  Serial.println(scale.get_units(5), 1);        // print the average of 5 readings from the ADC minus tare weight, divided 
                        // by the SCALE parameter set with set_scale

  Serial.println("Readings:");
}

void loop() {
  Serial.print("one reading:\t");
  Serial.print(scale.get_units(), 1);
  Serial.print("\t| average:\t");
  Serial.println(scale.get_units(10), 1);

  scale.power_down();                    // put the ADC in sleep mode
  delay(5000);
  scale.power_up();
}

Potpis ...
Prikačeni fajlovi
 
Odgovor na temu

anon300486

Član broj: 300486
Poruke: 17
62.193.159.*



Profil

icon Re: Potrebna pomoc oko sklapanja sms vage ARDUINO20.09.2018. u 13:01 - pre 67 meseci
Hvala puno na odgovoru radi mi i ovaj tvoj kod ali sva ocitavanja su mi 0 (nula) . Kad savijam senzor vrsim pritisak na njega morao bi nesto da pokaze
 
Odgovor na temu

eembedded
student
novi sad

Član broj: 338914
Poruke: 49
*.dynamic.isp.telekom.rs.



+8 Profil

icon Re: Potrebna pomoc oko sklapanja sms vage ARDUINO20.09.2018. u 16:47 - pre 67 meseci
A da li si proverio na koje pinove si nakacio senzor ? daj sliku toga sto si napravio
 
Odgovor na temu

anon300486

Član broj: 300486
Poruke: 17
*.com
Via: [es] mailing liste



Profil

icon Re: Potrebna pomoc oko sklapanja sms vage ARDUINO20.09.2018. u 20:38 - pre 67 meseci
Evo linkovi pokusao sam preko maila ali nisam uspeo nov sam relativno na forumu . Hvala ti puno sto pomazes .

ove kablice prema senzoru sam sve zalemio ovaj oguljen kabal nisam nigde stavio i drzim ga u ruci visak mi je kad sam ovo povezao po semi i sve mi ide boja na boju

A0 i A 1 je DATA i sat to sam po semi povezao na arduino i GND je na GND a VCC na 5 V evo linkovi ka slikama nadam se da se sve dobro vidi

https://ibb.co/mLcrUz
https://ibb.co/h9mwwe
https://ibb.co/ngJn2K
https://ibb.co/fRNQpz
 
Odgovor na temu

goran_68

Član broj: 89012
Poruke: 932
*.dynamic.isp.telekom.rs.



+81 Profil

icon Re: Potrebna pomoc oko sklapanja sms vage ARDUINO20.09.2018. u 21:49 - pre 67 meseci
Pogrešno si vezao DATA i CLK. U kodu si definisao da su to pinovi 3 i 2 a ne A1 i A0.
Pogledaj šta ti je u kodu:

Code:
HX711 cell(3, 2);

gorankg
 
Odgovor na temu

anon300486

Član broj: 300486
Poruke: 17
*.fco.mts.telekom.rs.



Profil

icon Re: Potrebna pomoc oko sklapanja sms vage ARDUINO20.09.2018. u 21:52 - pre 67 meseci
Prešao sam na gobsov kod prvi kod od gore

#include "HX711.h"

// HX711.DOUT - pin #A1
// HX711.PD_SCK - pin #A0
 
Odgovor na temu

eembedded
student
novi sad

Član broj: 338914
Poruke: 49
*.dynamic.isp.telekom.rs.



+8 Profil

icon Re: Potrebna pomoc oko sklapanja sms vage ARDUINO20.09.2018. u 22:15 - pre 67 meseci
Code:

#include "HX711.h"

//DOUT A1
//SCK A0

HX711 scale(A1, A0);

void setup() {
  Serial.begin(38400);
}

void loop() {
  Serial.println(scale.read());    
  delay(500);
}


Probaj ovako cisto da vidim da li cita nesto, a ako ne onda probaj na neke digitalne ulaze da ga povezes.
 
Odgovor na temu

gobs
Goran Surtov
ing. odrzavanje ,
K.Dubica

Član broj: 162343
Poruke: 51
89.111.232.*



+2 Profil

icon Re: Potrebna pomoc oko sklapanja sms vage ARDUINO21.09.2018. u 06:46 - pre 67 meseci
Zamjeni zelenu i bjelu žicu od mjerne ćelije.
Potpis ...
 
Odgovor na temu

anon300486

Član broj: 300486
Poruke: 17
62.193.159.*



Profil

icon Re: Potrebna pomoc oko sklapanja sms vage ARDUINO21.09.2018. u 07:28 - pre 67 meseci
http://prntscr.com/kwx4ck
evo posle zamene zica konstantno sam vrsio pritisak na senzorr.
 
Odgovor na temu

[es] :: Elektronika :: Mikrokontroleri :: Potrebna pomoc oko sklapanja sms vage ARDUINO

[ Pregleda: 2732 | Odgovora: 11 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.