ranenbg / Arduino-FFB-wheel

Stand alone directInput USB device recognized in Windows as a joystick with force feedback functionality, based on BRWheel by Fernando Igor from 2017.
149 stars 20 forks source link

SPI version of button box #27

Closed jwinfieldnz closed 1 year ago

jwinfieldnz commented 1 year ago

It would be great to have a SPI version of the button box firmware. So rather than use "DT," "CLK," and "PL" you could use SPI and then use something like a NRF24L01 to communicate between the wheel and the Leonardo removing the requirement to try and run wires up the steering shaft.

ranenbg commented 1 year ago

Hi, tnx for the suggestion. I agree, it would be a great feature for sure :) However, I'm not going to be implementing this any time soon, I don't think there is enough memory left and also, and SPI pins are already taken by the PWM outputs and various other buttons and functions.

You may go ahead and add it of course, but a major firmware modification will be required to free up the necessary pins for SPI comms.

ranenbg commented 1 year ago

I did have a look into this, to maybe try to get the NRF module working on the Arduino nano, but again, even nano has SPI pins used for the shift register communication, so I really see no easy possible way to add this module anyway.

RaceMax commented 1 year ago

Hi there. What about if, connect 2 slave boards to the master board? Or even use separate boards for different tasks with additional power supply (just, plug in to one usb hub to connect PC) ?

Warning - I'm a noob yet) But it's interesting project, and I get started ).. , now stuck with choosen fw version for fist prototype...

ranenbg commented 1 year ago

Haha, you wild ideas RaceMax :) Well, in principle Arduino Leonardo has 2 communication interfaces, one is i2C and other is SPI, so one could implement a 2 way communication using both. In theory, one could attach one more Arduino to each of those and offload some of the tasks, but this is way out of the scope of my project. If one needs more procesing power then switching to another microcontroler is a much better idea. There are plenty of ffb wheel firmware for STM32F407, like OpenFFB, VNM, EMC or MMOS.

For start, you can use HEX fw-v220 for Leonardo as this is the most basic and easy to get setup. You only have to connect encoder to get some functionality and first signs of life. You can use ffb monitor in gui to inspect ffb signals that games are sending, before you even start with a motor or other mechanical parts of your build.

RaceMax commented 1 year ago

Thanks for answer) I'm only on start and so badly in theme.

to topic: "...NRF24L01 to communicate between the wheel and the Leonardo..." - thinked about that trick, but, if removed wires from wheel, needs other microcontroller and power supply on the wheel, is in't?

jwinfieldnz commented 1 year ago

With the SPI pins on the leonardo already populated it sounds like it is dead in the water. You wouldn't use the shift register on the nano if you were using SPI maybe? I think a curly cord is a solution. It would just be cool to have a quick release with out having to plug in a cord. First world problems:)

ranenbg commented 1 year ago

Yes, if say I make an SPI version of button box, I need to free up pins 11, 13, 7 which means no PWM+dir mode, no FFB clip led indicator and no digital button on pin 7. It's not that much of a sacrifice, but another problem is I'm at about 95% of used memory already. Once I start adding libraries required for NRF it will probably get passed by 100%, then I would need to start cutting down other features which I'm not a fan of. I'm pretty much pushing this tiny MCU to the max and squeezing everything it has to offer.

You can use those mini din 6 pin style connector that thrustmaster uses to attach the wheel rim. There are even 3D models on thingverse made by RamJetx with 3 part quick release, a copy of thrustmaster one. Slight modification is required to implement such connector there. I printed one assembly for testing, with 0.1mm z layer height and sideways print with PLA, it seems quite strong.

RaceMax commented 1 year ago

Just theoretically. Replace Nano with Nano 33 IoT or some other BLE models?

ranenbg commented 1 year ago

Yes, it's a good idea, but that's only 1 part of the story. Still, a transmitter board and ble devices (inside wheel rim) need to be coded and an appropriate communication format has to be developed, which I really do not have time or motivation to get into. This is something one of you guys can contribute. I'm working alone on this since 2018, it's about time someone helps instead of asking me to do it :)