-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbdrcanlib.cpp
More file actions
2269 lines (2096 loc) · 44.8 KB
/
bdrcanlib.cpp
File metadata and controls
2269 lines (2096 loc) · 44.8 KB
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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "Arduino.h"
#include "bdrcanlib.h"
BDRCANLib::BDRCANLib() {
// constructor body left intentionally empty — real init can go in begin()
}
messageStruct BDRCANLib::createMessageInv(uint32_t id, const uint8_t* data, uint8_t length) {
messageStruct m;
m.id = id;
m.length = length;
if (data && length > 0) {
memcpy(m.data, data, length);
} else {
memset(m.data, 0, sizeof(m.data));
}
return m;
}
void BDRCANLib::sendOBD2Request(uint16_t pid)
{
CANMessage frame;
frame.id = OBD2_REQUEST_ID;
frame.ext = false;
frame.len = 8;
// OBD2 Mode 0x22 request format:
// Byte 0: Number of additional bytes (0x03)
// Byte 1: Mode (0x22 = Read Data by ID)
// Byte 2-3: PID (2 bytes, MSB first)
// Bytes 4-7: Padding (0x00)
frame.data[0] = 0x03; // 3 additional bytes
frame.data[1] = 0x22; // Mode 22
frame.data[2] = (pid >> 8) & 0xFF; // PID high byte
frame.data[3] = pid & 0xFF; // PID low byte
frame.data[4] = 0x00;
frame.data[5] = 0x00;
frame.data[6] = 0x00;
frame.data[7] = 0x00;
const bool ok = ACAN_T4::can2.tryToSend(frame);
if (!ok)
{
Serial.println("Failed to send OBD2 request");
}
waitingForResponse = true;
}
float BDRCANLib::conv_to_dec(const String& s) {
String tmp = s;
tmp.replace(',', '.');
return tmp.toFloat();
}
uint32_t* BDRCANLib::getAllCANIDs(int* count) {
static uint32_t ids[] = {
Set_AC_Current.id,
Set_Brake_Current.id,
Set_ERPM.id,
Set_Position.id,
Set_Relative_Current.id,
Set_Relative_Brake_Current.id,
Set_Digital_Output_1.id,
Set_Digital_Output_2.id,
Set_Digital_Output_3.id,
Set_Digital_Output_4.id,
Max_AC_Current.id,
Set_Maximum_AC_Brake_Current.id,
Max_DC_Current.id,
Set_Maximum_DC_Brake_Current.id,
Drive_Enable.id,
// Orion BMS CAN IDs
relays_status.id,
max_cells_supported_count.id,
populated_cell_count.id,
pack_charge_current_limit.id,
pack_discharge_current_limit.id,
signed_pack_current.id,
unsigned_pack_current.id,
pack_voltage.id,
pack_open_voltage.id,
pack_state_of_charge.id,
pack_amphours.id,
pack_resistance.id,
pack_depth_of_discharge.id,
pack_health.id,
pack_summed_voltage.id,
total_pack_cycles.id,
highest_pack_temperature.id,
lowest_pack_temperature.id,
avg_pack_temperature.id,
heatsink_temperature_sensor.id,
fan_speed.id,
requested_fan_speed.id,
low_cell_voltage.id,
low_cell_voltage_id.id,
high_cell_voltage.id,
high_cell_voltage_id.id,
avg_cell_voltage.id,
low_opencell_voltage.id,
low_opencell_voltage_id.id,
high_opencell_voltage.id,
high_opencell_voltage_id.id,
avg_opencell_voltage.id,
low_cell_resistance.id,
low_cell_resistance_id.id,
high_cell_resistance.id,
high_cell_resistance_id.id,
avg_cell_resistance.id,
input_power_supply_voltage.id,
fan_voltage.id,
// Cell voltage arrays
cell_voltages_1_12.id,
cell_voltages_13_24.id,
cell_voltages_25_36.id,
cell_voltages_37_48.id,
cell_voltages_49_60.id,
cell_voltages_61_72.id,
cell_voltages_73_84.id,
cell_voltages_85_96.id,
cell_voltages_97_108.id,
cell_voltages_109_120.id,
cell_voltages_121_132.id,
cell_voltages_133_144.id,
cell_voltages_145_156.id,
cell_voltages_157_168.id,
cell_voltages_169_180.id,
// Opencell voltage arrays
opencell_voltages_1_12.id,
opencell_voltages_13_24.id,
opencell_voltages_25_36.id,
opencell_voltages_37_48.id,
opencell_voltages_49_60.id,
opencell_voltages_61_72.id,
opencell_voltages_73_84.id,
opencell_voltages_85_96.id,
opencell_voltages_97_108.id,
opencell_voltages_109_120.id,
opencell_voltages_121_132.id,
opencell_voltages_133_144.id,
opencell_voltages_145_156.id,
opencell_voltages_157_168.id,
opencell_voltages_169_180.id,
// Internal resistance arrays
internal_resistances_1_12.id,
internal_resistances_13_24.id,
internal_resistances_25_36.id,
internal_resistances_37_48.id,
internal_resistances_49_60.id,
internal_resistances_61_72.id,
internal_resistances_73_84.id,
internal_resistances_85_96.id,
internal_resistances_97_108.id,
internal_resistances_109_120.id,
internal_resistances_121_132.id,
internal_resistances_133_144.id,
internal_resistances_145_156.id,
internal_resistances_157_168.id,
internal_resistances_169_180.id
};
if (count != nullptr) {
*count = sizeof(ids) / sizeof(ids[0]);
}
return ids;
}
// Interpret inverter message - extract value from raw CAN data
float BDRCANLib::interpretInverterMessage(const messageStruct& msg, const CanMessage& definition) {
// Verify the message ID matches
if (msg.id != definition.id) {
Serial.println("Error: Message ID mismatch!");
return 0.0f;
}
// Extract the raw value based on bit_start and length
int byteIndex = definition.bit_start / 8;
int bitOffset = definition.bit_start % 8;
int lengthBits = definition.length;
// Check bounds
if (byteIndex >= msg.length || (byteIndex + (lengthBits + bitOffset + 7) / 8) > msg.length) {
Serial.println("Error: Message data out of bounds!");
return 0.0f;
}
// Extract value (little-endian)
int32_t rawValue = 0;
int bytesNeeded = (lengthBits + bitOffset + 7) / 8;
for (int i = 0; i < bytesNeeded && (byteIndex + i) < 8; i++) {
rawValue |= (uint32_t)msg.data[byteIndex + i] << (i * 8);
}
// Shift to align
rawValue >>= bitOffset;
// Mask to length
if (lengthBits < 32) {
uint32_t mask = (1UL << lengthBits) - 1;
rawValue &= mask;
// Handle signed values (check if sign bit is set)
if (lengthBits > 1 && (rawValue & (1UL << (lengthBits - 1)))) {
// Sign extend
rawValue |= ~mask;
}
}
// Apply scaling
float scaledValue = (float)rawValue / definition.scale;
// Clamp to min/max
if (scaledValue < definition.min) scaledValue = definition.min;
if (scaledValue > definition.max) scaledValue = definition.max;
return scaledValue;
}
// Interpret BMS message - extract value from raw CAN data
float BDRCANLib::interpretBMSMessage(const messageStruct& msg, const CanMessage& definition) {
// Verify the message ID matches
if (msg.id != definition.id) {
Serial.println("Error: Message ID mismatch!");
return 0.0f;
}
// For BMS messages, the interpretation is similar but may have different byte ordering
// BMS typically uses big-endian (MSB first)
int byteIndex = definition.bit_start / 8;
int lengthBytes = definition.length / 8;
// Check bounds
if (byteIndex >= msg.length || (byteIndex + lengthBytes) > msg.length) {
Serial.println("Error: Message data out of bounds!");
return 0.0f;
}
// Extract value (big-endian for BMS)
int32_t rawValue = 0;
for (int i = 0; i < lengthBytes && (byteIndex + i) < 8; i++) {
rawValue = (rawValue << 8) | msg.data[byteIndex + i];
}
// Handle signed values (for 16-bit signed)
if (lengthBytes == 2 && (rawValue & 0x8000)) {
rawValue |= 0xFFFF0000; // Sign extend
} else if (lengthBytes == 4 && (rawValue & 0x80000000)) {
// Already 32-bit, no extension needed
}
// Apply scaling
float scaledValue = (float)rawValue * definition.scale;
// Clamp to min/max
if (scaledValue < definition.min) scaledValue = definition.min;
if (scaledValue > definition.max) scaledValue = definition.max;
return scaledValue;
}
// Find message definition by CAN ID
const CanMessage* BDRCANLib::findMessageByID(uint32_t id) {
// Check inverter messages (0x01 - 0x0F range)
if (id == Set_AC_Current.id) return &Set_AC_Current;
if (id == Set_Brake_Current.id) return &Set_Brake_Current;
if (id == Set_ERPM.id) return &Set_ERPM;
if (id == Set_Position.id) return &Set_Position;
if (id == Set_Relative_Current.id) return &Set_Relative_Current;
if (id == Set_Relative_Brake_Current.id) return &Set_Relative_Brake_Current;
if (id == Set_Digital_Output_1.id) return &Set_Digital_Output_1;
if (id == Max_AC_Current.id) return &Max_AC_Current;
if (id == Set_Maximum_AC_Brake_Current.id) return &Set_Maximum_AC_Brake_Current;
if (id == Max_DC_Current.id) return &Max_DC_Current;
if (id == Set_Maximum_DC_Brake_Current.id) return &Set_Maximum_DC_Brake_Current;
if (id == Drive_Enable.id) return &Drive_Enable;
// Check BMS messages (0xF000+ range)
if (id == relays_status.id) return &relays_status;
if (id == max_cells_supported_count.id) return &max_cells_supported_count;
if (id == populated_cell_count.id) return &populated_cell_count;
if (id == pack_charge_current_limit.id) return &pack_charge_current_limit;
if (id == pack_discharge_current_limit.id) return &pack_discharge_current_limit;
if (id == signed_pack_current.id) return &signed_pack_current;
if (id == unsigned_pack_current.id) return &unsigned_pack_current;
if (id == pack_voltage.id) return &pack_voltage;
if (id == pack_open_voltage.id) return &pack_open_voltage;
if (id == pack_state_of_charge.id) return &pack_state_of_charge;
if (id == pack_amphours.id) return &pack_amphours;
if (id == pack_resistance.id) return &pack_resistance;
if (id == pack_depth_of_discharge.id) return &pack_depth_of_discharge;
if (id == pack_health.id) return &pack_health;
if (id == pack_summed_voltage.id) return &pack_summed_voltage;
if (id == total_pack_cycles.id) return &total_pack_cycles;
if (id == highest_pack_temperature.id) return &highest_pack_temperature;
if (id == lowest_pack_temperature.id) return &lowest_pack_temperature;
if (id == avg_pack_temperature.id) return &avg_pack_temperature;
if (id == heatsink_temperature_sensor.id) return &heatsink_temperature_sensor;
if (id == fan_speed.id) return &fan_speed;
if (id == requested_fan_speed.id) return &requested_fan_speed;
if (id == low_cell_voltage.id) return &low_cell_voltage;
if (id == low_cell_voltage_id.id) return &low_cell_voltage_id;
if (id == high_cell_voltage.id) return &high_cell_voltage;
if (id == high_cell_voltage_id.id) return &high_cell_voltage_id;
if (id == avg_cell_voltage.id) return &avg_cell_voltage;
if (id == low_opencell_voltage.id) return &low_opencell_voltage;
if (id == low_opencell_voltage_id.id) return &low_opencell_voltage_id;
if (id == high_opencell_voltage.id) return &high_opencell_voltage;
if (id == high_opencell_voltage_id.id) return &high_opencell_voltage_id;
if (id == avg_opencell_voltage.id) return &avg_opencell_voltage;
if (id == low_cell_resistance.id) return &low_cell_resistance;
if (id == low_cell_resistance_id.id) return &low_cell_resistance_id;
if (id == high_cell_resistance.id) return &high_cell_resistance;
if (id == high_cell_resistance_id.id) return &high_cell_resistance_id;
if (id == avg_cell_resistance.id) return &avg_cell_resistance;
if (id == input_power_supply_voltage.id) return &input_power_supply_voltage;
if (id == fan_voltage.id) return &fan_voltage;
// Cell voltage arrays
if (id == cell_voltages_1_12.id) return &cell_voltages_1_12;
if (id == cell_voltages_13_24.id) return &cell_voltages_13_24;
if (id == cell_voltages_25_36.id) return &cell_voltages_25_36;
if (id == cell_voltages_37_48.id) return &cell_voltages_37_48;
if (id == cell_voltages_49_60.id) return &cell_voltages_49_60;
if (id == cell_voltages_61_72.id) return &cell_voltages_61_72;
if (id == cell_voltages_73_84.id) return &cell_voltages_73_84;
if (id == cell_voltages_85_96.id) return &cell_voltages_85_96;
if (id == cell_voltages_97_108.id) return &cell_voltages_97_108;
if (id == cell_voltages_109_120.id) return &cell_voltages_109_120;
if (id == cell_voltages_121_132.id) return &cell_voltages_121_132;
if (id == cell_voltages_133_144.id) return &cell_voltages_133_144;
if (id == cell_voltages_145_156.id) return &cell_voltages_145_156;
if (id == cell_voltages_157_168.id) return &cell_voltages_157_168;
if (id == cell_voltages_169_180.id) return &cell_voltages_169_180;
// Not found
return nullptr;
}
// Helper to determine if a message is from the inverter
bool BDRCANLib::isInverterMessage(const CanMessage* msg) {
if (msg == nullptr) return false;
// Inverter messages are in the 0x01-0xFF range
return (msg->id >= 0x01 && msg->id <= 0xFF);
}
// Helper to determine if a message is from the BMS
bool BDRCANLib::isBMSMessage(const CanMessage* msg) {
if (msg == nullptr) return false;
// BMS messages are in the 0xF000+ range
return (msg->id >= 0xF000);
}
/*
* Define every CAN ID used in the system.
* Add or modify as needed for your application.
*/
const CanMessage Set_AC_Current = {
"Set AC Current",
0x01,
"ac current",
"0",
1,
8,
-3276.8f,
3276.7f,
10.0f,
"A_pk",
"This command sets the target motor AC current (peak, not RMS). When the controller receives this message, it automatically switches to current control mode. This value must not be above the limits of the inverter and must be multiplied by 10 before sending. This is a signed parameter, and the sign represents the direction of the torque which correlates with the motor AC current. (For the correlation, please refer to the motor parameters)"
};
const CanMessage Set_Brake_Current = {
"Set Brake current",
0x02,
"target brake current",
"0-1",
0,
8,
-3276.8f,
3276.7f,
10.0f,
"A_pk",
"Targets the brake current of the motor. It will result negative torque relatively to the forward direction of the motor. This value must be multiplied by 10 before sending, only positive currents are accepted."
};
const CanMessage Set_ERPM = {
"Set ERPM",
0x03,
"Set speed (ERPM)",
"0-3",
0,
8,
-2147483648.0f,
2147483647.0f,
1.0f,
"ERPM",
"This command enables the speed control of the motor with a target ERPM. This is a signed parameter, and the sign represents the direction of the spinning. For better operation you need to tune the PID of speed control. Equation: ERPM = Motor RPM * number of the motor pole pairs."
};
const CanMessage Set_Position = {
"Set Position",
0x04,
"Target position",
"0-1",
0,
8,
-3276.8f,
3276.7f,
10.0f,
"degree",
"This value targets the desired position of the motor in degrees. This command is used to hold a position of the motor. This feature is enabled only if encoder is used as position sensor. The value has to be multiplied by 10 before sending."
};
const CanMessage Set_Relative_Current = {
"Set Relative current",
0x05,
"Set relative current",
"0-1",
0,
8,
-3276.8f,
3276.7f,
10.0f,
"%",
"This command sets a relative AC current to the minimum and maximum limits set by configuration. This achieves the same function as the “Set AC current” command. Gives you a freedom to send values between -100,0% and 100,0%. You do not need to know the motor limit parameters. This value must be between -100 and 100 and must be multiplied by 10 before sending."
};
const CanMessage Set_Relative_Brake_Current = {
"Set relative brake current",
0x06,
"",
"0-1",
0,
8,
0.0f,
0.0f,
1.0f,
"",
"Targets the relative brake current of the motor. It will result negative torque relatively to the forward direction of the motor. This value must be between 0 and 100 and must be multiplied by 10 before sending Gives you a freedom to send values between 0% and 100,0%. You do not need to know the motor limit parameters. This value must be between 0 and 100 and has to be multiplied by 10 before sending"
};
const CanMessage Set_Digital_Output_1 = {
"Set digital output",
0x07,
"Sets an output to HIGH or LOW",
"0",
0,
8,
0.0f,
1.0f,
1.0f,
"#",
"Sets the digital output 1 to HIGH (1) or LOW (0) state"
};
const CanMessage Set_Digital_Output_2 = {
"Set digital output",
0x07,
"Sets an output to HIGH or LOW",
"0",
1,
8,
0.0f,
1.0f,
1.0f,
"#",
"Sets the digital output 2 to HIGH (1) or LOW (0) state"
};
const CanMessage Set_Digital_Output_3 = {
"Set digital output",
0x07,
"Sets an output to HIGH or LOW",
"0",
2,
8,
0.0f,
1.0f,
1.0f,
"#",
"Sets the digital output 3 to HIGH (1) or LOW (0) state"
};
const CanMessage Set_Digital_Output_4 = {
"Set digital output",
0x07,
"Sets an output to HIGH or LOW",
"0",
3,
8,
0.0f,
1.0f,
1.0f,
"#",
"Sets the digital output 4 to HIGH (1) or LOW (0) state"
};
const CanMessage Max_AC_Current = {
"Max AC Current",
0x08,
"Limiting command",
"0-1",
0,
8,
-3276.8f,
3276.7f,
10.0f,
"A_pk",
"This value determines the maximum allowable drive current on the AC side. With this function you are able maximize the maximum torque on the motor. The value must be multiplied by 10 before sending."
};
const CanMessage Set_Maximum_AC_Brake_Current = {
"Set maximum AC brake current",
0x09,
"Limiting command",
"0-1",
0,
8,
-3276.8f,
3276.7f,
10.0f,
"A_pk",
"This value sets the maximum allowable brake current on the AC side. This value must be multiplied by 10 before sending, only negative currents are accepted."
};
const CanMessage Max_DC_Current = {
"Max DC Current",
0x0A,
"Limiting command",
"0-1",
0,
8,
-3276.8f,
3276.7f,
10.0f,
"A",
"This value determines the maximum allowable drive current on the DC side. With this command the BMS can limit the maximum allowable battery discharge current. The value has to be multiplied by 10 before sending."
};
const CanMessage Set_Maximum_DC_Brake_Current = {
"Set maximum DC brake current",
0x0B,
"Limiting command",
"0-1",
0,
8,
-3276.8f,
3276.7f,
10.0f,
"%",
"This value determines the maximum allowable brake current on the DC side. With this command the BMS can limit the maximum allowable battery charge current. The value has to be multiplied by 10 before sending. Only negative currents are accepted."
};
const CanMessage Drive_Enable = {
"Drive Enable",
0x0C,
"Limiting command",
0,
0,
8,
0,
255,
1,
"#",
"0: Drive not allowed 1: Drive allowed Only 0 and 1 values are accepted. Must be sent periodically to be enabled. Refer to chapter 4.3"
};
// Inverter Feedback Messages (Status/Telemetry from motor controller)
const CanMessage erpm = {
"ERPM",
0x20,
"Motor speed",
"0-3",
0,
32,
-2147483648.0f,
2147483647.0f,
1.0f,
"ERPM",
"Current electrical RPM of the motor"
};
const CanMessage duty_cycle = {
"Duty Cycle",
0x21,
"PWM duty",
"0-1",
0,
16,
0.0f,
100.0f,
0.1f,
"%",
"Current duty cycle percentage"
};
const CanMessage input_voltage = {
"Input Voltage",
0x22,
"DC bus voltage",
"0-1",
0,
16,
0.0f,
655.35f,
0.01f,
"V",
"DC bus input voltage"
};
const CanMessage AC_current = {
"AC Current",
0x23,
"Motor current",
"0-1",
0,
16,
-3276.8f,
3276.7f,
0.1f,
"A_pk",
"Current AC motor current"
};
const CanMessage DC_current = {
"DC Current",
0x24,
"Battery current",
"0-1",
0,
16,
-3276.8f,
3276.7f,
0.1f,
"A",
"Current DC battery current"
};
const CanMessage RESERVED_1 = {
"Reserved 1",
0x25,
"",
"0",
0,
8,
0.0f,
0.0f,
1.0f,
"",
"Reserved for future use"
};
const CanMessage controller_temperature = {
"Controller Temperature",
0x26,
"Inverter temp",
"0-1",
0,
16,
-40.0f,
215.0f,
0.1f,
"°C",
"Temperature of the motor controller"
};
const CanMessage motor_temperature = {
"Motor Temperature",
0x27,
"Motor temp",
"0-1",
0,
16,
-40.0f,
215.0f,
0.1f,
"°C",
"Temperature of the motor"
};
const CanMessage fault_code = {
"Fault Code",
0x28,
"Error code",
"0-1",
0,
16,
0.0f,
65535.0f,
1.0f,
"",
"Current fault/error code"
};
const CanMessage RESERVED_2 = {
"Reserved 2",
0x29,
"",
"0",
0,
8,
0.0f,
0.0f,
1.0f,
"",
"Reserved for future use"
};
const CanMessage Id = {
"Id Current",
0x2A,
"D-axis current",
"0-1",
0,
16,
-3276.8f,
3276.7f,
0.1f,
"A",
"D-axis current component"
};
const CanMessage Iq = {
"Iq Current",
0x2B,
"Q-axis current",
"0-1",
0,
16,
-3276.8f,
3276.7f,
0.1f,
"A",
"Q-axis current component"
};
const CanMessage throttle_signal = {
"Throttle Signal",
0x2C,
"Throttle input",
"0-1",
0,
16,
0.0f,
100.0f,
0.1f,
"%",
"Throttle input signal percentage"
};
const CanMessage brake_signal = {
"Brake Signal",
0x2D,
"Brake input",
"0-1",
0,
16,
0.0f,
100.0f,
0.1f,
"%",
"Brake input signal percentage"
};
const CanMessage digital_input_1 = {
"Digital Input 1",
0x2E,
"DI1",
"0",
0,
1,
0.0f,
1.0f,
1.0f,
"",
"State of digital input 1"
};
const CanMessage digital_input_2 = {
"Digital Input 2",
0x2E,
"DI2",
"0",
1,
1,
0.0f,
1.0f,
1.0f,
"",
"State of digital input 2"
};
const CanMessage digital_input_3 = {
"Digital Input 3",
0x2E,
"DI3",
"0",
2,
1,
0.0f,
1.0f,
1.0f,
"",
"State of digital input 3"
};
const CanMessage digital_input_4 = {
"Digital Input 4",
0x2E,
"DI4",
"0",
3,
1,
0.0f,
1.0f,
1.0f,
"",
"State of digital input 4"
};
const CanMessage digital_input_1_2 = {
"Digital Input 1 (Alt)",
0x2F,
"DI1_alt",
"0",
0,
1,
0.0f,
1.0f,
1.0f,
"",
"Alternate state of digital input 1"
};
const CanMessage digital_input_2_2 = {
"Digital Input 2 (Alt)",
0x2F,
"DI2_alt",
"0",
1,
1,
0.0f,
1.0f,
1.0f,
"",
"Alternate state of digital input 2"
};
const CanMessage digital_input_3_2 = {
"Digital Input 3 (Alt)",
0x2F,
"DI3_alt",
"0",
2,
1,
0.0f,
1.0f,
1.0f,
"",
"Alternate state of digital input 3"
};
const CanMessage digital_input_4_2 = {
"Digital Input 4 (Alt)",
0x2F,
"DI4_alt",
"0",
3,
1,
0.0f,
1.0f,
1.0f,
"",
"Alternate state of digital input 4"
};
const CanMessage drive_enable = {
"Drive Enable Status",
0x30,
"Drive status",
"0",
0,
8,
0.0f,
1.0f,
1.0f,
"",
"Current drive enable status"
};
const CanMessage capacitor_temp_limit = {
"Capacitor Temp Limit",
0x31,
"Cap temp limit active",
"0",
0,
1,
0.0f,
1.0f,
1.0f,
"",
"Capacitor temperature limit active flag"
};
const CanMessage DC_current_limit = {
"DC Current Limit",
0x31,
"DC limit active",
"0",
1,
1,
0.0f,
1.0f,
1.0f,
"",
"DC current limit active flag"
};
const CanMessage drive_enable_limit = {
"Drive Enable Limit",
0x31,
"Drive enable limit",
"0",
2,
1,
0.0f,
1.0f,
1.0f,
"",
"Drive enable limit active flag"
};
const CanMessage igbt_acceleration_temperature_limit = {
"IGBT Accel Temp Limit",
0x31,
"IGBT accel limit",
"0",
3,
1,
0.0f,
1.0f,
1.0f,
"",
"IGBT acceleration temperature limit active flag"
};
const CanMessage igbt_temperature_limit = {
"IGBT Temperature Limit",
0x31,
"IGBT temp limit",
"0",
4,
1,
0.0f,
1.0f,
1.0f,
"",
"IGBT temperature limit active flag"
};
const CanMessage input_voltage_limit = {
"Input Voltage Limit",
0x31,
"Voltage limit",
"0",
5,
1,
0.0f,
1.0f,
1.0f,
"",
"Input voltage limit active flag"
};
const CanMessage motor_acceleration_temperature_limit = {
"Motor Accel Temp Limit",
0x31,
"Motor accel limit",
"0",
6,
1,
0.0f,
1.0f,
1.0f,
"",
"Motor acceleration temperature limit active flag"
};
const CanMessage motor_temperature_limit = {
"Motor Temperature Limit",
0x31,
"Motor temp limit",
"0",
7,
1,
0.0f,