Read analog values via CAN BUS (#635)
* Read analog values via CAN BUS Allows reading of 16 analog signals via CAN-BUS. with selection of Edianness. * Moved function Function moved to improve data readability. --------- Co-authored-by: Josh Stewart <josh@noisymime.org>
This commit is contained in:
parent
8d99a9c971
commit
da57378684
|
@ -962,9 +962,9 @@ page = 9
|
|||
caninput_source_num_bytes12 = bits, U16, 65, [12:12], "1", "2"
|
||||
caninput_source_num_bytes13 = bits, U16, 65, [13:13], "1", "2"
|
||||
caninput_source_num_bytes14 = bits, U16, 65, [14:14], "1", "2"
|
||||
caninput_source_num_bytes15 = bits, U16, 65, [15:15], "1", "2"
|
||||
|
||||
unused10_67 = scalar, U08, 67, "", 1, 0, 0, 255, 0
|
||||
caninput_source_num_bytes15 = bits, U16, 65, [15:15], "1", "2"
|
||||
caninputEndianess = bits, U08, 67, [0:0], "Big-Endian", "Little-Endian"
|
||||
|
||||
unused10_68 = scalar, U08, 68, "", 1, 0, 0, 255, 0
|
||||
|
||||
enable_intcandata_out = bits, U08, 69, [0:0], "Off", "On"
|
||||
|
@ -993,8 +993,8 @@ page = 9
|
|||
canoutput_param_num_bytes5 = bits, U08, 107, [0:1], "INVALID", "1", "2", "INVALID"
|
||||
canoutput_param_num_bytes6 = bits, U08, 108, [0:1], "INVALID", "1", "2", "INVALID"
|
||||
canoutput_param_num_bytes7 = bits, U08, 109, [0:1], "INVALID", "1", "2", "INVALID"
|
||||
|
||||
unused10_110 = scalar, U08, 110, "", 1, 0, 0, 255, 0
|
||||
|
||||
unused10_110 = scalar, U08, 110, "", 1, 0, 0, 255, 0
|
||||
unused10_111 = scalar, U08, 111, "", 1, 0, 0, 255, 0
|
||||
unused10_112 = scalar, U08, 112, "", 1, 0, 0, 255, 0
|
||||
unused10_113 = scalar, U08, 113, "", 1, 0, 0, 255, 0
|
||||
|
@ -2357,6 +2357,7 @@ menuDialog = main
|
|||
tachoMode = "The output mode for the tacho pulse. Fixed timing will produce a pulse that is always of the same duration, which works better with mode modern digital tachos. Dwell based output creates a pulse that is matched to the coil/s dwell time. If enabled the tacho pulse duration and timing is same as coil dwell and the number of pulses is same as number of ignition events. This can work better on some styles of tacho but note that the pulse duration might become problem on higher cylinder number engines."
|
||||
canBMWCluster = "Enables CAN broadcasting for BMW E46, E39 and E38 instrument clusters with message ID's 0x316, 0x329 and 0x545"
|
||||
canVAGCluster = "Enables CAN broadcasting for VAG instrument clusters with message ID's 0x280 and 0x5A0"
|
||||
caninputEndianess= "Byte ordering for values with two bytes."
|
||||
|
||||
boostControlEnable = "Set the trigger to enable/disable the closedloop boost controller. When set to: \n 'fixed': if the fuel load exceeds the threshold closedloop boost controller is enbaled.\n 'baro': if the fuel load exceeds the baro the controller is enabled (legacy) "
|
||||
boostDCWhenDisabled = "When the closedloop boost controller is disabled by 'enable trigger', this is the Duty cycle set on the boost selenoid. Ususally this is 99% because it keeps the waste gate firmly closed until the threshold and builds boost as fast as possible (no wastegate leak)"
|
||||
|
@ -3452,7 +3453,10 @@ menuDialog = main
|
|||
displayOnlyField = !"Internal CANBUS NOT AVAILABLE to MCU", blankfield, {enable_intcan == 1 && intcan_available == 0},{enable_intcan == 1 && intcan_available == 0}
|
||||
displayOnlyField = !"Internal CANBUS NOT AVAILABLE to MCU", blankfield, {enable_intcan == 0 && intcan_available == 0},{enable_intcan == 0 && intcan_available == 0}
|
||||
field = " If Secondary Serial or Internal CANBUS is DISABLED then any input channel assigned to that external source will NOT function"
|
||||
|
||||
|
||||
dialog = selectionOfEdianness. , "Endianness", yAxis
|
||||
field = "", caninputEndianess {(enable_intcan && intcan_available)}
|
||||
|
||||
dialog = canAuxinput_alias, "", yAxis
|
||||
field = "Input Alias"
|
||||
field = "", AUXin00Alias , {(caninput_sel0a && (!enable_secondarySerial && (!enable_intcan || (enable_intcan && intcan_available == 0)))) || (caninput_sel0b && (enable_secondarySerial || (enable_intcan && intcan_available)))}
|
||||
|
@ -3630,7 +3634,11 @@ menuDialog = main
|
|||
panel = caninconfig_blank1
|
||||
panel = caninput_parameter_start_byte
|
||||
panel = caninconfig_blank1
|
||||
panel = caninput_parameter_num_byte
|
||||
panel = caninput_parameter_num_byte
|
||||
|
||||
dialog = AuxinCenter, "", xAxis
|
||||
field = ""
|
||||
panel = selectionOfEdianness.
|
||||
|
||||
;dialog = Canin_config2, "External Data Input"
|
||||
; field = "Enable External data input", enable_intcandata_in
|
||||
|
@ -3638,6 +3646,7 @@ menuDialog = main
|
|||
dialog = Canin_config, "",yAxis
|
||||
topicHelp = "http://speeduino.com/wiki/index.php/Secondary_Serial_IO_interface#Read_external_analog_data"
|
||||
panel = Auxin_north
|
||||
panel = AuxinCenter
|
||||
panel = Canin_config1
|
||||
|
||||
dialog = canAuxoutput_alias, "", yAxis
|
||||
|
|
|
@ -27,5 +27,6 @@ void sendcanValues(uint16_t offset, uint16_t packetLength, byte cmd, byte portNu
|
|||
void can_Command(void);
|
||||
void sendCancommand(uint8_t cmdtype , uint16_t canadddress, uint8_t candata1, uint8_t candata2, uint16_t sourcecanAddress);
|
||||
void obd_response(uint8_t therequestedPID , uint8_t therequestedPIDlow, uint8_t therequestedPIDhigh);
|
||||
void readAuxCanBus();
|
||||
|
||||
#endif // CANCOMMS_H
|
||||
|
|
|
@ -807,4 +807,35 @@ if (PIDmode == 0x01)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
void readAuxCanBus()
|
||||
{
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
if (inMsg.id == (configPage9.caninput_source_can_address[i] + 0x100)) //Filters frame ID
|
||||
{
|
||||
|
||||
if (!BIT_CHECK(configPage9.caninput_source_num_bytes, i))
|
||||
{
|
||||
// Gets the one-byte value from the Data Field.
|
||||
currentStatus.canin[i] = inMsg.buf[configPage9.caninput_source_start_byte[i]];
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
|
||||
if (configPage9.caninputEndianess == 1)
|
||||
{
|
||||
//Gets the two-byte value from the Data Field in Litlle Endian.
|
||||
currentStatus.canin[i] = ((inMsg.buf[configPage9.caninput_source_start_byte[i]]) | (inMsg.buf[configPage9.caninput_source_start_byte[i] + 1] << 8));
|
||||
}
|
||||
else
|
||||
{
|
||||
//Gets the two-byte value from the Data Field in Big Endian.
|
||||
currentStatus.canin[i] = ((inMsg.buf[configPage9.caninput_source_start_byte[i]] << 8) | (inMsg.buf[configPage9.caninput_source_start_byte[i] + 1]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1129,7 +1129,10 @@ struct config9 {
|
|||
uint16_t caninput_source_can_address[16]; //u16 [15] array holding can address of input
|
||||
uint8_t caninput_source_start_byte[16]; //u08 [15] array holds the start byte number(value of 0-7)
|
||||
uint16_t caninput_source_num_bytes; //u16 bit status of the number of bytes length 1 or 2
|
||||
byte unused10_67;
|
||||
|
||||
byte caninputEndianess:1;
|
||||
//byte unused:2
|
||||
//...
|
||||
byte unused10_68;
|
||||
byte enable_candata_out : 1;
|
||||
byte canoutput_sel[8];
|
||||
|
|
|
@ -123,12 +123,13 @@ void loop(void)
|
|||
#if defined (NATIVE_CAN_AVAILABLE)
|
||||
//currentStatus.canin[12] = configPage9.enable_intcan;
|
||||
if (configPage9.enable_intcan == 1) // use internal can module
|
||||
{
|
||||
{
|
||||
//check local can module
|
||||
// if ( BIT_CHECK(LOOP_TIMER, BIT_TIMER_15HZ) or (CANbus0.available())
|
||||
while (Can0.read(inMsg) )
|
||||
{
|
||||
can_Command();
|
||||
readAuxCanBus();
|
||||
//Can0.read(inMsg);
|
||||
//currentStatus.canin[12] = inMsg.buf[5];
|
||||
//currentStatus.canin[13] = inMsg.id;
|
||||
|
|
Loading…
Reference in New Issue