r/howdidtheycodeit • • Jan 16 '24

Question How did they code force feedback?

Hello everybody! I am making a steering wheel with ffb. It uses an arduino leonardo as the microcontroller. I am done with the hardware part, but know I don't know how to code the force feedback part. I was using the JoystickFFB library but it has one problem. It's really bad. The force feedback ''curve'' is not linear. It has stronger force feedback towards the middle and has weaker force feedback towards the maximum steering angle. That means when I let go of the wheel for it to self-center, it would overshoot, and then when it tries to self-center again it would overshoot again, and go into a cycle. Now I am trying to code the force feedback myself but I no idea where to start. If anyone could send me some source code or explain it better to me, I would appreciate it!

11 Upvotes

18 comments sorted by

View all comments

Show parent comment

1

u/Odd-Estate-2623 Jan 18 '24

Yes, there are a lot of PID controllers, but not a lot of them are for arduino and specifically for ffb. The ones I've seen that implement ffb and use arduinos all had to be loaded through Xloader with a hex file. Which is a problem because I can't modify the code. They use encoders while I use a really precise potentiometer. So I can't use them. And, about the PID driver part is it hard or complex? If it is complex I would like to do it because I wanna get a deeper understanding of PID devices and how they communicate and how to make them. I know that this is quite ambitious but I've been trying to figure it out for 4 months.