Our VIP Package gets you every single course at 80% off the individual price. For a limited time, save an additional $100 with coupon code 100VIP. Learn more

CAN Bus Communications Decoded: Step Four: Program devices to transmit required data

Watch This Course

$199.00 USD $129.00 USD

-OR-
Or 8 weekly payments of only $16.13 Instant access. Easy checkout. No fees. Learn more
Course Access for Life
60 day money back guarantee

Step Four: Program devices to transmit required data

11.31

00:00 - Step 4 of our process is going to be to program our devices to transmit the required data.
00:06 Now in this instance it's actually already been done for us because this racecar's been running for quite a while and our M150 is configured to transmit that required data out in its fixed template and that's being read by our C125.
00:20 I do want to confirm that though and we're just going to pop over to my laptop again quickly and I'm going to bring up the monitor channels function in our software here and I'm just going to make sure that we've got valid data coming through for our exhaust pressure measurement channel.
00:39 Sitting here static, the exhaust pressure obviously wouldn't be changing because the vehicle's not running and to be honest, it takes quite a few engine revs onboard and quite a bit of load for there to be a really measurable difference in that exhaust pressure so what I have instead done is I've hooked up a potentiometer to that sensor input and that just lets me swing the raw voltage that the ECU is seeing between 0 and 5 volts and then I can check that I've got matching data coming into the M150 and then being transmitted correctly through to our C125.
01:17 So you can see here that I've got our current pressure reading of around about 527 kPa and if I give that potentiometer just a wee twist back and forth we can see that measurement moving up and down as well, exactly like we expect.
01:35 So we're pretty confident there that our pressure reading is coming in as expect and our sensor scaling in the M150 is correct and it's coming through to our C125.
01:45 So that's that side of the transmission set up.
01:48 We do need to program our C125 now to transmit that out to our MoTeC CAN lambdas.
01:56 Now looking at the pressure reading I've got here, I've got, I've set my potentiometer it's just fixed at the moment and we've got 537 kPa.
02:05 So I'm just going to keep that in the back of my mind because when I'm looking at the data later on, that's what I'm going to want to see to make sure we're transmitting it in the right format.
02:15 Now popping back to our Link documentation quickly just for another quick look at that data byte we've got set up.
02:22 There's a couple of constants I'm going to have to send out.
02:25 85 and a 1 over in data byte 6 so in our MoTeC C125 software here, I can actually define some constants which are just background values in the dash that can be used for various purposes.
02:41 So it looks like we've got up to constant 4 is already used so I'm going to search for GP constant 5.
02:51 And we're going to choose that and I'm going to give that a value of 85 and then I'm going to put in GP constant 6 as well and I'm going to give that a value of 1.
03:07 Value of 1 there.
03:13 So I'm going to be able to use those constants in our data frame configuration and send them out to the Link CAN lambdas which is what it's going to want to see.
03:23 So I'm going to set up those transmission templates now, so in our MoTeC software here I'm up to connections, communications and I want to set up a new transmission profile.
03:37 So the parameters here, the device we're going to choose as a transmit message.
03:43 The format is fixed binary, it's the default and there's actually very very few reasons that you'd ever be changing this so we're going to leave that as it is.
03:52 Alignment here, normal vs word swap.
03:55 That is MoTeC's terminology for little or big endian.
03:59 Now we want to be transmitting this big endian so that's high byte first and for MoTeC that is normal.
04:05 I'm going to leave everything else here default, except for our base address for transmission and this is going to be that PID that the MoTeC Link CAN lambdas are going to be looking for.
04:18 So popping back over to our Link documentation again, we can see that our CAN lambdas will receive ID as 958 plus their index.
04:29 However if we look back up to the CAN IDs used by the Link CAN lambda modules, if I just transmit on 958 or OX3BE, that's transmit to all CAN lambda modules so that's a global PID that all those CAN lambdas are going to be looking for so I want to transmit this to all of the 4 CAN lambdas fitted to this vehicle so that's the PID I'm going to use.
04:53 OX3BE, so we can enter that in there.
04:59 Now we've got transmission rate to configure here.
05:04 Exhaust back pressure is something that changes very quickly so I'm going to want to be transmitting this at a minimum of 50 Hz.
05:12 And that's going to be linked to the transmission rate from the M150 to the C125 as well because obviously it can't, the C125 can't transmit it out to the Link CAN lambdas, any faster than it's receiving it from our M150.
05:28 So with that base frame settings configured, I can head over to our transmitted channel so that we can start configuring these.
05:37 So message type is going to be a single message, there's no compounding required here, I'm going to have to select our channels.
05:43 So the first one I'm going to select is actually that constant we set up.
05:47 Just going to search for GP constant 5.
05:53 And that was the constant that we configured to be 85.
05:57 Just heading back over to our Link documentation quickly we can see, yep our frame here, we've got 85 needs to be transmitted in data byte position 0.
06:06 So GP constant 5, offset is 0.
06:10 Now the offset there, what it means in the MoTeC software is how far along that data byte this value is transmitted.
06:22 So if I put an offset of say 3 in there, that means that this value here would be transmitted in the third data byte.
06:30 I want it in the, it's the first data byte but we call it data byte 0.
06:34 So I'm going to put an offset of 0 in there and it's actually only a 1 byte value or an 8 bit value so I'm just going to give it a length of 1.
06:43 Just open that up again.
06:47 Now bit mask, we're going to leave set to FF.
06:51 Bit masks, what they are is it's a mask of bits that is applied to your data byte and everywhere in that mask that there is a 1, it will allow the corresponding bit in the data byte to be transmitted and everywhere that there's a 0 in that mask, it will mean that no matter what the bit, the corresponding bit in the data byte is, it will always transmit as 0.
07:19 So it's literally like putting a mask across your data byte.
07:23 Most of the time, these are going to be set to all 1s or in this case it's FF because that's of course 8 ones in binary so that's how I'm going to want it left set.
07:36 Now this is going to be an unsigned value and I'm not going to put any multipliers, divisors or adders on it, we just want to transmit it out as 85.
07:47 So we're going to accept that there and that's going to be the configuration of data byte 0 or the first channel parameter that we want to send out.
07:58 Now the next one that we want to send out is going to be engine speed.
08:02 So I'm going to choose that channel.
08:05 Which is called engine RPM in MoTeC lingo.
08:11 And it's automatically changed my offset to 1 because that was the next available data byte in this frame that we're configuring now but having a quick look at our Link CAN lambda documentation you can see it's actually data bytes 2 and 3 that we want to have this in so I'm going to change that offset to 2.
08:29 And this is a 16 but value so it's going to take up 2 bytes, so we're going to have a length of 2, a mask of FFFF because I want all of those data bits to be transmitted through.
08:41 We're going to send it as an unsigned value and we're not going to put any multipliers or divisors on that because once again, looking at our Link documentation there's no multipliers implied there.
08:52 So we'll accept that.
08:54 Next one is going to be our exhaust pressure.
08:59 So we've got exhaust pressure bank 1 and that's given me an automatic offset of 4 there.
09:05 And we do want this transmitted in data byte positions 4 and 5 so that is going to be correct.
09:13 Length of 2, it does have a high byte and a low byte so that is correct.
09:17 Masking's correct, now looking back to our multiplier here, we've got a multiplier of times 10.
09:26 So something interesting is that it's got base resolution here in our MoTeC software of 0.1 kPa.
09:36 What that leads me to believe is that when this parameter gets sent out it's going to be with 1 decimal place of resolution which is the same thing as being multiplied by 10.
09:48 So I suspect that if I put a multiplier of 10 in there, it's actually going to be 1 position too high, multiplied by 10 one too many times.
09:58 However I'm not 100% certain of that so I am going to put a multiplier of 10 in there for the moment but we're going to come back and check that with a CAN analyser tool to make sure that it's correct.
10:08 So we'll accept that byte and then the last one that we need to put in is in data byte position 6 and that needs to be our other constant so we'll add that in, GP constant 6.
10:26 Offset position 6 is correct and it does only have a length of 1 though.
10:31 Unsigned, no multipliers or divisors, everything there should be fine.
10:38 And that's going to complete the configuration of that data frame to be transmitted by our MoTeC C125.
10:49 So that's quite a bit of information to take in so just to really recap what we've done there, we've got 4 MoTeC CAN lambdas on this vehicle, each reading an individual wideband O2 sensor, 1 in each of the runners.
11:03 We've got an exhaust manifold pressure measurement coming into our MoTeC M150.
11:07 That is being transmitted via CAN to our C125 dash.
11:12 Our C125 dash is taking that, it's modifying the format of that data and then it's transmitting it out on a PID that those MoTeC CAN lambdas are looking for.