CanBus for Beginners - Super Simple

Okay!

so lets break apart;
sprintf(temp, “%.2x”,data[b]);

I get its “Serial print function”, temp is your variable array. Its the “%.2x” part that really goes over my head.
What is the purpose of “%” is “.2x” sating you want it in 0x00 format vs %.4x being 0x0000 format?

then data[b] is just the bytes number as it comes out of your for loop?

I have seen tried and failed this method before.

Pretty sure %.2x simply prints a number in hex, but it will always use at least two digits. Although in our case it will always be two digits because we’re only feeding it between 0 and 255. Sprintf formats the number into hex into a temporary string variable which we then print with Serial.print. It prints out the hex value of just one byte at a time.

Yes %.4x would print four digit hex numbers (or greater).

Whenever I work with C standard format strings like that I have to look them up. For example, C library function - sprintf()

The variable “data” is the array of bytes that is passed to the function, and len tells it how many bytes to pull off of data. data[b] pulls out the "b"th byte from that array. It will print as many bytes as you have, up to any length (provided you don’t go off the end of the array). Hope that helps make it understandable.

1 Like

Gives me enough info to take another stab at it.

That is a great website, I have been googling like mad to learn C, and this is the first time i have seen it. Thanks.

I guess CAN shield is based on MCP2515 chip…
read Datashet from Microchip https://ww1.microchip.com/downloads/en/DeviceDoc/MCP2515-Stand-Alone-CAN-Controller-with-SPI-20001801J.pdf
In chapter 4.5 is explained “Acceptance and Filter operation”
Finally “simply”! (not really!) using few XOR , OR and AND gates fed by registers
image

1 Like

Or the TJA1050 chip as well not sure what the differences totally are.
It looks like the TJA1050 goes to ttl, and the MCP2515 boards have their own onboard crystal and talk I2C.

not I2C:SPI (very similar!)
image

So the crystal oscillator on the mcp2515 board, does it have to mach your Arduinos frequency? or is it just to match the timing of the CAN Bus?

Doesn’t matter, in the Arduino program when you setup the CAN speed you just set 8mhz or 16mhz clock speed on your CAN shield.

2 Likes

Speed on the can bus is important? Or with an arduino and these boards at 8000mhz it is possible to make it work, because otherwise we should migrate to ESP32 with integrated can, right?

The clock speed is not the bus speed. Bus speed is divided down to the correct setting whatever the clock speed.

I’ve been driving around a frozen field today with AOG steering my 724 via can bus.

Brilliant!

Very dirty patched in code cobbled together late last night but refinement is easy now I get how it works!

Full marks again to Tony (@CommonRail ) for this extremely useful topic.

There is quite a lot of theoretical garbage spoken, especially on the Telegram group but nothing gets close to proper practical solutions. :+1: :star:

11 Likes

The Filtered F02C Messages program really came into it’s own today. A friend has been struggling to get his new topcon x35 system to work with his Fendt 820 steer unit rather than the topcon wheel thing. Lots of calls to topcon but steer was really aggressive and basically all over the place. Everything calibrated as it should but there was an occasional WAS error.

I suggested trying my can units on it and what we found was the same erratic behaviour from the fendt navigation test program.

Looking at the can F02C messages we eventually found backlash in the messages coming from the WAS. Turns out the base plug for the WAS, that locates it, is loose allowing the whole thing to rotate a few degrees before it starts to register movement. Causes awful aggressive steer hunting as you would expect!!

6 Likes

Thats was a good diagnostic plan haha. Once you know how the system working, and can see the signals from the sensors it’s a lot easier to see who’s not doing there job and why.

1 Like

There isn’t a WAS readout anywhere so, apart from back pinning a connector we couldn’t see what was happening. We actually thought there was a connection issue somewhere but the messages gave it away nicely. Good to see it works on an 820 too.

1 Like

Backlash on factory sensors is the norm! When I approach the factory sensor, I expect slack rather than proper operation.

…well there’s no way it’s steering with that lash!! Track rod ends would be shot in a day! Wild oscillations. We estimated 5° of lash in the sensor mechanism.

How come a properly installed factory WAS could have any play. These are hall-effect sensors with no mechanical connection between the rotating part and the fixed part, no arms with joints. The only play I can see is between the left wheel and the right wheel but the one with the sensor should be measured accurately.

I understand the previously described case was cause by a lousy installation, lose parts that should have been securely fixed?

Fendt WAS

1 Like

WAS

4 plugs into 9. The square top of 4 turns with the kingpin, the round lower part is stationary and plugs into 9. There is considerable sprung loaded drag in 4 and the locating plug at the lower end is only a small diameter so reasonably high torque is transferred through it. Hence wear.

How many motor’s hours for this 820 ?

Hi

I have steer ready valtra tractor, can you advice me list of parts and where to order for test build canbus steering?

Regards,
Kimmo

The very 1st post at the top has the list of parts, then a few posts down has examples from AliExpress