Legacy Forum: Preserving Nearly 20 Years of Community History - A Time Capsule of Discussions, Memories, and Shared Experiences.

-127 to 127 values

Hitec robotics including ROBONOVA humanoid, HSR-8498HB servos, MR C-3024 Controllers and RoboBasic
6 postsPage 1 of 1
6 postsPage 1 of 1

-127 to 127 values

Post by roboTT » Mon Mar 31, 2008 11:17 pm

Post by roboTT
Mon Mar 31, 2008 11:17 pm

Guys,

whenever a values are read - the range is between -127 to 127 - why does MR-C set it this way?

Is this correct, or am i doing smth wrong while reading, maybe some coversion is required ?

For example 2axis accel returns values for X/Y as a range between:

-127 to 127.


Any idea?
Guys,

whenever a values are read - the range is between -127 to 127 - why does MR-C set it this way?

Is this correct, or am i doing smth wrong while reading, maybe some coversion is required ?

For example 2axis accel returns values for X/Y as a range between:

-127 to 127.


Any idea?
roboTT
Savvy Roboteer
Savvy Roboteer
Posts: 62
Joined: Mon Mar 10, 2008 10:06 am

Post by davidalecmcinnes » Wed Apr 02, 2008 10:26 am

Post by davidalecmcinnes
Wed Apr 02, 2008 10:26 am

Sounds like its using a signed byte, try using an integer instead asit will give you more resoltion wont overrun the sign boundary at 32768.
Sounds like its using a signed byte, try using an integer instead asit will give you more resoltion wont overrun the sign boundary at 32768.
davidalecmcinnes
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 33
Joined: Tue Jun 26, 2007 12:51 pm
Location: UK

Post by Gerry52 » Wed Apr 02, 2008 7:56 pm

Post by Gerry52
Wed Apr 02, 2008 7:56 pm

This is what I found, I'm new to this stuf so please correct me if I'm wrong.

Robobasic doesn't handle negative numbers at all! There is no sign bit. The range of the AD(x) inputs is 0 to 5V, it generates a 0 - 255 value in Robobasic, a byte type can be declared here.
However inputs connected to the 2 axis accelemeter generates a value from 400 to 700 (400 = laying on back side (or left side), 700 = laying on front side (or right side). For this an integer should be declared.

Gerry
This is what I found, I'm new to this stuf so please correct me if I'm wrong.

Robobasic doesn't handle negative numbers at all! There is no sign bit. The range of the AD(x) inputs is 0 to 5V, it generates a 0 - 255 value in Robobasic, a byte type can be declared here.
However inputs connected to the 2 axis accelemeter generates a value from 400 to 700 (400 = laying on back side (or left side), 700 = laying on front side (or right side). For this an integer should be declared.

Gerry
Gerry52
Robot Builder
Robot Builder
Posts: 20
Joined: Thu Feb 28, 2008 9:51 pm
Location: Netherlands

Post by roboTT » Wed Apr 02, 2008 9:45 pm

Post by roboTT
Wed Apr 02, 2008 9:45 pm

Gerry52 wrote:This is what I found, I'm new to this stuf so please correct me if I'm wrong.

Robobasic doesn't handle negative numbers at all! There is no sign bit. The range of the AD(x) inputs is 0 to 5V, it generates a 0 - 255 value in Robobasic, a byte type can be declared here.
However inputs connected to the 2 axis accelemeter generates a value from 400 to 700 (400 = laying on back side (or left side), 700 = laying on front side (or right side). For this an integer should be declared.

Gerry


You're saying about robobasic, and i'm speaking of reading values with C/C++.
The IR reports positive numbers all the time
The 2Axis reports -127 to +127 evein if being read to Integer.

The values are being read by:

bReadRC = ReadFile(hCom, &rxchar, 1, &iBytesRead, NULL);

into the char rxchar
and are returned mostly as numbers between -127 and 127
Gerry52 wrote:This is what I found, I'm new to this stuf so please correct me if I'm wrong.

Robobasic doesn't handle negative numbers at all! There is no sign bit. The range of the AD(x) inputs is 0 to 5V, it generates a 0 - 255 value in Robobasic, a byte type can be declared here.
However inputs connected to the 2 axis accelemeter generates a value from 400 to 700 (400 = laying on back side (or left side), 700 = laying on front side (or right side). For this an integer should be declared.

Gerry


You're saying about robobasic, and i'm speaking of reading values with C/C++.
The IR reports positive numbers all the time
The 2Axis reports -127 to +127 evein if being read to Integer.

The values are being read by:

bReadRC = ReadFile(hCom, &rxchar, 1, &iBytesRead, NULL);

into the char rxchar
and are returned mostly as numbers between -127 and 127
roboTT
Savvy Roboteer
Savvy Roboteer
Posts: 62
Joined: Mon Mar 10, 2008 10:06 am

Post by i-Bot » Wed Apr 02, 2008 10:22 pm

Post by i-Bot
Wed Apr 02, 2008 10:22 pm

The values being read are unsigned characters ranging from 0 to 255. The RoboNova does not work in signed except in a few special cases.

If you choose to interpret the unsigned character as a signed character, that is likely to give problems. While it may be true that an accelerometer has a signed output, you need to properly determine the zero point and then make a valid unsigned to signed conversion.
The values being read are unsigned characters ranging from 0 to 255. The RoboNova does not work in signed except in a few special cases.

If you choose to interpret the unsigned character as a signed character, that is likely to give problems. While it may be true that an accelerometer has a signed output, you need to properly determine the zero point and then make a valid unsigned to signed conversion.
i-Bot
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 1142
Joined: Wed May 17, 2006 1:00 am

Post by roboTT » Wed Apr 02, 2008 10:28 pm

Post by roboTT
Wed Apr 02, 2008 10:28 pm

i-Bot wrote:The values being read are unsigned characters ranging from 0 to 255. The RoboNova does not work in signed except in a few special cases.

If you choose to interpret the unsigned character as a signed character, that is likely to give problems. While it may be true that an accelerometer has a signed output, you need to properly determine the zero point and then make a valid unsigned to signed conversion.



Thank you i-Bot, as soon as i'll get my new servos, i'll do the patching on my code and return with the results.
i-Bot wrote:The values being read are unsigned characters ranging from 0 to 255. The RoboNova does not work in signed except in a few special cases.

If you choose to interpret the unsigned character as a signed character, that is likely to give problems. While it may be true that an accelerometer has a signed output, you need to properly determine the zero point and then make a valid unsigned to signed conversion.



Thank you i-Bot, as soon as i'll get my new servos, i'll do the patching on my code and return with the results.
roboTT
Savvy Roboteer
Savvy Roboteer
Posts: 62
Joined: Mon Mar 10, 2008 10:06 am


6 postsPage 1 of 1
6 postsPage 1 of 1