timer = timerBegin(0, 80, true);
timerAttachInterrupt(timer, &DCC::interrupt, true);
timerAlarmWrite(timer, 28, true);
timerAlarmEnable(timer);
case DCC_CUT_1: // 1/2 bit : zone de coupure
switch (m_dataMode)
{
case DCC_PACKET_CUTOUT :
if (!--m_cutoutCount)
{
m_dataMode = DCC_PACKET_HEADER;
m_headerCount = DCC_HEADER_SIZE;
digitalWrite(PIN_BRAKE, LOW);
}
else
digitalWrite(PIN_BRAKE, HIGH);
break;
default :
m_cut = DCC_CUT_0;
}
... lire les réponses des décodeurs ?
tester et faire des retours.
A noter : l'initialisation du DCC serait à améliorer, les locos démarrent tant que le montage n'a pas reçu le <1>
A noter : l'initialisation du DCC serait à améliorer, les locos démarrent tant que le montage n'a pas reçu le <1>
Pour le contrôle du courant, l'utilisation de la broche 8 du LMD18200 a été rappelée récemment.
En connectant, par exemple, une résistance de 2,7 K Ohm entre cette broche 8 et et GND on a une sensibilité d’environ 1V/A.
Ce qui donne avec la valeur de 2,7V, une protection à 2,7A.
Néanmoins cette sortie peut atteindre 12V si on a un courant de court-circuit de 12A, il faut donc prévoir une limitation à 3,3V pour ne pas détruire l'entrée de l'ESP32.
#define WIFI_SSID "xxxxxxxxxxxxxxx"
#define WIFI_PSW "xxxxxxxxxxxxxxx"
Mais toujours surpris, avant passer une commande (hors <1> initial), la loco posée sur les rails démarre à fond.
case 'S' :
// static bool start = false;
// if (! start) {
client->print("<p0>");
// start = true;
//}
break;
case '0' :
digitalWrite(PIN_PWM, LOW);
client->printf("<p%c>", com[0]);
break;
case '1' :
digitalWrite(PIN_PWM, HIGH);
client->printf("<p%c>", com[0]);
break;
#define WIFI_SSID "xxxxxxxxxx"
#define WIFI_PSW "xxxxxxxxxx"
#define COMM_INTERFACE 1
ligne 19 à 1#if COMM_INTERFACE == 1
IPAddress local_IP(192, 168, 1, 200);
IPAddress gateway(192, 168, 1, 1);
IPAddress subnet(255, 255, 255, 0);
Connexion à Firefox avec des <a 0>
mais mon JMRI n'y arrive pas :
// IPAddress local_IP(192, 168, 1, 200);
// IPAddress gateway(192, 168, 1, 1);
// IPAddress subnet(255, 255, 255, 0);
// if (!WiFi.config(local_IP, gateway, subnet))
// Serial.println("STA Failed to configure");
#if COMM_INTERFACE == 1
IPAddress local_IP(192, 168, 0, 200);
IPAddress gateway(192, 168, 0, 1);
IPAddress subnet(255, 255, 255, 0);
if (!WiFi.config(local_IP, gateway, subnet))
Serial.println("STA Failed to configure");
WiFi.begin(WIFI_SSID, WIFI_PSW);
while (WiFi.status() != WL_CONNECTED) {
Version : v 0.7
Fichier : C:\Users\miche\Documents\Arduino\Locoduino\Christophe Bobille\DCCxx_v_0.7_wifi_ESP32w\DCCxx_v_0.7_wifi_ESP32w.ino
Compiled : Jan 24 2022 - 14:01:07
.....
WiFi connected.
IP address: 192.168.0.200
End setup
Project : DCCxx ESP32 WIFI RAILCOM
Version : v 1.2
Fichier : /Users/dominiquebultez-1/Desktop/DCCxx-ESP32-WiFi-Railcom-main/DCCxx-ESP32-Railcom/DCCxx-ESP32-Railcom.ino
Compiled : Jan 31 2022 - 10:31:56
<p0>End setup
1
<p1>t 1 26 15 1
<T 1 15 1>
La commande <1> alimente les rails et la loco @26 se lance à vitesse 15 de façon satisfaisante// DEFINE COMMUNICATIONS INTERFACE
// 0 = Serial Port
// 1 = Wifi
#define COMM_INTERFACE 1
#if COMM_INTERFACE == 0
#define INTERFACE HardwareSerial
#elif COMM_INTERFACE == 1
#include <WiFi.h>
#define INTERFACE WiFiClient
#define LOCAL_IP 192, 168, 0, 200
#define PORT 2560
#endif
Et un test positif ...Ne craignez rien, vous ne serez pas cas contact !