• AVR Freaks

Helpful ReplyHot!Force Feedback Tutorial: PIC18F4550

Page: < 1234 > Showing page 3 of 4
Author
gpaolo
Starting Member
  • Total Posts : 81
  • Reward points : 0
  • Joined: 2011/02/22 15:43:15
  • Location: 0
  • Status: offline
Re: Force Feedback Tutorial: PIC18F4550 2020/09/24 02:58:39 (permalink)
0
The device is still visible in the hardware list, with the error "unknown element found in the report descriptor":
 

 
 
 
#41
gpaolo
Starting Member
  • Total Posts : 81
  • Reward points : 0
  • Joined: 2011/02/22 15:43:15
  • Location: 0
  • Status: offline
Re: Force Feedback Tutorial: PIC18F4550 2020/09/24 02:59:47 (permalink)
0
And this is the image for the previous post again. Sorry, if I include them in the post I get an error saying that I don't have permission to access the page… only one more to go.

Attached Image(s)

#42
gpaolo
Starting Member
  • Total Posts : 81
  • Reward points : 0
  • Joined: 2011/02/22 15:43:15
  • Location: 0
  • Status: offline
Re: Force Feedback Tutorial: PIC18F4550 2020/09/24 03:00:18 (permalink)
0
Looking into the details, it says "invalid instruction. It has been attempted to execute an invalid instruction":
 

 
 
The other information look correct. I can see the string with your name in the details, so the initialisation seems to have been done properly.
It seems that there is a problem with the descriptor, what do you think?
 
#43
gpaolo
Starting Member
  • Total Posts : 81
  • Reward points : 0
  • Joined: 2011/02/22 15:43:15
  • Location: 0
  • Status: offline
Re: Force Feedback Tutorial: PIC18F4550 2020/09/24 03:01:06 (permalink)
0
and last image. I hope I don't have to do it again… 

Attached Image(s)

#44
Coman
Senior Member
  • Total Posts : 44
  • Reward points : 0
  • Joined: 2016/11/06 14:56:29
  • Location: 0
  • Status: offline
Re: Force Feedback Tutorial: PIC18F4550 2020/09/24 09:08:27 (permalink)
+1 (1)
You must make sure the joystick data structure is the same as in the 18f4550 version ( the data you send must match the report descriptor ). This is for the input part.

The error you get it might be the fact that windows tries to create some ffb effects to witch you are not yet responding.

I tried it on windows 7 and 10 ( 64 bit) and it didn't show that error.
#45
gpaolo
Starting Member
  • Total Posts : 81
  • Reward points : 0
  • Joined: 2011/02/22 15:43:15
  • Location: 0
  • Status: offline
Re: Force Feedback Tutorial: PIC18F4550 2020/09/24 09:21:26 (permalink)
0
Do you mean the descriptor defined in usb_descript.c:
 
ROM struct{BYTE report[HID_RPT01_SIZE];}hid_rpt01={{

 0x05,0x01, // Usage Page Generic Desktop
 0x09,0x04, // Usage Joystick
 0xA1,0x01, // Collection Application
    0x85,0x01, // Report ID 1
   0x05,0x09, // [0x03]USAGE PAGE (BUTTON)
   0x19,0x01, // [0x04]USAGE_MINIMUM(BUTTON 1)
   0x29,0x10, // [0x05]USAGE_MAXIMUM(BUTTON 16)
   0x15,0x00, // [0x06]LOGICAL_MINIMUM
   0x25,0x01, // [0x07]LOGICAL_MAXIMUM
   0x35,0x00, // [0x08]PHYSICAL_MINIMUM
   0x45,0x01, // [0x09]PHYSICAL_MAXIMUM
   0x75,0x01, // [0x0A]REPORT_SIZE
   0x95,0x10, // [0x0B]REPORT_COUNT
   0x81,0x02, // [0x0C]INPUT
   0x05,0x01, // [0x0D]USAGE PAGE (GENERIC DESKTOP CONTROLS)
   0x09,0x39, // [0x0E]USAGE(HAT_SWITCH)
    0x15,0x00, // [0x0F]LOGICAL_MINIMUM
    0x25,0x07, // [0x10]LOGICAL_MAXIMUM
    0x35,0x00, // [0x11]PHYSICAL_MINIMUM
    0x46,0x3B,0x01, // [0x12]PHYSICAL_MAXIMUM
    0x65,0x14, // [0x13]UNIT
    0x75,0x04, // [0x14]REPORT_SIZE
    0x95,0x01, // [0x15]REPORT_COUNT
   0x81,0x42, // [0x16]INPUT
    0x65,0x00, // [0x17]UNIT
    0x95,0x01, // [0x18]REPORT_COUNT
   0x81,0x01, // [0x19]INPUT
   0x09,0x30, // [0x1A]USAGE(X)
   0x09,0x31, // [0x1B]USAGE(Y)
   0x09,0x32, // [0x1C]USAGE(Z)
   0x09,0x33, // [0x1D]USAGE(Rx)
    0x15,0x00, // [0x1E]LOGICAL_MINIMUM
    0x26,0x00,0x04, // [0x1F]LOGICAL_MAXIMUM
    0x35,0x00, // [0x20]PHYSICAL_MINIMUM
    0x46,0x00,0x04, // [0x21]PHYSICAL_MAXIMUM
    0x75,0x10, // [0x22]REPORT_SIZE
    0x95,0x04, // [0x23]REPORT_COUNT
   0x81,0x02, // [0x24]INPUT
    

 
 /*
  Input
  Collection Datalink (sub-collection)
  Physical Interface (Usage: PID State report)
  ID: 2
  state report: 5X1bit
  Padding: 3bit
  PID Device Control: 1bit
  Effect Block Index: 7bit
 */



    0x05,0x0F, // Usage Page Physical Interface
    0x09,0x92, // Usage PID State report
     0xA1,0x02, // Collection Datalink (logical)
 
        0x85,0x02, // Report ID 2
        0x09,0x9F, // Usage Device is Pause
        0x09,0xA0, // Usage Actuators Enabled
        0x09,0xA4, // Usage Safety Switch
        0x09,0xA5, // Usage Actuator Override Switch
        0x09,0xA6, // Usage Actuator Power
        0x15,0x00, // Logical Minimum 0
        0x25,0x01, // Logical Maximum 1
        0x35,0x00, // Physical Minimum 0
        0x45,0x01, // Physical Maximum 1
        0x75,0x01, // Report Size 1
        0x95,0x05, // Report Count 5
        0x81,0x02, // Input (Variable)
        0x95,0x03, // Report Count 3
        0x81,0x03, // Input (Constant, Variable)
 
 
        0x09,0x94, // Usage Effect Playing
        0x15,0x00, // Logical Minimum 0
        0x25,0x01, // Logical Maximum 1
        0x35,0x00, // Physical Minimum 0
        0x45,0x01, // Physical Maximum 1
        0x75,0x01, // Report Size 1
        0x95,0x01, // Report Count 1
        0x81,0x02, // Input (Variable)
        0x09,0x22, // Usage Effect Block Index
        0x15,0x01, // Logical Minimum 1
        0x25,0x28, // Logical Maximum 28h (40d)
        0x35,0x01, // Physical Minimum 1
        0x45,0x28, // Physical Maximum 28h (40d)
        0x75,0x07, // Report Size 7
        0x95,0x01, // Report Count 1
        0x81,0x02, // Input (Variable)
     0xC0 , // End Collection
 
 /*
  Output
  Collection Datalink:
  Usage Set Effect Report
  
  ID:1
  Effect Block Index: 8bit
  
  subcollection Effect Type
  12 effect types, 8bit each

 */
    0x09,0x21, // Usage Set Effect Report
    0xA1,0x02, // Collection Datalink (Logical)
       0x85,0x03, // Report ID 3
  
         0x09,0x22, // Usage Effect Block Index
         0x15,0x01, // Logical Minimum 1
         0x25,0x28, // Logical Maximum 28h (40d)
         0x35,0x01, // Physical Minimum 1
         0x45,0x28, // Physical Maximum 28h (40d)
         0x75,0x08, // Report Size 8
         0x95,0x01, // Report Count 1
         0x91,0x02, // Output (Variable)
  
         0x09,0x25, // Usage Effect Type
         0xA1,0x02, // Collection Datalink
            0x09,0x26, // Usage ET Constant Force
            0x09,0x27, // Usage ET Ramp
            0x09,0x30, // Usage ET Square
            0x09,0x31, // Usage ET Sine
            0x09,0x32, // Usage ET Triangle
            0x09,0x33, // Usage ET Sawtooth Up
            0x09,0x34, // Usage ET Sawtooth Down
            0x09,0x40, // Usage ET Spring
            0x09,0x41, // Usage ET Damper
            0x09,0x42, // Usage ET Inertia
            0x09,0x43, // Usage ET Friction
            0x09,0x28, // Usage ET Custom Force Data
            0x25,0x0C, // Logical Maximum Ch (12d)
            0x15,0x01, // Logical Minimum 1
            0x35,0x01, // Physical Minimum 1
            0x45,0x0C, // Physical Maximum Ch (12d)
            0x75,0x08, // Report Size 8
            0x95,0x01, // Report Count 1
            0x91,0x00, // Output
  
         0xC0 , // End Collection

       0x09,0x50, // Usage Duration
       0x09,0x54, // Usage Trigger Repeat Interval
       0x09,0x51, // Usage Sample Period
       0x15,0x00, // Logical Minimum 0
       0x26,0xFF,0x7F, // Logical Maximum 7FFFh (32767d)
       0x35,0x00, // Physical Minimum 0
       0x46,0xFF,0x7F, // Physical Maximum 7FFFh (32767d)
       0x66,0x03,0x10, // Unit 1003h (4099d)
       0x55,0xFD, // Unit Exponent FDh (253d)
       0x75,0x10, // Report Size 10h (16d)
       0x95,0x03, // Report Count 3
       0x91,0x02, // Output (Variable)

       0x55,0x00, // Unit Exponent 0
       0x66,0x00,0x00, // Unit 0
       0x09,0x52, // Usage Gain
       0x15,0x00, // Logical Minimum 0
       0x26,0xFF,0x00, // Logical Maximum FFh (255d)
       0x35,0x00, // Physical Minimum 0
       0x46,0x10,0x27, // Physical Maximum 2710h (10000d)
       0x75,0x08, // Report Size 8
       0x95,0x01, // Report Count 1
       0x91,0x02, // Output (Variable)

       0x09,0x53, // Usage Trigger Button
       0x15,0x01, // Logical Minimum 1
       0x25,0x08, // Logical Maximum 8
       0x35,0x01, // Physical Minimum 1
       0x45,0x08, // Physical Maximum 8
       0x75,0x08, // Report Size 8
       0x95,0x01, // Report Count 1
       0x91,0x02, // Output (Variable)

         0x09,0x55, // Usage Axes Enable
         0xA1,0x02, // Collection Datalink
            0x05,0x01, // Usage Page Generic Desktop
            0x09,0x30, // Usage X
            0x09,0x31, // Usage Y
            0x15,0x00, // Logical Minimum 0
            0x25,0x01, // Logical Maximum 1
            0x75,0x01, // Report Size 1
            0x95,0x02, // Report Count 2
            0x91,0x02, // Output (Variable)
         0xC0 , // End Collection

       0x05,0x0F, // Usage Page Physical Interface
       0x09,0x57, // Usage Direction Enable
       0x95,0x01, // Report Count 1
       0x91,0x02, // Output (Variable)

       0x95,0x05, // Report Count 5
       0x91,0x03, // Output (Constant, Variable)

         0x09,0x57, // Usage Direction
         0xA1,0x02, // Collection Datalink
            0x0B,0x01,0x00,0x0A,0x00, // Usage Ordinals: Instance 1
            0x0B,0x02,0x00,0x0A,0x00, // Usage Ordinals: Instance 2
            0x66,0x14,0x00, // Unit 14h (20d)
            0x55,0xFE, // Unit Exponent FEh (254d)
            0x15,0x00, // Logical Minimum 0
            0x26,0xFF,0x00, // Logical Maximum FFh (255d)
            0x35,0x00, // Physical Minimum 0
            0x47,0xA0,0x8C,0x00,0x00, // Physical Maximum 8CA0h (36000d)
            0x66,0x00,0x00, // Unit 0
            0x75,0x08, // Report Size 8
            0x95,0x02, // Report Count 2
            0x91,0x02, // Output (Variable)
            0x55,0x00, // Unit Exponent 0
            0x66,0x00,0x00, // Unit 0
         0xC0 , // End Collection

       0x05,0x0F, // Usage Page Physical Interface
       0x09,0xA7, // Usage Undefined
       0x66,0x03,0x10, // Unit 1003h (4099d)
       0x55,0xFD, // Unit Exponent FDh (253d)
       0x15,0x00, // Logical Minimum 0
       0x26,0xFF,0x7F, // Logical Maximum 7FFFh (32767d)
       0x35,0x00, // Physical Minimum 0
       0x46,0xFF,0x7F, // Physical Maximum 7FFFh (32767d)
       0x75,0x10, // Report Size 10h (16d)
       0x95,0x01, // Report Count 1
       0x91,0x02, // Output (Variable)
       0x66,0x00,0x00, // Unit 0
       0x55,0x00, // Unit Exponent 0
    0xC0 , // End Collection/ Usage Set Effect Report

    0x05,0x0F, // Usage Page Physical Interface
    0x09,0x5A, // Usage Set Envelope Report
    0xA1,0x02, // Collection Datalink

       0x85,0x04, // Report ID 0x04 Usage Set Envelope Report

       0x09,0x22, // Usage Effect Block Index
       0x15,0x01, // Logical Minimum 1
       0x25,0x28, // Logical Maximum 28h (40d)
       0x35,0x01, // Physical Minimum 1
       0x45,0x28, // Physical Maximum 28h (40d)
       0x75,0x08, // Report Size 8
       0x95,0x01, // Report Count 1
       0x91,0x02, // Output (Variable)
       0x09,0x5B, // Usage Attack Level
       0x09,0x5D, // Usage Fade Level
       0x15,0x00, // Logical Minimum 0
       0x26,0xFF,0x00, // Logical Maximum FFh (255d)
       0x35,0x00, // Physical Minimum 0
       0x46,0x10,0x27, // Physical Maximum 2710h (10000d)
       0x95,0x02, // Report Count 2
       0x91,0x02, // Output (Variable)
       0x09,0x5C, // Usage Attack Time
       0x09,0x5E, // Usage Fade Time
       0x66,0x03,0x10, // Unit 1003h (4099d)
       0x55,0xFD, // Unit Exponent FDh (253d)
       0x26,0xFF,0x7F, // Logical Maximum 7FFFh (32767d)
       0x46,0xFF,0x7F, // Physical Maximum 7FFFh (32767d)
       0x75,0x10, // Report Size 10h (16d)
       0x91,0x02, // Output (Variable)
       0x45,0x00, // Physical Maximum 0
       0x66,0x00,0x00, // Unit 0
       0x55,0x00, // Unit Exponent 0
    0xC0 , // End Collection

    0x09,0x5F, // Usage Set Condition Report
    0xA1,0x02, // Collection Datalink
          0x85,0x05, // Report ID 5
          0x09,0x22, // Usage Effect Block Index
          0x15,0x01, // Logical Minimum 1
          0x25,0x28, // Logical Maximum 28h (40d)
          0x35,0x01, // Physical Minimum 1
          0x45,0x28, // Physical Maximum 28h (40d)
          0x75,0x08, // Report Size 8
          0x95,0x01, // Report Count 1
          0x91,0x02, // Output (Variable)
          0x09,0x23, // Usage Parameter Block Offset
          0x15,0x00, // Logical Minimum 0
          0x25,0x01, // Logical Maximum 1
          0x35,0x00, // Physical Minimum 0
          0x45,0x01, // Physical Maximum 1
          0x75,0x04, // Report Size 4
          0x95,0x01, // Report Count 1
          0x91,0x02, // Output (Variable)
       0x09,0x58, // Usage Type Specific Block Off...
          0xA1,0x02, // Collection Datalink
            0x0B,0x01,0x00,0x0A,0x00, // Usage Ordinals: Instance 1
            0x0B,0x02,0x00,0x0A,0x00, // Usage Ordinals: Instance 2
            0x75,0x02, // Report Size 2
            0x95,0x02, // Report Count 2
            0x91,0x02, // Output (Variable)
    0xC0 , // End Collection
        0x15,0x80, // Logical Minimum 80h (-128d)
        0x25,0x7F, // Logical Maximum 7Fh (127d)
        0x36,0xF0,0xD8, // Physical Minimum D8F0h (-10000d)
        0x46,0x10,0x27, // Physical Maximum 2710h (10000d)
        0x09,0x60, // Usage CP Offset
        0x75,0x08, // Report Size 8
        0x95,0x01, // Report Count 1
        0x91,0x02, // Output (Variable)
        0x36,0xF0,0xD8, // Physical Minimum D8F0h (-10000d)
        0x46,0x10,0x27, // Physical Maximum 2710h (10000d)
        0x09,0x61, // Usage Positive Coefficient
        0x09,0x62, // Usage Negative Coefficient
        0x95,0x02, // Report Count 2
        0x91,0x02, // Output (Variable)
        0x15,0x00, // Logical Minimum 0
        0x26,0xFF,0x00, // Logical Maximum FFh (255d)
        0x35,0x00, // Physical Minimum 0
        0x46,0x10,0x27, // Physical Maximum 2710h (10000d)
        0x09,0x63, // Usage Positive Saturation
        0x09,0x64, // Usage Negative Saturation
        0x75,0x08, // Report Size 8
        0x95,0x02, // Report Count 2
        0x91,0x02, // Output (Variable)
        0x09,0x65, // Usage Dead Band
        0x46,0x10,0x27, // Physical Maximum 2710h (10000d)
        0x95,0x01, // Report Count 1
        0x91,0x02, // Output (Variable)
    0xC0 , // End Collection


    0x09,0x6E, // Usage Set Periodic Report
    0xA1,0x02, // Collection Datalink
       0x85,0x06, // Report ID 6
       0x09,0x22, // Usage Effect Block Index
       0x15,0x01, // Logical Minimum 1
       0x25,0x28, // Logical Maximum 28h (40d)
       0x35,0x01, // Physical Minimum 1
       0x45,0x28, // Physical Maximum 28h (40d)
       0x75,0x08, // Report Size 8
       0x95,0x01, // Report Count 1
       0x91,0x02, // Output (Variable)
       0x09,0x70, // Usage Magnitude
       0x15,0x00, // Logical Minimum 0
       0x26,0xFF,0x00, // Logical Maximum FFh (255d)
       0x35,0x00, // Physical Minimum 0
       0x46,0x10,0x27, // Physical Maximum 2710h (10000d)
       0x75,0x08, // Report Size 8
       0x95,0x01, // Report Count 1
       0x91,0x02, // Output (Variable)
       0x09,0x6F, // Usage Offset
       0x15,0x80, // Logical Minimum 80h (-128d)
       0x25,0x7F, // Logical Maximum 7Fh (127d)
       0x36,0xF0,0xD8, // Physical Minimum D8F0h (-10000d)
       0x46,0x10,0x27, // Physical Maximum 2710h (10000d)
       0x95,0x01, // Report Count 1
       0x91,0x02, // Output (Variable)
       0x09,0x71, // Usage Phase
       0x66,0x14,0x00, // Unit 14h (20d)
       0x55,0xFE, // Unit Exponent FEh (254d)
       0x15,0x00, // Logical Minimum 0
       0x26,0xFF,0x00, // Logical Maximum FFh (255d)
       0x35,0x00, // Physical Minimum 0
       0x47,0xA0,0x8C,0x00,0x00, // Physical Maximum 8CA0h (36000d)
       0x91,0x02, // Output (Variable)
       0x09,0x72, // Usage Period
       0x26,0xFF,0x7F, // Logical Maximum 7FFFh (32767d)
       0x46,0xFF,0x7F, // Physical Maximum 7FFFh (32767d)
       0x66,0x03,0x10, // Unit 1003h (4099d)
       0x55,0xFD, // Unit Exponent FDh (253d)
       0x75,0x10, // Report Size 10h (16d)
       0x95,0x01, // Report Count 1
       0x91,0x02, // Output (Variable)
       0x66,0x00,0x00, // Unit 0
       0x55,0x00, // Unit Exponent 0
    0xC0 , // End Collection


    0x09,0x73, // Usage Set Constant Force Rep...
    0xA1,0x02, // Collection Datalink
       0x85,0x07, // Report ID 7
       0x09,0x22, // Usage Effect Block Index
       0x15,0x01, // Logical Minimum 1
       0x25,0x28, // Logical Maximum 28h (40d)
       0x35,0x01, // Physical Minimum 1
       0x45,0x28, // Physical Maximum 28h (40d)
       0x75,0x08, // Report Size 8
       0x95,0x01, // Report Count 1
       0x91,0x02, // Output (Variable)
       0x09,0x70, // Usage Magnitude
       0x16,0x01,0xFF, // Logical Minimum FF01h (-255d)
       0x26,0xFF,0x00, // Logical Maximum FFh (255d)
       0x36,0xF0,0xD8, // Physical Minimum D8F0h (-10000d)
       0x46,0x10,0x27, // Physical Maximum 2710h (10000d)
       0x75,0x10, // Report Size 10h (16d)
       0x95,0x01, // Report Count 1
       0x91,0x02, // Output (Variable)
    0xC0 , // End Collection


    0x09,0x74, // Usage Set Ramp Force Report
    0xA1,0x02, // Collection Datalink
       0x85,0x08, // Report ID 8
       0x09,0x22, // Usage Effect Block Index
       0x15,0x01, // Logical Minimum 1
       0x25,0x28, // Logical Maximum 28h (40d)
       0x35,0x01, // Physical Minimum 1
       0x45,0x28, // Physical Maximum 28h (40d)
       0x75,0x08, // Report Size 8
       0x95,0x01, // Report Count 1
       0x91,0x02, // Output (Variable)
       0x09,0x75, // Usage Ramp Start
       0x09,0x76, // Usage Ramp End
       0x15,0x80, // Logical Minimum 80h (-128d)
       0x25,0x7F, // Logical Maximum 7Fh (127d)
       0x36,0xF0,0xD8, // Physical Minimum D8F0h (-10000d)
       0x46,0x10,0x27, // Physical Maximum 2710h (10000d)
       0x75,0x08, // Report Size 8
       0x95,0x02, // Report Count 2
       0x91,0x02, // Output (Variable)
    0xC0 , // End Collection


    0x09,0x68, // Usage Custom Force Report
    0xA1,0x02, // Collection Datalink
       0x85,0x09, // Report ID 9
       0x09,0x22, // Usage Effect Block Index
       0x15,0x01, // Logical Minimum 1
       0x25,0x28, // Logical Maximum 28h (40d)
       0x35,0x01, // Physical Minimum 1
       0x45,0x28, // Physical Maximum 28h (40d)
       0x75,0x08, // Report Size 8
       0x95,0x01, // Report Count 1
       0x91,0x02, // Output (Variable)
       0x09,0x6C, // Usage Custom Force Data Offset
       0x15,0x00, // Logical Minimum 0
       0x26,0x10,0x27, // Logical Maximum 2710h (10000d)
       0x35,0x00, // Physical Minimum 0
       0x46,0x10,0x27, // Physical Maximum 2710h (10000d)
       0x75,0x10, // Report Size 10h (16d)
       0x95,0x01, // Report Count 1
       0x91,0x02, // Output (Variable)
       0x09,0x69, // Usage Custom Force Data
       0x15,0x81, // Logical Minimum 81h (-127d)
       0x25,0x7F, // Logical Maximum 7Fh (127d)
       0x35,0x00, // Physical Minimum 0
       0x46,0xFF,0x00, // Physical Maximum FFh (255d)
       0x75,0x08, // Report Size 8
       0x95,0x0C, // Report Count Ch (12d)
       0x92,0x02,0x01, // Output (Variable, Buffered)
    0xC0 , // End Collection


    0x09,0x66, // Usage Download Force Sample
    0xA1,0x02, // Collection Datalink
       0x85,0x0A, // Report ID 10
       0x05,0x01, // Usage Page Generic Desktop
       0x09,0x30, // Usage X
       0x09,0x31, // Usage Y
       0x15,0x81, // Logical Minimum 81h (-127d)
       0x25,0x7F, // Logical Maximum 7Fh (127d)
       0x35,0x00, // Physical Minimum 0
       0x46,0xFF,0x00, // Physical Maximum FFh (255d)
       0x75,0x08, // Report Size 8
       0x95,0x02, // Report Count 2
       0x91,0x02, // Output (Variable)
    0xC0 , // End Collection


    0x05,0x0F, // Usage Page Physical Interface
    0x09,0x77, // Usage Effect Operation Report
    0xA1,0x02, // Collection Datalink
       0x85,0x0B, // Report ID 11
       0x09,0x22, // Usage Effect Block Index
       0x15,0x01, // Logical Minimum 1
       0x25,0x28, // Logical Maximum 28h (40d)
       0x35,0x01, // Physical Minimum 1
       0x45,0x28, // Physical Maximum 28h (40d)
       0x75,0x08, // Report Size 8
       0x95,0x01, // Report Count 1
       0x91,0x02, // Output (Variable)
       0x09,0x78, // Usage Effect Operation
       0xA1,0x02, // Collection Datalink
          0x09,0x79, // Usage Op Effect Start
          0x09,0x7A, // Usage Op Effect Start Solo
          0x09,0x7B, // Usage Op Effect Stop
          0x15,0x01, // Logical Minimum 1
          0x25,0x03, // Logical Maximum 3
          0x75,0x08, // Report Size 8
          0x95,0x01, // Report Count 1
          0x91,0x00, // Output
       0xC0 , // End Collection


       0x09,0x7C, // Usage Loop Count
       0x15,0x00, // Logical Minimum 0
       0x26,0xFF,0x00, // Logical Maximum FFh (255d)
       0x35,0x00, // Physical Minimum 0
       0x46,0xFF,0x00, // Physical Maximum FFh (255d)
       0x91,0x02, // Output (Variable)
    0xC0 , // End Collection


    0x09,0x90, // Usage PID Block Free Report
    0xA1,0x02, // Collection Datalink
       0x85,0x0C, // Report ID 11
       0x09,0x22, // Usage Effect Block Index
       0x25,0x28, // Logical Maximum 28h (40d)
       0x15,0x01, // Logical Minimum 1
       0x35,0x01, // Physical Minimum 1
       0x45,0x28, // Physical Maximum 28h (40d)
       0x75,0x08, // Report Size 8
       0x95,0x01, // Report Count 1
       0x91,0x02, // Output (Variable)
    0xC0 , // End Collection


    0x09,0x96, // Usage PID Device Control
    0xA1,0x02, // Collection Datalink
       0x85,0x0D, // Report ID 13 // ok, i get this on HID EP 1 after the PID POOL REPORT
       0x09,0x97, // Usage DC Enable Actuators
       0x09,0x98, // Usage DC Disable Actuators
       0x09,0x99, // Usage DC Stop All Effects
       0x09,0x9A, // Usage DC Device Reset
       0x09,0x9B, // Usage DC Device Pause
       0x09,0x9C, // Usage DC Device Continue
       0x15,0x01, // Logical Minimum 1
       0x25,0x06, // Logical Maximum 6
       0x75,0x08, // Report Size 8
       0x95,0x01, // Report Count 1
       0x91,0x00, // Output
    0xC0 , // End Collection

    0x09,0x7D, // Usage Device Gain Report
    0xA1,0x02, // Collection Datalink
       0x85,0x0E, // Report ID 14
       0x09,0x7E, // Usage Device Gain
       0x15,0x00, // Logical Minimum 0
       0x26,0xFF,0x00, // Logical Maximum FFh (255d)
       0x35,0x00, // Physical Minimum 0
       0x46,0xFF,0x00, // Physical Maximum 255
       0x75,0x08, // Report Size 8
       0x95,0x01, // Report Count 1
       0x91,0x02, // Output (Variable)
    0xC0 , // End Collection


    0x09,0x6B, // Usage Set Custom Force Report
    0xA1,0x02, // Collection Datalink
       0x85,0x0F, // Report ID 15
       0x09,0x22, // Usage Effect Block Index
       0x15,0x01, // Logical Minimum 1
       0x25,0x28, // Logical Maximum 28h (40d)
       0x35,0x01, // Physical Minimum 1
       0x45,0x28, // Physical Maximum 28h (40d)
       0x75,0x08, // Report Size 8
       0x95,0x01, // Report Count 1
       0x91,0x02, // Output (Variable)
       0x09,0x6D, // Usage Sample Count
       0x15,0x00, // Logical Minimum 0
       0x26,0xFF,0x00, // Logical Maximum FFh (255d)
       0x35,0x00, // Physical Minimum 0
       0x46,0xFF,0x00, // Physical Maximum FFh (255d)
       0x75,0x08, // Report Size 8
       0x95,0x01, // Report Count 1
       0x91,0x02, // Output (Variable)
       0x09,0x51, // Usage Sample Period
       0x66,0x03,0x10, // Unit 1003h (4099d)
       0x55,0xFD, // Unit Exponent FDh (253d)
       0x15,0x00, // Logical Minimum 0
       0x26,0xFF,0x7F, // Logical Maximum 7FFFh (32767d)
       0x35,0x00, // Physical Minimum 0
       0x46,0xFF,0x7F, // Physical Maximum 7FFFh (32767d)
       0x75,0x10, // Report Size 10h (16d)
       0x95,0x01, // Report Count 1
       0x91,0x02, // Output (Variable)
       0x55,0x00, // Unit Exponent 0
       0x66,0x00,0x00, // Unit 0
    0xC0 , // End Collection


    0x09,0xAB, // Usage Create New Effect Report
    0xA1,0x02, // Collection Datalink
       0x85,0x10, // Report ID 16
       0x09,0x25, // Usage Effect Type
       0xA1,0x02, // Collection Datalink
       0x09,0x26, // Usage ET Constant Force
       0x09,0x27, // Usage ET Ramp
       0x09,0x30, // Usage ET Square
       0x09,0x31, // Usage ET Sine
       0x09,0x32, // Usage ET Triangle
       0x09,0x33, // Usage ET Sawtooth Up
       0x09,0x34, // Usage ET Sawtooth Down
       0x09,0x40, // Usage ET Spring
       0x09,0x41, // Usage ET Damper
       0x09,0x42, // Usage ET Inertia
       0x09,0x43, // Usage ET Friction
       0x09,0x28, // Usage ET Custom Force Data
       0x25,0x0C, // Logical Maximum Ch (12d)
       0x15,0x01, // Logical Minimum 1
       0x35,0x01, // Physical Minimum 1
       0x45,0x0C, // Physical Maximum Ch (12d)
       0x75,0x08, // Report Size 8
       0x95,0x01, // Report Count 1
       0xB1,0x00, // Feature
    0xC0 , // End Collection


    0x05,0x01, // Usage Page Generic Desktop
    0x09,0x3B, // Usage Reserved
    0x15,0x00, // Logical Minimum 0
    0x26,0xFF,0x01, // Logical Maximum 1FFh (511d)
    0x35,0x00, // Physical Minimum 0
    0x46,0xFF,0x01, // Physical Maximum 1FFh (511d)
    0x75,0x0A, // Report Size Ah (10d)
    0x95,0x01, // Report Count 1
    0xB1,0x02, // Feature (Variable)
    0x75,0x06, // Report Size 6
    0xB1,0x01, // Feature (Constant)
 0xC0 , // End Collection


 0x05,0x0F, // Usage Page Physical Interface
 0x09,0x89, // Usage PID Block Load Status
 0xA1,0x02, // Collection Datalink
    0x85,0x11, // Report ID 17
    0x09,0x22, // Usage Effect Block Index
    0x25,0x28, // Logical Maximum 28h (40d)
    0x15,0x01, // Logical Minimum 1
    0x35,0x01, // Physical Minimum 1
    0x45,0x28, // Physical Maximum 28h (40d)
    0x75,0x08, // Report Size 8
    0x95,0x01, // Report Count 1
    0xB1,0x02, // Feature (Variable)
    0x09,0x8B, // Usage Block Load Status
    0xA1,0x02, // Collection Datalink
       0x09,0x8C, // Usage Block Load Success
       0x09,0x8D, // Usage Block Load Full
       0x09,0x8E, // Usage Block Load Error
       0x25,0x03, // Logical Maximum 3
       0x15,0x01, // Logical Minimum 1
       0x35,0x01, // Physical Minimum 1
       0x45,0x03, // Physical Maximum 3
       0x75,0x08, // Report Size 8
       0x95,0x01, // Report Count 1
       0xB1,0x00, // Feature
  /*
  FIELD ADDED
  */
  0x09,0xAC, // [0x19]USAGE(RAM POOL AVAILABLE)
  0x15,0x00, // [0x1A]LOGICAL_MINIMUM
  0x26,0x96,0x00, // [0x1B]LOGICAL_MAXIMUM
  0x75,0x08, // [0x1C]REPORT_SIZE
  0x95,0x01, // [0x1D]REPORT_COUNT
        0xB1,0x02, // Feature (Variable)
    0xC0 , // End Collection

/*
    0x09,0xAC, // Usage Undefined
    0x15,0x00, // Logical Minimum 0
    0x27,0xFF,0xFF,0x00,0x00, // Logical Maximum FFFFh (65535d)
    0x35,0x00, // Physical Minimum 0
    0x47,0xFF,0xFF,0x00,0x00, // Physical Maximum FFFFh (65535d)
    0x75,0x10, // Report Size 10h (16d)
    0x95,0x01, // Report Count 1
    0xB1,0x00, // Feature
*/
 0xC0 , // End Collection


 0x09,0x7F, // Usage PID Pool Report
 0xA1,0x02, // Collection Datalink
    0x85,0x22, // Report ID 17
    0x09,0x80, // Usage RAM Pool size
    0x75,0x08, // Report Size 8
    0x95,0x01, // Report Count 1
    0x15,0x00, // Logical Minimum 0
    0x35,0x00, // Physical Minimum 0
//-4 byte
    0x26,0x96,0x00, // Logical Maximum FFFFh (65535d)
    0x46,0x96,0x00, // Physical Maximum FFFFh (65535d)
    0xB1,0x02, // Feature (Variable)

/*
+13 bytes
ADDING ROM SIZE 0
*/
 0x09,0x81, // [0x0B]USAGE(ROM POOL SIZE)
 0x75,0x08, // [0x0F]REPORT_SIZE
 0x15,0x00, // [0x0C]LOGICAL_MINIMUM
 0x26,0x96,0x00, // [0x0D]LOGICAL_MAXIMUM 150
 0x95,0x01, // [0x0E]REPORT_COUNT
    0xB1,0x02, // Feature (Variable)
//+13
//-------------------------------end adding rom size
 0x09,0x82, // [0x13]USAGE(ROM EFFECT BLOCK COUNT)
 0x75,0x08, // [0x14]REPORT_SIZE 8
 0x95,0x01, // [0x17]REPORT_COUNT 1
 0x15,0x00, // [0x15]LOGICAL_MINIMUM 0
 0x26,0x96,0x00, // [0x16]LOGICAL_MAXIMUM 150
 0xB1,0x02, // [0x18]FEATURE (Variable)

//13+13-4=+22
//-------------------------------end adding rom effect block count
    0x09,0x83, // Usage Simultaneous Effects Max
    0x26,0xFF,0x00, // Logical Maximum FFh (255d)
    0x46,0xFF,0x00, // Physical Maximum FFh (255d)
    0x75,0x08, // Report Size 8
    0x95,0x01, // Report Count 1
    0xB1,0x02, // Feature (Variable)

    0x09,0xA9, // Usage Device Managed Pool
    0x09,0xAA, // Usage Shared Parameter Blocks
    0x75,0x01, // Report Size 1
    0x95,0x02, // Report Count 2
    0x15,0x00, // Logical Minimum 0
    0x25,0x01, // Logical Maximum 1
    0x35,0x00, // Physical Minimum 0
    0x45,0x01, // Physical Maximum 1
    0xB1,0x02, // Feature (Variable)
    0x75,0x06, // Report Size 6
    0x95,0x01, // Report Count 1

    0xB1,0x03, // Feature (Constant, Variable)
    0xC0, // End Collection
 0xC0 // End Collection
 
}
};

 
For what I could check, the data received on the PC matches this descriptor, apart from 6 extra 0x00 at the end that I was mentioning in a previous post. I am not sure if this is some sort of EOP of the usb protocol that you see in the raw data or is some error.
But I had to increase the size of this descriptor, in your instructions -and in the code- it was defined as 0x4FA, but I was getting errors during compiling saying that the last bytes were longer than the memory assigned, so I increased it up to 0x50D when the compiler stopped giving the warning. 
 
I don't think Windows reaches the point of recognising completely the device yet. I have tried the tester program you mentioned for the joystick but it just says that there are no FFB devices installed in the system and exit.
 
Well, I'll keep investigating. If you have any idea, I will be happy to hear it. Thanks in the meanwhile :)
#46
Coman
Senior Member
  • Total Posts : 44
  • Reward points : 0
  • Joined: 2016/11/06 14:56:29
  • Location: 0
  • Status: offline
Re: Force Feedback Tutorial: PIC18F4550 2020/09/24 11:08:14 (permalink)
0
The report descriptor size must be exact.
in : usb_config.h
#define HID_RPT01_SIZE 0x507. ( the report descriptor is exactly 0x507 (hexadecimal notation ) bytes long ).
 
If you define that size even 1 byte longer or shorter, it will not work.
because in :usb_function_hid.c
--------------------------------------------------------------
 USBEP0SendROMPtr(
                        (ROM BYTE*)&hid_rpt01,
                        sizeof(hid_rpt01),     //See usbcfg.h
                        USB_EP0_INCLUDE_ZERO);
---------------------------------------------------------------
it will send the data in the report descriptor array, for a length of sizeof(hid_rpt01).
 
Let's say you have a 10 byte descriptor in an 11 byte array.
that function will send all the array to the pc (11 bytes), and the pc doen't know the report descriptor is only 10 bytes instead of 11 bytes long and will do a wrong decoding of the functions defined in the descriptor.
 
What i don't recall now, is if windows, after getting the report descriptor, will ask for the supported effects of the device.
If it does it during enumeration, then that explains why you got that error maybe ( istruzione non valida, si è tentato di eseguire un.istruzione non valida ), because if you don't have the :
                USER_GET_REPORT_HANDLER();
                USER_SET_REPORT_HANDLER()
defined in : usb_function_hid.c and working, it will fail to create the effects on the device ( because the device does not respond or responds negative to the requests ).


 
 
 
#47
Coman
Senior Member
  • Total Posts : 44
  • Reward points : 0
  • Joined: 2016/11/06 14:56:29
  • Location: 0
  • Status: offline
Re: Force Feedback Tutorial: PIC18F4550 2020/09/24 11:09:23 (permalink)
0
i used wireshark to extract the frames, and in there you get the corect size of the data transmitted over the bus, splitted in groups ( data, headers etc ).
 
What i did while building it, was to listen on the usb port with wireshark and see what the pc asked, and what the microcontroller responded, like you are doing.
 
in the report descriptor:
0x85,0x01, // Report ID 1
is built like so :
 0x05,0x09, // [0x03]USAGE PAGE (BUTTON)
   0x19,0x01, // [0x04]USAGE_MINIMUM(BUTTON 1) // numero minimo di pulsanti : 1
   0x29,0x10, // [0x05]USAGE_MAXIMUM(BUTTON 16)// numero massimo di pulsanti 16 ( userà i bit inviati in questi 2 byte per vedere quale pulsante è premuto o meno

   0x15,0x00, // [0x06]LOGICAL_MINIMUM
   0x25,0x01, // [0x07]LOGICAL_MAXIMUM
   0x35,0x00, // [0x08]PHYSICAL_MINIMUM
   0x45,0x01, // [0x09]PHYSICAL_MAXIMUM
// valori minimi e massimi che i pulsanti possono avere ( se hai un asse da 8 bit puoi anche dire 0-100.000 windows scalera i valori
 

   0x75,0x01, // [0x0A]REPORT_SIZE
   0x95,0x10, // [0x0B]REPORT_COUNT
   0x81,0x02, // [0x0C]INPUT  // i dati sono da inviare dal microcontrollore al pc
 
// qui dico che invio report da 1 bit, ne invio 16 (10 =16, 0f =15, ma inviamo 16 pulsanti )
//  quando guarderai i primi byte dei dati in arrivo troverai il report id, poi 2 byte
// totale 3 byte.
 
// ora invio i dati del hat switch
 
 0x05,0x01, // [0x0D]USAGE PAGE (GENERIC DESKTOP CONTROLS)
   0x09,0x39, // [0x0E]USAGE(HAT_SWITCH)
    0x15,0x00, // [0x0F]LOGICAL_MINIMUM
    0x25,0x07, // [0x10]LOGICAL_MAXIMUM
    0x35,0x00, // [0x11]PHYSICAL_MINIMUM
    0x46,0x3B,0x01, // [0x12]PHYSICAL_MAXIMUM
    0x65,0x14, // [0x13]UNIT
    0x75,0x04, // [0x14]REPORT_SIZE
    0x95,0x01, // [0x15]REPORT_COUNT
   0x81,0x42, // [0x16]INPUT
 
// questa volta inviamo un report lungo 4 bit, solo una volta ( count )
 
 0x65,0x00, // [0x17]UNIT
    0x95,0x01, // [0x18]REPORT_COUNT
   0x81,0x01, // [0x19]INPUT
 
// ne inviamo un altro ( report count 1 ). usera  il REPORT_SIZE di prima 4 bit , ed inviamo altri 4 bit , per completare il byte
// questi 4 bit saranno sempre a 0 perché nella struttura del joytick abbiamo messo
/*  struct
        {
            BYTE hat_switch:4; // i quattro bit del hat switch
            BYTE :4;//filler     // i quattro bit per riempire il byte, saranno sempre a 0
        } hat_switch;
*/
// tutti i report devono avere byte interi, non puoi avere un byte e mezzo di dati, per exempio.
 
// poi inviamo i dati degli assi
 
 0x09,0x30, // [0x1A]USAGE(X)
   0x09,0x31, // [0x1B]USAGE(Y)
   0x09,0x32, // [0x1C]USAGE(Z)
   0x09,0x33, // [0x1D]USAGE(Rx)
    0x15,0x00, // [0x1E]LOGICAL_MINIMUM
    0x26,0x00,0x04, // [0x1F]LOGICAL_MAXIMUM
    0x35,0x00, // [0x20]PHYSICAL_MINIMUM
    0x46,0x00,0x04, // [0x21]PHYSICAL_MAXIMUM
// qui definiamo la grandezza (in bit ) dei report degli assi 0x16 = 16 bit = 2 byte ( la numerazione non parte da 0 ma da 1 )
    0x75,0x10, // [0x22]REPORT_SIZE
//qui definiamo il numero dei report ( 4 assi, 4 report count )
    0x95,0x04, // [0x23]REPORT_COUNT
   0x81,0x02, // [0x24]INPUT
--------------------------------------------------------------------------
quindi, per il report 1 ( report ID 1 ) avremmo :
Report ID : 1 Byte
Buttons :    2 Byte
Hat Switch : 1 Byte
4 axis, 2 bytes long : 8 Byte
---------------------------------------------------
Total : 12 bytes
---------------------------------------------------
Data Structure for the joystick :
 
typedef union _JOYSTICK
{
    struct
    {
  struct
        {
         BYTE RID;
        }REPORT_ID;
        struct
        {
            BYTE square:1;
            BYTE x:1;
            BYTE o:1;
            BYTE triangle:1;
            BYTE L1:1;
            BYTE R1:1;
            BYTE L2:1;
            BYTE R2:1;//
            BYTE select:1;
            BYTE start:1;
            BYTE left_stick:1;
            BYTE right_stick:1;
            BYTE home:1;
            BYTE :3; //filler
        } buttons;
        struct
        {
            BYTE hat_switch:4;
            BYTE :4;//filler
        } hat_switch;
        struct
        {
            unsigned short int X;
            unsigned short int Y;
            unsigned short Z;
            unsigned short Rz;
        } analog_stick;
    } members;
   BYTE val[12];
}JOYSTICK_UNION;

 
//    BYTE val[12];  we have a 12 bytes long structure ( it's a union of a struct of structs, and an array of the same size ).
sizeof(JOYSTICK_UNION) will be 12 bytes.
 
 
When you do the debugging process with the packet analizer, keep an eye on the size of data being transmitted .
 
count inside the descriptor, for each REPORT ID, how much data is being sent using
----------------------for input (microcontroller to pc )--------------------------------
 0x75,0x04, // [0x14]REPORT_SIZE
    0x95,0x01, // [0x15]REPORT_COUNT
   0x81,0x42, // [0x16]INPUT
----------------------for output ( pc to microcontroller)--------------------------------
 
 0x75,0x08, // Report Size 8
         0x95,0x01, // Report Count 1
         0x91,0x02, // Output (Variable)
-----------------------------------------------------------------
 
 
for example, report 4 ( REPORT ID 4 ) is an output report ( comes from the pc to the microcontroller )
 
      0x85,0x04, // Report ID 0x04 Usage Set Envelope Report

       0x09,0x22, // Usage Effect Block Index
       0x15,0x01, // Logical Minimum 1
       0x25,0x28, // Logical Maximum 28h (40d)
       0x35,0x01, // Physical Minimum 1
       0x45,0x28, // Physical Maximum 28h (40d)
       0x75,0x08, // Report Size 8
       0x95,0x01, // Report Count 1
       0x91,0x02, // Output (Variable)
       0x09,0x5B, // Usage Attack Level
       0x09,0x5D, // Usage Fade Level
       0x15,0x00, // Logical Minimum 0
       0x26,0xFF,0x00, // Logical Maximum FFh (255d)
       0x35,0x00, // Physical Minimum 0
       0x46,0x10,0x27, // Physical Maximum 2710h (10000d)
       0x95,0x02, // Report Count 2
       0x91,0x02, // Output (Variable)
       0x09,0x5C, // Usage Attack Time
       0x09,0x5E, // Usage Fade Time
       0x66,0x03,0x10, // Unit 1003h (4099d)
       0x55,0xFD, // Unit Exponent FDh (253d)
       0x26,0xFF,0x7F, // Logical Maximum 7FFFh (32767d)
       0x46,0xFF,0x7F, // Physical Maximum 7FFFh (32767d)
       0x75,0x10, // Report Size 10h (16d)
       0x91,0x02, // Output (Variable)
       0x45,0x00, // Physical Maximum 0
       0x66,0x00,0x00, // Unit 0
       0x55,0x00, // Unit Exponent 0
    0xC0 , // End Collection

 
and it's sending
Report ID : 1 byte
Usage Effect Block Index :1 Byte
Usage Attack Level + Fade Level, sent in sequence : 2 Byte ( 1 + 1 )
Usage Attack Time + fade time , sent in sequence : 4 byte ( 2 + 2 )
---------------------------------------------------------------------------------
total report size : 8 bytes
thus when you will receive them, you must remember what each byte means, and the meaning is defined in the report descriptor
post edited by Coman - 2020/09/24 11:42:15
#48
gpaolo
Starting Member
  • Total Posts : 81
  • Reward points : 0
  • Joined: 2011/02/22 15:43:15
  • Location: 0
  • Status: offline
Re: Force Feedback Tutorial: PIC18F4550 2020/09/24 11:24:23 (permalink)
+1 (1)
Ahhh!! It was that! Now it remains connected! How on earth did I came out with 50D? I must have been already quite tired at that point...
 
Now it is seen as "HID compatible game controller", not as a specific FFB device, and ForceTest doens't see it. Maybe some driver issue here. Did you have to install anything particular to see if as a Joystick Demo?
#49
Coman
Senior Member
  • Total Posts : 44
  • Reward points : 0
  • Joined: 2016/11/06 14:56:29
  • Location: 0
  • Status: offline
Re: Force Feedback Tutorial: PIC18F4550 2020/09/24 11:44:52 (permalink)
0
gpaolo
Ahhh!! It was that! Now it remains connected! How on earth did I came out with 50D? I must have been already quite tired at that point...
 
Now it is seen as "HID compatible game controller", not as a specific FFB device, and ForceTest doens't see it. Maybe some driver issue here. Did you have to install anything particular to see if as a Joystick Demo?


No, it is recognized by default as a force feedback device.
Maybe you don't see it in windows settings. But if you try to use ForceTest.exe, or how it's called ( i think there is a link here, it will tell you it's a ffb capable device
 
#50
Coman
Senior Member
  • Total Posts : 44
  • Reward points : 0
  • Joined: 2016/11/06 14:56:29
  • Location: 0
  • Status: offline
Re: Force Feedback Tutorial: PIC18F4550 2020/09/24 11:45:52 (permalink)
0
It will say it's HID in the device manager, because the ForceFeedback ( PID Physical Interface Device ) is actually a subclass of the HID class
#51
Coman
Senior Member
  • Total Posts : 44
  • Reward points : 0
  • Joined: 2016/11/06 14:56:29
  • Location: 0
  • Status: offline
Re: Force Feedback Tutorial: PIC18F4550 2020/09/24 11:47:08 (permalink)
0
What error does ForceTest give ?
Or it does not see it at all ?
#52
gpaolo
Starting Member
  • Total Posts : 81
  • Reward points : 0
  • Joined: 2011/02/22 15:43:15
  • Location: 0
  • Status: offline
Re: Force Feedback Tutorial: PIC18F4550 2020/09/24 11:52:46 (permalink)
0
It's odd. I do see it in the devices as COMAN NUTU V13R, which is you :) , I see it as a compatible game controller under the HID in the device manager, but ForceTest says just "no force feedback joystick detected" and exits. 
Apart from the original 0x04D8/0x005E, I have tried two different PID/VID from another thread:
 
045E / 001B - MS SideWinder FFB2
046D / C281 - Logitech Wingman Force Pro
 
to see if Windows recognise them, every time it says new devide detected, configured and ready to use, but I still see that it records it as generic compatible game controller. 
I am trying also the Joytester.exe that comes with the libraries from Microchip, which was working with the demo joystick, but it seems not to be receiving anything from it. 
 
No, correction. Joytester does see it:
 
Manufacturer ID: 046D
Product ID: C281
Product Name: Microsoft PC-joystick driver
RegKey: DINPUT.DLL
OEMVxD:
X range: 0 to 65535
Y range: 0 to 65535
Z range: 0 to 65535
Number of buttons: 16
Period range: 10 to 1000
R range: 0 to 65535
U range: 0 to 65535
V range: 0 to 65535
Capabilities: 51
   has Z
   has R
   has POV
   has POV 4 dir
Maximum axes: 6
Number of axes: 4
Maximum buttons: 32
 
Those VID/PID are the ones I'm trying now. So it's there.
post edited by gpaolo - 2020/09/24 11:54:48
#53
gpaolo
Starting Member
  • Total Posts : 81
  • Reward points : 0
  • Joined: 2011/02/22 15:43:15
  • Location: 0
  • Status: offline
Re: Force Feedback Tutorial: PIC18F4550 2020/09/24 12:10:43 (permalink)
+1 (1)
So, JoyTester sees it also with your VID/PID and receives the values.
It looks like it's just my Windows not seeing it as FFB device.
#54
Coman
Senior Member
  • Total Posts : 44
  • Reward points : 0
  • Joined: 2016/11/06 14:56:29
  • Location: 0
  • Status: offline
Re: Force Feedback Tutorial: PIC18F4550 2020/09/24 12:11:07 (permalink)
0
( long story short, i managed to burn 5 microcontrollers and the programmer 1 month ago... so i cannot test it now untill i get the new parts )
For what i can remember, forcetest will try to create the effects when it starts ( initialize it )
 
For it ( forcetest ) to recognize the device as a force feedback capable device, you have to write the code for these 2 functions :

USER_GET_REPORT_HANDLER();
USER_SET_REPORT_HANDLER();

and actually respond to the requests that forcetest is sending ( at least with a "no i don't support the effect" )

Those 2 functions are used in :
usb_function_hid.c
function: void USBCheckHIDRequest(void)
***
 switch(SetupPkt.bRequest)
    {
        case GET_REPORT:
            #if defined DEFINE_GET_REPORT_HANDLER
                USER_GET_REPORT_HANDLER();
            #endif
            break;
        case SET_REPORT:
           // #if defined DEFINE_SET_REPORT_HANDLER
    
                       
                USER_SET_REPORT_HANDLER();
            //#endif      
            break;
***
 
because when directX ( forcefeedback is handled by directX ) looks for ffb devices, it will send the reports for the PID part of the report descriptor.
 
Report ID 1 ( with the joystick data ) is only used for input, and it will work, but forcefeedback needs output instructions from the pc.
 
So directX sends reports to the microcontroller to discover if it handles effects, and if so, which ones.
 
get_report_handler, and set_report_handler are coded in :
API.c
 
void USER_GET_REPORT_HANDLER(void)
{

 switch(SetupPkt.W_Value.byte.LB) 
 {
   case 0x11:// REPORT ID  PID_BLOCK_LOAD_STATUS
 switch(SetupPkt.W_Value.byte.HB) // REPORT TYPE
 {
  case 0x01:// INPUT REPORT
  break;
  case 0x02: // OUTPUT, the host wants to send me the data
  break;
  case 0x03:// FEATURE, the host wants ME to send the data
   pid_report[0]=PID_BLOCK_LOAD_REPORT[0]; // PID BLOCK LOAD REPORT ID
   pid_report[1]=PID_BLOCK_LOAD_REPORT[1]; // EFFECT INDEX
   pid_report[2]=PID_BLOCK_LOAD_REPORT[2]; // SUCCESS/FAIL STATUS
   pid_report[3]=PID_BLOCK_LOAD_REPORT[3]; // AVAILABLE RAM
  
   USBDeviceTasks();
   
   USBEP0SendRAMPtr((BYTE*)&pid_report[0], 4, USB_EP0_NO_OPTIONS);     
  break;
 }
    break;
   case 0x22:// REPORT ID  PID_POOL_REPORT
 
 PID_POOL_REPORT[0]=0x22; // report ID
 PID_POOL_REPORT[1]=120;  // RAM POOL SIZE 120
 PID_POOL_REPORT[2]=0;  // ROM POOL SIZE 0
 PID_POOL_REPORT[3]=0;  // ROM EFFECT BLOCK COUNT 0
 PID_POOL_REPORT[4]=2;  //SIMULTANEOUS EFFECT MAX 2
 PID_POOL_REPORT[5]=0b10000000;// DEVICE MANAGED POOL/NO SHARED PARAMETER BLOCKS
 switch(SetupPkt.W_Value.byte.HB) // REPORT TYPE
 {
  case 0x01:// INPUT REPORT
  break;
     case 0x02: // OUTPUT, the host wants to send me the data
  break;
  case 0x03:// FEATURE, the host wants ME to send the data
   //USBEP0SendRAMPtr((BYTE*)&PID_POOL_REPORT, 6, USB_EP0_NO_OPTIONS);
  break;
 }
   break;
 }
 
}
 
 
void USER_SET_REPORT_HANDLER(void)
{
 switch(SetupPkt.W_Value.byte.LB) 
   {
    case 0x10:// REPORT ID 0x10 | Create New Effect Report
     
       switch(SetupPkt.W_Value.byte.HB) // REPORT TYPE
        {
         case 0x01:// INPUT REPORT
         break;
         case 0x02: // OUTPUT, the host wants to send me the data
         break;
         case 0x03:// FEATURE, the host wants ME to send the data
      
       USBEP0Receive((BYTE*)&pid_report[0], SetupPkt.wLength, USBSetEffect);
         break;
        }
    break;
  }
  
}
 
in some previous posts ( at the begining ) i had wrote some code that responded but did nothing, so i kinda tricked forcetest to belive i was accepting the requests.
 
now we have the complete piece, so look on what these 2 functions ( set / get report handler ) do.
You send and receive forcefeedback trough these 2 functions, and also the forcefeedback initialization part.
 
I think the sequence is : pc sends SET_REPORT, so we handle it with this :
 USBEP0Receive((BYTE*)&pid_report[0], SetupPkt.wLength, USBSetEffect);
when the microcontroller receives the data, it will call USBSetEffect() function. That function initializes the effects ( writes some values in the data structures ), then prepares PID_BLOCK_LOAD_REPORT[] vector with the success/failure of creating an effect.
 
PC sends GET_REPORT, almost immediatly after the set effect
you look at : SetupPkt.W_Value.byte.LB ( value of the setup packet ) and if it's :  
case 0x11:// REPORT ID  PID_BLOCK_LOAD_STATUS,
you look at the report type : SetupPkt.W_Value.byte.HB
and if it's : case 0x03:// FEATURE, the host wants ME to send the data
you copy the PID_BLOCK_LOAD_REPORT, that was set  with USBSetEffect()
 
  pid_report[0]=PID_BLOCK_LOAD_REPORT[0]; // PID BLOCK LOAD REPORT ID
   pid_report[1]=PID_BLOCK_LOAD_REPORT[1]; // EFFECT INDEX
   pid_report[2]=PID_BLOCK_LOAD_REPORT[2]; // SUCCESS/FAIL STATUS
   pid_report[3]=PID_BLOCK_LOAD_REPORT[3]; // AVAILABLE RAM
  
   USBDeviceTasks(); // this here is put out of desperation of the firmware blocking itself somehow
   
and you transmit back to the pc the feedback of success / failure to create the effect 
   USBEP0SendRAMPtr((BYTE*)&pid_report[0], 4, USB_EP0_NO_OPTIONS); 
post edited by Coman - 2020/09/24 12:23:57
#55
gpaolo
Starting Member
  • Total Posts : 81
  • Reward points : 0
  • Joined: 2011/02/22 15:43:15
  • Location: 0
  • Status: offline
Re: Force Feedback Tutorial: PIC18F4550 2020/09/24 12:12:27 (permalink)
+1 (1)
Thanks, I will try it as soon as possible and I will let you know!
#56
vtrx
Starting Member
  • Total Posts : 51
  • Reward points : 0
  • Joined: 2013/01/04 17:42:57
  • Location: 0
  • Status: offline
Re: Force Feedback Tutorial: PIC18F4550 2020/09/24 14:23:36 (permalink)
+2 (2)
You may have tried too many times and Windows is not updating the device in its list of drivers.
Change the PID, change a number and Windows will reinstall the driver
post edited by vtrx - 2020/09/24 14:27:42
#57
Coman
Senior Member
  • Total Posts : 44
  • Reward points : 0
  • Joined: 2016/11/06 14:56:29
  • Location: 0
  • Status: offline
Re: Force Feedback Tutorial: PIC18F4550 2020/09/25 11:57:11 (permalink)
+1 (1)
There is one think i'd like to ask from you, gpaolo.
Once you finish the firmware for the 16 bit processor, could you post here a complete version of it ?
( at least up to the point where forceedit will see it as a ffb device ).
 
Per i posteri, signore. Per coloro che in futuro, cercheranno una soluzione.
 
ps: i'm glad mister vtrx is still following the topic :)
#58
Coman
Senior Member
  • Total Posts : 44
  • Reward points : 0
  • Joined: 2016/11/06 14:56:29
  • Location: 0
  • Status: offline
Re: Force Feedback Tutorial: PIC18F4550 2020/09/25 12:27:24 (permalink)
+2 (2)
vtrx
You may have tried too many times and Windows is not updating the device in its list of drivers.
Change the PID, change a number and Windows will reinstall the driver


( tried with windows 7 / 10 64bit )
you do not need a driver for the device.
the standard driver that windows has already built in for joysticks will work, so there is no extra driver to install.
 
Windows communicates with force-feedback capable devices trough DirectX9/10/11/12/etc
I do not know how the actual driver for the usb hid + pid joysticks is built , but i know it's already installed on windows ( even when you make a new installation of the os, it will come already built in )
 
This firmware follows the "rules" of the default force feedback driver in windows os, so there is nothing else to install.
If somebody is curious on how directx handles ffb devices, i suggest you download a windows development kit for visual C++ ( insert newest edition ), and search for directX .h files in there, and look how forcefeedback is handled by the directx library. ( very usefull to see how it's done ).
 
I think extra drivers are needed if you want to filter out the data before sending it to the program that uses it, or if you want to have a window from witch to configure your device ( idk... effects force, deadzones, etc )
 
but ... we have a pic programmer attached to our pc, we just rewrite the firmware :)
#59
Coman
Senior Member
  • Total Posts : 44
  • Reward points : 0
  • Joined: 2016/11/06 14:56:29
  • Location: 0
  • Status: offline
Re: Force Feedback Tutorial: PIC18F4550 2020/09/25 12:34:35 (permalink)
+1 (1)
gpaolo
I do see it in the devices as COMAN NUTU V13R, which is you :)



Please change that setting with your personalized one :). It's a good feeling when you see your own name in the device list :)
 
you do it from here :
 
file : usb_descriptors.c
 
 
//Manufacturer string descriptor
ROM struct{BYTE bLength;BYTE bDscType;WORD string[25];}sd001={
sizeof(sd001),USB_DESCRIPTOR_STRING,
{'I','N','S','E','R','T',' ',' ',' ',' ',
'Y','O','U','R',' ',' ','N','A','M','E',' ','H','E','R','E'
}};

#60
Page: < 1234 > Showing page 3 of 4
Jump to:
© 2020 APG vNext Commercial Version 4.5