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

Ruby Decode Bytes from COM Port Module

For general discussion related FlowStone

Re: Ruby Decode Bytes from COM Port Module

Postby Tronic » Mon Nov 23, 2015 7:14 am

Please could you give a test-byte containing some value to the respective bytes, and their relative value to be obtained?
otherwise we could not help effectively, as I have not yet understood what his bit endianess order,
it seems to me that the example that represents the byte is in little-endian,
then offer us a test-bytes in this way, for example:
80, 2F, 58, 59, 22, 0 =
cursor = the value you should get;
x_lo_hi = the value you should get;
etc. etc

so it will be easier to make a check if the routine works.
Tronic
 
Posts: 539
Joined: Wed Dec 21, 2011 12:59 pm

Re: Ruby Decode Bytes from COM Port Module

Postby Tronic » Mon Nov 23, 2015 8:29 am

# Decoder for the CalComp DrawingBoard Digitizer
# CalComp DrawingBoard binary format #22
# byte B7 B6 B5 B4 B3 B2 B1 B0
# 0 1 C4 C3 C2 C1 C0 X15 X14
# 1 0 X13 X12 X11 X10 X9 X8 X7
# 2 0 X6 X5 X4 X3 X2 X1 X0
# 3 0 0 PROX 0 X16 Y16 Y15 Y14
# 4 0 Y13 Y12 Y11 Y10 Y9 Y8 Y7
# 5 0 Y6 Y5 Y4 Y3 Y2 Y1 Y0

:?: is this scheme of bit correct?
Last edited by Tronic on Mon Nov 23, 2015 2:01 pm, edited 1 time in total.
Tronic
 
Posts: 539
Joined: Wed Dec 21, 2011 12:59 pm

Re: Ruby Decode Bytes from COM Port Module

Postby Tronic » Mon Nov 23, 2015 11:09 am

Ok found some documents, is this your model?
http://www.gtcocalcomp.com/pdf/userguid ... e-5of5.pdf
Tronic
 
Posts: 539
Joined: Wed Dec 21, 2011 12:59 pm

Re: Ruby Decode Bytes from COM Port Module

Postby aronb » Mon Nov 23, 2015 3:17 pm

Hi Tronic,

Yes, the manual can be used to get the Formats for my Digitizer, I could not find my manual (found and bought another CalComp Digitizer on eBay with manual - will have it in a few days). So I used this PDF you also found, myself. I am very familiar with these Digitizers, as we used them to digitize artwork for laser shows from the early 80's to 2003, where I did R&D Engineering.

I believe the tablet is set up for "Format 23: 9500 Format #5", but as you can see a few are very similar and only vary in low / high byte pattern and resolution based on the size of the Digitizer (12" x 12" to more than 22" x 34"), and thus the high order bits may not be used, and on my Digitizer bits 16, 15, 14 for x and y are not used (I am 98% sure, the manual will tell me more). This Digitizer has a menu strip at the top, and while I can read what has been set, the "Format Mode" is a number between 1 and 9, and not the number of the Format - so that is why I need the manual.

So from the PDF you found, you can see that byte 3 is not used (proximity is not working, as it is a setup mode which I need the manual for, but merely tells the user if the cursor is not getting data from the Digitizer, i.e. out of range, etc.) And on byte 0, only the cursor info is used, and not the high order x bits. Note that C4 indicates a button has been pressed, and C3, C2, C1, & C0 indicate which of the 16 buttons (0 through F) have been pushed.

The bit mask decoding I am using seems to be working just fine, except for the the fact that when the incoming numbers are converted somewhere, sometimes they evaluate to false which causes the error when you try to perform math on a "false" and not an actual number and probably why Ruby throws and that particular error - it gets a number and everything is fine, but when a "false" enters the math messes up.

The final X and Y values are about 0 to 15239, for example the x position is on byte 1 (xhi 6 bits) and 2 (xlo 6 bits), so xlo + ( xhi * 128) is equal to the x position value, and the same for y on bytes 4 and 5. The number typically does not go up to 16384 due to mechanical limits of the internal PCB, but does meet the value of 0 to 15000 which is 1250 samples per inch over 12" (12" x 1250 = 15000) in high resolution mode.

I hope that helps you, just let me know and I will get more info to you.

Note: I tried to create the simulation array the same way the data enters the Ruby module from the Com Module... but could not capture the array of values properly. I believe that at various times the data may contain empty values, since the data streaming speed from the Digitizer can be changed, but of course the baud rate is always 9600, so data may get extra null or empty values, but I have not 100% verified this...

I have included the latest version code as well...
CalComp_v2.fsm
(27.07 KiB) Downloaded 757 times


Thanks so much for helping me on this !

Aron
User avatar
aronb
 
Posts: 154
Joined: Sun Apr 17, 2011 3:08 am
Location: Florida, USA

Re: Ruby Decode Bytes from COM Port Module

Postby Tronic » Mon Nov 23, 2015 4:19 pm

i have added an check before parse the buffer,
I think now you not get any error, the block of code is processed only if the buffer has valid nByte.
Attachments
CalComp_v2_(Tronic).fsm
(27.18 KiB) Downloaded 775 times
Tronic
 
Posts: 539
Joined: Wed Dec 21, 2011 12:59 pm

Re: Ruby Decode Bytes from COM Port Module

Postby aronb » Mon Nov 23, 2015 4:59 pm

Tronic,

I will give your version of the code a try when I get home today from work... I live on the east coast of the US so -5 GMT; I get home about 5 PM to 5:30 PM today based on traffic. I will try it as soon as I get home !

I hope my comments made sense, I am still learning Ruby - it is way different than most any other language I know ;)

Thanks again,

Aron
User avatar
aronb
 
Posts: 154
Joined: Sun Apr 17, 2011 3:08 am
Location: Florida, USA

Re: Ruby Decode Bytes from COM Port Module

Postby aronb » Tue Nov 24, 2015 1:46 am

Tronic :geek:

That was the ticket - it works perfectly now !

I am still figuring out exactly what your additional code does, but it looks like it gets the required number of samples (6 in this case) and only updates the data buffer then output when it is full... again 6 bytes. Something I played with but did not get it working as well as yours of course. It sure seems like you can do things more than one way with Ruby, and that is great but seems hard for an older programmer like me to "get" !

Thanks a lot, I learned even more Ruby code techniques on this one !!!

It is great having smart teacher to help out an "old" student like me :lol:

Aron
User avatar
aronb
 
Posts: 154
Joined: Sun Apr 17, 2011 3:08 am
Location: Florida, USA

Re: Ruby Decode Bytes from COM Port Module

Postby Tronic » Tue Nov 24, 2015 2:50 pm

Hi aron,
this is my version of how I translated the CaclComp 9100 Format5 #23,
I hope conversions bits are not all wrong ....
All code is now commented for easy understanding,
I used other practical methods of Ruby and FS, like the hash, to brighten up your "old 8-bit" mind :)
like a mini tutorial for your case

Also I wonder, reading the manual
<< the higher number of bits Xn represents the MSB >>
then the resolution should be 17-bit?
however there are both versions.

Let me know if my conversion is correct, otherwise I have to study again, I will always slam my head.
Attachments
CalComp_v2_Alternative(Tronic).fsm
(33.84 KiB) Downloaded 765 times
Tronic
 
Posts: 539
Joined: Wed Dec 21, 2011 12:59 pm

Re: Ruby Decode Bytes from COM Port Module

Postby aronb » Wed Nov 25, 2015 4:06 am

Tronic,

THANK YOU VERY MUCH ! ! ! ! :D

You essentially created another working custom Ruby (Flowstone version) lesson for me in a way I can understand because it is an application I have done before in PowerBASIC and C++ - WOW :shock:

Thank you to tulamide as well, because it got me thinking as well in a different way to solve and trouble shoot :!:

I feel I have learned more Ruby this week than ever before and I cannot thank you all / this group / Flowstone enough - this is such an amazing program and helpful smart people :ugeek: too !

I'll post something again soon - need to figure out how to get data out of Flowstone... look for my post if you are interested !

Thanks Again,

Aron 8-)
User avatar
aronb
 
Posts: 154
Joined: Sun Apr 17, 2011 3:08 am
Location: Florida, USA

Previous

Return to General

Who is online

Users browsing this forum: No registered users and 28 guests