How do I interface Arduino UNO with Logitech 3D Pro Extreme Joystick?

I've downloaded both code links you provided. And now its throwing me this error when compiling.


libraries\USB_Host_Shield_2.0-master\usbhid.cpp.o (symbol from plugin): In function `USBHID::GetReportDescr(unsigned int, USBReadParser*)':

(.text+0x0): multiple definition of `USBHID::GetReportDescr(unsigned int, USBReadParser*)'

sketch\usbhid.cpp.o (symbol from plugin):(.text+0x0): first defined here


is there a better folder to place the usb 2.0 file in other than the main library folder?

I had to copy the usbhid.h and usbhid.cpp files into the logitech 3d joystick file so they could find them, and now i get the above error.

Thanks for your generous help, I will pay it forward some day lol

Never mind I figured out the issue...

I deleted the usbhid.h and usbhid.cpp files out of the logitech 3d joystick file.

The issue was with the first rule of downloading arduino library files... I renamed the library folder USB_Host_Shield_2.0-master to USBHostShield2.

it compiled beautifully and uploaded fast to the arduino uno. I set the baud rate on the serial monitor to 115200 and every button prints out a reading!

My project is going to consist of 2X logitech 3d pro joysticks to remote control an excavator.

So my next step will be to send the joystick readings over wifi to the rc motor control.

Do you think it would be possible to stack a second usb host shield and still be able to get accurate readings simultaneously without issue? Or would i need to run a separate arduino and usb host shield?

Stacking probably won't work. I believe the shields interface using SPI, so you could theoretically move the SS (slave select) pin. But you probably would have problems. You could have 2 arduinos both sending data to a central arduino, possibly a Mega (which has multiple serial ports) and then send it to your excavator. Alternatively, you could hack into the joystick and read the internal pots directly. That would require a single Mega and no shield.

Hi Community,

I am also new using arduiono and I would like to control actuators with a joystick.

I have used the code whish was used here too. I have deleted the drift part, because I thought that my problem comes from this, but it seems not. My problem is, as soon as the program is running, I can see on the seriell monitor the following information:

Start
4073954033943993923953913913913873903833893803883763863733853713833683813673783653763643733633703623393353393313403290
960
0
X: 00000 Y: 96003C0 Hat Switch: 707 Twist: 000 Slider: 000 Buttons A: 000 Buttons B: 000
016803383283363283333273303283273293243293213303193303173293153283143273143253143233143203153183163153

From my understanding x,y, Hat Switch, Twist, Slider, Buttons A, Buttons B will change their values when
I use the joystick to give input.

What I dont understand what are the long numbers, e.g. directly under start. I was trying a lot within the last month, but I havent found a solution.

Please, can somebody explain me the numbers?

Many thanks for your support.

-----First Page-----------

/* Simplified Logitech Extreme 3D Pro Joystick Report Parser */

#include <usbhid.h>
#include <hiduniversal.h>
#include <usbhub.h>
#include <Servo.h>

#include "le3dp_rptparser.h"

// Satisfy the IDE, which needs to see the include statment in the ino too.

#ifdef dobogusinclude
#include <spi4teensy3.h>
#include <SPI.h>
#endif
USB Usb;
USBHub Hub(&Usb);
HIDUniversal Hid(&Usb);
JoystickEvents JoyEvents;
JoystickReportParser Joy(&JoyEvents);

// Defines 3 Linear Actuator Pins 9, 10, 11

#define LINEARACTUATORPIN 9 // Linear Actuator Digital Pin 9
#define LINEARACTUATORPIN 10 // Linear Actuator Digital Pin 10
#define LINEARACTUATORPIN 11 // Linear Actuator Digital Pin 11

// Defines 3 Joystick Pins X, Y, T
#define JOY_PIN_X X // Joystick Analog Pin X
#define JOY_PIN_Y Y // Joystick Analog Pin Y
#define JOY_PIN_T T // Joystick Analog Pin T

#define POS_MIN 1050 //Fully retracted
#define POS_MAX 2000 //Fully extended

Servo linearActuator1; //Create servo object to control the linear actuator 1
int X; //Variables to hold the last reading from the analog pins fo the joystick. The value will be between 0 and 1023
Servo linearActuator2; //Create servo object to control the linear actuator 1
int Y; //Variables to hold the last reading from the analog pins fo the joystick. The value will be between 0 and 1023
Servo linearActuator3; //Create servo object to control the linear actuator 1
int T; //Variables to hold the last reading from the analog pins fo the joystick. The value will be between 0 and 1023
int ValueMapped1; //The youstick values will be changed (or mapped)to new values to be set to the linear actuator 1
int ValueMapped2; //The youstick values will be changed (or mapped)to new values to be set to the linear actuator 2
int ValueMapped3; //The youstick values will be changed (or mapped)to new values to be set to the linear actuator 3

int LinearValue = 1500; // Current positional value being sent to the linear actuator. Start at the centered position
int speed = -1; // Alter this value to change the speed of the system. Higher values mean higer speeds

void setup()
{

linearActuator1.attach(9);
linearActuator1.attach(10);
linearActuator1.attach(11);

Serial.begin( 115200 );
#if !defined(MIPSEL)
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
#endif
Serial.println("Start");

if (Usb.Init() == -1)
Serial.println("OSC did not start.");

delay( 200 );

if (!Hid.SetReportParser(0, &Joy))
ErrorMessage<uint8_t>(PSTR("SetReportParser"), 1 );
}

void loop()
{
Usb.Task();

// Initalize servos

linearActuator1.attach(LINEARACTUATORPIN, POS_MIN, POS_MAX); // Attaches/activates the linearactuator on Pin LINEARACTUATORPIN
linearActuator2.attach(LINEARACTUATORPIN, POS_MIN, POS_MAX); // Attaches/activates the linearactuator on Pin LINEARACTUATORPIN
linearActuator3.attach(LINEARACTUATORPIN, POS_MIN, POS_MAX); // Attaches/activates the linearactuator on Pin LINEARACTUATORPIN

// Use the write Microseconds to set the linear actuator to a dafault centered position

linearActuator1.write(LinearValue);
linearActuator2.write(LinearValue);
linearActuator3.write(LinearValue);

/**Actuator 1 Positions/

// Read the values from the joystick

int angle1 = analogRead(JOY_PIN_X);

// Only update if the joystick is outside the deadzone (i.e. moved outside the centre positon)

{
ValueMapped1 = map(angle1, 0, 1023, speed, -speed);

// Map analog value form native joystick value (0 to 1023) to incremental chage (speed to -speed).

LinearValue = LinearValue + ValueMapped1;

//Add mapped joystick value to present value

}

// Use the write Microsecond to set the servos to their new positions

linearActuator1.write(LinearValue);
Serial.print(angle1);
delay(10);

//Waits for the servo to get they're in position before continuing

/**Actuator Positions 2/

// Read the values from the joystick

int angle2 = analogRead(JOY_PIN_Y);

// Only update if the joystick is outside the deadzone (i.e. moved outside the centre positon)

{
ValueMapped2 = map(angle2, 0, 1023, speed, -speed);

// Map analog value form native joystick value (0 to 1023) to incremental chage (speed to -speed).

LinearValue = LinearValue + ValueMapped2;

//Add mapped joystick value to present value

}

// Use the write Microsecond to set the servos to their new positions

linearActuator2.write(LinearValue);
Serial.print(angle2);
delay(10);

//Waits for the servo to get they're in position before continuing

/****************************** Actuator Positions 3 *****************************/

// Read the values from the joystick

int angle3 = analogRead(JOY_PIN_T);

// Only update if the joystick is outside the deadzone (i.e. moved outside the centre positon)

{
ValueMapped3 = map(angle3, 0, 1023, speed, -speed);

// Map analog value form native joystick value (0 to 1023) to incremental chage (speed to -speed).

LinearValue = LinearValue + ValueMapped3;

//Add mapped joystick value to present value

}

// Use the write Microsecond to set the servos to their new positions

linearActuator3.write(LinearValue);
Serial.print(angle3);
delay(10);

//Waits for the servo to get they're in position before continuing

}

-----------------second page ------------------

#include "le3dp_rptparser.h"

JoystickReportParser::JoystickReportParser(JoystickEvents *evt) :
joyEvents(evt)
{}

void JoystickReportParser::Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf)
{
bool match = true;

// Checking if there are changes in report since the method was last called
for (uint8_t i=0; i<RPT_GAMEPAD_LEN; i++)
{
if( buf != oldPad )
* {*
* match = false;*
* break;*
* }*
* }*
* // Calling Game Pad event handler*
* if (!match && joyEvents)*
* {*
_ joyEvents->OnGamePadChanged((const GamePadEventData*)buf);
for (uint8_t i=0; i<RPT_GAMEPAD_LEN; i++) oldPad = buf*;*
* }
}
void JoystickEvents::OnGamePadChanged(const GamePadEventData *evt)
{_

uint16_t myX = evt->x;
_ Serial.println(myX);*_

* uint16_t myY = evt->y;
_ Serial.println(myY);*_

* uint16_t myT = evt->twist;
_ Serial.println(myT);*_

* Serial.print("X: ");*
* Serial.print(evt->x); *
* PrintHex<uint16_t>(evt->x, 0x80);*

* Serial.print(" Y: ");*
* Serial.print(evt->y);*
* PrintHex<uint16_t>(evt->y, 0x80);*

* Serial.print(" Hat Switch: ");*
* Serial.print(evt->hat);*
* PrintHex<uint8_t>(evt->hat, 0x80);*

* Serial.print(" Twist: ");*
* Serial.print(evt->twist);*
* PrintHex<uint8_t>(evt->twist, 0x80);*

* Serial.print(" Slider: ");*
* Serial.print(evt->slider);*
* PrintHex<uint8_t>(evt->slider, 0x80);*

* Serial.print(" Buttons A: ");*
* Serial.print(evt->buttons_a);
PrintHex<uint8_t>(evt->buttons_a, 0x80);*

* Serial.print(" Buttons B: ");*
* Serial.print(evt->buttons_b);
PrintHex<uint8_t>(evt->buttons_b, 0x80);*

* Serial.println("");*
int angle1 = map (myX, 0, 1023, 0, 180);
Serial.print(angle1);
int angle2 = map (myY, 0, 1023, 0, 180);
Serial.print(angle2);
int angle3 = map (myT, 0, 1023, 0, 180);
Serial.print(angle3);
}

#if !defined(HIDJOYSTICKRPTPARSER_H)
#define HIDJOYSTICKRPTPARSER_H

#include <usbhid.h>

struct GamePadEventData
{
union { //axes and hut switch
uint32_t axes;
struct {
uint32_t x : 10;
uint32_t y : 10;
uint32_t hat : 4;
uint32_t twist : 8;
};
};
uint8_t buttons_a;
uint8_t slider;
uint8_t buttons_b;
};

class JoystickEvents
{
public:
virtual void OnGamePadChanged(const GamePadEventData *evt);
};

#define RPT_GAMEPAD_LEN sizeof(GamePadEventData)/sizeof(uint8_t)

class JoystickReportParser : public HIDReportParser
{
JoystickEvents *joyEvents;

uint8_t oldPad[RPT_GAMEPAD_LEN];

public:
JoystickReportParser(JoystickEvents *evt);

virtual void Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf);
};

#endif // HIDJOYSTICKRPTPARSER_H

I forgot to say that I am using the mega and also the numbers under e.g start are running and not stopping. This is te reason why I thought it is from the drift part.

Let me guess: you don't see italic code when you look at that program in the Arduino IDE.

Follow the guidelines in the how-to-use-this-forum post and edit your previous postings to fix the problem. We can't look at damaged, broken code.

What I don`t understand what are the long numbers, e.g. directly under start.

Remove unnecessary Serial.print statements. For example, Serial.print(angle1), Serial.print(angle2), Serial.print(angle3), etc. and see what happens.

How about Long nema 34 steper Motors for x and y axis

Hello guys.

I have followed the code from Yejinda, but why in the serial my monitor looks strange and the servo doesn't move. see the picture Whats-App-Image-2019-03-07-at-07-14-06 hosted at ImgBB — ImgBB

even though the pin is correct