Using SpaceNavigator with Arduino?

Post questions, comments and feedback to our 3Dconnexion Windows Development Team.

Moderator: Moderators

jwick
Moderator
Moderator
Posts: 2714
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Re: Using SpaceNavigator with Arduino?

Post by jwick » Mon Feb 24, 2020 8:13 am

I don't know anything about the CNC-Shield but it sounds like an interesting usage.

IIRC, the problem I had with the UNO was once I attached the USB shield, I ran out of pins to control my motors (too many used by the USB shield). Hopefully using proper shields eliminates that issue.

I would start by using the USB cable rather than complicate things with the wireless receiver.
The wireless receiver and SpaceMouse Wireless need to be paired. They should have been paired at the factory. I'd check them on a PC to make sure they are.

ricard.enquist
Posts: 2
Joined: Tue Sep 01, 2020 12:52 am

Re: Using SpaceNavigator with Arduino?

Post by ricard.enquist » Mon Oct 05, 2020 11:07 pm

I used some code previously posted here (thank you mlkoch and DRogers96) for a project where I control a Mavic Mini using the SpaceMouse and an Arduino. Works like a charm, check it out here: https://forum.3dconnexion.com/viewtopic.php?f=8&t=36183

Tijs
Posts: 6
Joined: Mon Oct 12, 2020 6:22 am

Re: Using SpaceNavigator with Arduino?

Post by Tijs » Tue Oct 13, 2020 2:43 am

Hello,

I'm using a arduino uno, a usb host shield and the spacemouse with usb cable. The code is working but i can't see any values in the serial monitor? Anyone got an idea how i can see the values?

Thank you
DRogers96 wrote:
Mon Feb 10, 2020 6:16 pm
Yep, that's what it was. I used a USB analyzer on my laptop to see all the data it was sending and saw there were a bunch of data packets that weren't being used by the Arduino code. I added six more variables to hold the six extra data packets that represent the rotation and was able to read the rotation data. The rotation packets are still in x-y-z order. Attached is the updated code (credits to mlkoch for the original code).

jwick
Moderator
Moderator
Posts: 2714
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Re: Using SpaceNavigator with Arduino?

Post by jwick » Wed Oct 14, 2020 12:38 am

I forget what the serial monitor does, but the device does not send ASCII data, if that is what it is expecting.

Tijs
Posts: 6
Joined: Mon Oct 12, 2020 6:22 am

Re: Using SpaceNavigator with Arduino?

Post by Tijs » Mon Oct 19, 2020 2:04 am

What kind of data is it sending?

jwick
Moderator
Moderator
Posts: 2714
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Re: Using SpaceNavigator with Arduino?

Post by jwick » Mon Oct 19, 2020 4:25 am

It sends USB packets. There is a ReportID in the first byte, then data following that varies with the type of report.
You have to parse it.
You probably just want the motion packet (6DOF) and the buttons packet.
I've put some code on github you can start with.

Tijs
Posts: 6
Joined: Mon Oct 12, 2020 6:22 am

Re: Using SpaceNavigator with Arduino?

Post by Tijs » Tue Oct 20, 2020 1:16 am

is there a link to that code?

jwick
Moderator
Moderator
Posts: 2714
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Re: Using SpaceNavigator with Arduino?

Post by jwick » Tue Oct 20, 2020 10:59 am


Tijs
Posts: 6
Joined: Mon Oct 12, 2020 6:22 am

Re: Using SpaceNavigator with Arduino?

Post by Tijs » Mon Oct 26, 2020 12:50 am

I'm using the arduino code but still i can't see any data, do i need to add a LED screen or something like that?

jwick
Moderator
Moderator
Posts: 2714
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Re: Using SpaceNavigator with Arduino?

Post by jwick » Mon Oct 26, 2020 4:04 am

There is a difference between some of the devices.

Older devices (SpaceNavigator) have two motion packets. One for Rotations. Another for Translations. Newer devices combine those into one packet. The code was written for the two packet models.

Print out what you get, at least the number of bytes in the packet. IIRC, it will be either 7 or 13.
And print out what you get from the buttons.

If you aren't getting anything, the electronics aren't working. The device may not be getting enough power to run.
Is the LED ring lit?

Tijs
Posts: 6
Joined: Mon Oct 12, 2020 6:22 am

Re: Using SpaceNavigator with Arduino?

Post by Tijs » Mon Oct 26, 2020 4:05 am

No (The blue light) it isn't lit, and i'm not getting any numbers

Tijs
Posts: 6
Joined: Mon Oct 12, 2020 6:22 am

Re: Using SpaceNavigator with Arduino?

Post by Tijs » Mon Oct 26, 2020 4:14 am

Tijs wrote:
Mon Oct 26, 2020 4:05 am
No (The blue light) it isn't lit, and i'm not getting any numbers
is it possible to put more power trought the arduino?

jwick
Moderator
Moderator
Posts: 2714
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Re: Using SpaceNavigator with Arduino?

Post by jwick » Mon Oct 26, 2020 5:15 am

I have no idea.
Make sure you are not using a device that consumes too much power. Such as one that has an LCD.

Post Reply