Arduino UNO komunikace přes USB COM

Odpovědět
Fajn-tom
Příspěvky: 2
Registrován: 01 dub 2020, 20:52
Reputation: 0

Arduino UNO komunikace přes USB COM

Příspěvek od Fajn-tom » 01 dub 2020, 21:11

Ahoj,
Mam problém s programem SimpleDyno https://sites.google.com/site/simpledyno/file-cabinet který ukladá ukládá a zobrazuje různé hodnoty, který mu posílá deska UNO z analogových i digitálních vstupů. Do desky nahraju sketch v pořádku. Ale program SimpleDyno se s deskou nespojí, napíše to chybu error reading com port. Zkoušeno na 8 různých PC a pouze na jednom to jde. Mam originál i replikovou desku, ale fungují jen na noteboku Asus, zbytek zkoušených PC se nepřipojí k desce. Je v PC něco co by bránilo kuminikaci COM portu mezi deskou a programem?
Děkuji

Kód: Vybrat vše

/*
  Sketch for use with SimpleDyno
  Developed on Arduino Uno Platform
  DamoRC - 2013-2014
  
  ALWAYS use the Sketch distributed with each new version of SimpleDyno
  
  Transmits:
    1 x Session timestamp 
    1 x Interrupt timestamp and 1 x time interval since last interrupt for INT0 / Pin2 / RPM1
    1 x Interrupt timestamp and 1 x time interval since last interrupt for INT1 / Pin3 / RPM2
    6 x Analog Inputs (A0 and A1 are Voltage and Current, A2 and A3 are Temperature, A4 and A5 are open)
  Values are comma delimeted
  Baud rates selected in SD must match coded values in this Sketch.
 */

  const int NumPortsToRead = 6;
  int AnalogResult[NumPortsToRead];
  volatile unsigned long TimeStamp = 0;
  volatile unsigned long time1 = 0;
  volatile unsigned long time2 = 0;
  volatile unsigned long Oldtime1 = 0;
  volatile unsigned long Oldtime2 = 0;
  volatile unsigned long TempTime1 = 0;
  volatile unsigned long TempTime2 = 0;
  String AllResult = "";

void setup() {
  // Initialize serial communication
  // Ensure that Baud rate specified here matches that selected in SimpleDyno
  // Availailable Baud rates are:
  // 9600, 14400, 19200, 28800, 38400, 57600, 115200
  Serial.begin(9600);
  // Initialize interupts (Pin2 is interrupt 0 = RPM1, Pin3 in interrupt 1 = RPM2)
  attachInterrupt(0,channel1,FALLING);
  attachInterrupt(1,channel2,FALLING);
}

void loop() {
  AllResult = "";
  AllResult += micros();
  AllResult += ",";
  AllResult += TempTime1;
  AllResult += ",";
  AllResult += time1;
  AllResult += ",";
  AllResult += TempTime2;
  AllResult += ",";
  AllResult += time2;
  for (int Looper = 0; Looper < NumPortsToRead;Looper++){
    AnalogResult[Looper] = analogRead(Looper);
    AllResult += ",";
    AllResult += AnalogResult[Looper];
  }
  Serial.println (AllResult);
  Serial.flush();
  delay(1);
}

//Interrupt routine for RPM1
void channel1(){
  TempTime1 = micros();
  time1 = TempTime1-Oldtime1;
  Oldtime1 = TempTime1;
}

//Interrupt routine for RPM2
void channel2(){
    TempTime2 = micros();
  time2 = TempTime2-Oldtime2;
  Oldtime2 = TempTime2;
}

Uživatelský avatar
pavel1tu
Příspěvky: 2054
Registrován: 26 říj 2017, 08:28
Reputation: 0
Bydliště: Trutnov
Kontaktovat uživatele:

Re: Arduino UNO komunikace přes USB COM

Příspěvek od pavel1tu » 01 dub 2020, 21:39

zvednout těch 9600 v nastavení komunikace bych zkusil - klidně 115200
UNO, NANO, Mikro, PRO mini, DUE, ESP32S2, RPi PICO
Pavel1TU
"Správně napsaný kod lze číst jako knihu"

Fajn-tom
Příspěvky: 2
Registrován: 01 dub 2020, 20:52
Reputation: 0

Re: Arduino UNO komunikace přes USB COM

Příspěvek od Fajn-tom » 01 dub 2020, 22:18

to jsem zkoušel, bohužel to nepomohlo

ondraN
Příspěvky: 932
Registrován: 08 srp 2019, 20:01
Reputation: 0

Re: Arduino UNO komunikace přes USB COM

Příspěvek od ondraN » 02 dub 2020, 07:52

jestli není problém tady:

Kód: Vybrat vše

  Serial.begin(9600);
  // Initialize interupts (Pin2 is interrupt 0 = RPM1, Pin3 in interrupt 1 = RPM2)
  attachInterrupt(0,channel1,FALLING);
  attachInterrupt(1,channel2,FALLING);
Piny 0 a 1 jsou vyhrazeny pro sériový port, když je použit. Když se podívám níže na syntaxi attachInterrupt, není moc zřejmé, jestli překladač použije verzi dva nebo tři. Takže bych rozhodně doporučil přepsat to na tu první doporučenou verzi

Kód: Vybrat vše

attachInterrupt(digitalPinToInterrupt(2),channel1,FALLING);
attachInterrupt(digitalPinToInterrupt(3),channel2,FALLING);

Syntax

attachInterrupt(digitalPinToInterrupt(pin), ISR, mode) (recommended)
attachInterrupt(interrupt, ISR, mode) (not recommended)
attachInterrupt(pin, ISR, mode) (Not recommended. Additionally, this syntax only works on Arduino SAMD Boards, Uno WiFi Rev2, Due, and 101.)
Parameters

interrupt: the number of the interrupt. Allowed data types: int.
pin: the Arduino pin number.
ISR: the ISR to call when the interrupt occurs; this function must take no parameters and return nothing. This function is sometimes referred to as an interrupt service routine.
mode: defines when the interrupt should be triggered. Four constants are predefined as valid values:

LOW to trigger the interrupt whenever the pin is low,

CHANGE to trigger the interrupt whenever the pin changes value

RISING to trigger when the pin goes from low to high,

FALLING for when the pin goes from high to low.

golog
Příspěvky: 1
Registrován: 10 dub 2020, 19:34
Reputation: 0

Re: Arduino UNO komunikace přes USB COM

Příspěvek od golog » 10 dub 2020, 19:37

čau mám stejný problém kdyby někoho něco napadlo bylo by to fajn ale slyšel jsem že se tato chyba vyskytuje primárně mimo USA

Odpovědět

Kdo je online

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