# OpenHaldex - HPA touchmotion done cheap



## A_Banging_Donk (Apr 22, 2017)

v2.0 has been pushed to GitHub [smiley=cheers.gif]

https://github.com/ABangingDonk/OpenHaldex

Have left the documentation below intact, in case it helps anyone.

*Intro:*
OpenHaldex uses a couple of cheap Arduino microcontrollers to modify the CAN data sent to gen 1 Haldex 4WD controllers, giving the user full control of the rear clutch pack engagement.

*Disclaimer:*
I am not responsible for *any* damages caused by or resulting from using this system. All software is released under the MIT licence. Track use only.

*OpenHaldex in action:*






*What to expect:*
Take this example.. you're on a damp greasy track and you're about to hit the apex of a hairpin about half way up 2nd gear. You mash the accelerator.

Stock behaviour:
Fronts light up and you start to understeer. The Haldex kicks in a quarter of a second later, upsetting the balance of the car which is closer to the outside of the track than you'd like it to be.

50/50 mode:
Slight understeer but you can tell the back is fully connected. All four wheels scrabble without shifting the weight of the car wildly. You make a fast, controlled exit wearing a fat grin :mrgreen:

*Contents:*

 Shopping list[/*]
 Wiring & setup[/*]
 Getting up and running[/*]
 Known issues & todo[/*]


----------



## A_Banging_Donk (Apr 22, 2017)

*Shopping list:*
1x Arduino DUE R3 Board SAM3X8E £12.49
1x Wire Kit 22-23 AWG Single Solid Core £4.22
1x Arduino Uno R3 £4.95
1x MCP2515 Can Bus Shield £6.09
1x HC-05 Bluetooth Serial Module £5.95
1x USB to TTL Serial Converter Adapter £2.69
*Subtotal £36.39*

Either:
2x SN65HVD230 CAN Bus Transceiver £3.52
OR
1x CAN shield for Arduino Due $36.95

Either:
2x VAG 8 pin connector plug set £21.98 (if you're being fancy)
OR
1x Dupont Wire Jumper Pin Header Connector £7.19 (less fancy but has come in handy so many times over the years)

eBay links will die (some are dead already), substitute with similar items.

*Tools required:*

 Soldering iron, solder (you want the multi-core leaded stuff), helping hand[/*]
 Needle nose pliers[/*]
 Stanley knife[/*]
 Socket set (13mm to remove wiper blade arms)[/*]
 Multimeter (probably not required but a handy thing to have around)[/*]


----------



## A_Banging_Donk (Apr 22, 2017)

*Wiring & setup:*
This is a long process and it gets a bit fiddly... stick with it and you'll be rewarded!

You'll see I'm a bit of a hack - take no notice, you can be patient and neat or just bodge the whole thing together like I did, the choice is yours.

*Disconnect your battery before doing any wiring work*

Interceptor unit prep:

I need to give credit to this site. It was bloody useful. You could buy a shield from these guys which includes CAN transceivers and means you can skip all of this prep work.

The Arduino Due is an awesome bit of kit but it requires CAN transceivers to make use of its two CAN ports. I wired mine together like this

















The Due has only one regulated 3v3 output so I chose to wire the two transceivers together and bodge up a connector made out of a 4x1 and a 6x1. You could make life easier by using a 6x2 and connecting them both to the Due's 3v3 output.

For the other pins, CTX & CRX connect to the Due and CANH & CANL form one side of the CAN bridge we are building, we'll get back to this later. CTX & CRX connect to these pins of the Due
















You don't want to mix these up, one transceiver is CAN0 and the other is CAN1.

You want to have the CANH & CANL from one transceiver to have a male connector and the other one female, it will become clear why when we come to install.









You should end up with something that looks like this









You also need to to program the Due using the sketch from GitHub. The 'Getting up and running' post has more details on this.

Interceptor unit install:

Take out the spare wheel and toolkit to expose the wiring going down to the Haldex controller









Gently cut the fabric sheath and unravel a 10cm section or so. The wires we're interested in here are:

CAN high: solid black (narrow gauge)
CAN low: solid white (narrow gauge)
12v switched: black/grey
Ground: solid brown

Expect the CAN lines to be a (loosely) twisted pair

Pick out either the 12v or ground wire and gently slice off the insulation so that you have 1-1.5cm of copper wire exposed. Push the two sides towards each other to splay out the strands slightly.









This is where the solid core wire you bought really pays off.. remove about 3cm of insulation from your solid core wire and thread it through the opening you just made in the wire from the loom.








It would be nice to solder this up properly but I don't have the luxury of 240v mains where I'm working so the tape and threading will have to do.

Tape up your first splice and then repeat for the other (12v or ground). Once you have your two solid core wires spliced in, use them to create a male 2x1 connector. This is the Due's power supply (Vin/GND).









Now cut the CAN lines (solid black & solid white). If you did the prep work like I did above, give them 2x1 connectors so that CAN0 connects to the Haldex (the side towards the front of the car) and CAN1 connects to the rest of the bus (towards the back of the car).









If you bought the shield from copperhilltech.com then just put the Haldex side into CAN1 and the car side into CAN2.

And we're done  on to the master unit...

Master unit prep:

A little more simple than the interceptor, we just need to make two 2x1 connections to the Bluetooth module; one for power and the other for data. The data lines should be crossed i.e. TX on the Bluetooth module should connect to RX on the Uno's CAN shield and vice versa.

The Bluetooth module gets power from the Uno's 5v output (of course, you don't cross this one!)

The CAN shield has a terminating 120Ω resistor which we need to disable. To do this, we need to use a knife to cut the trace between the two pads next to the power switch.









We need to do some coding for the Bluetooth module before we can use it. This page says it all really... We need to set the name to OpenHaldex and the baudrate to 115200.

One day there will be some code in the master unit to configure the BT module automatically.. but for now use the USB-TTL converter, TeraTerm and the guide linked.

You also need to to program the Uno using the sketch from GitHub. The 'Getting up and running' post has more details on this.

Master unit install:

*Ignore the extra brown/blue mains leads in these pictures, they are courtesy of wideband conversion (yes another shocking bodge)*

We need to get to the white connection box under the scuttle panel









Open up the box by pushing back the clips and working the lid loose. I loathe doing this, it's a pain but it gets a bit easier after the first 10 times....

Once you've got that open, look for the white connector. We need to splice into pins 2 and 3. The pin numbering is moulded into the plastic connector, you can confirm using the stupidly subtle difference in wire colour (CAN high orange/black, CAN low orange/brown)








Splice into these wires using the same method we used to splice the power for the interceptor (strip & weave) and then connect them to the CAN shield.

All we need to do now is find a switched 12v source for the master... I was too lazy at the time to find one and used something I already knew would work. Check the red & green wire coming out of the brown 6-pin connector (pin 4).. It should be switched... but check! Ground should be nearby too, if not, just ground it using the chassis.

Check that the unit is getting power when you turn the key and if it's all good, there is space inside the white box for it to live in.









Now you can close up the box, put everything back together and grab yourself a hard-earned beer.


----------



## A_Banging_Donk (Apr 22, 2017)

*Getting up and running:*

All code is available at https://github.com/ABangingDonk/OpenHaldex.

The latest Android app build can be found in the 'App' folder.

Yes, Android. Sorry iPhone users, I don't have one and I'm not prepared to spend time and money porting, debugging and gaining App Store approval for this. All the source code is there, if anyone wants to do this then be my guest!

*Required Software:*
You'll need the Arduino IDE available at https://www.arduino.cc/en/Main/Software. Download openhaldex_interceptor and openhaldex_master sketches from the GitHub repository and open them up in the IDE.

Once you've installed the IDE, follow the steps here to teach your IDE how to compile for the Due.

You'll need the following Arduino libraries installed:

 @collin80 due_can[/*]
 @collin80 can_common[/*]
 @Seeed-Studio CAN_BUS_Shield[/*]

See Seeed's wiki for library installation instructions.


----------



## A_Banging_Donk (Apr 22, 2017)

*Known issues & todo:*
Work in progress


----------



## StuartDB (Feb 10, 2018)

wow this will be exciting - I will keep an eye on this - I am loving the disclaimer


----------



## Delta4 (Jun 19, 2015)

This is interesting


----------



## Wiggles01 (Jun 27, 2014)

Can't wait to see the results, well done for giving it a go

Wig


----------



## Madmax199 (Jun 14, 2015)




----------



## HOGG (Mar 30, 2018)

I'm on this

Sent from my SM-G930F using Tapatalk


----------



## Horlixx (Aug 13, 2017)

Wow if you can get this up and running it would be some impressive shit, following with interest.

What does Gen 1 Haldex mean then - when was the switch to Gen 2?


----------



## David C (Apr 15, 2013)

Horlixx said:


> when was the switch to Gen 2?


Mk2 TT / Mk5 Golf.


----------



## Ganja47 (Oct 18, 2018)

oooooh, this looks like right up my alley. thanks for the hard work, looking forward to further instructions. ran the budget past the missus already :lol:

Regards,
Ganja47


----------



## Horlixx (Aug 13, 2017)

David C said:


> Horlixx said:
> 
> 
> > when was the switch to Gen 2?
> ...


Thx David, thats exactly what i wanted to hear


----------



## mk2zetec (Dec 27, 2015)

Looks amazing. Will watch developments here with interest!


----------



## BrianB (Apr 15, 2016)

Been looking at the HPA Touchmotion but at £700+ it's hard to justify, so really interested in how this turns out as a possible alternative.


----------



## bekkedal (Nov 23, 2018)

Agree with the people above, will be watching this topic with great interest!


----------



## A_Banging_Donk (Apr 22, 2017)

Hi guys, thank you all for the positive comments.

More updates to come over the weekend - I'm hoping to get the wiring and setup written and fix the communication issue I was seeing.. but I also have a FMIC to install along with discs & pads.. busy busy


----------



## sferg410 (Oct 23, 2015)

A_Banging_Donk said:


> Hi guys, thank you all for the positive comments.
> 
> More updates to come over the weekend - I'm hoping to get the wiring and setup written and fix the communication issue I was seeing.. but I also have a FMIC to install along with discs & pads.. busy busy


Someone near should offer to go install his FMIC and brakes so he can get to work on his DIY touchmotion!!


----------



## StuartDB (Feb 10, 2018)

Hi is this going to update the controller and persist after disconnecting the device, or will the app have to be running?


----------



## A_Banging_Donk (Apr 22, 2017)

StuartDB said:


> Hi is this going to update the controller and persist after disconnecting the device, or will the app have to be running?


Hi Stuart, it will continue working without the app based on the last configuration it received.

The app periodically sends updated information about the requested mode, if it stops sending, the rest of the system will stay in this mode until either the app re-connects and changes it or the engine is switched off.

The whole thing powers up in stock mode so if you cycle the ignition on->off->on, you'll be back to standard.

This is all up and running now and my god what a difference... I'm constructing a post with some pretty pictures and info now


----------



## Pukmeister (Dec 27, 2017)

Well done sir, you are a bit of a genius!

My Raspberry Pi3 only plays retro games, I wish I had the brains to build a working arduino device.

Look forward to seeing the end result of your hard work.


----------



## A_Banging_Donk (Apr 22, 2017)

Updated 

If anything is unclear, let me know and I'll clarify/correct.


----------



## HOGG (Mar 30, 2018)

The hardware part looks easy. I can wire in a motherboard. It's the other parts I don't understand

Sent from my SM-G930F using Tapatalk


----------



## A_Banging_Donk (Apr 22, 2017)

HOGG said:


> The hardware part looks easy. I can wire in a motherboard. It's the other parts I don't understand


Sorry bud, to be completely honest, I started to run out of steam halfway through writing this.

Let me know which parts in particular and I'll make an effort to give more explanation


----------



## Ganja47 (Oct 18, 2018)

thank you so much for your hard work on this. all parts ordered 

PS: part cost £58.05 in total for me


----------



## bekkedal (Nov 23, 2018)

Same here, all parts ordered  
Thank you very much!


----------



## Ganja47 (Oct 18, 2018)

one quick question, where does the arduino uno come into play?

edit: ignore me, should have looked at it properly before asking stupid questions


----------



## Horlixx (Aug 13, 2017)

Just wow...

Question regarding the Android device/app

My phone is used to connect to my headunit (running Android Auto, playing music, google maps etc), so i wouldnt be able to run your app at the same time would i?

So could i go and ebay a cheap old phone (say a Galaxy S3 or S4 kind of era), and just leave it in the car solely for operating this? Once the app and code is installed, and its connected via bluetooth, theres no requirement for internet or anything - its literally just a display screen, correct?


----------



## A_Banging_Donk (Apr 22, 2017)

Horlixx said:


> Just wow...
> 
> Question regarding the Android device/app
> 
> ...


Android auto integration is something I'm considering for the future, it bumps the minimum supported Android version up to 6 I think which is why I didn't jump on it straight away. Also, I don't have a head unit to test with so I didn't go any further with it.

Any Android device running kit kat or later should work, as long as it has Bluetooth - no need for internet.


----------



## A_Banging_Donk (Apr 22, 2017)

Ganja47 said:


> thank you so much for your hard work on this. all parts ordered
> 
> PS: part cost £58.05 in total for me


You went for the due can shield? It looks good, let me know if you have issues


----------



## A_Banging_Donk (Apr 22, 2017)

bekkedal said:


> Same here, all parts ordered
> Thank you very much!


You're welcome


----------



## Ganja47 (Oct 18, 2018)

A_Banging_Donk said:



> Ganja47 said:
> 
> 
> > thank you so much for your hard work on this. all parts ordered
> ...


I like soldering and electronics so went for the 2 transceivers rather than the shield. prices were
SAM3X8E 17.75 (uk seller, spent a few quid more than china)
wire kit 2.46
uno R3 4.99
mcp2515 6.09
hc-05 3.99
ttl adapter 3.10
2xcan transceiver 3.52
dupont jumper kit 7.59

should all be here by thursday apart from the can transceivers, looks like it'll be next week for them. they are listed as uk seller but looks like they're shipped from china or hong kong

all in all £49.49 don't know how I messed the sum up earlier :?:


----------



## Ganja47 (Oct 18, 2018)

was actually thinking about getting another arduino due for more processing power and one of these
https://www.ebay.co.uk/itm/2-4-Seri...h=item3aab4836c3:g:lQoAAOSwxp9W6hoD:rk:1:pf:0

use them as master and fit it inside the cabin. this way there's no bluetooth connection needed, just control it all with the touchscreen. and while we're at it some form of OpenLiquid display could run on it too :mrgreen:


----------



## A_Banging_Donk (Apr 22, 2017)

Ganja47 said:


> was actually thinking about getting another arduino due for more processing power and one of these
> https://www.ebay.co.uk/itm/2-4-Seri...h=item3aab4836c3:g:lQoAAOSwxp9W6hoD:rk:1:pf:0
> 
> use them as master and fit it inside the cabin. this way there's no bluetooth connection needed, just control it all with the touchscreen. and while we're at it some form of OpenLiquid display could run on it too :mrgreen:


Yeah, that would be awesome. Where would you mount the screen? The good thing is that the master has much less to do whereas the interceptor is a bit too busy already...


----------



## Ganja47 (Oct 18, 2018)

not sure yet. for starters a casing and just keep it in a mobile phone holder. I always liked how the liquid tt display looked in the air vent. after everything works perfect I might try and replicate that.

another way would be to go down the same route as this guy
https://github.com/ibanezgomez/FISBlocks
but that's a bit far fetched in the moment

my ABS and ESP warning light came on this morning [smiley=bigcry.gif] on my way to the car with a cloned delphi interface as we speak. hopefully just a sensor. wrong time for this to play up :evil:

PS: rear left sensor, another thing on the agenda


----------



## Amulet banana (Nov 12, 2018)

Donk you are my hero, this will hopefully be getting made over Christmas if the parts turn up in time, what's the difference between this and the screw method apart from the install obviously? I'm stil new to all this haldex trickery :lol:


----------



## A_Banging_Donk (Apr 22, 2017)

FISblocks is definitely on the agenda, it should be quite easy to implement.. was a big reason for offloading admin to the master unit.

The insert can't be turned off or removed too easily which is why I started this... You end up with much more control which the insert can't give you


----------



## Ganja47 (Oct 18, 2018)

A_Banging_Donk said:


> FISblocks is definitely on the agenda, it should be quite easy to implement.. was a big reason for offloading admin to the master unit.
> 
> The insert can't be turned off or removed too easily which is why I started this... You end up with much more control which the insert can't give you


that's awesome, looking forward to FISblocks. my wheel speed sensor is on the way and i've secured the wire so it's not a problem just now. abs and esp warning light are off so I'm ready to go but...

the parts are trickling in just now. only received the TTL usb adapter and the UNO so far. hoping for a few more goodies tomorrow. I'm more than happy to log/debug and test as much as you like as soon as everything is here. also ordered one of those fancy touchscreen IPS screens

I get paid for sitting around a lot nowadays so have ample time on my hands and take every excuse for taking my TT for a spin. it's only been 3 months that she's with me, loving this car


----------



## Ganja47 (Oct 18, 2018)

Amulet banana said:


> Donk you are my hero, this will hopefully be getting made over Christmas if the parts turn up in time, what's the difference between this and the screw method apart from the install obviously? I'm stil new to all this haldex trickery :lol:


I guess you are referring to the powertrack insert? from what I understood stock haldex will slowly transfer power to rear wheels in steps, something like 90/10 80/20 70/30 and so on whereas the powertrack insert will engage a 50/50 lock as soon as the ECU would ask for 90/10 which is certainly a nice concept but doesn't change the fact the car is spending most of it's time in 100/0 so the insert won't do anything until slip occurs

OpenHaldex is more a crude (so far) HPA touchmotion controller to force the haldex into a defined lock state no matter if there is slip or not

someone correct me if I'm wrong, I'm still new to all this too


----------



## A_Banging_Donk (Apr 22, 2017)

In stock form, you get anywhere from 0-100% engagement of the clutch pack but it's quite slow.

Several things affect this:
Throttle position
Engine RPM
Overall speed
Front wheel slip
Brake pedal

Probably some more I don't know about yet

The 50/50 mode currently forces about 85% when your stationary. As soon as you start moving, this will move to 100%

Above ~50mph, this starts to trail off. I need to make a couple of changes to the interceptor code to change these two things, not got round to it yet.

Brakes will disengage the rears - this is something I'd make optional, it should be fairly easy to prevent this from happening.

EDIT: 50/50 mode has been fixed - will give 100% lock at all speeds, including stationary. Brakes causing disengagement not so simple, there is a red & brown wire in the boot wiring harness which needs to be fiddled with in order to achieve this. I have some ideas but I've bigger fish to fry right now.


----------



## Ganja47 (Oct 18, 2018)

that makes sense.

do you happen to have any documentation regarding haldex CAN communication? would be nice to know a little bit more. what are the motor1 / motor3 /motor6 variables? any pointer would be helpful.

I received a few more parts today but still missing then UNO CAN shield and the 2 transceivers for the DUE and also the bluetooth module so can't really do anything over the weekend

your work on this is very much appreciated


----------



## A_Banging_Donk (Apr 22, 2017)

Not much documentation out there I'm afraid.. I'll dig out what I've been using (FR and a rather vague web page) a bit later

Spend this weekend on your ABS faults!


----------



## Ganja47 (Oct 18, 2018)

A_Banging_Donk said:


> Spend this weekend on your ABS faults!


new sensor should be here on Monday. old one seems to have a funky wire right where it goes into the sensor, fault codes are intermittent. I fixed the wire into a position where it works and doesn't throw any error codes for the moment. here's hope it'll come out fine and I don't have to take caliper and disc off, I've not removed screw and checked yet


----------



## Ganja47 (Oct 18, 2018)

I've attached a table from the internal Bosch EDC15+ manual. unfortunately it's in german but not a big problem since I am a native german speaker. let me know which ones you're interested in and I can translate the relevant info from the doc


----------



## A_Banging_Donk (Apr 22, 2017)

Some high level information about the Haldex system:
https://auditttuning.org/2010/12/07/haldex-service-training-self-study-program/

CAN protocol documentation can be found in the PDFs here.. page 1631 onwards
FR (German original)
FR (English translation #1)
FR (English translation #2)

Ah EDC15 looks to be compatible - that's good news


----------



## Ganja47 (Oct 18, 2018)

some good info in this document too!


----------



## Ganja47 (Oct 18, 2018)

A_Banging_Donk said:


> CAN protocol documentation can be found in the PDFs here.. page 1631 onwards


wow, thanks, a lot more details than the EDC15 docs. thanks for that


----------



## Ganja47 (Oct 18, 2018)

sorry for keep pestering you with questions, what's your plan regarding fisblocks. KWP or CAN or were you thinking about supporting both? from what I found so far switchover was around 2001. mine is a 51 plate. not checked which one I have yet


----------



## A_Banging_Donk (Apr 22, 2017)

The later models included the infotainment bus but the drivetrain bus is the same.

Will be KWP, all it requires is a logic level shifter and the FISblocks code and we're good to go


----------



## AshyS3 (Dec 12, 2018)

New member longtime lurker

Been watching this thread with interest and decided to bite the bullet and order all the parts to give it a go

Looks an amazing bit of kit.

Has anyone else got this up and running yet?


----------



## Ganja47 (Oct 18, 2018)

think most of us are in the same boat where the CAN transceivers and shield are shipped from hongkong or china even so they were listed as uk seller on the bay
mine should be here tomorrow accorfing to seller information


----------



## AshyS3 (Dec 12, 2018)

Well the first piece of my jigsaw turned up yesterday

little circuit board thingy - I have no actual idea what i'm doing here :lol: :lol: :lol:


----------



## Ganja47 (Oct 18, 2018)

AshyS3 said:


> Well the first piece of my jigsaw turned up yesterday
> 
> little circuit board thingy - I have no actual idea what i'm doing here :lol: :lol: :lol:


:lol:
last 2 pieces arrived today (CAN shield and transceivers)
got a really busy day tomorrow, left Sunday free for playing with the Haldex


----------



## Ganja47 (Oct 18, 2018)

found some spare time today since the weather up here is horribe :roll:

unfortunately I must have oredered the wrong dupont kit but just kept going anyways









here is how I prepared the CAN transceivers for the interceptor








soldered the power pins the other way around and bent the long pins over to connect to the other module








trimmed the wrong connectors so they would fit








hot glued the transceiver module to the Arduino Due and wired it all up. this is what I've ended up with









Interceptor programmed and ready to go into the car

I'll leave the master and install for tomorrow


----------



## A_Banging_Donk (Apr 22, 2017)

Looking good Ganja!

Even if they're not ideal, those connectors look like they'll do the job. Looking forward to seeing how you get on [smiley=thumbsup.gif]


----------



## Ganja47 (Oct 18, 2018)

built the master today, everything pretty straight forward. I didn't mind programming the bluetooth module manually at all. as far as I'm concerned it is much easier to touch the key pin with a needle during startup, wouldn't fancy soldering a wire to it though :lol:

I went a different route with connecting the bluetooth module to the shield. first I removed the two outer pins from the module (state and enable, no need for these). next I bent the power pins over by 180 degrees (be careful when doing this so they don't snap) and then rx and tx pins 90 degrees.
soldered 2 short wires that had connectors on them already to the 5V and GND holes of the shield UART connector and hooked them up to the BT module VCC and GND pins








flipped the whole thing over and soldered TX and RX pins to opposite UART holes in the shield. this soldered connection is enough to hold it in place nicely, was gonna hot glue it but really no need for it








Uno is programmed with master code and I powered the complete master up and was able to connect to it fine with the OpenHaldex app on an android oreo phone so looks like I'm ready to go.

because I was able to use the wrong dupont connectors on the interceptor transceivers I had quite a few standard dupont looms and wires that came with the arduinos and the TTL adapter. I used these for all the CAN and power wires on the inteceptor and had enough left to be able to use 4 of them for the wires splicing into the 2 sides of the CAN bus so really wouldn't have needed the wire kit but it'll come in handy one day for sure

here's what I ended up with in the end all ready to go into the car. ignore the ancient soldering station :lol: , it's been with me for ages and has always served me well. can not recommend these silicon work mats enough. loads of magnetic and non magnetic compartments for screws and bits plus it's heat proof for SMD hot air work









that's me done for today, gonna get a pint out and enjoy Sunday

I'm in luck for tomorrow, eight hours of paid work with only one appointment to do that will last for one hour so there's more than enough time to get it all hooked up and take her for an extensive test spin

I really can't thank you enough for doing this work Donk!!
love my TT but really don't like the unpredictiveness (if that's a word) of the 4WD. sometimes it can be really fun and scary at same time if you know what I mean but I'd really prefer a more predictive behaviour of the haldex unit. this is also just the start of it since the possibilities are nearly endless. Dynamic profiles like the HPA Touchmotion offers should be implementable without too much hassle but will need extensive testing and logging so here is where the open source concept can help massively. fisblocks and touchscreen controls with some fancy graphics are definitely high in my book as well. I've been reading up on CAN/Haldex/ECU stuff lately and try brushing up my coding skills just now as well. haven't been active in this kinda stuff for a good decade if not longer so I'm really rusty but should get up to speed fairly quick so hoping to be able to contribute a bit to this.

can't wait to see this in action tomorrow!


----------



## Ganja47 (Oct 18, 2018)

sooooo... had mixed results today

installed the interceptor without any problems. I pulled the plastic sleeve back right at the corner and taped it to the loom to give me some space









spliced and wired everything up as I should and wrapped it in some plastic so it can live in the corner










after that I had to do a 10 mile drive to see my only appointment for the day. ESP warning was on, no ABS warning. guess that's to do with no master installed yet? after I came back I had a go at the master install and that's where I ran into trouble.
after taking the scuttle panel off I realised there's no white box [smiley=bigcry.gif] instead I found a black plastic cover secured to two bodywork studs by 10mm nuts attached to crappy washers. the loom was running through a rubber grommet kinda thing but couldn't move the wires up and down within it, seemed solid attached. mine is a 51 plate quattro coupe with a BAM engine









managed to get the two nuts off but realised there is no way I could wriggle this cover out underneath the wiper assembly. not enough room and wires far too short. took the whole wiper assembly off to get proper access. only 3 10mm nuts









and here it is all unplugged and flipped over









CAN wires are the same as yours, white connector pin 2 and 3, same colour coding
I checked the wire you suggested for switched 12V but was permanent on mine. started looking around for switched 12V and found this combination









then I realised there is no metal pin in the brown connector where I was gonna grab ground so had a further look with the multimeter and the marked pin on the black connector was short to ground so that's what I used. double checked with multimeter. 0V ignition off. 12V ignition on so figured I should be all good
no way I would be able to fit the master in there without a lot of work
so I routed the wires outside, closed the cover loosely to not damage them and put the master into a ziplock bag and placed it behind the rubbery cover










checked it would power up with ignition on and it did. closed everything up started engine, all good until I tried to connect to master with my phone. couldn't see OpenHaldex device, no connection

stopped engine, opened bonnet and peeked through scuttle panel. looked fine to me. switched ignition on and could see all the lights in there no bother. connected via phone app and all fine. 00% shown in the app and here it is where it went sour. started engine and connection dropped. had another peek and no lights on the master

only 2 possibilities here the way I see it. either the chosen switched 12V goes live with ignition on but goes ground when engine starts or the chosen ground is low during ignition off and on but goes 12V when engine starts running.

anyways light was fading and I do this on the kerb so gave it up for today. have to take everything apart again tomorrow but as it is with most things if you've done it before it's easy. gonna find proper power supply for the master first thing tomorrow (day off) and hope for the best 

edit: typos :roll:


----------



## A_Banging_Donk (Apr 22, 2017)

Wow well done, the plenum on yours looks a pig to work with... Sorry, I'd have a better look at the wiring diagrams for a switched 12v but I'm away until January.

Going strong though! Thank you for documenting all of this, it sounds like we might have a bit of work to sort out the ESP - did you break the connection for the terminating resistor on the master? Should be open circuit when nothing's connected


----------



## Ganja47 (Oct 18, 2018)

it is a nightmare to work on, agreed. was in bed with the cold all day yesterday but wanted to take the TT to the shops for a second. car started fine but split second I tapped on the brakes engine switched off with 'check brake fluid and lines' error. I've got a few busy days ahead off me and can't be bothered to drive the chevy aveo of my wife so everything came back out this morning. all good now. I'll have another crack at it over the weekend

ps: the resistor was cut ok, measured 0 afterwards. I've scraped one line next to it a bit but measures out all fine. you can actually see the cut and the scrape if you zoom in on one of the master build images


----------



## A_Banging_Donk (Apr 22, 2017)

Ganja47 said:


> ps: the resistor was cut ok, measured 0 afterwards. I've scraped one line next to it a bit but measures out all fine. you can actually see the cut and the scrape if you zoom in on one of the master build images


Wait, do you mean measured infinity or was it actually 0?

This terminating resistor left me scratching my head for a while - causes the CAN to die after a few seconds, will be worse if the two lines are shorted!


----------



## Ganja47 (Oct 18, 2018)

pretty sure it was open (infinity) but I'll double check before I try again. my guess it was to do with the 'ground' going high 12V when I started engine. engine was running fine until I hit the brake pedal.
everything was fine and back to normal after removing the master. interceptor is still in there


----------



## A_Banging_Donk (Apr 22, 2017)

Yep fair enough, I've grounded the master to chassis - if you run out of options


----------



## Ganja47 (Oct 18, 2018)

I'll probably end up doing that.
anyone else got to play with this yet? unfortunately I was a lot busier during the festive season than I'd hoped for. I'm off all next week so the agenda is

- fit rear left wheel speed sensor
- replace thermostat (seems stuck open just now, barely reach 60C during cruising and overrun)

got all the parts here, OE from Barnetts VW in St Andrews, got the dipstick tube and 2 bottles of G12 for good measure. as soon as that's sorted the master goes back in [smiley=dude.gif]


----------



## A_Banging_Donk (Apr 22, 2017)

Good to hear from you again Ganja, I was thinking.. the master being absent shouldn't cause any issues, as long as the interceptor is working properly, everything should behave as stock.

Can you just confirm that you've got the Haldex plugged into port 0 (CANRX/CANTX) and the rest of the car into port 1 (DAC0/pin 53) I can't tell from your pics but it looks like your green/yellow CAN0 is connected to the car side.

I'm about a third of the way through implementing custom modes in the app, I've got big plans for this project!


----------



## Ganja47 (Oct 18, 2018)

A_Banging_Donk said:


> Good to hear from you again Ganja, I was thinking.. the master being absent shouldn't cause any issues, as long as the interceptor is working properly, everything should behave as stock.
> 
> Can you just confirm that you've got the Haldex plugged into port 0 (CANRX/CANTX) and the rest of the car into port 1 (DAC0/pin 53) I can't tell from your pics but it looks like your green/yellow CAN0 is connected to the car side.


good point, I will check over it all again when I get some time, hopefully over the weekend



A_Banging_Donk said:


> I'm about a third of the way through implementing custom modes in the app, I've got big plans for this project!


that's awesome, I'm really looking forward to get it all going. unfortunately I can only do work on the kerb and it gets dark very early. the business of my Wife kept me massively busy over the last 2 weeks but we're both off all next week. She'll demand some time but I'm hoping to put one day aside for the repairs and one day for OpenHaldex and test driving


----------



## Ganja47 (Oct 18, 2018)

just to clarify. tx of CAN transceiver goes to tx of Due or or are they crossed?

you can see all wiring here

edit: added the picture


----------



## A_Banging_Donk (Apr 22, 2017)

That's right, tx->tx; rx->rx. Nothing obviously wrong in that pic, I'm not sure what the ESP is getting upset about.. I'd need to spend time tinkering to find out.


----------



## Ganja47 (Oct 18, 2018)

not to worry in the moment. let me sort out my mechanical issues and install the master first and I can start debugging from that point on if still needed. I will double check all crimped connections to be on the safe side there too


----------



## AshyS3 (Dec 12, 2018)

All my parts have finally arrived, seems like some got stuck in the Xmas post !!

will get building up this week and see how it goes, really looking forward to trying this out


----------



## DjEzko (May 5, 2014)

Hi everybody, i hope this post will help with problem solving with clone due

Big thanks for A_Banging_Donk for making cheap haldex controller

i did order almost all my parts from china and it takes very long to arrive or get lost in mail but enough of that.

Problems what i did encounter:
in Master (Uno) unit i needed to change to 8Mhz because my canshield is using 8MHz clock 
while (CAN_OK != CAN.begin(CAN_500KBPS))
while (CAN_OK != CAN.begin(CAN_500KBPS,MCP_8MHz))

problem solving:
The real problems started with interceptor aka arduino DUE.
in first it did not work, my esp lights turn on and i checked all cables and connection.
i did get it working in my desk and looked if all is working correctly.
I placed my own print command to code to see if its working and some reason it did work and and i was lost, how sometimes it work but not other times.
Then i noticed wierd things when plugin in power.
i did but that blinking led example code inside interceptor code and noticed my due wont start run code without pressing reset or opening serial monitor that explained why it was working when i was monitorin it.
So there is cold boot bug in arduino due this is reason why it did take me so long to get everything working correctly, so be aware cheap arduino due clones.
If you have cheap arduino due or clone you maybe have the same cold boot error.
I started googling if anyone noticed same cold boot problems that i was having.

How the fix cold boot bug.
First you can test if there is bug, you can but led blinking test inside the interceptor code, to test if will start running code or not.
with blinking+interceptor code you can power off due for 10 second and but power back and notice the L light wont start flash before you open serial monitor or press reset button. if you´re fast enough to connect power back the cold bug wont affect.
if your board have this bug it will never start running code before you press reset.
You need flash fixed firmware. or install 10k resistor to fet legs to pull reset down

this thread did get me the path of fixing the due
https://forum.arduino.cc/index.php?topic=256771.60

here is link to post where you can get the fixed firmware.
https://forum.arduino.cc/index.php?topi ... msg1373055

here is guide for flashing due board with using uno board
https://www.arduino.cc/en/Hacking/Upgrading16U2Due

i did notice this command will not work in windows 10 with arduino 1.8.8

```
arduino-1.5.2/hardware/tool> avrdude.exe -C avrdude.conf -c arduino -P /dev/ttyACM0 -b 19200 -p m16u2 -vvv -U flash:w:/home/USER/newFirmware/16u2.hex:i
```
avrdude is located

```
"C:\Program Files (x86)\Arduino\hardware\tools\avr\bin\avrdude.exe"
```
you need correct config location

```
"C:\Program Files (x86)\Arduino\hardware\tools\avr\etc\avrdude.conf"
```
and correct hex file location but in full path with file

```
C:\Users\Dj\Documents\Arduino\firmware\Arduino-DUE-usbserial-prod-firmware-2013-02-05_resetfix.hex
```
and last one you need check what is you com port number because that ttyADM0 did not work for me

```
/dev/ttyACM0 -> COM7
```
Full command:

```
"C:\Program Files (x86)\Arduino\hardware\tools\avr\bin\avrdude.exe" -C "C:\Program Files (x86)\Arduino\hardware\tools\avr\etc\avrdude.conf"-c arduino -P COM7 -b 19200 -p m16u2 -vvv -U flash:w:C:\Users\Dj\Documents\Arduino\firmware\Arduino-DUE-usbserial-prod-firmware-2013-02-05_resetfix.hex:i
```


----------



## Ganja47 (Oct 18, 2018)

think I had the same problem with mine, that makes sense. I've removed my interceptor because of this and was busy with life but hopefully refit mine soon


----------



## A_Banging_Donk (Apr 22, 2017)

Wow... thank you Ezko for troubleshooting this and posting the solution, does that mean that you're up and running now?


----------



## DjEzko (May 5, 2014)

Yep, everything works like a charm now.

One mod i did do when trying the find real reason is i modified "SN65HVD230" transfermodules so they never go sleep or use slope control.

Looked up datasheet from that chip and removed 10k resistor and grounded Rs (PIN8) strait to ground.
http://www.ti.com/lit/ds/symlink/sn65hvd230.pdf


----------



## HOGG (Mar 30, 2018)

I've just reread the whole thing. The manual labour part is easy in my mind.

It's the coding and downloading that baffles me

Sent from my SM-G930F using Tapatalk


----------



## Ganja47 (Oct 18, 2018)

HOGG said:


> I've just reread the whole thing. The manual labour part is easy in my mind.
> 
> It's the coding and downloading that baffles me
> 
> Sent from my SM-G930F using Tapatalk


the programming is actually the easy part. if you need any help I can talk you through that step by step no bother.

slowly getting a little bit time on my hands and will definitely pick this up again myself

spent last 5 months working crazy hours to pay for my dogs chemotherapy but his petplan for life starts kicking in again 2nd of june.

got rid of the Due cold start bug on the bench, my MOT next week and after that I'll hopefully get everything up and running soon.

how's the project going anyway, any new code? always thought peeps would be interested a lot more into this but guess people prefer buying something off the shelves to tinkering. I've always been the other way around


----------



## HOGG (Mar 30, 2018)

Could I buy two Audi plugs and make it plug and play?

Sent from my SM-G930F using Tapatalk


----------



## A_Banging_Donk (Apr 22, 2017)

No updates from my side, I did write a lot of work on this but haven't really had the time to finish off.. I will pick it up again at some point but need to prep for spa & ring trip in July

Yes you can HOGG, not too difficult or expensive.. the connectors are available on eBay


----------



## HOGG (Mar 30, 2018)

Could you please list what I need to buy for plug and play. Also I'd wanna do it the easy way with a can shield


----------



## Kryton (Apr 20, 2019)

Subscribing for future reference


----------



## A_Banging_Donk (Apr 22, 2017)

HOGG said:


> Could you please list what I need to buy for plug and play. Also I'd wanna do it the easy way with a can shield


It's in the second post:


> 2x VAG 8 pin connector plug set £21.98 (if you're being fancy)


You'll need to create your own harness something like this:

```
Tailgate -{ <- Due -{ <- Haldex
```
So that you can remove the Due and plug everything back together:

```
Tailgate -{ <- Haldex
```
I would connect the Due harness as attached, all wires apart from the CAN data lines will run straight through to the connector on the other side.


----------



## HOGG (Mar 30, 2018)

That's confused me more

Sent from my SM-G930F using Tapatalk


----------



## A_Banging_Donk (Apr 22, 2017)

:lol: I considered selling pre-made units for plug and play once but came to conclusion that it's more trouble than it's worth with liability, support, testing, quality control... I'd have to finish off writing the software too..

My final attempt...


----------



## HOGG (Mar 30, 2018)

That's better. How many pins does the actual connection use ATM

Sent from my SM-G930F using Tapatalk


----------



## barry_m2 (Jun 29, 2015)

HOGG said:


> That's better. How many pins does the actual connection use ATM
> 
> Sent from my SM-G930F using Tapatalk


This is for Gen1 remember, Gen2 and 4 are different.


----------



## A_Banging_Donk (Apr 22, 2017)

HOGG said:


> That's better. How many pins does the actual connection use ATM


8 wires in the loom we're splicing, we use 4 and the rest go straight through to the other side.



barry_m2 said:


> This is for Gen1 remember, Gen2 and 4 are different.


This is the MK1 forum, all of us have a gen1 (if at all)

For what it's worth, I get the feeling that this would be quite easy to adapt for any generation Haldex, they all use data from the car to make decisions. Once you've figured out which strings you need to pull, the rest is easy.


----------



## culver10 (Jun 26, 2019)

Thank you so much for the great work you have done on this! I have ordered the parts and I'm teaching myself Arduino with a starter learning kit. This stuff is all new to me, my only experience so far with Arduino was to get my 3D printer working with much help from YouTube university.

My first question so far is how do I get the APP on Github onto my phone? Am I on the right track that I install Android Studio on my PC and then clone your file from GIT? Then I connect my phone to PC and it will install app to my S9??

Thanks again for help!

Sincerely,

Phil


----------



## A_Banging_Donk (Apr 22, 2017)

I *think* I left a built APK file on there which you can just copy to the phone and install it.

I have been meaning to do a lot more with this but never found the time... One day!

Feel free to ask here if you need help


----------



## culver10 (Jun 26, 2019)

I received my Arduino components in the mail the other day and got some 8 pin VAG plugs from Lithuania. I had no issues with the hardware/wiring part of project. My issue is with the programming of boards and getting APP to my Samsung?? My only experience with Arduino is with a UNO starter project kit using sample programs. So my questions for a complete novice are;
1) How do I get your files/project from GitHub onto my Windows PC and then into the Arduino units??
2) How do I get the APP on my phone??
3) I downloaded Android Studio today. Is this the program I should use? Or is there an easier program to use??

Thanks again for sharing your awesome project!!!

Cheers!

Phil Kite


----------



## StuartDB (Feb 10, 2018)

You 'clone' the github project or download a zip. Not sure whether it is java or c I thought arduino were C and installed using the usb cable if I remember rightly.

The mobile apk can be installed onto your phone after putting it into developer mode to install untrusted supplier unless it's in the play store. But I would expect you want the source code of that too. You can download the apk via a url or local desktop ftp server or usb cable


----------



## A_Banging_Donk (Apr 22, 2017)

https://github.com/ABangingDonk/OpenHal ... master.zip

You don't need android studio unless you're going to be customising the application. Just copy the OpenHaldex.1.0.apk file onto your phone via USB and then open it on the phone. Like Stuart said, it will be a bit paranoid about this App which hasn't come from the play store. You may or may not need to enable developer mode on the phone for this method, I'm not sure.

To program the Arduinos you should be able to follow the steps in this post. Basically, download and install the IDE & required libraries and then use the Arduino IDE to program the Due with openhaldex_interceptor.ino and the Uno with openhaldex_master.ino


----------



## culver10 (Jun 26, 2019)

Thanks guys! I work my last 12 hour night at the airport in a few hours and then I'm off for my 5 days. I will try it out on days off and report back. I just got the AWD system working after we got a bunch of freezing rain and snow on top. Car was sliding around a bunch on the ice and now It works great in these conditions, it will be interesting to see difference with full manual control??

Thanks again!

Phil


----------



## A_Banging_Donk (Apr 22, 2017)

Long time no update - sorry, I'm a busy guy!

For those who would rather use physical buttons or a rotary switch, I've committed a version of the interceptor sketch to GitHub which will use pins to select modes. This means you don't need the master or app at all - just a few resistors and switch(es).

GitHub link

Wiring diagram:









Default pins:
Stock mode - D22 high
50/50 mode - D24 high
FWD mode - D26 high


----------



## Essex2Visuvesi (Oct 22, 2019)

Found a rather cheeky 3 position switch
https://www.ebay.co.uk/itm/Metal-Select ... 3948675931


----------



## culver10 (Jun 26, 2019)

So in 50:50 mode, does the Haldex clutch stay engaged during braking? That would be a handy feature during our current extremely icy conditions. In my old Nissan 4x4 truck, it stops way better on the ice with all 4 wheels connected together.

I was thinking that a good spot for a 3 way switch would be the lighter plug location. It would be out of the way and no extra holes anywhere.

Thanks for all of the great work you have done on this and shared with us!!

Phil


----------



## A_Banging_Donk (Apr 22, 2017)

Haldex does not stay engaged during braking, hand brake or foot brake. That's not to say that it's impossible...

One of the haldex connector pins is a signal to say that the brakes are on. If this connection is broken then it will fall back to a bit within one of the CAN bus messages.

I've got a line currently commented out in the interceptor code to clear this bit... So, in theory, you'd just have to cut a wire and uncomment a line of code. Not tried this myself but since there's interest, I will look into it.


----------



## culver10 (Jun 26, 2019)

How often do you change the setting? I read elsewhere that most folks using HPA controller set it to Sport and leave it there. The interceptor could stay in spare tire area with a 3 way switch.

Could you please clarify which mode corresponds with which switch number? I must be a little bit slow.

Thanks,

Phil


----------



## A_Banging_Donk (Apr 22, 2017)

The mode per switch position will depend on how you wire it up.

You could quite easily just leave it in 50/50 mode.. but it does make reversing and tight low speed turns a pain.. in the same way you often hear about with wheels skipping in parking lots when the system isn't working properly. I don't think this is very healthy.

Normal driving I leave it stock, 50/50 when I'm going ham.

This is something I'm trying to address in my update. I'm working on custom modes that will be a bit more intelligent - customisable haldex engagement depending on speed and throttle input.. my own take on what the touchmotion does I guess


----------



## culver10 (Jun 26, 2019)

As per your nice drawing above, which switch number is which mode?


----------



## A_Banging_Donk (Apr 22, 2017)

A_Banging_Donk said:


> Default pins:
> Stock mode - D22 high
> 50/50 mode - D24 high
> FWD mode - D26 high


----------



## culver10 (Jun 26, 2019)

I must be thick, but on the drawing it shows the switches going to D2, D3 and D4. What/where are pins D22, D24, D26?? I'm obviously not an Arduino expert.


----------



## A_Banging_Donk (Apr 22, 2017)

You're right, it is a little misleading.. it's an image I grabbed off image search quickly, ignore the pin numbers on the diagram


----------



## culver10 (Jun 26, 2019)

Ok, I got it now. It is not a scale drawing, just a simple sketch. Thanks for all the help!

Cheers,

Phil


----------



## Essex2Visuvesi (Oct 22, 2019)

Ordered the parts today, so will make a start on building this soon

I have been playing around with an OLED display and now trying to figure out how I would pull the realtime data to show how much power is being sent to the back wheels.

I'm guessing somewhere on the CAN bus there will be a signal that says "Mr Haldex... we want X% of the power sent to the rear wheels.... make it so" or "Mr CANBUS, if you are interested we are currently transferring X% of the power to the rear wheels. Kind regards Mr Haldex"
Alternatively maybe this can be pulled from the controller itself?

Once I have a variable signal that I can feed into the arduino, it'll just be a bit of simple codong to get this this to show on the OLED as an infographic.


----------



## A_Banging_Donk (Apr 22, 2017)

Essex2Visuvesi said:


> Ordered the parts today, so will make a start on building this soon
> 
> I have been playing around with an OLED display and now trying to figure out how I would pull the realtime data to show how much power is being sent to the back wheels.
> 
> ...


The haldex 'listens' to the messages that the ECU and ABS system are spitting out and makes up its own mind about clutch engagement. It also spits out its own messages which contain a bunch of status bits, a portion of which represent clutch engagement.

Look at the interceptor code, it does pretty much exactly what you need.

Thinking about this more, you could just run a modified version of the interceptor which will use a display and buttons instead of the app.


----------



## Essex2Visuvesi (Oct 22, 2019)

A little wet Sunday afternoon tinkerage.
Still a WIP but you get the idea.


----------



## culver10 (Jun 26, 2019)

That is awesome! Would you be willing to share your parts list and files?

Thanks,

Phil


----------



## Essex2Visuvesi (Oct 22, 2019)

Thanks,
Its just a WIP at the moment but yes, once I have the parts to build the 3 way switched controller I'll share the code/parts list. 
Final build will most likely incorporate an arduino nano to save space.
Also still trying to locate the signal that tells the haldex how much power is being transmitted to the rear wheels, as this is the whole point of the build.
Going to cannibalise a 52mm gauge and see if I can get the display inside for a cleaner install.


----------



## A_Banging_Donk (Apr 22, 2017)

Looks good!

Be aware though that you will probably want a 3 position switch instead of a pot, the interceptor works in discrete modes and only has half-baked & untested functionality for something like what you've shown there...
Mostly because I don't want to start burning the haldex clutch through slippage.

Nano would be cool, you'll need a CAN interface on there though.. like the Uno w/ CAN shield.

Also, as I'm sure you're aware, you'd be going between 100:0 F:R and 50:50 F:R


----------



## Essex2Visuvesi (Oct 22, 2019)

Thank for the feedback
The pot in the video is just a test to mimic the variable signal received to the haldex that tells it what percentage of power to send to the rear (I'm still trying to figure out where to pick this signal up from)
The 3 way switch has yet to arrive so this is more a "Demo mode", but the lower "mode" part of the display will be triggered by the 3 position switch and the figures under the wheels controlled by the feed from to the Haldex
Hope this make sense!

Think of this as an optional extra to BD's work on the appless Haldex switcher.

Still some work to do, but it's looking promising!


----------



## Essex2Visuvesi (Oct 22, 2019)

A_Banging_Donk said:


> Looks good!
> Nano would be cool, you'll need a CAN interface on there though.. like the Uno w/ CAN shield.


Something like this?
https://www.ebay.co.uk/itm/MCP2515-CAN- ... cxzkeZPPCQ


----------



## A_Banging_Donk (Apr 22, 2017)

Ah, understood. Yep, that module should do what you need, it's pretty easy to extract the haldex engagement from the CAN messages it sends.

Looking forward to seeing it all come together


----------



## Essex2Visuvesi (Oct 22, 2019)

> it's pretty easy to extract the haldex engagement from the CAN messages it sends.


Don't suppose you can help with this? This is the part I'm struggling with


----------



## A_Banging_Donk (Apr 22, 2017)

Take a look at https://github.com/ABangingDonk/OpenHal ... master.ino

Line 124 onwards


----------



## maattttyy_ (Jan 8, 2020)

Essex2Visuvesi said:


> > it's pretty easy to extract the haldex engagement from the CAN messages it sends.
> 
> 
> Don't suppose you can help with this? This is the part I'm struggling with


I think you may need to have a quick read up ref CANBUS data and it may become a bit clearer.

A good place to start - https://www.instructables.com/id/CAN-Bu ... h-Arduino/


----------



## Essex2Visuvesi (Oct 22, 2019)

Ah
I've only been looking in the interceptor code. Looks like all the white man magic I'm looking for is in the Master Code

Thanks guys
Waiting on parts now. But should be able to start tinkering at the weekend


----------



## A_Banging_Donk (Apr 22, 2017)

Oh.. shit sorry, that is what I wanted to point you at a few posts ago but typed the wrong thing


----------



## Essex2Visuvesi (Oct 22, 2019)

No worries, appreciate you allowing me to piggy back on your project 

Still waiting for parts so been playing with the display
the 1.3" OLED display has arrived and needed a bit of a mess with the code to display correctly.
Looks to be better refresh rate so the animation looks a little smoother over the previous smaller display

Still a bit of alignment work to do but its looking a bit more polished now






Does anyone have a 2" (52mm) aftermarket gauge kicking around I can canibalise to see if I can get the screen inside
Can be broken and or tatty


----------



## A_Banging_Donk (Apr 22, 2017)

I prefer collaborate over piggyback, it's open source for a reason 

Looks like a much better screen, looking forward to seeing the end result


----------



## Essex2Visuvesi (Oct 22, 2019)

A_Banging_Donk said:


> I prefer collaborate over piggyback, it's open source for a reason
> 
> Looks like a much better screen, looking forward to seeing the end result


collaborate... that was the word I was looking for!
Yes the screen is a massive improvement as was still less than a fiver!
https://www.ebay.co.uk/itm/128x64-O...var=453247539077&_trksid=p2057872.m2749.l2649
It's been a fun learning experience and as I had a load of Arduino stuff in a box that I've had since the boy was at school, it's not not been a huge outlay.
I think I'm into it for less than 20 quid so far as I had to buy the bigger screen and can-bus bits.

Gauge is sorted, one of my work mates has crappy Chinese boost gauge I can have


----------



## culver10 (Jun 26, 2019)

Since you guys seem to have the VAG CanBus figured out, you need to come up with a ColorMFA screen like the dude from Russia makes. I have been trying to contact him for the last few months with no response back. He must be busy building more lucrative things, hopefully??

Cheers,

Phil


----------



## Andre-77 (Jan 27, 2018)

Simply Amazing!!! you're a genius! i'm very interested about it! i've the powertrack insert but i think that your system are better


----------



## A_Banging_Donk (Apr 22, 2017)

v2.0 has been pushed to GitHub [smiley=cheers.gif]

https://github.com/ABangingDonk/OpenHaldex

The new shiny toys:

 Custom modes (up to 10 data points)[/*]
 Interceptor will boot up in the same mode it was switched off in[/*]
 Added minimum pedal threshold option[/*]
 Improved overall system robustness[/*]

Note that anyone upgrading will need to program everything, mixing and matching with what was previously released isn't going to work


----------



## davebowk (Aug 16, 2019)

If i bought all the bits and assembled them as in this thread. All boxed and wired. Would someone be able and willing to install the software for me for beer tokens if I posted it to them. I really don't have a clue when it comes to working with software.


----------



## vimu (May 20, 2020)

Real nice project 

I'm currently trying to port this on the modded a3 of my brother and ran into some troubles with the interceptor
When connecting it to the haldex it's making the same sound like it is not connected to can at all

I thought maybe the haldex adeess is different in his can network so id like to ask you to reup the pdfs to mediafire from this post:



A_Banging_Donk said:


> Some high level information about the Haldex system:
> https://auditttuning.org/2010/12/07/haldex-service-training-self-study-program/
> 
> CAN protocol documentation can be found in the PDFs here.. page 1631 onwards
> ...


Or you may have an idea what else could be the reason for our problems? Wiring should be fine cause my bro did it and he ised your instructions.

Edit: maybe you can give me the information how large a can message is and how it's normaly looking to sniff the id

Vimu


----------



## DjEzko (May 5, 2014)

vimu said:
 

> Real nice project
> 
> I'm currently trying to port this on the modded a3 of my brother and ran into some troubles with the interceptor
> When connecting it to the haldex it's making the same sound like it is not connected to can at all
> ...


All docs uploaded to onedrive.
https://1drv.ms/u/s!AimN2UPsZklMg5M6GPQ ... g?e=4Q4cze


----------



## culver10 (Jun 26, 2019)

Hi,

I'm waiting for my Can Bus Shield and HC-05 BT Module to show up, then I will install this stuff finally. I finally figured out how to get the app onto my old Samsung 5 that I will leave in car. I'm 56 now and not as software savvy as you smart younger chaps, but I'm really interested and committed to learning! Question for you Arduino experts (which I'm a complete novice knob), can I use this AT command method to code the HC-05??




Are there any updates on this awesome project? Has anyone shared this awesome project on the MK4 R32 forums?

Cheers from cold as woopsie and very snowy western Canada!

Phil


----------



## culver10 (Jun 26, 2019)

I have other questions on how this system works? My limited understanding is the CAN BUS sends digital signals throughout the car from the ECU and each controller throughout the car uses this digital information to do it's job. The Haldex controller gets a signal that the front wheels are slipping from the ABS sensors, so the controller engages the clutch to send power to rear wheels. My understanding is the rear interceptor tricks the Haldex controller into thinking the front wheels are slipping and they engage? So what is the master unit doing connected to the CAN BUS up front? Is it sending front wheel slip messages to ECU and then interceptor engages clutch? Why could the entire unit not be in the back like the expensive HPA system?

Thanks for all the awesome work on this!

Phil


----------



## silkman (Jul 29, 2004)

Amazing that I just discovered this thread. Subscribed.


----------



## Nadim_m (Oct 21, 2013)

Likewise great thread following


----------



## vimu (May 20, 2020)

Hey Guys i could need your help debugging my device :/
When i connect the interceptor to the haldex it started making weird noise and so i took me interceptor home for debugging i currently have a setup with 2 Arduino Uno and 1 Arduino DUE R3 Board SAM3X8E which runs the interceptor code.

One Arduino Uno uses a CAN-BUS Shield of diymore and spans the can with this code:

```
// demo: CAN-BUS Shield, send data
// [email protected]

#include <mcp_can.h>
#include <SPI.h>

/*SAMD core*/
#ifdef ARDUINO_SAMD_VARIANT_COMPLIANCE
    #define SERIAL SerialUSB
#else
    #define SERIAL Serial
#endif

// the cs pin of the version after v1.1 is default to D9
// v0.9b and v1.0 is default D10
const int SPI_CS_PIN = 10;

MCP_CAN CAN(SPI_CS_PIN);                                    // Set CS pin

void setup() {
    SERIAL.begin(115200);

    while (CAN_OK != CAN.begin(CAN_500KBPS)) {            // init can bus : baudrate = 500k
        SERIAL.println("CAN BUS Shield init fail");
        SERIAL.println(" Init CAN BUS Shield again");
        delay(100);
    }
    SERIAL.println("CAN BUS Shield init ok!");
}

unsigned char stmp[8] = {0, 0, 0, 0, 0, 0, 0, 0};
void loop() {
    // send data:  id = 0x00, standrad frame, data len = 8, stmp: data buf
    stmp[7] = stmp[7] + 1;
    if (stmp[7] == 100) {
        stmp[7] = 0;
        stmp[6] = stmp[6] + 1;

        if (stmp[6] == 100) {
            stmp[6] = 0;
            stmp[5] = stmp[6] + 1;
        }
    }

    CAN.sendMsgBuf(0x2C0, 0, 8, stmp);
    delay(100);                       // send data per 100ms
}

// END FILE
```
The Interceptor runs this code:

```
/*
   MIT License

   Copyright (c) 2018 ABangingDonk

   Permission is hereby granted, free of charge, to any person obtaining a copy
   of this software and associated documentation files (the "Software"), to deal
   in the Software without restriction, including without limitation the rights
   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
   copies of the Software, and to permit persons to whom the Software is
   furnished to do so, subject to the following conditions:

   The above copyright notice and this permission notice shall be included in all
   copies or substantial portions of the Software.

   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
   SOFTWARE.

   OpenHaldex interceptor:
    Forwards all CAN frames (except those from the master) to the haldex
    Master frames are read into operating_mode and false_slip globals

   Some experimentation to be done with regards to false_slip and BRAKES1
   frames... I've seen a maximum haldex engagement of 0xc6, I'm sure there's
   more to be had here.

   At the very least, we can keep the haldex enaged through braking by editing
   the brake pedal signal sent in BRAKES1.
*/

#include "variant.h"
#include <due_can.h>
#include "Timer.h"

#define ARRAY_LEN(array)    ((size_t)(sizeof(array) / sizeof(array[0])))

//Leave defined if you use native port, comment if using programming port
//#define Serial SerialUSB

#define HALDEX_ID               0x2C0
#define BRAKES1_ID              0x1A0
#define BRAKES3_ID              0x4A0
#define MOTOR1_ID               0x280
#define MOTOR2_ID               0x288
#define MOTOR3_ID               0x380
#define MOTOR6_ID               0x488
#define INTERCEPTOR_ID          0x2C1
#define MASTER_ID               0x7ff

#define STOCK_LOCKING           0x0
#define NO_LOCKING              0x1
#define FULL_LOCKING            0x2
#define CUSTOM_LOCKING          0x3

#define CAN0_DEBUG              1
#define CAN1_DEBUG              1

#define BUTTONS_NO_MASTER       1
#define PIN_STOCK_BUTTON        3
#define PIN_5050_BUTTON         5
#define PIN_FWD_BUTTON          7

static uint8_t operating_mode = 0;
static uint32_t false_slip = (0x1 << 24) + (0x1 << 8);
static const uint8_t motor1_lock_data[] = { 0x0, 0xf0, 0x20, 0x4e, 0xf0, 0xf0, 0x20, 0xf0 };

static void get_lock_data(CAN_FRAME *frame)
{
  switch (frame->id)
  {
    case MOTOR1_ID:
      memcpy(frame->data.bytes, motor1_lock_data, ARRAY_LEN(motor1_lock_data));
      break;
    case MOTOR3_ID:
      frame->data.bytes[2] = 0xfa;
      frame->data.bytes[7] = 0xfe;
      break;
    case MOTOR6_ID:
      frame->data.bytes[1] = 0xfe;
      frame->data.bytes[2] = 0xfe;
      break;
    case BRAKES3_ID:
      frame->data.high = (0xa << 24) + (0xa << 8);
      frame->data.low = frame->data.high + false_slip;
      break;
    case BRAKES1_ID:
      //frame->data.bytes[1] &= ~0x8;
      frame->data.bytes[2] = 0x0;
      frame->data.bytes[3] = 0xa;
      break;
  }
}

void haldex_callback(CAN_FRAME *incoming)
{
  Can1.sendFrame(*incoming, 7);

#if CAN0_DEBUG
  Serial.print("ID: 0x");
  Serial.print(incoming->id, HEX);
  Serial.print(" DATA: ");
  for (int i = 0; i < incoming->length; i++)
  {
    Serial.print(incoming->data.bytes[i], HEX);
    Serial.print(" ");
  }
  Serial.println();
  Serial.print("Due in ");
  if (operating_mode == STOCK_LOCKING)
  {
    Serial.print("STOCK ");
  }
  else if (operating_mode == FULL_LOCKING)
  {
    Serial.print("50:50 ");
  }
  else
  {
    Serial.print("FWD ");
  }
  Serial.print("mode.");
  Serial.println();
#endif
}

void can1_rx_callback(CAN_FRAME *incoming)
{
  if (incoming->id == MASTER_ID)
  {
    operating_mode = incoming->data.bytes[0];
    if (operating_mode == CUSTOM_LOCKING)
    {
      false_slip = (incoming->data.bytes[1] << 24) + (incoming->data.bytes[1] << 8);
    }
    else
    {
      false_slip = (0x1 << 24) + (0x1 << 8);
    }
  }
  else
  {
    if (operating_mode == NO_LOCKING && incoming->id == MOTOR1_ID)
    {
      return;
    }
    else if (operating_mode == FULL_LOCKING || operating_mode == CUSTOM_LOCKING)
    {
      get_lock_data(incoming);
    }

    Can0.sendFrame(*incoming);
  }
#if CAN1_DEBUG
  if (incoming->id == MOTOR1_ID)
  {
    Serial.print("ID: 0x");
    Serial.print(incoming->id, HEX);
    Serial.print(" DATA: ");
    for (int i = 0; i < incoming->length; i++)
    {
      Serial.print(incoming->data.bytes[i], HEX);
      Serial.print(" ");
    }
    Serial.println();
  }
#endif
}

void setup()
{
  pinMode(LED_BUILTIN, OUTPUT);
  Serial.begin(115200);

  Can0.begin(CAN_BPS_500K);
  Can1.begin(CAN_BPS_500K);

  Can0.setRXFilter(0, HALDEX_ID, MASTER_ID, false);
  Can0.setCallback(0, haldex_callback);
  Can0.mailbox_set_mode(1, 3);
  Can0.mailbox_set_mode(2, 3);
  Can0.mailbox_set_mode(3, 3);
  Can0.mailbox_set_mode(4, 3);
  Can0.mailbox_set_mode(5, 3);
  Can0.mailbox_set_mode(6, 3);
  Can0.mailbox_set_mode(7, 3);

  Can1.setRXFilter(0, 0, 0, false);
  Can1.setCallback(0, can1_rx_callback);
  Can1.setRXFilter(1, 0, 0, false);
  Can1.setCallback(1, can1_rx_callback);
  Can1.setRXFilter(2, 0, 0, false);
  Can1.setCallback(2, can1_rx_callback);
  Can1.setRXFilter(3, 0, 0, false);
  Can1.setCallback(3, can1_rx_callback);
  Can1.setRXFilter(4, 0, 0, false);
  Can1.setCallback(4, can1_rx_callback);
  Can1.setRXFilter(5, 0, 0, false);
  Can1.setCallback(5, can1_rx_callback);
  Can1.setRXFilter(6, 0, 0, false);
  Can1.setCallback(6, can1_rx_callback);
  Can1.mailbox_set_mode(7, 3);

  Can0.disable_tx_repeat();
  Can1.disable_tx_repeat();

#if BUTTONS_NO_MASTER
  pinMode(PIN_STOCK_BUTTON, INPUT_PULLUP);
  pinMode(PIN_5050_BUTTON, INPUT_PULLUP);
  pinMode(PIN_FWD_BUTTON, INPUT_PULLUP);

#endif
}

void loop()
{
  /*
     Do nothing, we're purely interrupt driven.
  */

#if BUTTONS_NO_MASTER
  if (digitalRead(PIN_STOCK_BUTTON) == HIGH)
  {
    operating_mode = STOCK_LOCKING;

  }

  if (digitalRead(PIN_5050_BUTTON) == HIGH)
  {
    operating_mode = FULL_LOCKING;

  }

  if (digitalRead(PIN_STOCK_BUTTON) == LOW && digitalRead(PIN_5050_BUTTON) == LOW)
  {
    operating_mode = NO_LOCKING;

  }
#endif
}
```
and the receiver which should be the haldex dummy runs this code:

```
/**
 * CAN MCP2515_nb
 * Copyright 2020 WitchCraftWorks Team, All Rights Reserved
 *
 * Licensed under Apache 2.0
 */

#include "MCP2515_nb.h"

MCP2515 MCP = MCP2515();

void setup() {
	Serial.begin(115200);
	while (!Serial) {
		;
	}

	Serial.println("CAN Receiver Callback");

	// start the CAN bus at 50 kbps
	if (!MCP.begin(50E3)) {
		Serial.println("Starting CAN failed!");
		while (true);
	}
}

void loop() {
	CANPacket packet = CANPacket();

	if (MCP.receivePacket(&packet) == 0) {
		Serial.print("Received ");

		if (packet.isExtended()) {
			Serial.print("extended ");
		}

		if (packet.getRtr()) {
			// Remote transmission request, packet contains no data
			Serial.print("RTR ");
		}

		Serial.print("packet with id 0x");
		Serial.print(packet.getId(), HEX);

		// only print packet data for non-RTR packets
		if (packet.getRtr()) {
			Serial.print(" and requested length ");
			Serial.println(packet.getDlc());
		} else {
			Serial.print(" and length ");
			Serial.println(packet.getDlc());

			for (int i = 0; i < packet.getDlc(); i++) {
				Serial.print(packet.getData()[i]);
			}

			Serial.println();
		}

		Serial.println();
	}
}
```
So when i connect the receiver directly to the sender i get messages like this:

```
21:48:40.419 -> Extended ID: 0x12048120  DLC: 1  Data: 0x48
21:48:40.419 -> Extended ID: 0x12048120  DLC: 1  Data: 0x48
21:48:40.486 -> Extended ID: 0x12048120  DLC: 1  Data: 0x48
```
And the Interceptor connected to the sender via an cjmcu-230 receives:

```
21:53:56.875 -> ID: 0x2C0 DATA: 0 0 0 0 0 0 22 63 
21:53:56.875 -> Due in STOCK mode.
21:53:56.875 -> ID: 0x2C0 DATA: 0 0 0 0 0 0 22 63 
21:53:56.875 -> Due in STOCK mode.
```
But when i connect the Receiver via another cjmcu-230 there are no messages received.
Any ideas what the problem could be? I tried both cjmcu-230 receivers and they both workes this way but none of them forwards the messages to the receiver uno. I have no idea what else could cause this. I wired up exactly like mentioned in the Tutorial.


----------



## jixxa (11 mo ago)

Hi guys!

will openhaldex work on haldex without connecting to engine CAN at all? i plan to install haldex on old car so there is now can in it. only manualy controlled and brake cutoff.

Thanks for any info.


----------



## BigChungus (10 mo ago)

Hey, I was wondering why not just use a simple ESP32 to communicate, rather than multiple arduinos ?


I've attached my proposed design.


----------



## WachuTT (3 mo ago)

Hi folks! Is there any update in this project? I am attempting to reproduce it but i am wondering as well about redesigning it a little bit.


----------



## barry_m2 (Jun 29, 2015)

I’d love to see something like this for the mk2


----------

