Go Back   NoGripRacing Forums > General Discussion > Computech

Reply
 
Thread Tools
Old 11 July 09, 23:33   #1
hardjack79
Richard Jackett
 
hardjack79's Avatar
 
Join Date: Dec 2006
Location: London
Age: 31
Default Fun Project: Brake Vibration Mod

I made a brake vibration modification for rFactor (and GTR2, see post #20) and my Porsche 911 Turbo wheel and had a great time doing it, so I'm posting this here in case it gives someone else some ideas or inspiration to do something similar. This was my first go at programming for an electronic device and it was great fun and not as difficult as I had thought, so if you are curious about doing something yourself my advice is to dive right in!

A more thorough explanation is posted here but I'll give a quick run down below.

Aim:
Modify the brake pedal to give vibration feedback of locking wheels in rFactor

The Damage:
Velleman K8055 USB Experiment Interface Board from Maplin (UK) - 25GBP
Vibration motor from PlayStation2 controller - 5GBP for 2nd hand controller
Small 5V relay, a few shielded wires, 4xAA battery holder and batteries - 5GBP?
So I guess it was about 35 quid all up, but I bought the USB interface as a general investment, not specifically for this mod.

Putting it Together:
The board has 8 digital outputs (among other features), one of which is to be switched by the rFactor plugin when there is brake lockup. Assembling the USB interface was pretty easy, the instructions were very clear. I'm not a complete novice with a soldering iron, but by no means a pro either.

The tricky bit for this was always going to be programming the plugin, as I am a complete novice with C++. To soften the learning curve I took it in steps:
1) Write some Visual Basic code that can toggle a digital output on/off with the click of a button. I know a bit of VB, so this was just about working out how to call the dll supplied by Velleman to connect and switch an output.
2) Write the same functionality in C++
3) Write the plugin in C++ by using ISI's plugin template as a base.
In essence, the logic was
IF Moving AND Braking AND AnyWheelRotationSpeed << ThatImpliedByCarSpeed
THEN TurnOnVibration
ELSE TurnOffVibration


The vibration motor was stolen from a DualShock controller, and operated by 4 NiMH AA batteries. The vibration circuit is switched by a relay triggered by a digital output of the board (its actually slightly more complicated in practice).

The Result:
Amazingly it worked more or less straight out of the box, and after a bit of tweaking of the code I now get a noticable vibration on my foot when I lock up, without suffering any noticable frame rate drops (erherm Fanatec ).

Future Plans:
I keep meaning to try this logic instead:
IF Moving AND Braking AND NotLockedUp THEN Vibrate
ELSE Don'tVibrate

I would like to improve it by using an analogue/PWM output and have the vibration on every time I brake but linked to car speed (the slower the brake rotor is turning, the slower the vibration), and then have vibration cut out entirely if a wheel locks, but although the code is already written for that, I'd have to power the motor with the board, which would probably cook it. If anyone knows another way to do this, please let me know.
I'd love to implement this in GTR2 because it would be brilliant with P&G where I lock up several times per lap. If anyone knows how to get telemetry out of GTR2 to do this please reply (need car speed, brake%, individual wheel speed)

Conclusion:
For the price of 35 quid and about 5 full evenings I have a pretty good addition to rFactor. Its not going to lower my laptimes but it is another useful addition to the 'immersion factor'. But the real payoff was the fun and confidence gained from programming an external device to work with some existing software. Not as hard as I thought it would be, and it leaves me looking forward to the next project, whatever and whenever that will be.




Last edited by hardjack79; 3 September 09 at 18:51. Reason: Added photos for folks who think words are worth 0.001*pic
hardjack79 is offline   Reply With Quote
Old 12 July 09, 01:43   #2
Freddyfartbox
Since 1979
 
Freddyfartbox's Avatar
 
Join Date: Oct 2006
Location: Bunbury. Western Australia.
Age: 31
Default

Geez that's some pretty ingenious work there mate, well done. One question, does that mean the brake pedal is constantly vibrating unless the wheels lock, or does it require pedal pressure to initiate the vibration? Now all you need is a 4 sided steel box with independently moving sides to smash into you whenever you crash, and a bucket of broken glass to be thrown over you and the immersion factor is complete.
Freddyfartbox is offline   Reply With Quote
Old 12 July 09, 11:10   #3
hardjack79
Richard Jackett
 
hardjack79's Avatar
 
Join Date: Dec 2006
Location: London
Age: 31
Default

Thanks mate. Yeah I had thought about the steel box, but the broken glass is a new one -- thanks for that

The first thing the code does is check whether the car is moving faster than 1m/s and whether the brake is depressed more than 10%. If either of these isn't true then there is no vibration. From there its pretty easy to choose between having the vibration on when the wheels are locked; or on when braking unless the wheels are locked.

I can post the source code if anyone is interested.
hardjack79 is offline   Reply With Quote
Old 12 July 09, 14:29   #4
redi
Superator
 
redi's Avatar
 
Join Date: Oct 2006
Location: On a thin crust covering a huge ball of hot molten stone whizzing through space
Age: 37
Default

I suggest to send the code + hardware info to Fanatec, because their implementation is VERY resource-heavy...
redi is offline   Reply With Quote
Old 12 July 09, 15:57   #5
Freddyfartbox
Since 1979
 
Freddyfartbox's Avatar
 
Join Date: Oct 2006
Location: Bunbury. Western Australia.
Age: 31
Default

Quote:
Originally Posted by hardjack79 View Post

The first thing the code does is check whether the car is moving faster than 1m/s and whether the brake is depressed more than 10%. If either of these isn't true then there is no vibration.
Yeah, well that is actually quite obvious when you read the code logic, bit of a brain fade there.
Freddyfartbox is offline   Reply With Quote
Old 12 July 09, 22:40   #6
SgtH3nry3
 
Join Date: Jan 2008
Default

The pedals of today lack haptic feedback. I can't feel the clutch gripping, you'll have to guess the engagement point by using the RPM display and change in rev sound pitch.

Can you actually feel the ABS kick in with this mod?
You should release it under GPL licence at Google Code, so other developers can implement it natively!

Last edited by SgtH3nry3; 12 July 09 at 22:55.
SgtH3nry3 is offline   Reply With Quote
Old 13 July 09, 11:30   #7
hardjack79
Richard Jackett
 
hardjack79's Avatar
 
Join Date: Dec 2006
Location: London
Age: 31
Default

Quote:
Originally Posted by SgtH3nry3 View Post
The pedals of today lack haptic feedback. I can't feel the clutch gripping, you'll have to guess the engagement point by using the RPM display and change in rev sound pitch.

Can you actually feel the ABS kick in with this mod?
You should release it under GPL licence at Google Code, so other developers can implement it natively!
I'm not using ABS in the game so its just when the brakes lock up that the vibration is felt, but its quite noticable when it comes on!

I'd have to have another look at what telemetry is sent out by rFactor, but I don't recall it reporting whether ABS is interferring in real time; just whether it is switched on or not. But if it does report that then it'd be easy to modify the code to implement it and it would be quite a realistic feeling effect.

Also your comments about the clutch are quite interesting, SgtH3nry3... You got me thinking: I could sharpen up the clutch response with dxtweak2 and use the smaller PS2 motor on the clutch to denote the friction point.

Thanks for your interest in this, guys
hardjack79 is offline   Reply With Quote
Old 13 July 09, 12:11   #8
redi
Superator
 
redi's Avatar
 
Join Date: Oct 2006
Location: On a thin crust covering a huge ball of hot molten stone whizzing through space
Age: 37
Default

Richard, any idea why with the Fanatec driver the brake pedal vibe has such a huge performance hit?
redi is offline   Reply With Quote
Old 13 July 09, 12:57   #9
hardjack79
Richard Jackett
 
hardjack79's Avatar
 
Join Date: Dec 2006
Location: London
Age: 31
Default

I'd like to see their code for sure, but I would speculate that it could be down to either:
1) Its not the brake vibe code that is causing the problem, maybe its the display code. Is there still a big hit when all but brake lockup is disabled? Even if there is it could be that the display routine is still run, just not output.
2) When I first ran this mod I assigned 4 LEDs on the board to indicate blocking in each wheel separately -- and why not? the outputs were there to be used -- but whenever I did lock up it dropped to <1fps. I need to revisit this because I have since made improvements to the code, but perhaps Fanatec do something similar en-route to deciding whether the state is LOCKED or NOT LOCKED?

My hardware is of course completely different, and I noticed that it does not do well sending multiple instructions to the board in rapid succession (ie the state of each wheel (D1-4), plus the general lockup indicator (D6), plus analog rotor speed (A1)). Presumably the latency is too much for soft real time at ~60fps and it grinds to a halt. My code originally set D6 and A1 every frame, but this wasn't efficient, so now it only sets it if there has been a significant change in state. It means keeping track of the state within the plugin, and introducing a threashold for changing A1, but it has meant no fps hit and no sudden drops when lock up occurs.

Sorry this was a bit unclear, I'm not a programmer really, and I only had a few minutes to type it before the web marshall blocks me from posting for the afternoon. Hope you can make sense of that!
hardjack79 is offline   Reply With Quote
Old 23 July 09, 14:53   #10
riches
 
Join Date: May 2007
Default

How about using a pc compatible joypad?
Than use it's controller and its rumble motors?
That controller should also be able to power the rumble effect by it self.

Is it possible for rFactor to use 2 FFB devices?

Last edited by riches; 23 July 09 at 15:00.
riches is offline   Reply With Quote
Old 23 July 09, 17:41   #11
hardjack79
Richard Jackett
 
hardjack79's Avatar
 
Join Date: Dec 2006
Location: London
Age: 31
Default

I'm not sure what you mean about the PC joypad, but i'll guess.... You could probably miss out the K8055 altogether if you could call the joypad's driver/dll routines directly, but I'm probably not clever enough to do that yet. That's a pretty good idea though.

In terms of rFactor using 2 devices, it has in built support for at least one controller (obviously) and you can add support for as many more as you like if you make a plugin(s). You could control several devices from one plugin, that isn't a problem at all. Latency could become a problem if you really go overboard on complexity of FFB instructions/calculations though --> the fps will crumble.
hardjack79 is offline   Reply With Quote
Old 23 July 09, 17:58   #12
riches
 
Join Date: May 2007
Default

I was talking about a gamepad, is my typo...

But you get the idea, as the gamepad device is allready supported by it's driver.

I was hoping some simple command to the gamespad should make it rumble.
Just like it does when you only use the gamepad without a steeringwheel connected.

(edit)
Been reading about this Velleman USB card.
I'm tempted to buy one, just to play around with.
You can connect quite a lot more to this device.

Last edited by riches; 23 July 09 at 18:58.
riches is offline   Reply With Quote
Old 25 July 09, 09:25   #13
Jules327
 
Jules327's Avatar
 
Join Date: Dec 2008
Location: Oz-Stralya, Mate
Age: 53
Default

I've been playing about with adding feedback effects a little myself and thought you guys might find this usefull....



These come from one of those massage cushions, they typically run on 12v and come in little pods making them easier to mount, there are useually six to eight per cushion and it comes equiped with a power supply. As you can see these ones have brass vibration weights which means they are easy to alter (file or cut down) to change the pitch of the vibration.

Cheers, Jules
Jules327 is offline   Reply With Quote
Old 26 July 09, 19:06   #14
hardjack79
Richard Jackett
 
hardjack79's Avatar
 
Join Date: Dec 2006
Location: London
Age: 31
Default

Cheers Jules, I'll look into that. Hadn't thought of using a vibration cushion.
hardjack79 is offline   Reply With Quote
Old 27 July 09, 13:44   #15
Jules327
 
Jules327's Avatar
 
Join Date: Dec 2008
Location: Oz-Stralya, Mate
Age: 53
Default

Try reject shops/clearence houses, type of places, you can pick them up at reasonable prices, I bought another one recently that can respond to music/sound inputs and has eight motors. Now I figure that if I modify half the motors to vibrate higher by trimming down the "weights" and arange them in pairs (like a duel shock controller) it gives me two for the pedels, gearshift, wheel and seat of my race frame, all responding to the audio of the game much like my "Buttkicker Gamer" (gotta love that name) does only producing different vibrations.

I have one of the motors pictured above mounted behind the dash but running at it's lowest RPM so if I stall the car and go for the starter the dash vibrates a bit like a real starter motors been engaged. (Yes I have way too much spare time) There are heaps of ways to use these things!



You can just make out the "pod" mounted behind the ignition switch, rubbish pic but I was kinda upside down when I took it! lol
Jules327 is offline   Reply With Quote
Old 28 July 09, 19:04   #16
hardjack79
Richard Jackett
 
hardjack79's Avatar
 
Join Date: Dec 2006
Location: London
Age: 31
Default

Quote:
Originally Posted by Jules327 View Post
Try reject shops/clearence houses, type of places, you can pick them up at reasonable prices...
Excellent, I now have plans for my weekend
Saturday: Scavenge some cool sh!t
Sunday: Whip this sh!t into sim-racing gold.


Jules, have you got any idea where one could raid some linear actuators from? I can't think of anything cheap that would have them. I'd like to start on something to provide some actual forces rather than just vibration.

PS Your ignition switch mod cracked me up. I love it!
hardjack79 is offline   Reply With Quote
Old 28 July 09, 20:00   #17
Jules327
 
Jules327's Avatar
 
Join Date: Dec 2008
Location: Oz-Stralya, Mate
Age: 53
Default

Hardjack, if that cracked you up, prepare to wet your pants

The ignition key and lock (which are real) work like this, turning it to the first position gives power to the gauges'n'stuff and the needles Jump to life, the second position turns on the dashboard lights and the third position dims the lights in the guages (simulating the power drain of a starter motor), triggers the starter motor of the car in-game and makes the dash vibrate like a real starter motor would!



There is nothing quite like grinding away on an ignition key while muttering unrepeatable profanity when you stall the car, it brings a smile to my face every time! Now dry yourself off sunshine and have a fun weekend! Actuators are a bit out of my league, I'm afraid, But I'm interested in hearing your ideas!

For laughs aplenty there's a link to my Photobuket page in my profile, there's some other "mods" on there that I'm working on, you might like my car stereo

P.S. Before the weekend comes have you checked out what the X-sim software can do? I havn't looked into the FF side of it yet but it controls servo's real easy and servos can be made to control motors........ (many possibilities) It's also what's used for controlling actators for motion sims.

Last edited by Jules327; 28 July 09 at 20:18.
Jules327 is offline   Reply With Quote
Old 28 July 09, 21:32   #18
hardjack79
Richard Jackett
 
hardjack79's Avatar
 
Join Date: Dec 2006
Location: London
Age: 31
Default

Dude, its a masterpiece. Epic.

You should get along to the Aussie PnG league, great bunch of dudes there that would mock you relentlessly if they knew your whole desk was vibrating each time you fired up, accuse you of stalling deliberately... We are having fun races Sat and Sun evenings at the moment, drop by.

Now I'll check out your other mods.
hardjack79 is offline   Reply With Quote
Old 29 July 09, 08:53   #19
Jules327
 
Jules327's Avatar
 
Join Date: Dec 2008
Location: Oz-Stralya, Mate
Age: 53
Default

I'm all for upping the volume level on the 'immersion factor' as you called it above, I want to introduce feedback from a number of sources, not over the top, but subtle effects, think London Philharmonic not The Sex Pistols!

I think Electric DC Motors are a very versatile source of feedback, my Speedo & Tacho are powered by motors, so just in normal opperation they will add a vibration to the frame, one increaseing with vehicle speed the other with engine revs. BUT! I'd like to add another pair of motors that mimmick the others, just for effects perhaps driving something, ya know, add some centrifugle(?) force or inertia to the frame. I reckon THAT would be cool!
Jules327 is offline   Reply With Quote
Old 3 September 09, 18:48   #20
hardjack79
Richard Jackett
 
hardjack79's Avatar
 
Join Date: Dec 2006
Location: London
Age: 31
Default

A few updates if anyone is interested:

1) I tried out the clutch friction point mod discussed earlier. Basically the same physical setup as the brake mod, using the same power supply and switched by a different channel of the board by a different 5V relay. The coding was pretty simple too, just turn on when the clutch is anywhere in between 0 and 100%. Then I adjusted the clutch travel in dxtweak2 to be a lot sharper than it was. The result is so-so, its not particularly realistic feeling and doesn't really help the starts as far as I can tell. Plus there is only one start per race. Still, it was pretty easy to do and I'm not going to dismantle it unless I use the motor/relay for something else.

2) Added ini file support so that I can tweak some parameters without recompiling the plugin or exiting the game. I know: "who cares?"

3) Got brake lockup vibration working in GTR2 by using Nye's OCX and example code (what a legend for making that available ). The OCX (and maybe GTR2?) doesn't output car speed or position, so I had to average the 4 wheel speeds and use that as car speed, which is obviously less than optimal if we are trying to work out if one or more of the wheels are no rotating, but in practice this works very well. So I have to run the code as an exe before I start GTR2, but the result in PnG2 is just awesome! I'll try and write up what I did a bit better when I get some time in case anyone is interested now that it can be used in GTR2.

Not sure what the next project will be now.
hardjack79 is offline   Reply With Quote
Old 5 September 09, 13:47   #21
gtr2_race_pro
 
gtr2_race_pro's Avatar
 
Join Date: Oct 2007
Location: Brisbane, Australia
Default

just a question... when u lock up wouldnt the pedel just go dead and lose all pressure as the tires are sliding on one spot?.... thats what i figgureds they did in a racecar atleast
gtr2_race_pro is offline   Reply With Quote
Old 5 September 09, 18:15   #22
hardjack79
Richard Jackett
 
hardjack79's Avatar
 
Join Date: Dec 2006
Location: London
Age: 31
Default

Yeah mate, I agree that makes more sense. Check out the future plans section of the original post... I mean to try it but I'm just too lazy. I want the vibration to be proportional to brake rotor speed, and until I can do that I haven't been bothered to even try the alternate coding out
hardjack79 is offline   Reply With Quote
Old 6 September 09, 00:35   #23
gtr2_race_pro
 
gtr2_race_pro's Avatar
 
Join Date: Oct 2007
Location: Brisbane, Australia
Default

the vibrating through the wheel from a flatspot would be kool if it was big enough
gtr2_race_pro is offline   Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 17:48.


Powered by vBulletin® Version 3.8.6 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.

www.nogripracing.com 2003 - 2010
Page generated in 0.15359 seconds with 10 queries