KGBRUS

Zentrale_2_0

May 26th, 2023
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.31 KB | None | 0 0
  1. /*History Version 1.0 Variablen aus Ebene 0 (SBH) angelegt
  2. Funktioniert!
  3. 1.1 Daten direkt in CAN Data 0 schreiben Also ohne Variable Data00 für Nachricht 1 & 2
  4. 1.2 Nachricht 3 von Modul 4 hinzugefügt - Funktioniert
  5. 1.3 Nachricht 4 von Modul 5 hinzugefügt - funktioniert
  6. 1.4 Nachricht 5 von Modul 6 hinzugefügt - funktioniert
  7. 1.5 Nachricht 6 von Modul 8 hinzugefügt - funktioniert
  8. 1.6 LCD ANzeige hinzugefügt und State maschine für Display LCD Anzeige bis Modul3 programiert
  9. 1.7 Modul 4,5,6,7,8,9,10 und 11 hinzugefügt.--- Funktioniert
  10. 1.8 Code verschönert, leerzeichen usw gelöscht
  11. 2.0 Sendesequenz zu Modul 2 implementiert
  12.  
  13.  
  14.  
  15.  
  16. */
  17. // -------------------------------------- Umbenenen der STM Pins
  18. // Bliotheken
  19. //------------------------------------------------------------------------------------------------------------Testweise auskommentiert #include <assert.h>
  20. #include "stm32f103.h" // Bei selbst erstellten Bibliotheken der name immer in Anführungszeichen!! Nicht in größer kleiner als Zeichen!
  21. #include <LiquidCrystal.h>
  22.  
  23. // EIngänge
  24. const int rs = PA0, en = PA1, d4 = PA2, d5 = PA3, d6 = PA4, d7 = PA5;
  25. LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
  26. const int NextAnzeige = PA9;
  27. const int TestCAN1 = PB15;
  28. const int TestCAN2 = PA8;
  29. uint8_t NextAnzeigeState = 0;
  30. uint8_t TestCAN1State = 0;
  31. uint8_t TestCAN2State = 0;
  32.  
  33.  
  34. // Ausgänge
  35.  
  36.  
  37.  
  38.  
  39. uint8_t counter = 0; // Zahler für nachricht wurde x mal versand
  40. uint8_t frameLength = 0; // framelegth ist die länge der nachricht hier kann man auch im Sendeteil eine Zahl angeben
  41. unsigned long previousMillis = 0; // stores last time output was updated
  42. const long interval = 100; // transmission interval (milliseconds) Intervall in dem gesendet wird
  43. CAN_msg_t CAN_TX_msg; // Initialisierung Senden
  44. CAN_msg_t CAN_RX_msg; // Initialisierung EMPFANGEN
  45.  
  46.  
  47.  
  48. //-------------------------------------------------------Variablen
  49. // Modul 2 SBH Süd Einfahrt
  50. uint8_t LSEinfahrtSBHSudState = 0;
  51. uint8_t LSVmaxSBHSudState = 0;
  52. uint8_t LSEinfahrtWendelSudState = 0;
  53.  
  54. uint8_t WeicheEinfahrtSBHSudGeradeausState = 0;
  55. uint8_t WeicheEinfahrtSBHSudAbbiegenState = 0;
  56.  
  57.  
  58. // Modul 3 SBH Süd rechts
  59. uint8_t LSEinfahrtSBHSudGleis1State = 0;
  60. uint8_t LSEinfahrtSBHSudGleis2State = 0;
  61. uint8_t LSEinfahrtSBHSudGleis3State = 0;
  62. uint8_t LSEinfahrtSBHSudGleis4State = 0;
  63. uint8_t LSEinfahrtSBHSudGleis5State = 0;
  64.  
  65. uint8_t WeicheSBHSudGleis1geradeausState = 0;
  66. uint8_t WeicheSBHSudGleis1abbiegenState = 0;
  67. uint8_t WeicheSBHSudGleis2geradeausState = 0;
  68. uint8_t WeicheSBHSudGleis2abbiegenState = 0;
  69. uint8_t WeicheSBHSudGleis3geradeausState = 0;
  70. uint8_t WeicheSBHSudGleis3abbiegenState = 0;
  71. uint8_t WeicheSBHSudGleis4geradeausState = 0;
  72. uint8_t WeicheSBHSudGleis4abbiegenState = 0;
  73.  
  74. // Modul4 SBH süd links
  75. uint8_t LSEndposSBHSudGleis1State = 0;
  76. uint8_t LSEndposSBHSudGleis2State = 0;
  77. uint8_t LSEndposSBHSudGleis3State = 0;
  78. uint8_t LSEndposSBHSudGleis4State = 0;
  79. uint8_t LSEndposSBHSudGleis5State = 0;
  80.  
  81. // Modul5 SBH Süd Kehrschleife
  82. uint8_t LSEinfahrtKehrschleifeSBHSudState = 0;
  83.  
  84. uint8_t WeicheKehrschleifeSBHSudGeradeausState = 0;
  85. uint8_t WeicheKehrschleifeSBHSudAbbiegenState = 0;
  86.  
  87. // Modul6 Kreuzung
  88. uint8_t LSEinfahrtVonSBHWest1State = 0;
  89. uint8_t LSEinfahrtVonSBHWest2State = 0;
  90. uint8_t LSEinfahrtVonSBHSudState = 0;
  91. uint8_t LSEinfahrtVonWendelWestState = 0;
  92.  
  93. uint8_t FahrstromSBHWestWendelSudState = 0;
  94. uint8_t FahrstromSBHWestWendelWestState = 0;
  95. uint8_t FahrstromSBHSudWendelSudState = 0;
  96. uint8_t FahrstromSBHSudWendelWestState = 0;
  97. uint8_t FahrstromKreuzungAllgemeinState = 0;
  98. uint8_t WeicheKehrschleifeSBHWestGeradeausState = 0;
  99. uint8_t WeicheKehrschleifeSBHWestAbbiegenState = 0;
  100.  
  101. // Modul 8 SBH West rechts
  102. uint8_t LSEndposSBHWestGleis1State = 0;
  103. uint8_t LSEndposSBHWestGleis2State = 0;
  104. uint8_t LSEndposSBHWestGleis3State = 0;
  105. uint8_t LSEndposSBHWestGleis4State = 0;
  106. uint8_t LSEndposSBHWestGleis5State = 0;
  107.  
  108. uint8_t FahrstromSBHWestGleis1State = 0;
  109. uint8_t FahrstromSBHWestGleis2State = 0;
  110. uint8_t FahrstromSBHWestGleis3State = 0;
  111. uint8_t FahrstromSBHWestGleis4State = 0;
  112. uint8_t FahrstromSBHWestGleis5State = 0;
  113. uint8_t FahrstromSBHSudAllgemeinState = 0;
  114.  
  115. // Modul 9 SBH West Links
  116. uint8_t LSEinfahrtSBHWestGleis1State = 0;
  117. uint8_t LSEinfahrtSBHWestGleis2State = 0;
  118. uint8_t LSEinfahrtSBHWestGleis3State = 0;
  119. uint8_t LSEinfahrtSBHWestGleis4State = 0;
  120. uint8_t LSEinfahrtSBHWestGleis5State = 0;
  121.  
  122. uint8_t WeicheSBHWestGleis1geradeausState = 0;
  123. uint8_t WeicheSBHWestGleis1abbiegenState = 0;
  124. uint8_t WeicheSBHWestGleis2geradeausState = 0;
  125. uint8_t WeicheSBHWestGleis2abbiegenState = 0;
  126. uint8_t WeicheSBHWestGleis3geradeausState = 0;
  127. uint8_t WeicheSBHWestGleis3abbiegenState = 0;
  128. uint8_t WeicheSBHWestGleis4geradeausState = 0;
  129. uint8_t WeicheSBHWestGleis4abbiegenState = 0;
  130.  
  131. // Modul 10 Einfahrt SBH West
  132. uint8_t LSEinfahrtSBHWestState = 0;
  133. uint8_t LSVmaxSBHWestState = 0;
  134. uint8_t LSEinfahrtWendelWestState = 0;
  135.  
  136. uint8_t WeicheEinfartSBHWestGeradeausState = 0;
  137. uint8_t WeicheEinfahrtSBHWestAbbiegenState = 0;
  138.  
  139. // --------------- State Maschine
  140. enum LCDANZEIGE
  141. {
  142. MODUL1 , MODUL2 , MODUL3 , MODUL4 , MODUL5 , MODUL6 , MODUL7 , MODUL8 , MODUL9 , MODUL10 , MODUL11 , ZENTRALE
  143. };
  144. LCDANZEIGE akt_state_LCDANZEIGE = MODUL1;
  145. LCDANZEIGE next_state_LCDANZEIGE = MODUL1;
  146.  
  147. void setup()
  148. {
  149. // -------------------------------------- pinMode
  150. pinMode(NextAnzeige, INPUT);
  151. pinMode(TestCAN1, INPUT);
  152. pinMode(TestCAN2, INPUT);
  153.  
  154. pinMode(LED_BUILTIN, OUTPUT); //LED auf Arduino Blinken um programierung zu bestätigen
  155. delay(1500);
  156. digitalWrite(PC13, HIGH);
  157. delay(500);
  158. digitalWrite(PC13, LOW);
  159. delay(500);
  160. digitalWrite(PC13, HIGH);
  161. delay(500);
  162. digitalWrite(PC13, LOW);
  163. delay(500);
  164. digitalWrite(PC13, HIGH);
  165. // CAN aktivieren
  166. {
  167. Serial.begin(115200);
  168. bool ret = CANInit(CAN_500KBPS, 0); // CAN_RX mapped to PA11, CAN_TX mapped to PA12
  169. if (!ret) while (true);
  170. }
  171. // LCD initialisieren
  172. {
  173. lcd.begin(20, 4);
  174. lcd.print("Tach Kay!");
  175. delay(1000);
  176. lcd.clear();
  177. delay(1000);
  178. }
  179. }
  180. void loop()
  181. {
  182. // put your main code here, to run repeatedly:
  183.  
  184. // ---------------------------- Begin CAN
  185. {
  186. // ---------------------------- Begin CAN Empfangen
  187. {
  188. // ---------------------------- CAN Nachricht 0x000001 empfangen LED 1 & 2 Grün und Rot
  189. if (CANMsgAvail())
  190. {
  191. CANReceive(&CAN_RX_msg); // Prüfen ob neue Nacvhricht empfangen werden kann (liegt eine neue Nachricht zum abholen bereit?)
  192. if (CAN_RX_msg.type == DATA_FRAME)
  193. {
  194. if (CAN_RX_msg.id == 0x100001) // Empfang der nachricht 0x100001 von Modul 2
  195. {
  196. LSEinfahrtSBHSudState = bitRead (CAN_RX_msg.data[0], 0);
  197. LSVmaxSBHSudState = bitRead (CAN_RX_msg.data[0], 1);
  198. LSEinfahrtWendelSudState = bitRead (CAN_RX_msg.data[0], 2);
  199. }
  200. if (CAN_RX_msg.id == 0x100002) // nachrichten ID 0x100002 von Modul 3
  201. {
  202. LSEinfahrtSBHSudGleis1State = bitRead(CAN_RX_msg.data[0], 0);
  203. LSEinfahrtSBHSudGleis2State = bitRead(CAN_RX_msg.data[0], 1);
  204. LSEinfahrtSBHSudGleis3State = bitRead(CAN_RX_msg.data[0], 2);
  205. LSEinfahrtSBHSudGleis4State = bitRead(CAN_RX_msg.data[0], 3);
  206. LSEinfahrtSBHSudGleis5State = bitRead(CAN_RX_msg.data[0], 4);
  207. }
  208. if (CAN_RX_msg.id == 0x100003) // nachrichten ID 0x100003 von Modul 4
  209. {
  210. LSEndposSBHSudGleis1State = bitRead(CAN_RX_msg.data[0], 0);
  211. LSEndposSBHSudGleis2State = bitRead(CAN_RX_msg.data[0], 1);
  212. LSEndposSBHSudGleis3State = bitRead(CAN_RX_msg.data[0], 2);
  213. LSEndposSBHSudGleis4State = bitRead(CAN_RX_msg.data[0], 3);
  214. LSEndposSBHSudGleis5State = bitRead(CAN_RX_msg.data[0], 4);
  215. }
  216. if (CAN_RX_msg.id == 0x100004) // nachrichten ID 0x100004 von Modul 5
  217. {
  218. LSEinfahrtKehrschleifeSBHSudState = bitRead(CAN_RX_msg.data[0], 0);
  219. }
  220. if (CAN_RX_msg.id == 0x100005) // nachrichten ID 0x100005 von Modul 6
  221. {
  222. LSEinfahrtVonSBHWest1State = bitRead(CAN_RX_msg.data[0], 0);
  223. LSEinfahrtVonSBHWest2State = bitRead(CAN_RX_msg.data[0], 1);
  224. LSEinfahrtVonSBHSudState = bitRead(CAN_RX_msg.data[0], 2);
  225. LSEinfahrtVonWendelWestState = bitRead(CAN_RX_msg.data[0], 3);
  226. }
  227. if (CAN_RX_msg.id == 0x100006) // nachrichten ID 0x100006 von Modul 8
  228. {
  229. LSEndposSBHWestGleis1State = bitRead(CAN_RX_msg.data[0], 0);
  230. LSEndposSBHWestGleis2State = bitRead(CAN_RX_msg.data[0], 1);
  231. LSEndposSBHWestGleis3State = bitRead(CAN_RX_msg.data[0], 2);
  232. LSEndposSBHWestGleis4State = bitRead(CAN_RX_msg.data[0], 3);
  233. LSEndposSBHWestGleis5State = bitRead(CAN_RX_msg.data[0], 4);
  234. }
  235. if (CAN_RX_msg.id == 0x100007) // nachrichten ID 0x100007 von Modul 9
  236. {
  237. LSEinfahrtSBHWestGleis1State = bitRead(CAN_RX_msg.data[0], 0);
  238. LSEinfahrtSBHWestGleis2State = bitRead(CAN_RX_msg.data[0], 1);
  239. LSEinfahrtSBHWestGleis3State = bitRead(CAN_RX_msg.data[0], 2);
  240. LSEinfahrtSBHWestGleis4State = bitRead(CAN_RX_msg.data[0], 3);
  241. LSEinfahrtSBHWestGleis5State = bitRead(CAN_RX_msg.data[0], 4);
  242. }
  243. if (CAN_RX_msg.id == 0x100008) // Empfang der nachricht 0x100008 von Modul 10
  244. {
  245. LSEinfahrtSBHWestState = bitRead (CAN_RX_msg.data[0], 0);
  246. LSVmaxSBHWestState = bitRead (CAN_RX_msg.data[0], 1);
  247. LSEinfahrtWendelWestState = bitRead (CAN_RX_msg.data[0], 2);
  248. }
  249. }
  250. }
  251. }
  252. // Ende CAN Empfangen
  253. // begin CAN senden
  254. {
  255. {
  256. // ---------------------------- Begin CAN Nachricht 0x10009 senden
  257. // eigentliche Daten werden eingefüllt
  258. // mit bitwrite lassen sich einzelne bits innerhalb eines Bytes beschreiben. Hier Zustand TasterState in Erstes (ganz rechtes) Bit von Data0 schreiben
  259. bitWrite (CAN_TX_msg.data[0], 0, WeicheEinfahrtSBHSudGeradeausState); // Data 00 Steuerung der Ausgaenge Modul2 Einfahrt SBH Sued
  260. bitWrite (CAN_TX_msg.data[0], 1, WeicheEinfahrtSBHSudAbbiegenState);
  261. bitWrite (CAN_TX_msg.data[1], 0, WeicheSBHSudGleis1geradeausState); // Data 01 Steuerung der Ausgaenge Modul3 SBH Sued Rechts
  262. bitWrite (CAN_TX_msg.data[1], 1, WeicheSBHSudGleis1abbiegenState);
  263. bitWrite (CAN_TX_msg.data[1], 2, WeicheSBHSudGleis1geradeausState);
  264. bitWrite (CAN_TX_msg.data[1], 3, WeicheSBHSudGleis1abbiegenState);
  265. bitWrite (CAN_TX_msg.data[1], 4, WeicheSBHSudGleis1geradeausState);
  266. bitWrite (CAN_TX_msg.data[1], 5, WeicheSBHSudGleis1abbiegenState);
  267. bitWrite (CAN_TX_msg.data[1], 6, WeicheSBHSudGleis1geradeausState);
  268. bitWrite (CAN_TX_msg.data[1], 7, WeicheSBHSudGleis1abbiegenState); // Data 02 Steuerung der Ausgänge Modul3 SBH Sued Rechts
  269. CAN_TX_msg.len = 2; // Länge der Nachricht
  270. unsigned long currentMillis = millis(); // Senden alle x millisekunden
  271. if (currentMillis - previousMillis >= interval)
  272. {
  273. previousMillis = currentMillis;
  274. if ( ( counter % 2) == 0)
  275. { // Rest der Nachricht wird befüllt
  276. CAN_TX_msg.type = DATA_FRAME;
  277. if (CAN_TX_msg.len == 0) CAN_TX_msg.type = REMOTE_FRAME;
  278. CAN_TX_msg.format = EXTENDED_FORMAT;
  279. CAN_TX_msg.id = 0x100009; // nachrichten ID
  280. }
  281. CANSend(&CAN_TX_msg); // Übergabe der Nachricht an die Hardware
  282. }
  283.  
  284. //// ---------------------------- Ende CAN Nachricht 0x10009 senden an Modul 2
  285. }
  286. }
  287. }
  288. // ---------------------------------------------------- Ende CAN
  289. // ------------------------------------- Ansteuerung LCD 20x4 Beginn
  290. {
  291. // -------------------------------------- State Maschine für LCD Anzeige
  292. if (next_state_LCDANZEIGE != akt_state_LCDANZEIGE) // Hat sich der State geändert ?
  293. {
  294. switch (next_state_LCDANZEIGE) // State Mashine für Wechselzwischen den Sates
  295. {
  296. case MODUL1:
  297. {
  298. lcd.clear(); // immer nur das LCd einmal löschen
  299. }
  300. case MODUL2:
  301. {
  302. lcd.clear();
  303. }
  304. case MODUL3:
  305. {
  306. lcd.clear();
  307. }
  308. case MODUL4:
  309. {
  310. lcd.clear();
  311. }
  312. case MODUL5:
  313. {
  314. lcd.clear();
  315. }
  316. case MODUL6:
  317. {
  318. lcd.clear();
  319. }
  320. case MODUL7:
  321. {
  322. lcd.clear();
  323. }
  324. case MODUL8:
  325. {
  326. lcd.clear();
  327. }
  328. case MODUL9:
  329. {
  330. lcd.clear();
  331. }
  332. case MODUL10:
  333. {
  334. lcd.clear();
  335. }
  336. case MODUL11:
  337. {
  338. lcd.clear();
  339. }
  340. case ZENTRALE:
  341. {
  342. lcd.clear();
  343. }
  344.  
  345. }
  346. akt_state_LCDANZEIGE = next_state_LCDANZEIGE; // -----------------Zustand Next in Zustand aktuell schreiben
  347. }
  348. switch (akt_state_LCDANZEIGE) // Eigentliche State mschine für die verschiedenen ANzeigen am LCD
  349. {
  350. case MODUL1:
  351. {
  352. lcd.setCursor(0, 0);
  353. lcd.print("M-1 Wendel Sud");
  354. lcd.setCursor(0, 1);
  355. lcd.print("Keine Daten!");
  356. NextAnzeigeState = digitalRead(NextAnzeige);
  357. if (NextAnzeigeState == 0)
  358. {
  359. next_state_LCDANZEIGE = MODUL2;
  360. delay(250);
  361. }
  362.  
  363. break;
  364. }
  365. case MODUL2:
  366. {
  367. lcd.setCursor(0, 0);
  368. lcd.print("M-2 SBH Sud Einfahrt");
  369. lcd.setCursor(0, 1);
  370. lcd.print("LS-Einf= ");
  371. lcd.print(LSEinfahrtSBHSudState);
  372. lcd.setCursor(0, 2);
  373. lcd.print("LS-VMAX= ");
  374. lcd.print(LSVmaxSBHSudState);
  375. lcd.setCursor(0, 3);
  376. lcd.print("LS-Wende= ");
  377. lcd.print(LSEinfahrtWendelSudState);
  378. NextAnzeigeState = digitalRead(NextAnzeige);
  379. if (NextAnzeigeState == 0)
  380. {
  381. next_state_LCDANZEIGE = MODUL3;
  382. delay(250);
  383. }
  384. break;
  385. }
  386. case MODUL3:
  387. {
  388. lcd.setCursor(0, 0);
  389. lcd.print("M-3 SBH Sud Rechts");
  390. lcd.setCursor(0, 1);
  391. lcd.print("Gleis 1=");
  392. lcd.print(LSEinfahrtSBHSudGleis1State);
  393. lcd.setCursor(10, 1);
  394. lcd.print("Gleis 2=");
  395. lcd.print(LSEinfahrtSBHSudGleis2State);
  396. lcd.setCursor(0, 2);
  397. lcd.print("Gleis 3=");
  398. lcd.print(LSEinfahrtSBHSudGleis3State);
  399. lcd.setCursor(10, 2);
  400. lcd.print("Gleis 4=");
  401. lcd.print(LSEinfahrtSBHSudGleis4State);
  402. lcd.setCursor(0, 3);
  403. lcd.print("Gleis 5=");
  404. lcd.print(LSEinfahrtSBHSudGleis5State);
  405. NextAnzeigeState = digitalRead(NextAnzeige);
  406. if (NextAnzeigeState == 0)
  407. {
  408. next_state_LCDANZEIGE = MODUL4;
  409. delay(250);
  410. }
  411. break;
  412. }
  413. case MODUL4:
  414. {
  415. lcd.setCursor(0, 0);
  416. lcd.print("M-4 SBH Sud Links");
  417. lcd.setCursor(0, 1);
  418. lcd.print("Gleis 1=");
  419. lcd.print(LSEndposSBHSudGleis1State);
  420. lcd.setCursor(10, 1);
  421. lcd.print("Gleis 2=");
  422. lcd.print(LSEndposSBHSudGleis2State);
  423. lcd.setCursor(0, 2);
  424. lcd.print("Gleis 3=");
  425. lcd.print(LSEndposSBHSudGleis3State);
  426. lcd.setCursor(10, 2);
  427. lcd.print("Gleis 4=");
  428. lcd.print(LSEndposSBHSudGleis4State);
  429. lcd.setCursor(0, 3);
  430. lcd.print("Gleis 5=");
  431. lcd.print(LSEndposSBHSudGleis5State);
  432. NextAnzeigeState = digitalRead(NextAnzeige);
  433. if (NextAnzeigeState == 0)
  434. {
  435. next_state_LCDANZEIGE = MODUL5;
  436. delay(250);
  437. }
  438. break;
  439. }
  440. case MODUL5:
  441. {
  442. lcd.setCursor(0, 0);
  443. lcd.print("M-5 SBH Sud Kehrschl");
  444. lcd.setCursor(0, 1);
  445. lcd.print("LS-Einf-Wende = ");
  446. lcd.print(LSEinfahrtKehrschleifeSBHSudState);
  447. NextAnzeigeState = digitalRead(NextAnzeige);
  448. if (NextAnzeigeState == 0)
  449. {
  450. next_state_LCDANZEIGE = MODUL6;
  451. delay(250);
  452. }
  453. break;
  454. }
  455. case MODUL6:
  456. {
  457. lcd.setCursor(0, 0);
  458. lcd.print("M-6 Kreuzung");
  459. lcd.setCursor(0, 1);
  460. lcd.print("WeSBH = ");
  461. lcd.print(LSEinfahrtVonSBHWest1State);
  462. lcd.setCursor(10, 1);
  463. lcd.print("WeWen = ");
  464. lcd.print(LSEinfahrtVonSBHWest2State);
  465. lcd.setCursor(0, 2);
  466. lcd.print("SuSBH = ");
  467. lcd.print(LSEinfahrtVonSBHSudState);
  468. lcd.setCursor(10, 2);
  469. lcd.print("SuWen = ");
  470. lcd.print(LSEinfahrtVonWendelWestState);
  471. NextAnzeigeState = digitalRead(NextAnzeige);
  472. if (NextAnzeigeState == 0)
  473. {
  474. next_state_LCDANZEIGE = MODUL7;
  475. delay(250);
  476. }
  477. break;
  478. }
  479. case MODUL7:
  480. {
  481. lcd.setCursor(0, 0);
  482. lcd.print("M-7 ");
  483. lcd.setCursor(0, 1);
  484. lcd.print("Keine Daten!");
  485. NextAnzeigeState = digitalRead(NextAnzeige);
  486. if (NextAnzeigeState == 0)
  487. {
  488. next_state_LCDANZEIGE = MODUL8;
  489. delay(250);
  490. }
  491.  
  492. break;
  493. }
  494. case MODUL8:
  495. {
  496. lcd.setCursor(0, 0);
  497. lcd.print("M-8 SBH West Links");
  498. lcd.setCursor(0, 1);
  499. lcd.print("Gleis 1=");
  500. lcd.print(LSEndposSBHWestGleis1State);
  501. lcd.setCursor(10, 1);
  502. lcd.print("Gleis 2=");
  503. lcd.print(LSEndposSBHWestGleis2State);
  504. lcd.setCursor(0, 2);
  505. lcd.print("Gleis 3=");
  506. lcd.print(LSEndposSBHWestGleis3State);
  507. lcd.setCursor(10, 2);
  508. lcd.print("Gleis 4=");
  509. lcd.print(LSEndposSBHWestGleis4State);
  510. lcd.setCursor(0, 3);
  511. lcd.print("Gleis 5=");
  512. lcd.print(LSEndposSBHWestGleis5State);
  513. NextAnzeigeState = digitalRead(NextAnzeige);
  514. if (NextAnzeigeState == 0)
  515. {
  516. next_state_LCDANZEIGE = MODUL9;
  517. delay(250);
  518. }
  519. break;
  520. }
  521. case MODUL9:
  522. {
  523. lcd.setCursor(0, 0);
  524. lcd.print("M-9 SBH West Rechts");
  525. lcd.setCursor(0, 1);
  526. lcd.print("Gleis 1=");
  527. lcd.print(LSEinfahrtSBHWestGleis1State);
  528. lcd.setCursor(10, 1);
  529. lcd.print("Gleis 2=");
  530. lcd.print(LSEinfahrtSBHWestGleis2State);
  531. lcd.setCursor(0, 2);
  532. lcd.print("Gleis 3=");
  533. lcd.print(LSEinfahrtSBHWestGleis3State);
  534. lcd.setCursor(10, 2);
  535. lcd.print("Gleis 4=");
  536. lcd.print(LSEinfahrtSBHWestGleis4State);
  537. lcd.setCursor(0, 3);
  538. lcd.print("Gleis 5=");
  539. lcd.print(LSEinfahrtSBHWestGleis5State);
  540. NextAnzeigeState = digitalRead(NextAnzeige);
  541. if (NextAnzeigeState == 0)
  542. {
  543. next_state_LCDANZEIGE = MODUL10;
  544. delay(250);
  545. }
  546. break;
  547. }
  548. case MODUL10:
  549. {
  550. lcd.setCursor(0, 0);
  551. lcd.print("M10 SBHWest Einfahrt");
  552. lcd.setCursor(0, 1);
  553. lcd.print("LS-Einf= ");
  554. lcd.print(LSEinfahrtSBHWestState);
  555. lcd.setCursor(0, 2);
  556. lcd.print("LS-VMAX= ");
  557. lcd.print(LSVmaxSBHWestState);
  558. lcd.setCursor(0, 3);
  559. lcd.print("LS-Wende= ");
  560. lcd.print(LSEinfahrtWendelWestState);
  561. NextAnzeigeState = digitalRead(NextAnzeige);
  562. if (NextAnzeigeState == 0)
  563. {
  564. next_state_LCDANZEIGE = MODUL11;
  565. delay(250);
  566. }
  567. break;
  568. }
  569. case MODUL11:
  570. {
  571. lcd.setCursor(0, 0);
  572. lcd.print("M-11 Wendel West");
  573. lcd.setCursor(0, 1);
  574. lcd.print("Keine Daten!");
  575. NextAnzeigeState = digitalRead(NextAnzeige);
  576. if (NextAnzeigeState == 0)
  577. {
  578. next_state_LCDANZEIGE = ZENTRALE;
  579. delay(250);
  580. }
  581. break;
  582. }
  583. case ZENTRALE:
  584. {
  585. lcd.setCursor(0, 0);
  586. lcd.print("ZENTRALE ");
  587. lcd.setCursor(0, 1);
  588. lcd.print("Weiche Sud Einfa. =");
  589. lcd.print(WeicheEinfahrtSBHSudGeradeausState);
  590. lcd.setCursor(0, 2);
  591. lcd.print("Weiche Sud Glei.1 =");
  592. lcd.print(WeicheSBHSudGleis1geradeausState);
  593. NextAnzeigeState = digitalRead(NextAnzeige);
  594. if (NextAnzeigeState == 0)
  595. {
  596. next_state_LCDANZEIGE = MODUL1;
  597. delay(250);
  598. }
  599.  
  600. break;
  601. }
  602. }
  603.  
  604. }
  605. // ------------------------------------- Ansteuerung LCD 20x4 Ende
  606. // Eingänge auslesen
  607. {
  608. TestCAN1State = digitalRead(TestCAN1);
  609. if (TestCAN1State == 1)
  610. {
  611. WeicheEinfahrtSBHSudGeradeausState = 1;
  612. WeicheEinfahrtSBHSudAbbiegenState = 1;
  613. }
  614. else
  615. {
  616. WeicheEinfahrtSBHSudGeradeausState = 0;
  617. WeicheEinfahrtSBHSudAbbiegenState = 0;
  618. }
  619. // ---------------------------------
  620. TestCAN2State = digitalRead(TestCAN2);
  621. if (TestCAN2State == 1)
  622. {
  623. WeicheSBHSudGleis1geradeausState = 1;
  624. }
  625. else
  626. {
  627. WeicheSBHSudGleis1geradeausState = 0;
  628. }
  629. }
  630. // Ausgänge schalten
  631. {
  632.  
  633. }
  634. }
Advertisement
Add Comment
Please, Sign In to add comment