Znaleziono 2 wyniki

autor: pitsa
23 lut 2020, 16:29
Forum: Elektronika CNC
Temat: dziwne działanie czujnika wysokości narzędzia
Odpowiedzi: 20
Odsłony: 2461

Re: dziwne działanie czujnika wysokości narzędzia

Analogowy pin z kablem i nie podciągnięty do masy lub zasilania odpowiednim rezystorem to detektor promieniowania elektromagnetycznego. Na twoim zdjęciu widać, że tuż obok arduino masz źródło - zasilacz. To wystarczy.

Tu przykład działania takiego kabelka podpiętego do pinu analogowego w Arduino (czyli atmedzie) i efekty
od kabla ładującego telefon. Zrobiłem taką zabawkę aby sprawdzić co mi zakłóca urządzenia.


Możesz wgrać do swojego arduino taki kod:

Kod: Zaznacz cały

// EMF Detector for LED Bargraph v1.0
// 5.12.2009
// original code/project by Aaron ALAI - [email protected]
// modified for use w/ LED bargraph by Collin Cunningham - [email protected]
// modified for use buzzer signalization by Tomasz Bartuś
// http://home.agh.edu.pl/~bartus/index.php?action=efekty&subaction=arduino&item=28

#define NUMREADINGS 15                        // raise this number to increase data smoothing

int senseLimit = 15;                          // raise this number to decrease sensitivity (up to 1023 max)
int probePin = 5;                             // analog 5
int val = 0;                                  // reading from probePin


// variables for smoothing
int readings[NUMREADINGS];                    // the readings from the analog input
int inde = 0;                                // the index of the current reading
int total = 0;                                // the running total
int average = 0;                              // final average of the probe reading

void setup() {
  Serial.begin(9600);                         // initiate serial connection for debugging/etc
  for (int i = 0; i < NUMREADINGS; i++)
    readings[i] = 0;                          // initialize all the readings to 0
}

void loop() {
  val = analogRead(probePin);                 // take a reading from the probe

  if(val >= 1){                               // if the reading isn't zero, proceed

    val = constrain(val, 1, senseLimit);      // turn any reading higher than the senseLimit value into the senseLimit value
    val = map(val, 1, senseLimit, 1, 1023);   // remap the constrained value within a 1 to 1023 range

    total -= readings[inde];                 // subtract the last reading
    readings[inde] = val;                    // read from the sensor
    total += readings[inde];                 // add the reading to the total
    inde = (inde + 1);                      // advance to the next index

    if (inde >= NUMREADINGS){                 // if we're at the end of the array...
      inde = 0;                              // ...wrap around to the beginning
    }
    average = total / NUMREADINGS;            // calculate the average
    
    Serial.println(val);                       // use output to aid in calibrating
  }
}
i zobaczyć w Monitorze portu szeregowego jakie wartości będzie pokazywać gdy pod pin A5 jest podpięty kabel, gdy dotkniesz go ręką...
autor: pitsa
22 lut 2020, 23:47
Forum: Elektronika CNC
Temat: dziwne działanie czujnika wysokości narzędzia
Odpowiedzi: 20
Odsłony: 2461

Re: dziwne działanie czujnika wysokości narzędzia

Zawsze w tym samym miejscu się zatrzymuje?

Wróć do „dziwne działanie czujnika wysokości narzędzia”