Po ukončení zápisu do ESP32, tam nic není

hafca
Příspěvky: 86
Registrován: 23 říj 2017, 23:05
Reputation: 0

Re: Po ukončení zápisu do ESP32, tam nic není

Příspěvek od hafca » 15 lis 2021, 18:56

Pohledal jsem nějaké drivery a budu čekat jak reklamace dopadne. Pak dám vědět.

hafca
Příspěvky: 86
Registrován: 23 říj 2017, 23:05
Reputation: 0

Re: Po ukončení zápisu do ESP32, tam nic není

Příspěvek od hafca » 19 lis 2021, 15:54

Deska je doma z reklamace s tím, že je v pořádku. Když jsem jí připojil, blikala modrá LED a v rytmu blikání byl na sériovém monitoru vidět opakující se nápis. Takže asi funkční je, ale jak to tam dostali nevím. Zkusil jsem tam znovu poslat program a jediný výsledek je, že nápis se ztratil a vše je při starém.
Drivery jsem nainstaloval co jsem kde našel, ale výsledek řádný.
Je mi jasné, že chyba je u mě, ale už nevím, co ještě zkusit. Nastavení desky v IDE je na obrázku a ovladač je CP210x.
Přílohy
deska.jpg

Axamith
Příspěvky: 530
Registrován: 09 srp 2017, 08:17
Reputation: 0
Kontaktovat uživatele:

Re: Po ukončení zápisu do ESP32, tam nic není

Příspěvek od Axamith » 19 lis 2021, 16:47

Pokud dodavatel umí do desky program dostat, tak bych sklopil uši a zeptal se ho, jestli by byl ochoten ti poradit. Slušný prodejce by toto jako službu zákazníkovi mohl udělat.

hafca
Příspěvky: 86
Registrován: 23 říj 2017, 23:05
Reputation: 0

Re: Po ukončení zápisu do ESP32, tam nic není

Příspěvek od hafca » 19 lis 2021, 17:08

Na to se chystám, ale fungují až v pondělí. Tak zatím bádám, ale výsledky pořád nula.

hafca
Příspěvky: 86
Registrován: 23 říj 2017, 23:05
Reputation: 0

Re: Po ukončení zápisu do ESP32, tam nic není

Příspěvek od hafca » 22 lis 2021, 13:23

Mluvil jsem s někým z podpory. Řekl mi, že modul jen připojil k IDE a nahrál program, který byl funkční. Kdž jsem mu četl hlášky ze sériového monitoru, říkal, že chyba může být v programu, který se resetuje stále dokola. Jen je mi divné, proč to nedělá všem spokojeným uživatelům, ale jen mě?
Ještě mi napadají knihovny, ale když prošla kompilace? Jsem pořád ještě začátečník a do všeho nevidím, ale kdyby se chtěl někdo kouknout, čím to může být, dávám sem ten program.

Kód: Vybrat vše

// settings
#define EIGHT_DIGIT false     // true if your machine has 8 digits
#define ORIGIN_SENSOR false   // true if you installed origin sensor
#define TOUCH_CONTROL false   // true if you want to compensate origin by touch
#define ORIGIN_COMPENSATION 50 // compensation of origin mark position
#define ORIGIN_THRES 3500      // photo reflector sensor threshold
#define DEBUG false

const char* ssid     = "name"; // your WiFi's SSID
const char* password = "password"; // your WiFi's password
#define TIMEZONE 1 // timezone (GMT = 0, Japan = 9)
// settings end

#if EIGHT_DIGIT
#define DIGIT 8
#else
#define DIGIT 4
#endif
typedef struct {
  int v[DIGIT];
} Digit;

#include <WiFi.h>

// Motor and clock parameters
#define STEPS_PER_ROTATION 4096 // steps of a single rotation of motor

// wait for a single step of stepper
#define MOTOR_DELAY 1

// ports used to control the stepper motor
// if your motor rotate to the opposite direction, 
int port[4] = {12, 32, 25, 27};

// sequence of stepper motor control
int seq[8][4] = {
  {  LOW, HIGH, HIGH,  LOW},
  {  LOW,  LOW, HIGH,  LOW},
  {  LOW,  LOW, HIGH, HIGH},
  {  LOW,  LOW,  LOW, HIGH},
  { HIGH,  LOW,  LOW, HIGH},
  { HIGH,  LOW,  LOW,  LOW},
  { HIGH, HIGH,  LOW,  LOW},
  {  LOW, HIGH,  LOW,  LOW}
};

// stepper motor rotation
void rotate(int step) {
  int count = 0;
  static int phase = 0;
  int i, j;
  int delta = (step > 0) ? 1 : 7;

  step = (step > 0) ? step : -step;
  for(j = 0; j < step; j++) {
    phase = (phase + delta) % 8;
    for(i = 0; i < 4; i++) {
      digitalWrite(port[i], seq[phase][i]);
    }
    count++;
    delay(MOTOR_DELAY);
    if(step - j < 410) delay(MOTOR_DELAY); // deacceleration
    if(count < 100) delay(MOTOR_DELAY); // acceleration
    if(count < 50) delay(MOTOR_DELAY); // acceleration
    if(count < 20) delay(MOTOR_DELAY); // acceleration
    if(count < 10) delay(MOTOR_DELAY); // acceleration
  }
  // power cut
  for(i = 0; i < 4; i++) {
    digitalWrite(port[i], LOW);
  }
}

void findOrigin(void) {
  while(analogRead(34) > ORIGIN_THRES) { // if origin is sensed, back a bit
    rotate(-1);
  }
  while(analogRead(34) < ORIGIN_THRES) { // find origin
    rotate(1);
  }
  rotate(ORIGIN_COMPENSATION);
  delay(1000);
}
  
#define KILL_BACKLASH 10

// avoid error accumuration of fractional part of 4096 / 10
void rotStep(int s) {
  static long currentPos;
  static long currentStep;
  
  currentPos += s;
  long diff = currentPos * STEPS_PER_ROTATION / 10 - currentStep;
  if(diff < 0) diff -= KILL_BACKLASH;
  else diff += KILL_BACKLASH;
  rotate(diff);
  currentStep += diff;
}

void printDigit(Digit d) {
#if DEBUG
  String s = "        ";
  int i;

  for(i = 0; i < DIGIT; i++) {
    s.setCharAt(i, d.v[i] + '0');
  }
  Serial.println(s);
#endif
}

//increase specified digit
Digit rotUp(Digit current, int digit, int num) {
  int freeplay = 0;
  int i;
  
  for(i = digit; i < DIGIT - 1; i++) {
    int id = current.v[i];
    int nd = current.v[i+1];
    if(id <= nd) id += 10;
    freeplay += id - nd - 1;
  }
  freeplay += num;
  rotStep(-1 * freeplay);
  current.v[digit] = (current.v[digit] + num) % 10;
  for(i = digit + 1; i < DIGIT; i++) {
    current.v[i] = (current.v[i - 1] + 9) % 10;
  }
#if DEBUG
  Serial.print("up end : ");
  printDigit(current);
#endif
  return current;
}

// decrease specified digit
Digit rotDown(Digit current, int digit, int num) {
  int freeplay = 0;
  int i;
  
  for(i = digit; i < DIGIT - 1; i++) {
    int id = current.v[i];
    int nd = current.v[i+1];
    if(id > nd) nd += 10;
    freeplay += nd - id;
  }
  freeplay += num;
  rotStep( 1 * freeplay);
  current.v[digit] = (current.v[digit] - num + 10) % 10;
  for(i = digit + 1; i < DIGIT; i++) {
    current.v[i] = current.v[i - 1];
  }
#if DEBUG
  Serial.print("down end : ");
  printDigit(current);
#endif
  return current;
}

// decrease or increase specified digit 
Digit rotDigit(Digit current, int digit, int num) {
  if(num > 0) {
    return rotUp(current, digit, num);
  }
  else if(num < 0) {
    return rotDown(current, digit, -num);
  }
  else return current;
}

// set single digit to the specified number
Digit setDigit(Digit current, int digit, int num) {
  if(digit == 0) { // most significant digit
    int rot = num - current.v[0];
    // use decreasing rotation because following digits tend to be 000 or 999
    if(rot > 1) rot -= 10;
    return rotDigit(current, digit, rot);
  }
  int cd = current.v[digit];
  int pd = current.v[digit - 1];
  if(cd == num) return current;
  
  // check if increasing rotation is possible
  int n2 = num;
  if(n2 < cd) n2 += 10;
  if(pd < cd) pd += 10;
  if(pd <= cd || pd > n2) {
    return rotDigit(current, digit, n2 - cd);
  }
  // if not, do decrease rotation
  if(num > cd) cd += 10;
  return rotDigit(current, digit, num - cd);  
}

Digit current = {0, 0, 0, 0};
void setNumber(Digit n) {
  for(int i = 0; i < DIGIT; i++) {
    current = setDigit(current, i, n.v[i]);
  }
}

void getNTP(void) {
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  
  do {
#if DEBUG
    Serial.println("retry..");
#endif
    delay(300);
  } while (WiFi.status() != WL_CONNECTED);

  configTime(TIMEZONE * 3600L, 0, "ntp.nict.jp", "time.google.com", "ntp.jst.mfeed.ad.jp");//NTPの設定

  delay(1000);
  WiFi.disconnect();
}

void setup() {

#if DEBUG
  Serial.begin(9600);
  Serial.println("start");
#endif

  getNTP();
  
  pinMode(port[0], OUTPUT);
  pinMode(port[1], OUTPUT);
  pinMode(port[2], OUTPUT);
  pinMode(port[3], OUTPUT);

#if ORIGIN_SENSOR
  findOrigin();
#endif

  rotate(STEPS_PER_ROTATION * (DIGIT - 1));
}


void loop() {
  static int prevhour;
  struct tm tmtime;

#if TOUCH_CONTROL
  if(touchRead(T8) < 15) { // GPIO33 pin
    rotate(10);
    return;
  }
  else if(touchRead(T6) < 15) { // GPIO14 pin
    rotate(-10);
    return;
  }
#endif

  getLocalTime(&tmtime);
  if(tmtime.tm_hour != prevhour) {
    prevhour = tmtime.tm_hour;
    getNTP();
  }

  Digit n;
#if EIGHT_DIGIT
  n.v[0] = (tmtime.tm_mon + 1) / 10;
  n.v[1] = (tmtime.tm_mon + 1) % 10;
  n.v[2] = tmtime.tm_mday / 10;
  n.v[3] = tmtime.tm_mday % 10;
  n.v[4] = tmtime.tm_hour / 10;
  n.v[5] = tmtime.tm_hour % 10;
  n.v[6] = tmtime.tm_min / 10;
  n.v[7] = tmtime.tm_min % 10;
#else
  n.v[0] = tmtime.tm_hour / 10;
  n.v[1] = tmtime.tm_hour % 10;
  n.v[2] = tmtime.tm_min / 10;
  n.v[3] = tmtime.tm_min % 10;
#endif
  setNumber(n);

  delay(1000);
}

Uživatelský avatar
kiRRow
Příspěvky: 1152
Registrován: 07 kvě 2019, 07:03
Reputation: 0
Bydliště: Opava

Re: Po ukončení zápisu do ESP32, tam nic není

Příspěvek od kiRRow » 22 lis 2021, 14:00

Zkoušel jsi kabel ?
Já po tom pátral dva dny, proč se mi to chová velmi prapodivně. Jednou jedno arduino šlo, druhé ne - druhý den nešlo první, ale druhé jo. Co chvilku bylo třeba odpojit, připojit USB ( monitor jel jak po másle, ale nešel nahrát program )

hafca
Příspěvky: 86
Registrován: 23 říj 2017, 23:05
Reputation: 0

Re: Po ukončení zápisu do ESP32, tam nic není

Příspěvek od hafca » 22 lis 2021, 14:37

To bylo první, co jsem zkoušel. 3 kabely a ještě různé USB konektory.

Hanz
Příspěvky: 262
Registrován: 25 dub 2019, 23:52
Reputation: 0

Re: Po ukončení zápisu do ESP32, tam nic není

Příspěvek od Hanz » 22 lis 2021, 22:25

Mluvil jsem s někým z podpory. Řekl mi, že modul jen připojil k IDE a nahrál program, který byl funkční.
poptej se znovu u podpory a vyžádej si emailem prográmek s knihovnou co ti nahrál,třeba ti opět pomůže a ty si ověříš co je nebo může být špatně ... držím palce

hafca
Příspěvky: 86
Registrován: 23 říj 2017, 23:05
Reputation: 0

Re: Po ukončení zápisu do ESP32, tam nic není

Příspěvek od hafca » 23 lis 2021, 08:32

Našel jsem blikací demo, přidal si k tomu výpis textu na sériový monitor a jde to. Vestavěná LED bliká a text běží. V poslání programu na desku tedy problém není. Jediná knihovna co tam je, je WiFI, tu jsem zkusil jinou a nic.
Mě to přijde, že ten program se někde sekne a nedostane se do míst, kde by měl vypisovat na sériový monitor. I přesto, že debug je povolený.
Dnes konečně dorazí krokový motor s řadičem. Připojím ho a uvidím, co to bude dělat.

hafca
Příspěvky: 86
Registrován: 23 říj 2017, 23:05
Reputation: 0

Re: Po ukončení zápisu do ESP32, tam nic není

Příspěvek od hafca » 23 lis 2021, 14:25

Zkoušel jsem to celou dobu bez motoru, který dorazil teprve dnes. A i když jsem si myslel, že je to jedno, tak nebylo. Po připojení driveru a motoru se všechno rozběhlo jak má.
Dík všem za pomoc hafca.

Odpovědět

Kdo je online

Uživatelé prohlížející si toto fórum: Žádní registrovaní uživatelé a 13 hostů