Jump to content

Open Source Joystick FFB / DIY FFB Joystick


Recommended Posts

Hi

 

has somebody else build a test setup?

 

 

 

 

 

 

Hello MetalGear,

Thank you so much for your efforts in this.What you have achieved for the community really is something special and I imagine people are going to benefit from it for a long time.

I have a test set up being made. I already have a sturdy gimbal from a previous project made based on this. It should be easy to adapt that to a forcefeedback setup.

I also have a Pro Micro that is working and appearing as "Big Block" in my devices list. It was quite a lot for me to learn to achieve that as although I have plenty of experience with discrete components, I do not have any experience with microcontrolers.

Am I right in thinking that the finished setup should look something like this image?

Thanks again.

 

QOtATYk.jpg

Link to comment
Share on other sites

  • Replies 419
  • Created
  • Last Reply

Top Posters In This Topic

Hi

yes that is correct.

but i think the version that i have uploaded is still using the ADC from the Mega. so you need to conect the Pots to the corresponding pins on the ATMEGA32U directly.

 

 

MetalGear_Honk

The threemost dangerous threads to Programmers:

  • Fresh air
  • Bright sun light
  • The horrifying screams of singingbirds

Link to comment
Share on other sites

Hi

yes that is correct.

but i think the version that i have uploaded is still using the ADC from the Mega. so you need to conect the Pots to the corresponding pins on the ATMEGA32U directly.

 

 

This is concerning for me. I had assumed that the ADC was not onboard the mega because I hooked up a couple of 10k pots directly to the ATMEGA and it didn't show any input from them in the windows game controller settings (imaged below).

 

My best guesses for troubleshooting are that either that there is something wrong with the way I set the bootloader up on the Pro Micro or it's because I don't have the shift registers attached yet (waiting on parts).

 

 

s4MxOHS.jpg

Link to comment
Share on other sites

Hi

Sounds like a Bug (or I have blocked the transfer to pc again)

Definitely no problem with the Bootloader.

BL problems lead always to "Device not recognized"

I don't have a Compiler here but from Memory there should be a line

ReportData->axis[0] = XAchse;

Where ReportDAta is the Value send to PC

And XAchse is the ADC Value

XAche is set in the Einlesen function.

Another idea is that you have the Descriptor not correct.

That way you will not get any Values from the Device.

You can try to set pin 9 to high. That should set all Buttons to "on"

Hope that helps.

MetalGear_Honk

The threemost dangerous threads to Programmers:

  • Fresh air
  • Bright sun light
  • The horrifying screams of singingbirds

Link to comment
Share on other sites

I re-imaged the bootloader anyway and interestingly the Big Block properties now looks different. I suspect I had the wrong version imaged before. Strange.

The same problem persists. Setting pin 9 high had no effect on the button states either.

 

 

I only have a very, very basic understanding of the code. I have included an image of the parts you mentioned below.

 

 

I have not touched the Descriptor. Is it likely to be incorrect?

NrC3pry.jpg

Link to comment
Share on other sites

Hi

Still working from memory here.

But it looks like a mismatch between Descriptor and RepertData.

In the Joystick.h is a struct for JoystickReport_Data

You need to count the Bits.

And compare them to the Descriptor Bits declared.

Report sizes * report count. Of all integrated functions (Axis, Buttons...)

If you have a mismatch here the PC will not get any data.

MetalGear_Honk

The threemost dangerous threads to Programmers:

  • Fresh air
  • Bright sun light
  • The horrifying screams of singingbirds

Link to comment
Share on other sites

Thankyou once again for your assistance Honk. It is appreciated very much.

I am at the absolute limit of my understanding, so I apologise if my questions show a lack of understanding. I am doing my best to learn things my self and avoid treating you like technical support.

 

 

The joystick.h reads:

typedef struct

{

int8_t repID;

int16_t axis[8];

int8_t Buttons[4];

int8_t Hat[2];

 

} USB_JoystickReport_Data_t;

 

 

Is this the relevant part?

 

 

You need to count the Bits.

And compare them to the Descriptor Bits declared.

Report sizes * report count. Of all integrated functions (Axis, Buttons...)

 

 

I am sorry, I do not understand what is meant here.

Perhaps I should wait until you have time to revisit this project?

Link to comment
Share on other sites

Hi

No problem. I will try to help as good as possible.

The Struct is the correct one.

And for counting the Bits:

Simple take a Variable int8 for 8Bit int16 for 16 Bit

And multiply by the number of Declared Variables.

int8_t repID; = 8 Bit

int16_t axis[8]; = 128 Bit

int8_t Buttons[4]; = 32 Bit

int8_t Hat[2]; = 16 Bit

Gives a total of 184 Bit

That is the number of bits that our Program sends to the PC

Now we need to find out how many Bits we have Declared in the Descriptor

The Descriptor is in the Descriptors.c

USB_Descriptor_Report_Data_t if I remember correctly

It is a list of Hex Values

We need the count and the Size

Normally I have it written after the //

there are always two Hex Values separated by a ","

First Value is the description (0x75 for Size and 0x95 for count)

The second Hex is the Value we are looking for (0x01 for one or 0x10 for 16)

So there should be a line like

0x75, 0x20, // Report Count

0x95, 0x01, // Report SIZE

That is the Value for the Buttons 32 Buttons with the size of one Bit (on/off)

For the axis it should be 0x10 for Size as it is a 16 Bit that I was aiming for.

The Head switches are 4Bit (0x04) as they have four Directions.

As a fast test of your code simply set one bit in the ReportData part

Like ReportData->Buttons[1] = 0b00000100;

This needs to go at the end of the GetNextReport function.

MetalGear_Honk

The threemost dangerous threads to Programmers:

  • Fresh air
  • Bright sun light
  • The horrifying screams of singingbirds

Link to comment
Share on other sites

OK, I think I understand.

There are 8 axis at 16 bits each in the descriptors, so that's correct, however your //comments suggested there where 9 axis.

0x95, 0x04, // REPORT_COUNT (5)

I assume that is just a error with the comment.

 

There are 32 buttons at one bit each, so that is correct, however your comment suggested there are 48 buttons.

 

0x95, 0x20, // REPORT_COUNT (48 )

Just another error with the comment I assume.

 

 

The HAT switch has 16 bits declared, so that is correct.

 

 

I can't tell what 'repID' refers to in descriptors. REPORT_ID is mentioned several times with several different bit values.

 

 

Here is a pastebin of the descriptors

Link to comment
Share on other sites

Hi

The Numbers in the comments are mostly as a reminder for me how many Buttons/Axis I have in my Hardware setup.

Sorry for that.

 

The RepID is simple the Number of the Device on that controller. We can declare more Devices in one ATMega. But for now it is simple an 8Bit with the Value 1 written in it.

 

As far as I can see there is nothing wrong with the Descriptor or the Report.

Can you try to load the Hex file that I uploaded last time? It was included in the Sources. That version was running on my test setup.

 

I am setting up some Test Rig now but I have only very basic equipment where I am at the time.

 

MetalGear_Honk

P.S.: I think I found the Problem. The Daisy Chain part is not working Properly.

To test it you need to delete the part between" //---Read Daisy Chain " to "return InputChanged;"


Edited by MetalGear_Honk
explanation added

The threemost dangerous threads to Programmers:

  • Fresh air
  • Bright sun light
  • The horrifying screams of singingbirds

Link to comment
Share on other sites

Hi

Can you try to load the Hex file that I uploaded last time? It was included in the Sources. That version was running on my test setup.

 

Do you mean THIS one?

 

 

 

P.S.: I think I found the Problem. The Daisy Chain part is not working Properly.

To test it you need to delete the part between" //---Read Daisy Chain " to "return InputChanged;"

 

 

Well, That didn't fix the problem, but it did cause an interesting result that may assist in finding out what is happening.

EpQ6pnD.jpg

 

The axis are stuck at 255 still, but now random buttons are pressed that periodically change for a microsecond or so and then go back.

Link to comment
Share on other sites

Hi

I am not able to reproduce this behavior.

I have added a new version. For testing.

You should be able to use the Data Pin to trigger the first Button.

For the axes:

I can set them manually in the source. So the HID Descriptor is OK

But there must be a Bug in the conversation somewhere.

The Motors are driven correctly in relation to Axis. But the Axis are not send to the PC.

I will keep searching for it.

 

 

 

MetalGear_Honk

 

 

 

JOYSTICK_Test.zip

JOYSTICK_Test.zip

The threemost dangerous threads to Programmers:

  • Fresh air
  • Bright sun light
  • The horrifying screams of singingbirds

Link to comment
Share on other sites

ReHi

 

 

I think i found a few more things.

 

 

here is the new Einlesen Function:

void einlesen(void)

{

ADMUX = (ADMUX & 0xF8)|(1<<MUX0)| (1<<MUX1)| (1<<MUX2);

// ADMUX =(1<<MUX0)| (1<<MUX1)| (1<<MUX2) ;

ADCSRA |= (1<<ADSC);

while (ADCSRA & (1<<ADSC) ) { }

 

// ADMUX =(1<<MUX0)| (1<<MUX1)| (1<<MUX2) ;

ADCSRA |= (1<<ADSC);

while (ADCSRA & (1<<ADSC) ) { }

// XAchse = ADCH;

XAchse = ADCW;

 

ADMUX = (ADMUX & 0xF8)|(1<<MUX1)| (1<<MUX2) ;

// ADMUX = (1<<MUX1)| (1<<MUX2) ;

ADCSRA |= (1<<ADSC);

while (ADCSRA & (1<<ADSC) ) { }

 

// ADMUX = (1<<MUX1)| (1<<MUX2) ;

ADCSRA |= (1<<ADSC);

while (ADCSRA & (1<<ADSC) ) { }

YAchse = ADCW;

 

}

 

 

 

and a new SetupHardware:

 

 

void SetupHardware(void)

{

MCUSR &= ~(1 << WDRF);

wdt_disable();

clock_prescale_set(clock_div_1);

ADMUX = 0b01100000;

ADCSRA = 0b11000110;

// ADCSRA |= (1<<ADSC); // eine ADC-Wandlung

while (ADCSRA & (1<<ADSC) ) { }

(void) ADCW;

TCCR4A = 0b10100011;

TCCR4B = 0b00000011;

 

TCCR1A = 0b00000000;

TCCR1B = 0b00001010;

TIFR1 = 0b00000010;

 

TCNT1 = 0;

OCR1A = 2100; //vergleichs wert 1400

//OCR1A = F_CPU / 1000/8;

TIMSK1 = 0b00000010;

// Joystick_Init();

// Buttons_Init();

USB_Init();

}

 

 

I am in a Hurry so you need to insert them in your Version Manualy.

 

 

MetalGear_Honk

The threemost dangerous threads to Programmers:

  • Fresh air
  • Bright sun light
  • The horrifying screams of singingbirds

Link to comment
Share on other sites

Pin 9 now triggers button '1' when pin 9 is set LOW.

The axis are also moving now!

However, the axis values do not have anything to do with the pot's resistance value. Instead, they fluctuate wildly between five values: 0, -16384, -32768, 16384 and 32768.

 

 

When I ground the axis pins or leave them open, they stay at zero, but as soon as a pot is connected (or even if I touch the pins) they start to fluctuate wildly.

 

m39QKSw.jpg

Link to comment
Share on other sites

Hi' Been following this thread for a few days now and just joined the forum, took a while before being able to post.

So I have been wanting to do a ffb stick for a while, Love my MSFFB but like many of you I want more. Reading up on as much as I can, what I have a question on is the motor drives.

 

Are they in any way like cnc stepper/servo drives. I have an extra drive and some steppers I'd like to test to see, but how would I program the drivers if they would work?

 

I am not in any way shape or form a programmer so I get lost in all that alien talk.

Thanks

Link to comment
Share on other sites

Steppers are no good.

You need a DC motor. Ideally one without much 'cogging'. Perhaps something that draws 2-4 amps for a full length stick.

 

Roger that, but its more just for testing to see if the drivers would work. I can get drivers for cnc application cheaper than we can for FFB like the ones I've seen on the web. if they both work the same, I'd rather go cheaper.

Link to comment
Share on other sites

Stepper motor torque control can be done, but it's going to require a lot more work. You would need a torque control method and that's not at all easy to do. It's way out of the scope of this thread.


Edited by Browning
Link to comment
Share on other sites

I'm not planning on using steppers, I was just going to test what I have to see if they did work, I can also use servo motors which a lot of the ffb sticks that I have seen use. But if someone knows what other cards we can use other than the one I posted that would be great.

 

Not sure how MS made their ffb stick so cheap compared to the newer ones, What kind of cards did they use? And were can we get some that are a bit more beefier?

Link to comment
Share on other sites

Hi

For testing your setup you can use mostly every DC Motor you can find.

From toy cars to the opening Motor of an old CD-drive.

All you need is an H-Bridge that can handle the current.

If you go for high power Motors the Sabretooth boards are the ones you are looking for. For tests you can use the cheap l298 chips.

For the problems about Stepper / Servos / DC Motors:

Steppers use impulses to move a distance

Servos use PWM to move to a Position

DC motors are simply on off.

To set a tork value to a DC we reduce the power to it by using a PWM signal. And the H-Bridge is only necessary for direction control.

Steppers and Servos use all there tork to get to a fixed position.

MetalGear_Honk

The threemost dangerous threads to Programmers:

  • Fresh air
  • Bright sun light
  • The horrifying screams of singingbirds

Link to comment
Share on other sites

Thank you Metal, When it comes to electronics I can be a bit slow, I can work with them but knowing what goes with what is a problem. so I found this

 

 

https://www.ebay.com/itm/50A-Dual-Channel-H-Bridge-Motor-Driver-Module-for-Arduino-Robot-Chassis-Servo/171442705595?_trkparms=aid%3D555018%26algo%3DPL.SIM%26ao%3D2%26asc%3D52935%26meid%3D29354450210c4969a0057f51dc10dbc0%26pid%3D100005%26rk%3D4%26rkt%3D12%26mehot%3Dpp%26sd%3D152850634270%26itm%3D171442705595&_trksid=p2047675.c100005.m1851

And I have a few MS FFB sticks I can use the motors from one just for testing. My plan is to build a few for some wingmen buddy's and see how that goes, Not many want to spend a thousand bucks or more for a stick.

 

So am I getting close to what I need?

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...