A21 centrale digitale ethernet/Wifi...a 27 euro!

Il sistema digitale (DCC) applicato al modellismo ferroviario.

Moderatore: roy67

Rispondi
Avatar utente
sal727
Messaggi: 3177
Iscritto il: dom apr 26, 2015 5:22 pm
Nome: Salvatore
Regione: Emilia Romagna
Città: Bologna
Ruolo: Moderatore
Età: 62
Stato: Non connesso

Re: A21 centrale digitale ethernet/Wifi...a 27 euro!

Messaggio da sal727 » mer mar 13, 2019 7:12 pm

nella pagina di controllo del sistema di fianco alla com c'è anche scritto il tipo di oggetto che è collegato, se hai verificato sulla com4 e settato quella giusta senza vedere nessun avvertimento di errore vuol dire che i driver li avevi già caricati qualche altra volta altrimenti ti appariva l'icona gialla di non connessione
Ciao, Salvatore

Avatar utente
sal727
Messaggi: 3177
Iscritto il: dom apr 26, 2015 5:22 pm
Nome: Salvatore
Regione: Emilia Romagna
Città: Bologna
Ruolo: Moderatore
Età: 62
Stato: Non connesso

Re: A21 centrale digitale ethernet/Wifi...a 27 euro!

Messaggio da sal727 » mer mar 13, 2019 7:30 pm

Stavo riguardando lo sketch che hai postato ed ho verificato un errore, hai messo l'indirizzo ip sbagliato
//Z21 WLAN Default config
static IPAddress Ip(192, 168, 0, 1); //default IP
static IPAddress Gw(192, 168, 0, 1); //default Gateway
static IPAddress Sb(255, 255, 255, 0); //default Subnet
nella prima riga non può essere l'indirizzo del tuo router devi modificare e assegnargli un numero che non corrisponda a nessun apparecchio collegato in rete
nello sketch originale c'era
//Z21 WLAN Default config:
static IPAddress Ip(192, 168, 0, 111); //default IP
static IPAddress Gw(192, 168, 0, 1); //default Gateway
static IPAddress Sb(255, 255, 255, 0); //default Subnet
dove 111 è il numero assegnato alla centrale, 1 è quello del router e non può andare bene, metti 111 se non è già assegnato ad altro apparecchio
Ciao, Salvatore

Avatar utente
ClaBos
Messaggi: 178
Iscritto il: mer lug 06, 2016 10:01 pm
Nome: Claudio
Regione: Friuli-Venezia Giulia
Città: Martignacco
Età: 41
Stato: Non connesso
Contatta:

Re: A21 centrale digitale ethernet/Wifi...a 27 euro!

Messaggio da ClaBos » mer mar 13, 2019 7:35 pm

Ho una ipcam in casa... Credevo che andasse inserito il mio ip.. Tornerò a mettere 111 al posto di 1.
Claudio - Volere é potere!!

Avatar utente
sal727
Messaggi: 3177
Iscritto il: dom apr 26, 2015 5:22 pm
Nome: Salvatore
Regione: Emilia Romagna
Città: Bologna
Ruolo: Moderatore
Età: 62
Stato: Non connesso

Re: A21 centrale digitale ethernet/Wifi...a 27 euro!

Messaggio da sal727 » mer mar 13, 2019 7:39 pm

Anche la IPcam avra un suo indirizzo di rete ma non può essere 192.168.0.1 che è quello del Gateway
Ciao, Salvatore

Avatar utente
ClaBos
Messaggi: 178
Iscritto il: mer lug 06, 2016 10:01 pm
Nome: Claudio
Regione: Friuli-Venezia Giulia
Città: Martignacco
Età: 41
Stato: Non connesso
Contatta:

Re: A21 centrale digitale ethernet/Wifi...a 27 euro!

Messaggio da ClaBos » mer mar 13, 2019 11:51 pm

Eventualmente... Per riportare la wemos al suo stato originale... Cioè formattarla.. Come devo fare?
Claudio - Volere é potere!!

Avatar utente
sal727
Messaggi: 3177
Iscritto il: dom apr 26, 2015 5:22 pm
Nome: Salvatore
Regione: Emilia Romagna
Città: Bologna
Ruolo: Moderatore
Età: 62
Stato: Non connesso

Re: A21 centrale digitale ethernet/Wifi...a 27 euro!

Messaggio da sal727 » gio mar 14, 2019 10:04 am

Ogni volta che installi un nuovo sketch quello precedente viene sovrascritto
Ciao, Salvatore

Avatar utente
ClaBos
Messaggi: 178
Iscritto il: mer lug 06, 2016 10:01 pm
Nome: Claudio
Regione: Friuli-Venezia Giulia
Città: Martignacco
Età: 41
Stato: Non connesso
Contatta:

Re: A21 centrale digitale ethernet/Wifi...a 27 euro!

Messaggio da ClaBos » gio mar 14, 2019 10:47 am

Codice: Seleziona tutto

Serial.write(packetBuffer, packetSize); //send to Zentrale (trenne erst dort kombinierte Pakete!) 
Dopo aver cambiato il valore dell ip ho riprovato da capo.. Ma quando vado per caricare lo sketch Z21_ESPArduinoUDP_v27 mi torna a dare questo errore.
Ho tenuto premuto il tasto, ma sempre mi esce questo errore.
Claudio - Volere é potere!!

Avatar utente
sal727
Messaggi: 3177
Iscritto il: dom apr 26, 2015 5:22 pm
Nome: Salvatore
Regione: Emilia Romagna
Città: Bologna
Ruolo: Moderatore
Età: 62
Stato: Non connesso

Re: A21 centrale digitale ethernet/Wifi...a 27 euro!

Messaggio da sal727 » gio mar 14, 2019 11:09 am

che versione hai installato?
465
477
480
Ciao, Salvatore

Avatar utente
ClaBos
Messaggi: 178
Iscritto il: mer lug 06, 2016 10:01 pm
Nome: Claudio
Regione: Friuli-Venezia Giulia
Città: Martignacco
Età: 41
Stato: Non connesso
Contatta:

Re: A21 centrale digitale ethernet/Wifi...a 27 euro!

Messaggio da ClaBos » gio mar 14, 2019 11:14 am

Ho provato prima la 477 e poi la 480 ma sempre con lo stesso errore
Claudio - Volere é potere!!

Avatar utente
sal727
Messaggi: 3177
Iscritto il: dom apr 26, 2015 5:22 pm
Nome: Salvatore
Regione: Emilia Romagna
Città: Bologna
Ruolo: Moderatore
Età: 62
Stato: Non connesso

Re: A21 centrale digitale ethernet/Wifi...a 27 euro!

Messaggio da sal727 » gio mar 14, 2019 11:21 am

Ogni versione deve avere le sue librerie aggiornate, le trovi sul sito di Gahtow se tu hai installato librerie diverse avrai sempre problemi, quindi ti consiglio di non installare la 480 perchè anche a me ha dato problemi non di installazione ma di funzionamento, io ho usato la 477 con le sue librerie, a questo punto devi eliminare le librerie che hai già installato e caricare quelle per la versione che vuoi usare.
Ciao, Salvatore

Avatar utente
ClaBos
Messaggi: 178
Iscritto il: mer lug 06, 2016 10:01 pm
Nome: Claudio
Regione: Friuli-Venezia Giulia
Città: Martignacco
Età: 41
Stato: Non connesso
Contatta:

Re: A21 centrale digitale ethernet/Wifi...a 27 euro!

Messaggio da ClaBos » gio mar 14, 2019 11:29 am

Ok.. Forse devo aver fatto un fritto misto... Ora devo andare a lavorare.. Stasera provo ad andare sul sito di gahtow e scrico la versione 477.poi ti farò sapere.
Claudio - Volere é potere!!

Avatar utente
ClaBos
Messaggi: 178
Iscritto il: mer lug 06, 2016 10:01 pm
Nome: Claudio
Regione: Friuli-Venezia Giulia
Città: Martignacco
Età: 41
Stato: Non connesso
Contatta:

Re: A21 centrale digitale ethernet/Wifi...a 27 euro!

Messaggio da ClaBos » ven mar 15, 2019 9:12 am

Buongiorno.
Ho scaricato la versione 477.

Volevo chiedere se c'è la possibilità,e come si fa,per cancellare le vecchie librerie da arduino.
Claudio - Volere é potere!!

Avatar utente
ClaBos
Messaggi: 178
Iscritto il: mer lug 06, 2016 10:01 pm
Nome: Claudio
Regione: Friuli-Venezia Giulia
Città: Martignacco
Età: 41
Stato: Non connesso
Contatta:

Re: A21 centrale digitale ethernet/Wifi...a 27 euro!

Messaggio da ClaBos » ven mar 15, 2019 9:23 am

Ho ricominciato da capo...ora altri problemi...

Adesso andando a caricare Z21_WiFi_DCC_Zentrale_v477_MSH.ino mi compare questo errore...

Codice: Seleziona tutto

Arduino:1.8.8 (Windows 10), Scheda:"Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\39349\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\39349\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\39349\Documents\Arduino\libraries -fqbn=arduino:avr:mega:cpu=atmega2560 -ide-version=10808 -build-path C:\Users\39349\AppData\Local\Temp\arduino_build_582433 -warnings=none -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude-6.3.0-arduino14.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc-5.4.0-atmel3.6.1-arduino2.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA-1.2.1.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose C:\Users\39349\Desktop\Z21 new\Z21_Ethernet_DCC_Zentrale_v477_MSH\Z21_Ethernet_DCC_Zentrale_v477_MSH.ino
C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\39349\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\39349\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\39349\Documents\Arduino\libraries -fqbn=arduino:avr:mega:cpu=atmega2560 -ide-version=10808 -build-path C:\Users\39349\AppData\Local\Temp\arduino_build_582433 -warnings=none -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude-6.3.0-arduino14.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc-5.4.0-atmel3.6.1-arduino2.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA-1.2.1.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose C:\Users\39349\Desktop\Z21 new\Z21_Ethernet_DCC_Zentrale_v477_MSH\Z21_Ethernet_DCC_Zentrale_v477_MSH.ino
Using board 'mega' from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr
Using core 'arduino' from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr
Detecting libraries used...
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10808 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "C:\\Users\\39349\\AppData\\Local\\Temp\\arduino_build_582433\\sketch\\Z21_Ethernet_DCC_Zentrale_v477_MSH.ino.cpp" -o nul
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10808 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "-IC:\\Users\\39349\\Documents\\Arduino\\libraries\\DCCInterfaceMaster" "C:\\Users\\39349\\AppData\\Local\\Temp\\arduino_build_582433\\sketch\\Z21_Ethernet_DCC_Zentrale_v477_MSH.ino.cpp" -o nul
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10808 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "-IC:\\Users\\39349\\Documents\\Arduino\\libraries\\DCCInterfaceMaster" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\SPI\\src" "C:\\Users\\39349\\AppData\\Local\\Temp\\arduino_build_582433\\sketch\\Z21_Ethernet_DCC_Zentrale_v477_MSH.ino.cpp" -o nul
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10808 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "-IC:\\Users\\39349\\Documents\\Arduino\\libraries\\DCCInterfaceMaster" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\SPI\\src" "-IC:\\Program Files (x86)\\Arduino\\libraries\\Ethernet\\src" "C:\\Users\\39349\\AppData\\Local\\Temp\\arduino_build_582433\\sketch\\Z21_Ethernet_DCC_Zentrale_v477_MSH.ino.cpp" -o nul
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10808 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "-IC:\\Users\\39349\\Documents\\Arduino\\libraries\\DCCInterfaceMaster" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\SPI\\src" "-IC:\\Program Files (x86)\\Arduino\\libraries\\Ethernet\\src" "-IC:\\Users\\39349\\Documents\\Arduino\\libraries\\z21" "C:\\Users\\39349\\AppData\\Local\\Temp\\arduino_build_582433\\sketch\\Z21_Ethernet_DCC_Zentrale_v477_MSH.ino.cpp" -o nul
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10808 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "-IC:\\Users\\39349\\Documents\\Arduino\\libraries\\DCCInterfaceMaster" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\SPI\\src" "-IC:\\Program Files (x86)\\Arduino\\libraries\\Ethernet\\src" "-IC:\\Users\\39349\\Documents\\Arduino\\libraries\\z21" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\EEPROM\\src" "C:\\Users\\39349\\AppData\\Local\\Temp\\arduino_build_582433\\sketch\\Z21_Ethernet_DCC_Zentrale_v477_MSH.ino.cpp" -o nul
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10808 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "-IC:\\Users\\39349\\Documents\\Arduino\\libraries\\DCCInterfaceMaster" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\SPI\\src" "-IC:\\Program Files (x86)\\Arduino\\libraries\\Ethernet\\src" "-IC:\\Users\\39349\\Documents\\Arduino\\libraries\\z21" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\EEPROM\\src" "C:\\Users\\39349\\Documents\\Arduino\\libraries\\DCCInterfaceMaster\\DCCHardware.c" -o nul
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10808 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "-IC:\\Users\\39349\\Documents\\Arduino\\libraries\\DCCInterfaceMaster" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\SPI\\src" "-IC:\\Program Files (x86)\\Arduino\\libraries\\Ethernet\\src" "-IC:\\Users\\39349\\Documents\\Arduino\\libraries\\z21" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\EEPROM\\src" "C:\\Users\\39349\\Documents\\Arduino\\libraries\\DCCInterfaceMaster\\DCCPacket.cpp" -o nul
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10808 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "-IC:\\Users\\39349\\Documents\\Arduino\\libraries\\DCCInterfaceMaster" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\SPI\\src" "-IC:\\Program Files (x86)\\Arduino\\libraries\\Ethernet\\src" "-IC:\\Users\\39349\\Documents\\Arduino\\libraries\\z21" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\EEPROM\\src" "C:\\Users\\39349\\Documents\\Arduino\\libraries\\DCCInterfaceMaster\\DCCPacketQueue.cpp" -o nul
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10808 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "-IC:\\Users\\39349\\Documents\\Arduino\\libraries\\DCCInterfaceMaster" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\SPI\\src" "-IC:\\Program Files (x86)\\Arduino\\libraries\\Ethernet\\src" "-IC:\\Users\\39349\\Documents\\Arduino\\libraries\\z21" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\EEPROM\\src" "C:\\Users\\39349\\Documents\\Arduino\\libraries\\DCCInterfaceMaster\\DCCPacketScheduler.cpp" -o nul
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10808 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "-IC:\\Users\\39349\\Documents\\Arduino\\libraries\\DCCInterfaceMaster" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\SPI\\src" "-IC:\\Program Files (x86)\\Arduino\\libraries\\Ethernet\\src" "-IC:\\Users\\39349\\Documents\\Arduino\\libraries\\z21" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\EEPROM\\src" "C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\SPI\\src\\SPI.cpp" -o nul
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10808 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "-IC:\\Users\\39349\\Documents\\Arduino\\libraries\\DCCInterfaceMaster" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\SPI\\src" "-IC:\\Program Files (x86)\\Arduino\\libraries\\Ethernet\\src" "-IC:\\Users\\39349\\Documents\\Arduino\\libraries\\z21" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\EEPROM\\src" "C:\\Program Files (x86)\\Arduino\\libraries\\Ethernet\\src\\Dhcp.cpp" -o nul
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10808 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "-IC:\\Users\\39349\\Documents\\Arduino\\libraries\\DCCInterfaceMaster" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\SPI\\src" "-IC:\\Program Files (x86)\\Arduino\\libraries\\Ethernet\\src" "-IC:\\Users\\39349\\Documents\\Arduino\\libraries\\z21" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\EEPROM\\src" "C:\\Program Files (x86)\\Arduino\\libraries\\Ethernet\\src\\Dns.cpp" -o nul
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10808 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "-IC:\\Users\\39349\\Documents\\Arduino\\libraries\\DCCInterfaceMaster" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\SPI\\src" "-IC:\\Program Files (x86)\\Arduino\\libraries\\Ethernet\\src" "-IC:\\Users\\39349\\Documents\\Arduino\\libraries\\z21" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\EEPROM\\src" "C:\\Program Files (x86)\\Arduino\\libraries\\Ethernet\\src\\Ethernet.cpp" -o nul
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10808 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "-IC:\\Users\\39349\\Documents\\Arduino\\libraries\\DCCInterfaceMaster" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\SPI\\src" "-IC:\\Program Files (x86)\\Arduino\\libraries\\Ethernet\\src" "-IC:\\Users\\39349\\Documents\\Arduino\\libraries\\z21" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\EEPROM\\src" "C:\\Program Files (x86)\\Arduino\\libraries\\Ethernet\\src\\EthernetClient.cpp" -o nul
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10808 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "-IC:\\Users\\39349\\Documents\\Arduino\\libraries\\DCCInterfaceMaster" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\SPI\\src" "-IC:\\Program Files (x86)\\Arduino\\libraries\\Ethernet\\src" "-IC:\\Users\\39349\\Documents\\Arduino\\libraries\\z21" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\EEPROM\\src" "C:\\Program Files (x86)\\Arduino\\libraries\\Ethernet\\src\\EthernetServer.cpp" -o nul
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10808 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "-IC:\\Users\\39349\\Documents\\Arduino\\libraries\\DCCInterfaceMaster" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\SPI\\src" "-IC:\\Program Files (x86)\\Arduino\\libraries\\Ethernet\\src" "-IC:\\Users\\39349\\Documents\\Arduino\\libraries\\z21" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\EEPROM\\src" "C:\\Program Files (x86)\\Arduino\\libraries\\Ethernet\\src\\EthernetUdp.cpp" -o nul
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10808 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "-IC:\\Users\\39349\\Documents\\Arduino\\libraries\\DCCInterfaceMaster" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\SPI\\src" "-IC:\\Program Files (x86)\\Arduino\\libraries\\Ethernet\\src" "-IC:\\Users\\39349\\Documents\\Arduino\\libraries\\z21" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\EEPROM\\src" "C:\\Program Files (x86)\\Arduino\\libraries\\Ethernet\\src\\socket.cpp" -o nul
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10808 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "-IC:\\Users\\39349\\Documents\\Arduino\\libraries\\DCCInterfaceMaster" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\SPI\\src" "-IC:\\Program Files (x86)\\Arduino\\libraries\\Ethernet\\src" "-IC:\\Users\\39349\\Documents\\Arduino\\libraries\\z21" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\EEPROM\\src" "C:\\Program Files (x86)\\Arduino\\libraries\\Ethernet\\src\\utility\\w5100.cpp" -o nul
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10808 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "-IC:\\Users\\39349\\Documents\\Arduino\\libraries\\DCCInterfaceMaster" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\SPI\\src" "-IC:\\Program Files (x86)\\Arduino\\libraries\\Ethernet\\src" "-IC:\\Users\\39349\\Documents\\Arduino\\libraries\\z21" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\EEPROM\\src" "C:\\Users\\39349\\Documents\\Arduino\\libraries\\z21\\z21.cpp" -o nul
Generating function prototypes...
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10808 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "-IC:\\Users\\39349\\Documents\\Arduino\\libraries\\DCCInterfaceMaster" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\SPI\\src" "-IC:\\Program Files (x86)\\Arduino\\libraries\\Ethernet\\src" "-IC:\\Users\\39349\\Documents\\Arduino\\libraries\\z21" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\EEPROM\\src" "C:\\Users\\39349\\AppData\\Local\\Temp\\arduino_build_582433\\sketch\\Z21_Ethernet_DCC_Zentrale_v477_MSH.ino.cpp" -o "C:\\Users\\39349\\AppData\\Local\\Temp\\arduino_build_582433\\preproc\\ctags_target_for_gcc_minus_e.cpp"
"C:\\Program Files (x86)\\Arduino\\tools-builder\\ctags\\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\\Users\\39349\\AppData\\Local\\Temp\\arduino_build_582433\\preproc\\ctags_target_for_gcc_minus_e.cpp"
Sto compilando lo sketch...
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10808 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "-IC:\\Users\\39349\\Documents\\Arduino\\libraries\\DCCInterfaceMaster" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\SPI\\src" "-IC:\\Program Files (x86)\\Arduino\\libraries\\Ethernet\\src" "-IC:\\Users\\39349\\Documents\\Arduino\\libraries\\z21" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\EEPROM\\src" "C:\\Users\\39349\\AppData\\Local\\Temp\\arduino_build_582433\\sketch\\Z21_Ethernet_DCC_Zentrale_v477_MSH.ino.cpp" -o "C:\\Users\\39349\\AppData\\Local\\Temp\\arduino_build_582433\\sketch\\Z21_Ethernet_DCC_Zentrale_v477_MSH.ino.cpp.o"
C:\Users\39349\Desktop\Z21 new\Z21_Ethernet_DCC_Zentrale_v477_MSH\Z21_Ethernet_DCC_Zentrale_v477_MSH.ino: In function 'void setup()':

Z21_Ethernet_DCC_Zentrale_v477_MSH:766:40: error: call of overloaded 'setup(int, int, int)' is ambiguous

       dcc.setup(DCCPin, 0, SwitchFormat);  //no NDCC and no RAILCOM

                                        ^

In file included from C:\Users\39349\Desktop\Z21 new\Z21_Ethernet_DCC_Zentrale_v477_MSH\Z21_Ethernet_DCC_Zentrale_v477_MSH.ino:182:0:

C:\Users\39349\Documents\Arduino\libraries\DCCInterfaceMaster/DCCPacketScheduler.h:113:7: note: candidate: void DCCPacketScheduler::setup(uint8_t, uint8_t, uint8_t)

  void setup(uint8_t pin = 6, uint8_t steps = DCC128, uint8_t format = ROCO);  //for any post-constructor initialization

       ^

C:\Users\39349\Documents\Arduino\libraries\DCCInterfaceMaster/DCCPacketScheduler.h:114:7: note: candidate: void DCCPacketScheduler::setup(uint8_t, uint8_t, uint8_t, uint8_t)

  void setup(uint8_t pin, uint8_t pin2, uint8_t steps = DCC128, uint8_t format = ROCO);  //for any post-constructor initialization - with RailCom

       ^

Uso la libreria DCCInterfaceMaster alla versione 3.7.0 nella cartella: C:\Users\39349\Documents\Arduino\libraries\DCCInterfaceMaster 
Uso la libreria SPI alla versione 1.0 nella cartella: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI 
Uso la libreria Ethernet alla versione 2.0.0 nella cartella: C:\Program Files (x86)\Arduino\libraries\Ethernet 
Uso la libreria z21 alla versione 1.7.0 nella cartella: C:\Users\39349\Documents\Arduino\libraries\z21 
Uso la libreria EEPROM alla versione 2.0 nella cartella: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\EEPROM 
exit status 1
call of overloaded 'setup(int, int, int)' is ambiguous
Claudio - Volere é potere!!

Avatar utente
ClaBos
Messaggi: 178
Iscritto il: mer lug 06, 2016 10:01 pm
Nome: Claudio
Regione: Friuli-Venezia Giulia
Città: Martignacco
Età: 41
Stato: Non connesso
Contatta:

Re: A21 centrale digitale ethernet/Wifi...a 27 euro!

Messaggio da ClaBos » ven mar 15, 2019 9:24 am

e questo è lo sketch

Codice: Seleziona tutto

/**************************************************************
 * Z21 Ethernet DCC Zentrale
 * Copyright (c) 2015-2017 by Philipp Gahtow
***************************************************************
Arduino MOTOR SHIELD update by BR95009, VVRR
 * 
 * Change log:
 * 
 * All features is OFF except of DCC internal booster. 
 * 
 * Pins realocated in MCU_config.h: 
 * DCC out pin - 12 
 * On/Off pin - 3 - now inverted!!!
 * Current monitor - A0 (VAmpIntPin A0) - ShortC logic added. 
 * DCCLed 39
 * WLAN Serial2 changed to WLAN Serial3 for Arduino MEGA+WiFi board
 * 
Unterstützte Funktionen/Protokolle:
 * NMRA DCC output (with Railcom)
 * ROCO Z21 over LAN and/or WLAN
 * S88N
 * XpressNet
 * LocoNet with MASTER-MODE (Slotserver) or SLAVE-MODE
 * NMRA DCC Input
 * support for ATmega 328/644/1280/1284/2560 (UNO, MEGA, Sanguino)

This is a simple command station that receive commands via ethernet.
It base on the Z21 protocol from ROCO!

- DCC Master Interface with Timer 2 by modifired CmdrArduino library by Philipp Gahtow
- Z21 LAN Protokoll mit W5100 Ethernet Shield with z21.h library
- LAN HTTP Website on Port 80 to Configure IP & S88
- ESP8266 WiFi Z21 LAN Untersützung with z21.h library
- fast S88N Bus
- old:(DCC input, to read signal from other Central Station via Interrupt 0 and Timer 4)
- LocoNet at MEGA with Timer 5, normal Timer1 with Loconet.h library
- XpressNet via LOOP-Function with XpressNetMaster.h library
- old:(Kehrschleifen output for ROCO Booster) 

***************************************************************
*Softwareversion: */
#define Z21mobileVERSIONMSB 4
#define Z21mobileVERSIONLSB 77
/*
Change log:
15.04.2015  Abschaltung S88 Interface per Define (S88N)
16.04.2015  Aktualisierung Z21 LAN Protokoll V1.05 & Firmware-Version 1.26
17.04.2015  LN OPC_INPUT_REP msg von Belegmeldern über LAN_LOCONET_DETECTOR
20.04.2015  kurze/Lange DCC Adressen (1..99 kurz, ab 100 lang)
22.04.2015  Add in DCC Lib Function support F13 - F28
            Add Power Button with Reset (press at startup)
23.04.2015  Add LocoNet set Railpower (OPC_GPOFF, OPC_GPON, OPC_IDLE)
            Add LocoNet Slot Write (OPC_WR_SL_DATA)
            New Broadcast Msg (8 Bit) Z21 Protokoll V1.05 (Include LocoNet)
            Add LocoNet OPC_RQ_SL_DATA, OPC_UHLI_FUN, OPC_SW_REQ, OPC_SW_REP, OPC_SW_ACK, OPC_SW_STATE
28.04.2015  Add DCC CV Write and Decoder Reset Packet before CV-Programming            
04.07.2015  Add Support Sanguino (ATmega644p and ATmega1284p) =>MCU_config.h
10.07.2015  Change Timer for DCC Interface and S88 to support LocoNet for all MCU
            Add second Booster support (intenal/external)
21.07.2015  S88 max Module define hinzu und S88 HTTP Ausgabe angepasst
30.07.2015  Versionsnummer für Debug definiert
02.08.2015  DCC Accessory Befehl korrigiert
            PowerButton Input geändert von Pin 51 nach Pin 47
03.08.2015  DCC Decoder Funktion korrigiert
17.09.2015  S88 Timer Auswahl (MEGA = Timer3)
18.09.2015  ESP8266 WiFi Support; Z21 LAN über externe Library
23.09.2015  Überarbeitung LAN_LOCONET_DETECTOR
            Neues Kommando OPC_MULTI_SENSE
            DCC Dekoder ohne Timer4!
            Optionale Lok-Event-Informationen im LocoNet (reduzierung der Sendedaten)
03.10.2015  S88 verbessert -> Fehler in der S88 Modulanzahl korrigiert (Überlauf der Zählervariale)       
            LocoNet TX/RX Packetverarbeitung verbessert  
04.10.2015  ROCO EXT Booster Short mit Transistor (invertiert!) 
            Optimierung S88 Timer (Rechenoperationen und Seicherbedarf)              
10.10.2015  Anzeigen Reset Zentrale mittels binkenden LEDs   
13.10.2015  Rückmelder über LocoNet
            Senden von DCC Weichenschaltmeldungen auch über LocoNet         
            LAN Webseite angepasst für Smartphone Display
14.10.2015  Einstellung der Anzahl von S88 Modulen über WiFi
            Verbesserung der Kommunikation mit dem ESP    
04.11.2015  LocoNet Master- oder Slave-Mode auswählbar
19.12.2015  Support kombinierte UDP Paket für WLAN und LAN            
26.12.2015  Add Track-Power-Off after Service Mode 
20.02.2016  Speicherreduzierung wenn kein WLAN und LAN genutzt wird
            LocoNet Client Modus Kommunikation mit IB verbessert
            Extra Serial Debug Option für XpressNet
27.02.2016  Änderung Dekodierung DCC14 und DCC28
            Invertierung Fahrtrichtung DCC Decoder DIRF            
            LocoNet Slave-Mode ignoriere Steuerbefehle, wenn Slot = 0
02.06.2016  Baud für Debug und WiFi einstellbar
            Software Serial für WiFi wählbar (zB. für Arduino UNO)
            -> WiFi Modul Firmware ab v2.5
17.07.2016 Fix Network UDP Antwortport - Sende Pakete an Quellport zurück
25.07.2016 add busy message for XpressNet (MultiMaus update screen now)
Aug.2016   add Railcom Support and update DCCInterfaceMaster and Booster Hardware,
           support POM read over I2C (GLOBALDETECTOR)
26.08.2016 add DHCP for Ethernet Shield      
21.11.2016 DCC: fix Railcom - still Problem with Startup: Analog-Power on the rails - Hardware change needed!
26.11.2016 LocoNet: add Uhlenbrock Intellibox-II F13 to F28 support
27.11.2016 LocoNet: fix Speed DIR in OPC_SL_RD_DATA in data byte to 0x80 = B10000000 and OPC_LOCO_DIRF remove invert
27.12.2016 Z21 add CV lesen am Programmiergleis
01.02.2017 add negative DCC output option and seperate this feature from RAILCOM
15.03.2017 fix narrowing conversation inside LNInterface.h
28.03.2017 external Booster active in ServiceMode when no internal Booster
24.04.2017 fix data lost on loconet - s88 timer3 block packets - deactivated
28.04.2017 add MultiMaus support for F13 to F20 without fast flashing
10.05.2017 add XpressNet information for loco speed and function and switch position change
11.05.2017 add internal Booster Short Detection over Current Sence Resistor
----
toDo:
-> Rückmelder via XpressNet
-> Programmieren von CVs im LocoNet -> works with Z21mobile APP!
(-> store loco adr use via per ip? (max 16?))

*/
/*--------------------------------------------------------------------------------------------------------
------------------------------------*********************************-------------------------------------
                                      CHANGE HERE FOR CONFIGURATION
----------------------------------------------------------------------------------------------------------
Command Station Config:
=> uncomment ("//") the following lines, if you not USE the protokoll!
*/
/**************************************************************/
//#define Debug Serial  //Interface for Debugging
//#define DebugBaud 115200
//#define DEBUG    //To see DATA on Serial
//#define REPORT    //To see Sensor Messages (LocoNet & S88)
//#define LnDEB    //To see HEX DATA of LocoNet Protokoll
//#define XnDEB    //To see XpressNet
//#define Z21DEBUG //to see DATA of Z21 LAN Protokoll

/**************************************************************
Singel S88 Bus Interface (max 62 * 8 Module)*/
//#define S88N

/**************************************************************
WiFi ESP 8266 Z21 LAN Komunikation via Serial*/
#define WIFI
//#define Z21VIRTUAL  //SoftSerial for UNO only - LAN and LocoNet will be inaktiv!

/**************************************************************
LAN W5100 Ethernet Z21 LAN Kommunikation*/
#define LAN       //Standard IP ist 192.168.0.111. Bitte diese IP nur über die Webseite (http://192.168.0.111) ändern!
//#define DHCP      //Activate to Receive a IP Adress from the DHCP Server, if no DHCP found fix IP Adress vom EEPROM will be load.
#define HTTPCONF  //Website to configure IP Adress and Number of S88 Bus Module

/**************************************************************
DCC Decoder (only for MEGA, To decode a DCC-Signal, add this data to command station DCC output)*/
//#define DECODER

/**************************************************************
XpressNet Master Interface*/
//#define XPRESSNET  
//#include <XpressNetMaster.h>

/**************************************************************
LocoNet Master Interface (Timer1, Timer5 on MEGA)*/
//#define LOCONET  
//#include <LocoNet.h>
//#define TXAllLokInfoOnLN false    //sende alle Lok-Ereignisse ins LocoNet (MASTER-MODE only)
//#define LnSLOTSRV    //Z21 DCC Arduino provide a Slot Server for Loco (MASTER-MODE)

/**************************************************************
Booster external: (zB. ROCO)*/
//#define BOOSTER_EXT
//#define BOOSTER_EXT_ON HIGH
//#define BOOSTER_EXT_OFF LOW

/**************************************************************
Booster internal: (zB. TLE5205)*/
#define BOOSTER_INT
#define BOOSTER_INT_ON HIGH    //only for old Mode without RAILCOM support over NDCC!
#define BOOSTER_INT_OFF LOW  //only for old Mode without RAILCOM support over NDCC!
/*(GoIntPin) activate inverted booster signal*/
//#define BOOSTER_INT_NDCC    //for new RAILCOM Booster3R
/*(VAmpIntPin) activate the current sensor for prog track:*/
#define BOOSTER_INT_MAINCURRENT   //MEGA, SANGUINO and for UNO only without external Booster, 
/*(VAmpIntPin) activate SHORT CIRCUIT SENCE over MAINCURRENT*/
#define BOOSTER_INT_CURRENT_SHORT_DETECT     //alternativ Short Circuit Detection over current sence resistor
/**************************************************************
DCC Master to create a DCC Signal:*/
#include <DCCPacketScheduler.h>   //DCC Interface Library
//#define DCCGLOBALDETECTOR  //activate the I2C DCC Railcom Global Detector for CV POM read
//---------
#define SwitchFormat ROCO   //ROCO (+0) or IB (+4) => Define Accessory Address start value!
/***************************************************************/

//--------------------------------------------------------------------------------------------------------
//----------------------------------*********************************-------------------------------------
//                                  DON'T CHANGE ANYTHING DOWN HERE!
//--------------------------------------------------------------------------------------------------------
//Setup up PIN-Configuration for different MCU (UNO/MEGA/Sanduino)
#include "MCU_config.h"

//**************************************************************
#if defined(Z21VIRTUAL)  
#include <SoftwareSerial.h>
SoftwareSerial SoftSerial(TXvWiFi, RXvWiFi); // init Soft Serial
#undef LAN    //LAN nicht zulassen - Doppelbelegung der Signalleitungen!
#undef HTTPCONF
#undef LOCONET
#endif

#if defined(LAN)      //W5100 LAN Interface Library
#include <SPI.h>         // needed for Arduino versions later than 0018
#include <Ethernet.h>
#include <EthernetUdp.h>         // UDP library
#endif

//**************************************************************
static void globalPower (byte state);

//Z21 LAN Protokoll:
#include <z21.h> 
z21Class z21;

//**************************************************************
#include <EEPROM.h>   //EEPROM - to store number of S88 Module and LAN IP
#define EES88Moduls 38  //Adresse EEPROM Anzahl der Module für S88
#define EEip 40    //Startddress im EEPROM für die IP

#if defined(LAN)  //W5100 LAN Udp Setup:
EthernetUDP Udp;    //UDP for communication with APP/Computer (Port 21105)
//EthernetUDP UdpMT;  //UDP to Z21 Maintenance Tool (Port 34472)
//---------------------------------------------------------------
// The IP address will be dependent on your local network:
// Die MAC Adresse der Z21 beginnt mit „84:2B:BC:..:..:..“!
static byte mac[] = { 0x84, 0x2B, 0xBC, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 168, 0, 111);   //Werkseinstellung ist: 192.168.0.111

//---------------------------------------------------------------
#if defined(HTTPCONF) //W5100 LAN config Website:
EthernetServer server(80);  // (port 80 is default for HTTP):
#endif
#endif    //LAN end
//--------------------------------------------------------------
//Z21 Protokoll Typ Spezifikationen
#if defined(LAN) || defined (WIFI)
#include "Z21type.h"    //Z21 Data Information
#endif

//--------------------------------------------------------------
//S88 Singel Bus:
#if defined(S88N)
#include "S88.h"
#endif

//--------------------------------------------------------------
//DCC Interface Master Short Detection:
//EXTERNAL BOOSTER:
#define DetectShortCircuit 0x1FF    //to detect short circuit  (0xFF)
unsigned int ShortTime = 0;            //Time Count for Short Detect
unsigned long LEDcount = 0;    //Timer for Status LED
//INTERNAL BOOSTER:
#if defined(BOOSTER_INT_CURRENT_SHORT_DETECT)
byte ShortTimeINT = 0;      //Time Count for internal short detect
#define DetectShortCircuit_INT  3 //Time after internal short circuit is detected
#define DETECT_SHORT_INT_VALUE  400  //analogRead value for "mA" that is too much
#endif

//--------------------------------------------------------------
DCCPacketScheduler dcc;
#define DCC     //activate DCC Interface

//--------------------------------------------------------------
#if defined(DCCGLOBALDETECTOR) && defined(DCC)
#include <Wire.h>
byte RailcomCVAdr = 0;  //init global RailCom detector
#endif

//--------------------------------------------------------------
#if defined(XPRESSNET)
XpressNetMasterClass XpressNet;
#endif

//--------------------------------------------------------------
// certain global XPressnet status indicators
#define csNormal 0x00 // Normal Operation Resumed ist eingeschaltet
#define csEmergencyStop 0x01 // Der Nothalt ist eingeschaltet
#define csTrackVoltageOff 0x02 // Die Gleisspannung ist abgeschaltet
#define csShortCircuit 0x04 // Kurzschluss
#define csServiceMode 0x08 // Der Programmiermodus ist aktiv - Service Mode
byte Railpower = csTrackVoltageOff;   //State of RailPower at Startup
bool Z21ButtonLastState = false;    //store last value of the Push Button for GO/STOP

//--------------------------------------------------------------
//LocoNet-Bus:
#if defined (LOCONET)
#include "LNInterface.h"
#endif

//--------------------------------------------------------------
//DCC Decoder:
#if defined(DECODER)
#include "DCCDecoder.h"
#endif

//--------------------------------------------------------------
//XpressNet-Bus:
#if defined(XPRESSNET)
#include "XBusInterface.h"
#endif

//--------------------------------------------------------------
//Z21 Ethernet communication:
#if defined(LAN) || defined(WIFI)
#include "Z21_LAN.h"
#endif

//--------------------------------------------------------------------------------------------
//POWER set configuration:
static void globalPower (byte state) {
  if (Railpower != state) {
    if (Railpower == csServiceMode && state == csShortCircuit) {
      z21.setCVNackSC();  //response SHORT while Service Mode!
    }
    Railpower = state;
    #if defined(DEBUG)
    Debug.print(F("Power: "));
    Debug.println(state);
    #endif
    switch (state) {
      case csNormal: 
        #if defined(DCC)
        dcc.setpower(ON);
        digitalWrite(ProgRelaisPin, LOW);     //ProgTrack 
        #endif
        #if defined(BOOSTER_EXT)
        if (digitalRead(ShortExtPin) == LOW)
          digitalWrite(GoExtPin, BOOSTER_EXT_ON);
        #endif
       
        #if (defined(BOOSTER_INT) && !defined(BOOSTER_INT_NDCC))
        digitalWrite(GoIntPin, BOOSTER_INT_ON);
        #endif
     
      break;
      case csTrackVoltageOff: 
        #if defined(DCC)
        dcc.setpower(OFF);
        digitalWrite(ProgRelaisPin, LOW);     //ProgTrack 
        #endif
        #if defined(BOOSTER_EXT)
        digitalWrite(GoExtPin, BOOSTER_EXT_OFF);
        #endif
        
        #if (defined(BOOSTER_INT) && !defined(BOOSTER_INT_NDCC))
        digitalWrite(GoIntPin, BOOSTER_INT_OFF);
        #endif
        
      break;
      case csServiceMode:
        #if defined(DCC) 
        dcc.setpower(SERVICE); //already on!
        digitalWrite(ProgRelaisPin, HIGH);     //ProgTrack 
        #endif
        #if defined(BOOSTER_EXT)
          #if defined(BOOSTER_INT)
          digitalWrite(GoExtPin, BOOSTER_EXT_OFF);
          #else
          if (digitalRead(ShortExtPin) == LOW)
            digitalWrite(GoExtPin, BOOSTER_EXT_ON);
          #endif
        #endif

        #if (defined(BOOSTER_INT) && !defined(BOOSTER_INT_NDCC))
        digitalWrite(GoIntPin, BOOSTER_INT_ON);
        #endif
        
      break;
      case csShortCircuit: 
        #if defined(DCC)
        dcc.setpower(SHORT);  //shut down via GO/STOP just for the Roco Booster
        digitalWrite(ProgRelaisPin, LOW);     //ProgTrack 
        #endif
        #if defined(BOOSTER_EXT)
        digitalWrite(GoExtPin, BOOSTER_EXT_OFF);
        #endif
        
        #if (defined(BOOSTER_INT) && !defined(BOOSTER_INT_NDCC))
        digitalWrite(GoIntPin, BOOSTER_INT_OFF);
        #endif
        
      break;
      case csEmergencyStop:
        #if defined(DCC)
        dcc.eStop();  
        #endif
      break;
    }
    if (Railpower == csShortCircuit)
      digitalWrite(ShortLed, HIGH);   //Short LED show State "short"
    if (Railpower == csNormal)  
      digitalWrite(ShortLed, LOW);   //Short LED show State "normal" 
    #if defined(LAN) || defined(WIFI)
    z21.setPower(Railpower);
    #endif
    #if defined(XPRESSNET)
    XpressNet.setPower(Railpower);  //send to XpressNet
    #endif
    #if defined(LOCONET)
    LNsetpower(); //send to LocoNet
    #endif
  }
}

//--------------------------------------------------------------------------------------------
//from DCCPacketScheduler -> notify power state
void notifyPower(uint8_t state) {
  globalPower(state);
}

//--------------------------------------------------------------------------------------------
#if defined(DCC)
void ShortDetection() { 
  //Short Circuit?
  //Check BOOSTER extern
  #if defined(BOOSTER_EXT)
  if ((digitalRead(ShortExtPin) == HIGH) && (digitalRead(GoExtPin) == BOOSTER_EXT_ON) && (Railpower != csShortCircuit)) {  
    ShortTime++;
    if(ShortTime == DetectShortCircuit) {
        globalPower(csShortCircuit);
        #if defined(DEBUG)
        Debug.println(F("TRACK_SHORT_CIRCUIT EXT"));
        #endif
    }
    /*  NOT IN USE ANYMORE from v4.75 on!
    //Before Railpower cut out test change polarity:
    else if (ShortTime == KSRelaisShortCircuit) {   
      digitalWrite(KSPin, !digitalRead(KSPin));     //Kehrschleife
      #if defined(DEBUG)
      Debug.print(F("KS "));
      Debug.println( digitalRead(KSPin) );
      #endif
    }
    */
  }
  else ShortTime = 0;
  #endif
  //Check BOOSTER2 (z.B. TLE5205)
  #if defined(BOOSTER_INT)
  #if defined(BOOSTER_INT_NDCC)
  if ((digitalRead(ShortIntPin) == LOW) && (Railpower != csShortCircuit)) {
  #else
  if ((analogRead(VAmpIntPin) > 700) && (digitalRead(GoIntPin) == BOOSTER_INT_ON) && (Railpower != csShortCircuit)) {   
  #endif
    globalPower(csShortCircuit);
    #if defined(DEBUG)
    Debug.println(F("TRACK_SHORT_CIRCUIT INT"));
    #endif
  }
  #if defined(BOOSTER_INT_CURRENT_SHORT_DETECT) && defined(BOOSTER_INT_MAINCURRENT)
  uint16_t VAmp = analogRead(VAmpIntPin);
  if ((VAmp >= DETECT_SHORT_INT_VALUE) && (Railpower != csShortCircuit)) {
    ShortTimeINT++;
    if (ShortTimeINT == DetectShortCircuit_INT) {
      globalPower(csShortCircuit);
      #if defined(DEBUG)
      Debug.print(VAmp);
      Debug.println(F(" TRACK_SHORT_CIRCUIT INT"));
      #endif
    }
  }
  else ShortTimeINT = 0;
  #endif
  #endif
}
#endif

//--------------------------------------------------------------------------------------------
void updateLedButton() {
  //Button to control Railpower state
  if ((digitalRead(Z21ButtonPin) == LOW) && (Z21ButtonLastState == false)) {  //Button DOWN
    Z21ButtonLastState = true;
    LEDcount = millis();
  }
  else {
    if ((digitalRead(Z21ButtonPin) == HIGH) && (Z21ButtonLastState == true)) {  //Button UP
       #if defined(DEBUG)
         Debug.print(F("Button "));
      #endif
      unsigned long currentMillis = millis(); 
      Z21ButtonLastState = false;
      if(currentMillis - LEDcount > 750) //push long?
        if (EEPROM.read(52) == 0x00)  //Power-Button (short): 0=Gleisspannung aus, 1=Nothalt  
          globalPower(csEmergencyStop);  
        else globalPower(csTrackVoltageOff);
      else {
        if (Railpower == csNormal) {
          if (EEPROM.read(52) == 0x00) //Power-Button (short): 0=Gleisspannung aus, 1=Nothalt  
            globalPower(csTrackVoltageOff);
          else globalPower(csEmergencyStop);
        }
        else globalPower(csNormal);
      }
      LEDcount = 0;
    }
  }
  //Update LED  
  if (Z21ButtonLastState == false) {  //flash
    if (Railpower == csNormal) {
      digitalWrite(DCCLed, HIGH);
      return;
    }
    unsigned long currentMillis = millis(); 
    if (currentMillis > LEDcount) {
      if (Railpower == csTrackVoltageOff) {
        if (digitalRead(DCCLed) == HIGH)
          LEDcount = currentMillis + 1100;    //long OFF
        else LEDcount = currentMillis + 300;  //short ON
      }
      if (Railpower == csEmergencyStop) {
        if (digitalRead(DCCLed) == HIGH)
          LEDcount = currentMillis + 80;    //short OFF
        else LEDcount = currentMillis + 700;  //long ON
      }
      if (Railpower == csShortCircuit) 
        LEDcount = currentMillis + 200;  //short flash
        
      digitalWrite(DCCLed, !digitalRead(DCCLed));
    }
  }
}

//--------------------------------------------------------------------------------------------
#if defined(HTTPCONF) && defined(LAN)
void Webconfig() {
  EthernetClient client = server.available();
  if (client) {
    String receivedText = String(50);
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        if (receivedText.length() < 50) {
          receivedText += c;
        }
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (c == '\n' && currentLineIsBlank) {
          // send a standard http response header
          client.println(F("HTTP/1.1 200 OK"));
          client.println(F("Content-Type: text/html"));
          client.println(F("Connection: close"));  // the connection will be closed after completion of the response
          //client.println(F("Refresh: 5"));  // refresh the page automatically every 5 sec
          client.println();   //don't forget this!!!
          //Website:
          client.println(F("<!DOCTYPE html>"));
          client.println(F("<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"/>"));
          client.println(F("<html><title>Z21</title><body><h1>Z21</h1>"));
          //----------------------------------------------------------------------------------------------------          
          int firstPos = receivedText.indexOf("?");
          if (firstPos > -1) {
            byte lastPos = receivedText.indexOf(" ", firstPos);
            String theText = receivedText.substring(firstPos+3, lastPos); // 10 is the length of "?A="
            byte S88Pos = theText.indexOf("&S88=");
            #if defined(S88N)
              S88Module = theText.substring(S88Pos+5, theText.length()).toInt();
            #endif  
            byte Aip = theText.indexOf("&B=");
            byte Bip = theText.indexOf("&C=", Aip);
            byte Cip = theText.indexOf("&D=", Bip);
            byte Dip = theText.substring(Cip+3, S88Pos).toInt();
            Cip = theText.substring(Bip+3, Cip).toInt();
            Bip = theText.substring(Aip+3, Bip).toInt();
            Aip = theText.substring(0, Aip).toInt();
            ip[0] = Aip;
            ip[1] = Bip;
            ip[2] = Cip;
            ip[3] = Dip;
            client.println(F("-> RESET Z21"));
            #if defined(S88N)
            if (EEPROM.read(EES88Moduls) != S88Module) {
              EEPROM.write(EES88Moduls, S88Module);
              SetupS88();
              #if defined(WIFI)
              WLANSetup();
              #endif
            }
            #endif
            EEPROM.update(EEip, Aip);
            EEPROM.update(EEip+1, Bip);
            EEPROM.update(EEip+2, Cip);
            EEPROM.update(EEip+3, Dip);
          }
          //----------------------------------------------------------------------------------------------------          
          client.print(F("<form method=get>IP:<input type=number min=0 max=254 name=A value="));
          client.println(ip[0]);
          #if defined(DHCP)
          client.print(F(" disabled=disabled"));
          #endif
          client.print(F("><input type=number min=0 max=254 name=B value="));
          client.println(ip[1]);
          #if defined(DHCP)
          client.print(F(" disabled=disabled"));
          #endif
          client.print(F("><input type=number min=0 max=254 name=C value="));
          client.println(ip[2]);
          #if defined(DHCP)
          client.print(F(" disabled=disabled"));
          #endif
          client.print(F("><input type=number min=0 max=254 name=D value="));
          client.println(ip[3]);
          #if defined(DHCP)
          client.print(F(" disabled=disabled"));
          #endif
          client.print(F("><br/>8x S88:<input type=number min=0 max="));
          #if defined(S88N)
          client.print(S88MAXMODULE);
          #else
          client.print("0");
          #endif
          client.print(F(" name=S88 value="));
          #if defined(S88N)
            client.print(S88Module);
          #else
            client.print("-");
          #endif
          client.println(F("><br/><input type=submit></form></body></html>"));
          break;
        }
        if (c == '\n') 
          currentLineIsBlank = true; // you're starting a new line
        else if (c != '\r') 
          currentLineIsBlank = false; // you've gotten a character on the current line
      }
    }
    client.stop();  // close the connection:
  }
}
#endif

//--------------------------------------------------------------
//DCC handle back updated loco information:
void notifyLokAll(uint16_t Adr, uint8_t Steps, uint8_t Speed, uint8_t F0, uint8_t F1, uint8_t F2, uint8_t F3, bool bc)
{     
  #if defined(XPRESSNET)  
  if (XNetReturnLoco > 0) {
    if ((XNetReturnLoco & 0x01) > 0) {
      bitWrite(XNetReturnLoco,0,0);
      XpressNet.SetLocoInfo(XNetUserOps, Speed, F0, F1); //UserOps,Speed,F0,F1
    }
    if ((XNetReturnLoco & 0x02) > 0) {
      bitWrite(XNetReturnLoco,1,0);
      XpressNet.SetFktStatus(XNetUserOps, F2, F3); //Fkt4, Fkt5
    }
    if ((XNetReturnLoco & 0x04) > 0) {
      bitWrite(XNetReturnLoco,2,0);
      if (Steps == 0x03)  //128 Steps?
        Steps++;  //set Steps to 0x04
      XpressNet.SetLocoInfoMM(XNetUserOps, Steps, Speed, F0, F1, F2, F3); //Fkt4, Fkt5
    }
    return;
  }
  else if (bc == false) {   //Wenn nicht durch XpressNet genutzt: setzte BUSY Flag
    if (XNetUserOps == 0) 
      XpressNet.ReqLocoBusy(Adr);   //Lok wird nicht von LokMaus gesteuert!
    else XNetUserOps = 0;
  }
  #endif
  
  #if defined(LOCONET) && defined(LnSLOTSRV)
    LNSetLocoStatus(Adr, Speed, F0, F1);
  #endif

  z21.setLocoStateFull (Adr, Steps,Speed, F0, F1, F2, F3, bc);
}

//--------------------------------------------------------------
//DCC handle back the request switch state
void notifyTrnt(uint16_t Adr, bool State) 
{
  z21.setTrntInfo(Adr, State);
  #if defined(DEBUG)
  Debug.print(F("DCC Trnt "));
  Debug.print(Adr);
  Debug.print("-");
  Debug.println(State);
  #endif
}

//-------------------------------------------------------------- 
//DCC return a CV value:
void notifyCVVerify(uint16_t CV, uint8_t value) {
  z21.setCVReturn (CV, value);
  #if defined(DEBUG)
  Debug.print(F("Loco CV#"));
  Debug.print(CV);
  Debug.print(" - ");
  Debug.println(value);
  #endif
}

//-------------------------------------------------------------- 
//DCC return no ACK:
void notifyCVNack() {
  z21.setCVNack();  //send back to device and stop programming!
  #if defined(DEBUG)
  Debug.println("CV# no ACK");
  #endif
}

//-------------------------------------------------------------- 
//DCC handle railpower while programming (Service Mode ON/OFF)
void notifyRailpower(uint8_t state) {
  globalPower(state); //send Power state to all Devices!
}

//--------------------------------------------------------------------------------------------
#if defined(DEBUG)
int freeRam () 
{
  extern int __heap_start, *__brkval;
  int v;
  return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);
}
#endif

//--------------------------------------------------------------
//INIT all ports and interfaces:
void setup() {
  /*
  #if defined(BOOSTER_INT_MAINCURRENT)
    #if defined(MEGA_MCU) //Arduino MEGA
      analogReference(INTERNAL1V1); //or INTERNAL2V56
    #else  //others Arduino's
      analogReference(INTERNAL);  //1,1 Volt
    #endif   
    pinMode(VAmpIntPin, INPUT); 
  #endif  
  */
  pinMode(DCCLed, OUTPUT);      //DCC Status LED
  digitalWrite(DCCLed, LOW);    //DCC LED is in "off" State
  pinMode(ShortLed, OUTPUT);    //Short Status LED
  digitalWrite(ShortLed, HIGH);    //Short LED showes working and Power up
  pinMode(ProgRelaisPin, OUTPUT);       //ProgTrack-Relais
  digitalWrite(ProgRelaisPin, LOW);     //ProgTrack 
  #if defined(BOOSTER_EXT)    //Booster (ROCO) external: 
    pinMode(ShortExtPin, INPUT_PULLUP);  //set short pin and Turn on internal Pull-Up Resistor
    pinMode(GoExtPin, OUTPUT);      //GO/STOP Signal
    digitalWrite(GoExtPin, BOOSTER_EXT_OFF);    //set STOP to Booster
  #endif
  #if defined(BOOSTER_INT)    //Booster2 internal:
    #if !defined(BOOSTER_INT_NDCC)
    pinMode(GoIntPin, OUTPUT);    //GO/STOP2 Signal
    digitalWrite(GoIntPin, BOOSTER_INT_OFF);   //set STOP to Booster2 invertet
    #endif
    pinMode(ShortIntPin, INPUT_PULLUP);  //set up short2 PIN and Turn on internal Pull-Up Resistor
  #endif
  pinMode(Z21ResetPin, INPUT_PULLUP); //Turn on internal Pull-Up Resistor
  pinMode(Z21ButtonPin, INPUT_PULLUP); //Turn on internal Pull-Up Resistor

  #if defined(MEGA_MCU)
  pinMode(VAmSencePin, INPUT_PULLUP);  //AC 5A Sensor (for testing only)
  pinMode(VoltIntPin, INPUT_PULLUP);  //Rail Voltage: Rail:100k - Sence - 4,7k - GND
  pinMode(TempPin, INPUT_PULLUP);     //Temp.Resistor(15k)
  #endif

  #if defined(DCC)
    //setup the DCC signal:
    #if defined(BOOSTER_INT_NDCC)
      dcc.setup(DCCPin, GoIntPin, SwitchFormat); 
    #else
      dcc.setup(DCCPin, 0, SwitchFormat);  //no NDCC and no RAILCOM
    #endif  
    //for CV reading activate the current control:
    #if defined(BOOSTER_INT_MAINCURRENT) 
      dcc.setCurrentLoadPin(VAmpIntPin);
    #endif
    //for CV reading over RAILCOM activate i2c communication:
    #if defined(DCCGLOBALDETECTOR)
    Wire.begin(1);                // join i2c bus with address #8
    Wire.onReceive(RailComReceiveEvent); // register event
    #endif
  #endif

  #if defined(DEBUG) || defined(LnDEB) || defined(Z21DEBUG) || defined(REPORT) || defined(XnDEB)
    Debug.begin(DebugBaud);
    Debug.print(F("Z21 "));
    Debug.print(Z21mobileVERSIONMSB);
    Debug.print(".");
    Debug.print(Z21mobileVERSIONLSB);
    Debug.print(SwitchFormat);
    #if defined (BOOSTER_INT_NDCC)
      if (EEPROM.read(EEPROMRailCom) == 0x01)
        Debug.print(".RAILCOM");
    #endif
    #if defined(UNO_MCU)
    Debug.println(F(" - UNO"));
    #elif defined(MEGA_MCU)
    Debug.println(F(" - MEGA"));
    #elif defined(SANGUINO_MCU)
    Debug.println(F(" - SANGUINO"));
    #endif
  #endif

  #if defined(LAN)
  if ((digitalRead(Z21ButtonPin) == LOW) || (EEPROM.read(EEip) == 255)) {
      #if defined(DEBUG)
        Debug.println(F("RESET")); 
      #endif  
      EEPROM.update(EEip, ip[0]);
      EEPROM.update(EEip+1, ip[1]);
      EEPROM.update(EEip+2, ip[2]);
      EEPROM.update(EEip+3, ip[3]);
      while (digitalRead(Z21ButtonPin) == LOW) {  //Wait until Button - "UP"
        #if defined(DEBUG)
          Debug.print("."); 
        #endif  
        delay(200);   //Flash:
        digitalWrite(DCCLed, !digitalRead(DCCLed));
        digitalWrite(ShortLed, !digitalRead(DCCLed));
      }
      #if defined(DEBUG)
          Debug.println();  //new line!
      #endif  
      digitalWrite(DCCLed, LOW);    //DCC LED is in "off" State
      digitalWrite(ShortLed, LOW);    //Short LED is in "off" State
  }
  
  ip[0] = EEPROM.read(EEip);
  ip[1] = EEPROM.read(EEip+1);
  ip[2] = EEPROM.read(EEip+2);
  ip[3] = EEPROM.read(EEip+3);
  #endif

  #if defined(S88N)
    SetupS88();    //S88 Setup 
  #endif  

  #if defined(XPRESSNET)  
    XpressNet.setup(XNetFahrstufen, XNetTxRxPin);    //Initialisierung XNet Serial und Send/Receive-PIN  
  #endif

  #if defined(DECODER)
    DCCDecoder_init();    //DCC Decoder init
  #endif
  
  #if defined(LOCONET)
    LNsetup();      //LocoNet Interface init
  #endif

  #if defined(WIFI)
    WLANSetup();    //Start ESP WLAN
  #endif 

  #if defined(LAN)
    // start the Ethernet and UDP:
    delay(100); //wait for ethernet to get up
    #if defined(DHCP)
      #if defined(DEBUG)
          Debug.print(F("IP over DHCP..."));  
      #endif  
      if (Ethernet.begin(mac) == 0) { //Trying to get an IP address using DHCP
        #if defined(DEBUG)
          Debug.println(F("fail!"));  
        #endif
        #undef DHCP
      }
      else {
        //Save IP that receive from DHCP
        ip = Ethernet.localIP();
        #if defined(DEBUG)
          Debug.println("OK");  
        #endif
      }
    #endif
    #if !defined(DHCP)
      // initialize the Ethernet device not using DHCP:
      Ethernet.begin(mac,ip);  //set IP and MAC  
    #endif
    Udp.begin(z21Port);  //UDP Z21 Port 21105

  //UdpMT.begin(34472);   //UDP Maintenance Tool
  //0x30 0x80 0x01 0x02

    #if defined(HTTPCONF)
      server.begin();    //HTTP Server
    #endif
  #endif

  #if defined(DEBUG)
    #if defined(LAN)
    Debug.println(ip);
    #endif
    #if defined(S88N)
      Debug.print(F("S88: "));
      Debug.println(S88Module);
    #endif
    Debug.print(F("RAM: "));
    Debug.println(freeRam());  
  #endif  
  
  globalPower(Railpower); //send Power state to all Devices!
}

//--------------------------------------------------------------------------------------------
//run the state machine to update all interfaces
void loop() {
  
  updateLedButton();     //DCC Status LED and Button

  #if defined(DCC)
  ShortDetection();  //handel short on rail to => power off
  dcc.update();    //handel Rail Data
  #endif

  #if defined(HTTPCONF) && defined(LAN)
    Webconfig();    //Webserver for Configuration
  #endif
  
  #if defined(S88N)
    notifyS88Data();    //R-Bus geänderte Daten 1. Melden
  #endif  
  
  #if defined(DECODER)
    DCCDecoder_update();    //Daten vom DCC Decoder
  #endif
  
  #if defined(XPRESSNET)  
    XpressNet.update(); //XpressNet Update
  #endif
  
  #if defined(LOCONET)
    LNupdate();      //LocoNet update
  #endif
  
  #if defined(LAN) || defined(WIFI)
    Z21LANreceive();   //Z21 LAN Decoding
  #endif
}
Non so più che fare :x
Claudio - Volere é potere!!

Avatar utente
ClaBos
Messaggi: 178
Iscritto il: mer lug 06, 2016 10:01 pm
Nome: Claudio
Regione: Friuli-Venezia Giulia
Città: Martignacco
Età: 41
Stato: Non connesso
Contatta:

Re: A21 centrale digitale ethernet/Wifi...a 27 euro!

Messaggio da ClaBos » ven mar 15, 2019 9:42 am

Allora...credo di avercela fatta...o meglio..ho caricato tutti e tre gli sketch...

Ho cancellato tutte le cartelle che avevo sul desktop...ho scaricato la 477 e ho rifatto tutto da capo.

Fin qui tutto bene.Però ora ho fatto Strumenti-> Monitoraggio seriale ma quando si apre la finestra non vedo nulla.Normale?

Tutti gli sketch si sono caricati senza problema.
Claudio - Volere é potere!!

Avatar utente
sal727
Messaggi: 3177
Iscritto il: dom apr 26, 2015 5:22 pm
Nome: Salvatore
Regione: Emilia Romagna
Città: Bologna
Ruolo: Moderatore
Età: 62
Stato: Non connesso

Re: A21 centrale digitale ethernet/Wifi...a 27 euro!

Messaggio da sal727 » ven mar 15, 2019 11:14 am

Se ti leggi tutti i post indietro trovi le soluzioni
Ciao, Salvatore

Avatar utente
ccomincini
Messaggi: 5
Iscritto il: dom apr 16, 2017 9:04 am
Nome: Carlo
Regione: Lombardia
Città: Brescia
Età: 47
Stato: Non connesso

Re: A21 centrale digitale ethernet/Wifi...a 27 euro!

Messaggio da ccomincini » dom mar 17, 2019 5:24 pm

ClaBos ha scritto:
ven mar 15, 2019 9:42 am
Allora...credo di avercela fatta...o meglio..ho caricato tutti e tre gli sketch...

Ho cancellato tutte le cartelle che avevo sul desktop...ho scaricato la 477 e ho rifatto tutto da capo.

Fin qui tutto bene.Però ora ho fatto Strumenti-> Monitoraggio seriale ma quando si apre la finestra non vedo nulla.Normale?

Tutti gli sketch si sono caricati senza problema.
devi decommentare le righe di debug

Codice: Seleziona tutto

#define Debug Serial  //Interface for Debugging
#define DebugBaud 115200  //Debug speed
#define DEBUG    //To see DATA on Serial
#define REPORT    //To see Sensor Messages (LocoNet & S88)
#define LnDEB    //To see HEX DATA of LocoNet Protokoll
#define XnDEB    //To see XpressNet
#define Z21DEBUG //to see Z21 LAN control data
#define Z21DATADEBUG //to see DATA of Z21 LAN Protokoll
#define Z21SYSTEMDATADEBUG  //to see the mainpower and temp
#define RCDEB     //To see RailCom Data
Togliendo i due caratteri "//" prima delle righe attivi il debug. Scegli cosa vuoi vedere, probabilmente alcuni degli elementi non ti servono.
Carlo

Avatar utente
echoes
Messaggi: 16
Iscritto il: mar ago 02, 2016 10:33 pm
Nome: Enrico
Regione: Veneto
Città: Montebelluna
Età: 42
Stato: Non connesso

Re: A21 centrale digitale ethernet/Wifi...a 27 euro!

Messaggio da echoes » ven ago 23, 2019 10:35 am

ciao a tutti,
mi inserisco in questa discussione per alcune domande di base in merito all'utilizzo dei controller Software su PC.
Io ho una centrale DCC fatta in casa (echoesdcc.wordpress.com) con tre porte RS485 per connettere dei controller estreni.

Sto valutando la possibilità di usare dei controller Software su PC (ad esempio Rocrail) ma non so se utilizzano dei protocolli "open" per comunicare con le centrali commerciali oppure ciascun costruttore ha il suo. Per questo mi rivolgo a voi che avete realizzato un sistema dcc++ (centrale A21) con Arduino.

Secondo voi è possibile utilizzare Rocrail (o altro) con una comunicazione seriale UART? in questo caso per me basterebbe convertire UART/485 e fare un parser di comandi nel FW della centrale.

Nella documentazione del dcc++ (Arduino DCC++ Base Station v1.0) c'è una lista di comandi con formato < C P1 P2 ... PN >

<t>: sets the throttle for a mobile engine decoder using 128-step speeds
<f>: controls mobile engine decoder functions F0-F28
<a>: controls stationary accessory decoders
<T>: controls turnouts connected to stationary accessory decoders
<w>: writes a configuration variable byte to an engine decoder on the main ops track
<b>: sets/clear a configuration variable bit in an engine decoder on the main operations track
<W>: writes a configuration variable byte to an engine decoder on the programming track
<B>: sets/clear a configuration variable bit in an engine decoder on the programming track
<R>: reads a configuration variable byte from an engine decoder on the programming track
<1>: turns on track power
<0>: turns off track power
<c>: reads current draw from main operations track
<s>: returns status messages, including power state, turnout states, and sketch version

Questi sono i comandi usati dai controller su PC? (come Rocrail)

vi ringrazio in anticipo
ciao!
Enrico
Enrico - echoesdcc.wordpress.com

Avatar utente
antogar
Messaggi: 56
Iscritto il: mer dic 31, 2014 1:52 pm
Nome: Antonino
Regione: Campania
Città: C.mare
Età: 53
Stato: Non connesso

Re: A21 centrale digitale ethernet/Wifi...a 27 euro!

Messaggio da antogar » mar set 03, 2019 11:52 am

Ciao,
ho una DCC++ che uso per prove da banco con JMRI e qualche volta ricordo di aver anche usato RocRail che di fatto utilizza il protocollo descritto nella documentazione DCC++ (ho anche realizzato qualche palmare con Arduino, qui sul forum ce ne sono diversi…), e quindi, per rispondere alla tua domanda, RocRail utilizza il protocollo proprietario di ogni centrale per comunicare con essa.
L' autore del sw, Robert Versluis, di fatto sviluppa interfacce per le varie centrali in commercio ed anche alcune autocostruite e/o open source fra quelle più "famose", tipo DCC++, ClaudiaCS di Nuccio, NanoX di Paco Canada ed altri…

Potresti emulare la DCC++ con la tua centrale, il protocollo è semplice e ben descritto

Saluti e complimenti per il tuo lavoro !
Antonino

Avatar utente
echoes
Messaggi: 16
Iscritto il: mar ago 02, 2016 10:33 pm
Nome: Enrico
Regione: Veneto
Città: Montebelluna
Età: 42
Stato: Non connesso

Re: A21 centrale digitale ethernet/Wifi...a 27 euro!

Messaggio da echoes » ven set 06, 2019 4:28 pm

Grazie mille Antonio per la tua conferma e precisazione.
Ora so che posso andare per questa strada, ti ringrazio ciao
Enrico - echoesdcc.wordpress.com

Avatar utente
fabio2703
Messaggi: 8
Iscritto il: ven ago 24, 2012 4:56 pm
Nome: fabio
Regione: Lazio
Città: roma
Età: 54
Stato: Non connesso

Re: A21 centrale digitale ethernet/Wifi...a 27 euro!

Messaggio da fabio2703 » gio nov 07, 2019 8:03 am

Buongiorno,
sto provando a caricare lo sketch Z21_ESPArduinoUPD_v27 ma prendo un errore che non capisco:

Arduino:1.8.9 (Windows 7), Scheda:"WeMos D1 R1, 80 MHz, Flash, Disabled, All SSL ciphers (most compatible), 4M (3M SPIFFS), v2 Lower Memory, Disabled, None, Only Sketch, 57600"

Opzioni di compilazione cambiate, ricompilo tutto
Lo sketch usa 284268 byte (27%) dello spazio disponibile per i programmi. Il massimo è 1044464 byte.
Le variabili globali usano 29072 byte (35%) di memoria dinamica, lasciando altri 52848 byte liberi per le variabili locali. Il massimo è 81920 byte.
esptool.py v2.6
2.6
esptool.py v2.6
Serial port COM8
Connecting........_____....._____....._____....._____....._____....._____....._____
Traceback (most recent call last):
File "C:\Users\fabio\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2/tools/upload.py", line 25, in <module>
esptool.main(fakeargs)
File "C:/Users/fabio/AppData/Local/Arduino15/packages/esp8266/hardware/esp8266/2.5.2/tools/esptool\esptool.py", line 2653, in main
esp.connect(args.before)
File "C:/Users/fabio/AppData/Local/Arduino15/packages/esp8266/hardware/esp8266/2.5.2/tools/esptool\esptool.py", line 468, in connect
raise FatalError('Failed to connect to %s: %s' % (self.CHIP_NAME, last_error))
esptool.FatalError: Failed to connect to ESP8266: Invalid head of packet (0xF9)
esptool.FatalError: Failed to connect to ESP8266: Invalid head of packet (0xF9)


Ho seguito le istruzioni ma non capisco perchè esce questo errore. Il primo sketch è stato caricato correttamente.

E' la terza A21 che preparo e per le altre 2 non ho avuto nessun problema.

Grazie a chi mi saprà aiutare.
Fabio

Avatar utente
MrMassy86
Socio GAS TT
Messaggi: 13804
Iscritto il: sab nov 10, 2012 3:42 pm
Nome: Massimiliano
Regione: Toscana
Città: Marlia - Lucca
Ruolo: Moderatore
Età: 33
Stato: Non connesso
Contatta:

Re: A21 centrale digitale ethernet/Wifi...a 27 euro!

Messaggio da MrMassy86 » gio nov 07, 2019 11:36 am

Ciao Fabio, sicuramente qualcuno degli amici saprà darti una risposta al tuo problema :)
Vedo che non ti sei mai presentato, io come membro dello staff del forum ti invito a presentarti nell'apposita sezione
viewforum.php?f=44
Serve a conoscersi meglio e permettere a tutti di darti il giusto benvenuto :D
Massimiliano [253]
Massimiliano Paolinelli - il mio canale YouTubeViaggio in quel di Verni -Il Ponte dei Pescatori - C.L.A.F. Lucca

Avatar utente
sal727
Messaggi: 3177
Iscritto il: dom apr 26, 2015 5:22 pm
Nome: Salvatore
Regione: Emilia Romagna
Città: Bologna
Ruolo: Moderatore
Età: 62
Stato: Non connesso

Re: A21 centrale digitale ethernet/Wifi...a 27 euro!

Messaggio da sal727 » gio nov 07, 2019 11:42 am

Se hai aggiornato l'IDE con le ultime versioni, prova a settare la scheda con il vecchio bootloader impostandolo sull'IDE come da figura
Arduino.JPG
Ciao, Salvatore

Avatar utente
fabio2703
Messaggi: 8
Iscritto il: ven ago 24, 2012 4:56 pm
Nome: fabio
Regione: Lazio
Città: roma
Età: 54
Stato: Non connesso

Re: A21 centrale digitale ethernet/Wifi...a 27 euro!

Messaggio da fabio2703 » gio nov 07, 2019 8:15 pm

Grazie Salvatore,
ho provato ma l'errore rimane.

Ho provato ad usare diverse schede
- wemos d1 r1
- generic ESP8266 Module

Non riesco a capire......
Fabio

Avatar utente
fabio2703
Messaggi: 8
Iscritto il: ven ago 24, 2012 4:56 pm
Nome: fabio
Regione: Lazio
Città: roma
Età: 54
Stato: Non connesso

Re: A21 centrale digitale ethernet/Wifi...a 27 euro!

Messaggio da fabio2703 » gio nov 07, 2019 8:26 pm

fabio2703 ha scritto:
gio nov 07, 2019 8:15 pm
Grazie Salvatore,
ho provato ma l'errore rimane.

Ho provato ad usare diverse schede
- wemos d1 r1
- generic ESP8266 Module

Non riesco a capire......
ecco il messaggio di errore:

Arduino:1.8.9 (Windows 7), Scheda:"Generic ESP8266 Module, 80 MHz, Flash, Disabled, All SSL ciphers (most compatible), ck, 26 MHz, 40MHz, DOUT (compatible), 4M (3M SPIFFS), 2, nonos-sdk 2.2.1 (legacy), v2 Lower Memory, Disabled, None, Only Sketch, 115200"

Lo sketch usa 284268 byte (27%) dello spazio disponibile per i programmi. Il massimo è 1044464 byte.
Le variabili globali usano 29072 byte (35%) di memoria dinamica, lasciando altri 52848 byte liberi per le variabili locali. Il massimo è 81920 byte.
esptool.py v2.6
2.6
esptool.py v2.6
Serial port COM8
Connecting........_____....._____....._____....._____....._____....._____.....____Traceback (most recent call last):
File "C:\Users\fabio\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2/tools/upload.py", line 25, in <module>
esptool.main(fakeargs)
File "C:/Users/fabio/AppData/Local/Arduino15/packages/esp8266/hardware/esp8266/2.5.2/tools/esptool\esptool.py", line 2653, in main
esp.connect(args.before)
File "C:/Users/fabio/AppData/Local/Arduino15/packages/esp8266/hardware/esp8266/2.5.2/tools/esptool\esptool.py", line 468, in connect
raise FatalError('Failed to connect to %s: %s' % (self.CHIP_NAME, last_error))
esptool.FatalError: Failed to connect to ESP8266: Timed out waiting for packet header
esptool.FatalError: Failed to connect to ESP8266: Timed out waiting for packet header

_
Fabio

Rispondi

Torna a “DIGITALE”