flyingbrick

Arduino stuff/ programing/so cheap

Recommended Posts

Oh, re the Arduino environment doesn't do autocomplete:

VisualMicro is an arduino extension for MS VisualStudio. 

Do try it.

 

 

  • Like 1

Share this post


Link to post
Share on other sites

I have some questions for the wizards.

I am wanting to fiddle with the suspension control unit in my Audi wag, it runs an air system where suspension heights can be selected but at certain speed thresholds the control unit will adjust the height itself. I'm wanting to find a way to stop this so I can have a manual adjustment only option. 

The road speed is provided via the canbus and by a redundant direct wire into the control unit.

Is it possible to create a box (e.g. arduino) to intercept and modify the canbus road speed signal? (I would only be looking to switch between 2 options, either pass through or replace it with a fixed signal, say one that translates to 40kph). I'm guessing the direct wire could be disconnected based on what I have read so far.

dS53kdT.jpg

Chur

Share this post


Link to post
Share on other sites

Not the best way to do it, but I would set up a second CAN network just for that device. You could hook it into the main network too, as a pass-through for when you want to disable your special controller.

Share this post


Link to post
Share on other sites

Teensy 3.6 has dual canbus, so what that means is you can snip the canbus wires to the controller. connect 1 canbus to your controller and the other side back to your main bus. Then pass all the info  through the Teensy both ways. This way you can tell which direction the signals are coming from and isolate the controller data. You can allow all traffic from the height controller back to main bus so it still communicates as needed. Isolating just the controller will help you figure out what each byte means. When the speed info comes from the direction of ECU you can intercept it and modify the signal before passing it through. This project is a bit more complex than it sounds (do you know the canbus datarate? Packet ids?)

Some time initially with a scope would be handy unless you have this info on hand from the manual.

Its definitely doable but definitely a learning curve! 

I can write you a pass through sketch for teensy 3.6 that would get you started identifying can frames.

But it would be a learning exercise from there as decoding can frames is a bit like reading tea leaves haha.

  • Like 3

Share this post


Link to post
Share on other sites

Depending on what thd redunfant speed wire signal is like you could most likely input that at a different speed also.

Pity you dont live closer as this sounds like a cool project to try figure out! 

  • Like 1

Share this post


Link to post
Share on other sites

Cheers for the info, very useful! The teensy sounds like a good unit.

Canbus datarate for the drivetrain (which this stuff is on) is 500kbps max, Convenience and Infotainment are 100kbps max.

I have dug out a few packet ID's so far from others sniffing them out, will keep snooping to see what I can find.

Share this post


Link to post
Share on other sites

You only need to know the can frame id that contains vehicle speed, and then which of the bytes contain speed.

As this is the only one that yku need to pick out to modify. Everything else you can just tell to pass straight on through as is.

Keep in mind that you also need a transciever on the teensy to interact with canbus. (Sounds stupid and it is)There is a dual can backpack board available for it if you google.

 

  • Like 1

Share this post


Link to post
Share on other sites

Cool, will keep researching the soft side before committing, I don't need to do it but it would be fun to suss out :) 

Found this earlier
#define SPEED 0x351
/*
351h 8 45 00 00 00 00 75 7B 10 100 1795 Geschwindigkeit speed

h351, Geschwindigkeit, 8 byte, 100ms 
- byte 0: h00 vorwaerts, h02 rueckwaerts 
- byte 1/2: Geschwindigkeit 
- byte 4/5: Wegstreckenimpuls 

which roughly translates to

h351, speed, 8 bytes, 100ms
- byte 0: h00 forward, h02 backward
- byte 1/2: speed
- byte 4/5: distance pulse

and also
ID 0x351. Speed is contained in Byte 2. Calculation is (Speed = (buf[2] * 256) + (buf[3]-1)) / 190; )

 

Share this post


Link to post
Share on other sites

^^^Thats pretty much everything you need! Just need to know which byte of the can frame is the ID, probably 7 if 0 is already info. 


In other news, read a really good tip to stop those infuriating situations where you use = instead of ==

If you mean to write:

if (engineSpeed == 7)

But you accidentally write:

if (engineSpeed = 7)

Then you're in the shit because it makes the Engine Speed 7. 

But if you swap the order of your variable and the constant:

if (7 == engineSpeed)

Then if you accidentally use

if (7 = engineSpeed)

 7 can never become your variable so the code doesnt show a positive result 100% of the time.

I have screwed myself over with this one, multiple times hahhaa.

  • Like 4
  • Thanks 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now