Support

If you have a problem or need to report a bug please email : support@dsprobotics.com

There are 3 sections to this support area:

DOWNLOADS: access to product manuals, support files and drivers

HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects

USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here

NEW REGISTRATIONS - please contact us if you wish to register on the forum

Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright

Need a quick intro on using the com port

For general discussion related FlowStone

Need a quick intro on using the com port

Postby Asbjørn » Tue Jul 12, 2011 5:00 pm

I got myself an old serial SpaceBall 4000FLX because it doesnt seem like Flowstone will get support for the 3DConnexxion Space Navigator USB.

I found a document describing the protocol it uses, but I have no experience with the com port. I would really appreciate it if you could make me a small example using one or two of the commands in this document so I can understand how it works.

http://lists.unc.edu/read/attachment/1682004/5/a4_public.1.20.doc

Thanks!
Asbjørn
 
Posts: 45
Joined: Thu Sep 16, 2010 11:51 am

Re: Need a quick intro on using the com port

Postby Embedded » Wed Jul 13, 2011 3:52 am

Here you go!

The only thing you need to set is the correct Com port number. On some OS only Com 1-8 work, so you might have to force the comport number in this range in the device manager.

I have added the Beep command and the Data Enable so that the device will send positional data etc.

Let me know if it works?
Attachments
SpaceBall Test.fsm
(508 Bytes) Downloaded 1421 times
Embedded
 
Posts: 143
Joined: Sat Oct 30, 2010 1:42 pm

Re: Need a quick intro on using the com port

Postby Asbjørn » Wed Jul 13, 2011 3:27 pm

It works perfectly! Thank you! :D
Now I'll try to get the different buttons on the device working, and then try to decode the positional data from the ball. I'll post the result.

If anyone else needs a 6 DOF 3D "mouse", they are really cheap on ebay: http://shop.ebay.com/i.html?_from=R40&_trksid=p5197.m570.l1313&_nkw=spaceball+4000&_sacat=See-All-Categories
Asbjørn
 
Posts: 45
Joined: Thu Sep 16, 2010 11:51 am

Re: Need a quick intro on using the com port

Postby Asbjørn » Wed Jul 13, 2011 7:59 pm

Ok, I got all of the buttons and the send packets working! It's not perfect, it freaks out if more than one button is pressed at the same time, and it could probably be done with less components than I used.

I started working on the ball data, that's the difficult part. I figured out how to separate the different axes, but the data is confusing.

The protocol document says this about ball data:

Code: Select all
4.2.2   Ball Data
Description:   Whenever the ball is moved, a packet is generated by the Spaceball.  This packet contains data about the movement data for the Spaceball.
In order to receive a data packet, the “Enable Data” packet has to be sent first.
Packet Header:   D (0x44)
Packet Data:   Dppxxyyzzrruuvv (each letter stands for 1 byte)
Data Format:   pp   Period of data.  This is the number of 1/16th milliseconds since the last ball data packet.
   xx…zz   Translational forces.
   rr…vv   Rotational forces (torque).
      Actual force and torque values are 16-bit signed integers.
The first byte is the higher significant byte of the 16 bit signed integer, the second byte is the lower significant byte. Decoding to a 16bit signed integer can be done like this:
signed int ForceX = ( packet[3] << 8) | (packet[4]);

The resolution is 160 mNm and 4.4mNm for force and torque.  This results in a force and torque range of +/- 20.48 N and +/- 0.5632 mNm.  Positive x is to the right, +y is up and +z is upwards.  Positive torque values are clockwise as viewed from the center of the ball out along the positive force axes. 


Period of data: What do I need this for?

I need help dumbing down this: "Decoding to a 16bit signed integer can be done like this:
signed int ForceX = ( packet[3] << 8) | (packet[4]);"
Attachments
SpaceBall Test 2.fsm
(100.13 KiB) Downloaded 1420 times
Asbjørn
 
Posts: 45
Joined: Thu Sep 16, 2010 11:51 am

Re: Need a quick intro on using the com port

Postby Asbjørn » Wed Jul 13, 2011 9:22 pm

I think i understand it a little better now, I have a 16 bit unsigned integer I need to convert to a 16 bit signed integer. How can I do this with flowstone?
Asbjørn
 
Posts: 45
Joined: Thu Sep 16, 2010 11:51 am

Re: Need a quick intro on using the com port

Postby DSP » Wed Jul 13, 2011 9:36 pm

You normally just subtract the zero offset.

16 Bit Unsigned Integer = 0 to 65536

16 Bit Signed Integer = +32768 to -32768

So just subtract 32768 !
DSP
 
Posts: 150
Joined: Fri May 14, 2010 10:55 pm

Re: Need a quick intro on using the com port

Postby Asbjørn » Wed Jul 13, 2011 11:10 pm

DSP wrote:You normally just subtract the zero offset.

16 Bit Unsigned Integer = 0 to 65536

16 Bit Signed Integer = +32768 to -32768

So just subtract 32768 !


Thanks but I don't think it's that easy, the x-axis output after converting string to integer is 0 when the ball is in the middle. If I move the ball to the right, the value climbs to 65536, if I move it to the left it seems to start at 65536 and decrease the further to the left I move it.

Confused :|

I'm probably doing something wrong.
Asbjørn
 
Posts: 45
Joined: Thu Sep 16, 2010 11:51 am

Re: Need a quick intro on using the com port

Postby DSP » Thu Jul 14, 2011 1:26 pm

Looking at the manual the ball data isn't positional information anyway it's force xx,yy,zz,rr,uu,vv, the period is so that you can calculate acceleration :

>>
4.2.2 Ball Data
Description: Whenever the ball is moved, a packet is generated by the Spaceball. This packet contains data about the movement data for the Spaceball.
In order to receive a data packet, the “Enable Data” packet has to be sent first.
Packet Header: D (0x44)
Packet Data: Dppxxyyzzrruuvv (each letter stands for 1 byte)
Data Format: pp Period of data. This is the number of 1/16th milliseconds since the last ball data packet.
xx…zz Translational forces.
rr…vv Rotational forces (torque).
Actual force and torque values are 16-bit signed integers.
The first byte is the higher significant byte of the 16 bit signed integer, the second byte is the lower significant byte. Decoding to a 16bit signed integer can be done like this:
signed int ForceX = ( packet[3] << 8) | (packet[4]);

The resolution is 160 mNm and 4.4mNm for force and torque. This results in a force and torque range of +/- 20.48 N and +/- 0.5632 mNm. Positive x is to the right, +y is up and +z is upwards. Positive torque values are clockwise as viewed from the center of the ball out along the positive force axes.

<<

So the data is already a signed 16bit Int so you just need to convert it from 16bit to 32bit for FlowStone. To do this you need to detect the sign bit (bit 16) and then subtract 32768 when it's negative (ie > 32768).

Here's a FS project that should work for you:
Attachments
Signed 16bit Int.fsm
Signed 16 bit int to 32bit conversion
(9.09 KiB) Downloaded 1495 times
DSP
 
Posts: 150
Joined: Fri May 14, 2010 10:55 pm

Re: Need a quick intro on using the com port

Postby Asbjørn » Thu Jul 14, 2011 5:03 pm

Thanks DSP, looks like that took care of one problem.

I think there might be something wrong with the data comming from the device, it's jumping all over the place. I'll do some testing..
Asbjørn
 
Posts: 45
Joined: Thu Sep 16, 2010 11:51 am

Re: Need a quick intro on using the com port

Postby Asbjørn » Wed Sep 14, 2011 10:09 pm

Ok, I'm back! ;)

I put my Spaceball 4000 on the shelf and started working on my Spaceball 5000 which uses a different protocol, hopefully with some more success!

When the ball returns to the zero position, I should be getting:

dH000H000H000H000H000H000

However, I'm getting:

dà€à€à€à€à€à€

I need help to figure out how I can convert à€ to H000
Asbjørn
 
Posts: 45
Joined: Thu Sep 16, 2010 11:51 am


Return to General

Who is online

Users browsing this forum: No registered users and 32 guests