RE: MäCAN-Projekt - Universalplatine fertig - 10x Servodecoder

#101 von ricky , 25.02.2018 20:40

Hallo Jochen

Mir ist da was aufgeallen in der MäCan Input da konnte man doch die Slider nicht verstellen
jetzt habe ich die Zeilen an Ende Void verschoben.
Wie ist es bei dir.
Jetzt tut es

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
 
  else if ((can_frame_in.cmd == SYS_CMD) && (can_frame_in.resp_bit == 0)) {   //Abhandlung bei gültigem Weichenbefehl
//************************************************************************************************
// START - STOP / GO / HALT -
//************************************************************************************************
uint8_t sub_cmd = can_frame_in.data[4];
if ( (sub_cmd == SYS_STOP) || (sub_cmd == SYS_HALT) ) {
//----------------------------------------------------------------------------------------------
// STOP oder HALT - Eingaben verhindern.
//----------------------------------------------------------------------------------------------
#ifdef DEBUG_CAN
Serial.print(millis());
Serial.println(" - System locked.");
#endif
locked = true;
 
}
else if (sub_cmd == SYS_GO) {
//----------------------------------------------------------------------------------------------
// GO - Eingaben zulassen.
//----------------------------------------------------------------------------------------------
#ifdef DEBUG_CAN
Serial.print(millis());
Serial.println(" - System unlocked.");
#endif
locked = false;
 
}
//************************************************************************************************
// ENDE - STOP / GO / HALT
//************************************************************************************************
}
 
 




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
 
void incomingFrame() {
//==================================================================================================
// Frames ohne UID
//==================================================================================================
if ((can_frame_in.cmd == PING) && (can_frame_in.resp_bit == 0)) {
//************************************************************************************************
// START - PING Frame - Auf Ping Request antworten
//************************************************************************************************
#ifdef DEBUG_CAN
Serial.print(millis());
Serial.println(" - Sending ping response.");
#endif
mcan.sendPingFrame(device, true);
 
//************************************************************************************************
// ENDE - PING Frame
//************************************************************************************************
}
else if ((can_frame_in.cmd == SWITCH_ACC) && (can_frame_in.resp_bit == 0)) { //Abhandlung bei gültigem Weichenbefehl
 

 

 

 

 

 

 

 

 

 

 

 

 

 

//************************************************************************************************
// START - ACC Frame - Püfen auf Schaltbefehle
//************************************************************************************************
#ifdef LED_FEEDBACK
uint16_t locid = (can_frame_in.data[2] << 8) | can_frame_in.data[3];
#ifdef DEBUG_CAN
Serial.print(millis());
Serial.print(" - Recieved ACC-Frame for ACC: ");
Serial.println(mcan.getadrs(prot, locid));
#endif
for (int i = 0; i < NUM_ACCs; i++) {
if (locid == acc_articles[i].locID) { //Auf benutzte Adresse überprüfen
#ifdef DEBUG_CAN
Serial.print(millis());
Serial.println(" => match found -> Set target state.");
#endif
acc_articles[i].state_set = can_frame_in.data[4];
acc_articles[i].power_set = can_frame_in.data[5];
break;
}
 
}
#endif
//************************************************************************************************
// ENDE - ACC Frame
//************************************************************************************************
}
else if ((uid_mat[0] == can_frame_in.data[0]) && (uid_mat[1] == can_frame_in.data[1]) && (uid_mat[2] == can_frame_in.data[2]) && (uid_mat[3] == can_frame_in.data[3])) {
//==================================================================================================
// Befehle nur für eine UID
//==================================================================================================
if ((can_frame_in.cmd == CONFIG) && (can_frame_in.resp_bit == 0)) {
//**********************************************************************************************
// START - Config Frame -
//**********************************************************************************************
#ifdef DEBUG_CAN
Serial.print(millis());
Serial.print(" - Recieved config frame. - INDEX:");
Serial.println(can_frame_in.data[4]);
#endif
config_poll = true;
config_index = can_frame_in.data[4];
if (config_index == 0) locked = true;
if (config_index == CONFIG_NUM) {
locked = false;
config_sent = true;
Serial.println(" - CONFIG SENT");
Serial.println(" - System unlocked");
}
 
//**********************************************************************************************
// ENDE - Config Frame
//**********************************************************************************************
} else if ((can_frame_in.cmd == SYS_CMD) && (can_frame_in.resp_bit == 0) && (can_frame_in.data[4] == SYS_STAT)) {
//**********************************************************************************************
// START - Status Frame -
//**********************************************************************************************
#ifdef DEBUG_CAN
Serial.print(millis());
Serial.print(" - Recieved Status Frame for config_index: ");
Serial.println(can_frame_in.data[5]);
#endif
//----------------------------------------------------------------------------------------------
// CAN_FRAME_IN.DATA[5] => CONFIG_INDEX
//----------------------------------------------------------------------------------------------
if (can_frame_in.data[5] == 1) {
//--------------------------------------------------------------------------------------------
// Protokoll schreiben ( MM oder DCC)
//--------------------------------------------------------------------------------------------
prot_old = prot;
if (!can_frame_in.data[7]) {
prot = DCC_ACC;
} else {
prot = MM_ACC;
}
if (prot != prot_old) {
EEPROM.put(REG_PROT, can_frame_in.data[7]);
#ifdef DEBUG_CAN
Serial.print(millis());
Serial.print(" - => Changing protocol: ");
Serial.print(prot_old);
Serial.print(" -> ");
Serial.println(prot);
#endif
change_prot();
}
mcan.statusResponse(device, can_frame_in.data[5]);
 
} else if (can_frame_in.data[5] >= 2) {
#ifdef use_uncuppler
//--------------------------------------------------------------------------------------------
// mit Entkuppler
//--------------------------------------------------------------------------------------------
 
uint8_t acc_num = ( can_frame_in.data[5] / 2 ) - 1;
#ifdef DEBUG_CAN
Serial.print(millis());
Serial.print(" - => Change ACC Definition of ACC_NUM: #");
Serial.println(acc_num);
#endif
 
if ( (can_frame_in.data[5] % 2) > 0 ) {
//------------------------------------------------------------------------------------------
// TYP:
//------------------------------------------------------------------------------------------
#ifdef DEBUG_CAN
Serial.print(millis());
Serial.print(" - => Changing Acc Type: ");
Serial.print(acc_articles[acc_num].acc_type);
Serial.print(" -> ");
#endif
acc_articles[acc_num].acc_type = can_frame_in.data[7];
EEPROM.put(acc_articles[acc_num].reg_type, can_frame_in.data[7]);
#ifdef DEBUG_CAN
Serial.print(acc_articles[acc_num].acc_type);
Serial.println(" ==> 0 = Weiche/Signal ; 1 = Entkuppler");
#endif
} else {
//------------------------------------------------------------------------------------------
// ADRESSE:
//------------------------------------------------------------------------------------------
#ifdef DEBUG_CAN
Serial.print(millis());
Serial.print(" - => Changing address: ");
Serial.print(mcan.getadrs(prot, acc_articles[acc_num].locID));
Serial.print(" -> ");
#endif
acc_articles[acc_num].locID = mcan.generateLocId(prot, (can_frame_in.data[6] << 8) | can_frame_in.data[7] );
byte locid_high = acc_articles[acc_num].locID >> 8;
byte locid_low = acc_articles[acc_num].locID;
EEPROM.put(acc_articles[acc_num].reg_locid , locid_high);
EEPROM.put(acc_articles[acc_num].reg_locid + 1, locid_low);
#ifdef DEBUG_CAN
Serial.println(mcan.getadrs(prot, acc_articles[acc_num].locID));
#endif
}
mcan.statusResponse(device, can_frame_in.data[5]);
#else
//--------------------------------------------------------------------------------------------
// ohne Entkuppler
//--------------------------------------------------------------------------------------------
#ifdef DEBUG_CAN
Serial.print("Changing address: ");
Serial.print(mcan.getadrs(prot, acc_articles[can_frame_in.data[5] - start_adrs_channel].locID));
Serial.print(" -> ");
#endif
acc_articles[can_frame_in.data[5] - start_adrs_channel].locID = mcan.generateLocId(prot, (can_frame_in.data[6] << 8) | can_frame_in.data[7] );
byte locid_high = acc_articles[can_frame_in.data[5] - start_adrs_channel].locID >> 8;
byte locid_low = acc_articles[can_frame_in.data[5] - start_adrs_channel].locID;
EEPROM.put(acc_articles[can_frame_in.data[5] - start_adrs_channel].reg_locid, locid_high);
EEPROM.put(acc_articles[can_frame_in.data[5] - start_adrs_channel].reg_locid + 1, locid_low);
mcan.statusResponse(device, can_frame_in.data[5]);
#ifdef DEBUG_CAN
Serial.println(mcan.getadrs(prot, acc_articles[can_frame_in.data[5] - start_adrs_channel].locID));
#endif
#endif
}
//**********************************************************************************************
// ENDE - Status Frame
//**********************************************************************************************
}
//==================================================================================================
// ENDE - Befehle nur für eine UID
//==================================================================================================
}
else if ((can_frame_in.cmd == SYS_CMD) && (can_frame_in.resp_bit == 0)) { //Abhandlung bei gültigem Weichenbefehl
//************************************************************************************************
// START - STOP / GO / HALT -
//************************************************************************************************
uint8_t sub_cmd = can_frame_in.data[4];
if ( (sub_cmd == SYS_STOP) || (sub_cmd == SYS_HALT) ) {
//----------------------------------------------------------------------------------------------
// STOP oder HALT - Eingaben verhindern.
//----------------------------------------------------------------------------------------------
#ifdef DEBUG_CAN
Serial.print(millis());
Serial.println(" - System locked.");
#endif
locked = true;
 
}
else if (sub_cmd == SYS_GO) {
//----------------------------------------------------------------------------------------------
// GO - Eingaben zulassen.
//----------------------------------------------------------------------------------------------
#ifdef DEBUG_CAN
Serial.print(millis());
Serial.println(" - System unlocked.");
#endif
locked = false;
 
}
//************************************************************************************************
// ENDE - STOP / GO / HALT
//************************************************************************************************
}
}
 

 




Gruß Reiner


 
ricky
Regionalbahn (RB)
Beiträge: 44
Registriert am: 19.03.2016


RE: MäCAN-Projekt - Universalplatine fertig - 10x Servodecoder

#102 von ricky , 29.12.2018 08:32

Hallo Maxi

Es gibt bei nur was neues was denn Servo Decoder angeht habe in deinem Code ein paar Sachen abgeändert.
So kann man jetzt über die Gui die Servowinkel und ein paar andere Dinge darüber abwickeln ich will dem Rest
HIER die Änderungen nicht vor enthalten daher würde ich dir den Code zur Veröffentlichung schicken der Grundcode ist ja von dir.

Gruss Reiner


 
ricky
Regionalbahn (RB)
Beiträge: 44
Registriert am: 19.03.2016


RE: MäCAN-Projekt - Universalplatine fertig - 10x Servodecoder

#103 von Ixam97 , 08.01.2019 16:05

Hallo Reiner,

entschuldige die späte Antwort. Ich bin derzeit etwas eingespannt in meinem Praktikum und außer zum lesen komme ich zu nicht wirklich viel ops:

Der Code für die MäCAN-Geräte ist schon ziemlich alt. Ich selber würde ihn mit meinem Zuwachs an Erfahrung seit der Entstehung so nicht mehr einsetzen, sondern von Grund auf neu programmieren. Derzeit schwirren mir da auch ein Paar Ideen für einen Modulareren im Kopf herum. Aber dazu mehr, wenn es so weit ist.

Wenn mich nicht alles täuscht müsstest du deine Änderungen direkt in mein Github-Repo laden können, sodass ich sie nur noch freigeben muss. Das kannst du gerne machen. Du kannst mir aber auch per PN die Datei zuschicken und ich pflege sie demnächst selber ein.


Viele Grüße und Clausthaler Glück Auf,

Maxi.
____________________________________________________

github.com/Ixam97
MäCAN Reborn


 
Ixam97
InterRegioExpress (IRE)
Beiträge: 255
Registriert am: 13.01.2014


RE: MäCAN-Projekt - Universalplatine fertig - 10x Servodecoder

#104 von Clooney , 28.04.2019 12:04

Hallo Stummis,

ich habs jetzt endlich geschafft mein GBS fertig zu machen.






HW:
1x Teensy 3.6 als Hirn und 31 AddOn Module (maximum wären 32 AddOns) zur Steuerung der Taster und LEDs.
Den Code lade bei Gelegenheit noch auf mein Github Repo.

Edit: Code ist jetzt auf GitHub verfügbar.


Gruß Jochen

Meine Saunakellerbahn: RE: Saunakellerbahn
Anlageplanung: RE: Endlich eigene MoBa im Saunakeller


Clooney  
Clooney
InterCity (IC)
Beiträge: 582
Registriert am: 02.01.2016
Ort: Gammelshausen
Gleise Märklin C-Gleis
Spurweite H0
Steuerung CS3 & iTrain 5
Stromart AC, Digital


   


  • Ähnliche Themen
    Antworten
    Zugriffe
    Letzter Beitrag
Xobor Einfach ein eigenes Forum erstellen
Datenschutz