h4nd Posted January 15, 2019 Share Posted January 15, 2019 Oh, re the Arduino environment doesn't do autocomplete: VisualMicro is an arduino extension for MS VisualStudio. Do try it. 1 Quote Link to comment Share on other sites More sharing options...
kicker Posted January 27, 2019 Share Posted January 27, 2019 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. Chur Quote Link to comment Share on other sites More sharing options...
ajg193 Posted January 27, 2019 Share Posted January 27, 2019 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. Quote Link to comment Share on other sites More sharing options...
Roman Posted January 27, 2019 Share Posted January 27, 2019 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. 3 Quote Link to comment Share on other sites More sharing options...
Roman Posted January 27, 2019 Share Posted January 27, 2019 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! 1 Quote Link to comment Share on other sites More sharing options...
kicker Posted January 28, 2019 Share Posted January 28, 2019 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. Quote Link to comment Share on other sites More sharing options...
Roman Posted January 28, 2019 Share Posted January 28, 2019 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. 1 Quote Link to comment Share on other sites More sharing options...
kicker Posted January 30, 2019 Share Posted January 30, 2019 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; ) Quote Link to comment Share on other sites More sharing options...
Roman Posted January 31, 2019 Share Posted January 31, 2019 ^^^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. 4 1 Quote Link to comment Share on other sites More sharing options...
Ghostchips Posted March 19, 2019 Share Posted March 19, 2019 Quote avrdude: ser_open(): can't set com-state for "\\.\COM4" An error occurred while uploading the sketch This report would have more information with "Show verbose output during compilation" option enabled in File -> Preferences. What does this mean? Did i fry it again? Quote Link to comment Share on other sites More sharing options...
IvyMike Posted March 19, 2019 Share Posted March 19, 2019 Maybe. When you connect/disconnect the Arduino does 'Port' under the Tools menu display an extra COM port? (Make sure you collapse the menu to allow it to refresh its state) Quote Link to comment Share on other sites More sharing options...
Ghostchips Posted March 19, 2019 Share Posted March 19, 2019 COM 4 wasn't responding, i re-installed the drivers and plugged it into a different serial port and it started responding again as COM 5. Stupidly forgot to test which fix it was. I'll just guess a cooked my USB port by plugging it in while the car was running. Beats me why this doesn't flash at 20ms intervals void setup() { pinMode(LED_BUILTIN, OUTPUT); } void HighOut(uint8_t outPin) { delay(20); } void loop() { digitalWrite(LED_BUILTIN, LOW); delay(1500); digitalWrite(LED_BUILTIN, HighOut); delay(250); digitalWrite(LED_BUILTIN, LOW); delay(500); digitalWrite(LED_BUILTIN, HighOut); delay(250); digitalWrite(LED_BUILTIN, LOW); delay(500); digitalWrite(LED_BUILTIN, HighOut); delay(1000); digitalWrite(LED_BUILTIN, LOW); delay(500); digitalWrite(LED_BUILTIN, HighOut); delay(250); digitalWrite(LED_BUILTIN, LOW); delay(1500); digitalWrite(LED_BUILTIN, HighOut); delay(250); digitalWrite(LED_BUILTIN, LOW); delay(500); digitalWrite(LED_BUILTIN, HighOut); delay(250); digitalWrite(LED_BUILTIN, LOW); delay(500); digitalWrite(LED_BUILTIN, HighOut); delay(1000); digitalWrite(LED_BUILTIN, LOW); delay(1500); digitalWrite(LED_BUILTIN, HighOut); delay(1000); digitalWrite(LED_BUILTIN, LOW); delay(500); digitalWrite(LED_BUILTIN, HighOut); delay(250); digitalWrite(LED_BUILTIN, LOW); delay(500); digitalWrite(LED_BUILTIN, HighOut); delay(1000); digitalWrite(LED_BUILTIN, LOW); delay(500); digitalWrite(LED_BUILTIN, HighOut); delay(250); digitalWrite(LED_BUILTIN, LOW); delay(1500); digitalWrite(LED_BUILTIN, HighOut); delay(1000); digitalWrite(LED_BUILTIN, LOW); delay(500); digitalWrite(LED_BUILTIN, HighOut); delay(250); digitalWrite(LED_BUILTIN, LOW); delay(500); digitalWrite(LED_BUILTIN, HighOut); delay(1000); digitalWrite(LED_BUILTIN, LOW); delay(2500); digitalWrite(LED_BUILTIN, HighOut); delay(1000); digitalWrite(LED_BUILTIN, LOW); delay(500); digitalWrite(LED_BUILTIN, HighOut); delay(250); digitalWrite(LED_BUILTIN, LOW); delay(500); digitalWrite(LED_BUILTIN, HighOut); delay(1000); digitalWrite(LED_BUILTIN, LOW); delay(500); digitalWrite(LED_BUILTIN, HighOut); delay(1000); digitalWrite(LED_BUILTIN, LOW); delay(1500); digitalWrite(LED_BUILTIN, HighOut); delay(1000); digitalWrite(LED_BUILTIN, LOW); delay(500); digitalWrite(LED_BUILTIN, HighOut); delay(1000); digitalWrite(LED_BUILTIN, LOW); delay(500); digitalWrite(LED_BUILTIN, HighOut); delay(1000); digitalWrite(LED_BUILTIN, LOW); delay(1500); digitalWrite(LED_BUILTIN, HighOut); delay(250); digitalWrite(LED_BUILTIN, LOW); delay(500); digitalWrite(LED_BUILTIN, HighOut); delay(250); digitalWrite(LED_BUILTIN, LOW); delay(500); digitalWrite(LED_BUILTIN, HighOut); delay(1000); digitalWrite(LED_BUILTIN, LOW); delay(2500); digitalWrite(LED_BUILTIN, HighOut); delay(250); digitalWrite(LED_BUILTIN, LOW); delay(500); digitalWrite(LED_BUILTIN, HighOut); delay(1000); digitalWrite(LED_BUILTIN, LOW); delay(500); digitalWrite(LED_BUILTIN, HighOut); delay(250); digitalWrite(LED_BUILTIN, LOW); delay(500); digitalWrite(LED_BUILTIN, HighOut); delay(1000); digitalWrite(LED_BUILTIN, LOW); delay(500); digitalWrite(LED_BUILTIN, HighOut); delay(250); digitalWrite(LED_BUILTIN, LOW); delay(500); digitalWrite(LED_BUILTIN, HighOut); delay(1000); digitalWrite(LED_BUILTIN, LOW); delay(5000); } Quote Link to comment Share on other sites More sharing options...
ajg193 Posted March 19, 2019 Share Posted March 19, 2019 That code isn't very nice to look at. You could do the same thing with about 10 lines. Also, why HighOut instead of HIGH? Quote Link to comment Share on other sites More sharing options...
sentra Posted March 19, 2019 Share Posted March 19, 2019 Hey rusty your highout function is not returning anything, what were you aiming for? Quote Link to comment Share on other sites More sharing options...
Ned Posted March 20, 2019 Share Posted March 20, 2019 Yeah, that shit no work. What trying to do? Quote Link to comment Share on other sites More sharing options...
sentra Posted March 20, 2019 Share Posted March 20, 2019 be gentle with rusty hes a good boy 1 1 Quote Link to comment Share on other sites More sharing options...
Roman Posted March 20, 2019 Share Posted March 20, 2019 One thing which has been a ball buster until i realised why. Any program that scans the com ports looking for a device fucks with any others doing the same. If i have arduino ide open i cant connect on pclink. And vice versa. Took a while to figure that out... 1 Quote Link to comment Share on other sites More sharing options...
Roman Posted March 20, 2019 Share Posted March 20, 2019 Something else ive figured out recently while trying to make a trip meter. I got caught up thinking that to convert hours into a smaller number you need to go minutes then seconds... but this is a problem because you need to divide by 60 so you get a remainder on your number that gets wiped so its less accurate when you're dicing up 50kph into 10hz snippets (or whatever) Instead of that. Figured out i could just use interrupts at 1000th of an hour (or whatever) so the value you end up with is only ever divided or multiplied by 10. So for example 50kph you might set your interrupt frequency so you get a number back saying you travelled 50cm in that time. Makes the maths super easy! Kinda like a metric version of time keeping haha. Quote Link to comment Share on other sites More sharing options...
h4nd Posted March 20, 2019 Share Posted March 20, 2019 13 hours ago, Ghostchips said: Beats me why this doesn't flash at 20ms intervals Hide contents Perhaps because of the 43.8 seconds of delay statements in the main loop? Quote Link to comment Share on other sites More sharing options...
h4nd Posted March 20, 2019 Share Posted March 20, 2019 I suggest you start with the example code called blink, and read the pages associated with each keyword/ library routine, i.e. "delay" and "digitalWrite". The answers are there. 2 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.