Flight Sim rudder pedals - USB - PIC18F4550

Author
smitthhyy
New Member
  • Total Posts : 7
  • Reward points : 0
  • Joined: 2007/12/06 20:39:37
  • Location: Adelaide, South Australia
  • Status: offline
2008/01/13 02:44:42 (permalink)
0

Flight Sim rudder pedals - USB - PIC18F4550

I am building a set of rudder pedals to use with flight simulator. They have three analog inputs, rudder, left toe brake and right toe brake. I’ve been able to make the rudder work on it’s own but am having difficulty with the toe brakes. If I just do the rudder section it works all the way through to flight simulator. If I try and include Toe Brakes, the first transfer USB setup is zero byte buffer followed by the host sending an ABORT_PIPE (as seen by SnoopyPro).  Really appreciate your guidance.  By the way, chip is PIC18F4550.
/* HID_RPT01_SIZE in usbcfg.h set to 44 byte value */
rom struct{byte report[HID_RPT01_SIZE];}hid_rpt01={
   0x05, 0x01,                    // USAGE_PAGE (Generic Desktop)
   0x15, 0x00,                    // LOGICAL_MINIMUM (0)
               
   0x09, 0x04,                    // USAGE (Joystick)
   0xa1, 0x01,                    // COLLECTION (Application)
 
   0x05, 0x02,                    //   USAGE_PAGE (Simulation Controls)
   0x09, 0xBA,                    //   USAGE (Rudder)
   0x15, 0,                       //   LOGICAL_MINIMUM (0)
   0x25, 255,                     //   LOGICAL_MAXIMUM (255)
   0x75, 0x08,                    //   REPORT_SIZE (8)
   0x95, 0x01,                    //   REPORT_COUNT (1)
   0x81, 0x02,                    //   INPUT (Data,Var,Abs)
 
   0x05, 0x02,                    //   USAGE_PAGE (Simulation Controls)
   0x09, 0xBF,                    //   USAGE (Toe Brake)
   0xa1, 0x00,                    //   COLLECTION (Physical)
   0x09, 0x30,                    //     USAGE (X)
   0x09, 0x31,                    //     USAGE (Y)
   0x15, 0,                       //   LOGICAL_MINIMUM (0)
   0x25, 255,                     //   LOGICAL_MAXIMUM (255)
   0x75, 0x08,                    //   REPORT_SIZE (8)
   0x95, 0x01,                    //   REPORT_COUNT (2)
   0x81, 0x02,                    //   INPUT (Data,Var,Abs)
   0xc0,                          // END_COLLECTION (Collection Physical)
 
 
void Emulate_Rudder(void)
// following variable definitions copied down to here for convenience
// do not uncomment. Must be declared in variables section above.
// byte rudder_pot_value;
// byte left_brake_pot_value;
// byte right_brake_pot_value;
// char buffer[5];
 
// byte0 Rudder
// byte1 Left diff brake
// byte2 Right diff brake
 
{
                if(emulate_mode == TRUE)
                {
                                if (movement_length > 14)
                                {
                                                buffer[0] = rudder_pot_value;
                                                buffer[1] = left_brake_pot_value;
                                                buffer[2] = right_brake_pot_value;
                                               
                                                if (rudder_pot_value > 0xFA)
                                                {
                                                                rudder_pot_value = 0x00;
                                                }
                                                else
                                                {
                                                                rudder_pot_value = rudder_pot_value + 0x02;
                                                }             
                                               
                                                if (left_brake_pot_value > 0xFA)
                                                {
                                                                left_brake_pot_value = 0x00;
                                                }
                                                else
                                                {
                                                                left_brake_pot_value = left_brake_pot_value + 0x03;
                                                }
 
                                                if (right_brake_pot_value > 0xFA)
                                                {
                                                                right_brake_pot_value = 0x00;
                                                }
                                                else
                                                {
                                                                right_brake_pot_value = right_brake_pot_value + 0x04;
                                                }
 
                                                movement_length = 0;
                                }
                }
    else
        buffer[0] = buffer[1] = buffer[2] = 0;
 
    if(!mHIDTxIsBusy())
    {
        HIDTxReport(buffer,3);
        movement_length++;          
                }
}
#1

3 Replies Related Threads

    nsxt
    Super Member
    • Total Posts : 198
    • Reward points : 0
    • Joined: 2006/11/04 21:23:04
    • Location: Albuquerque
    • Status: offline
    RE: Flight Sim rudder pedals - USB - PIC18F4550 2008/01/13 08:39:27 (permalink)
    +1 (1)
    In a few places you have:
     0x25, 255,                     //   LOGICAL_MAXIMUM (255)

    This is not correct. They are SIGNED values, so 1 byte can support a range from 0x80 (-128) to 0x7F (+127).
    try  0x26, 0xFF, 0x00       // Logical maximum 255
    or, you can save a byte:
    0x15, 0x80            ; Logical Minimum (-128)
    0x25, 0x7F             ; Logical Maximum (+127)


    post edited by nsxt - 2008/01/13 08:48:57
    #2
    smitthhyy
    New Member
    • Total Posts : 7
    • Reward points : 0
    • Joined: 2007/12/06 20:39:37
    • Location: Adelaide, South Australia
    • Status: offline
    RE: Flight Sim rudder pedals - USB - PIC18F4550 2008/01/13 13:23:20 (permalink)
    0
    Thanks nsxt. It did not make any difference.

    I suspect something with the Toe Brake section. I don't think it's how to do it with the X and Y, but the USB spec's don't break out to a left and right toe brake in the usage (0x09) section. 
     
    Thanks
    #3
    Jateu
    New Member
    • Total Posts : 1
    • Reward points : 0
    • Joined: 2014/05/11 00:50:34
    • Location: 0
    • Status: offline
    Re: RE: Flight Sim rudder pedals - USB - PIC18F4550 2014/05/11 01:00:57 (permalink)
    0
    I need help with this too smithy. I am having quite a few problems with this. I'm much better at circuit design over programming. Is there anyway I can get a copy of your source code. This is driving me mad lol.

    Many thanks
    #4
    Jump to:
    © 2017 APG vNext Commercial Version 4.5