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

Input values on AD(x)

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

Input values on AD(x)

Post by Gerry52 » Fri Mar 07, 2008 8:17 pm

Post by Gerry52
Fri Mar 07, 2008 8:17 pm

Hi,

Trying to get warnings on several voltage levels with this code. “robot_voltage” is called from MAIN by “GOSUB robot_voltage”

robot_voltage: ' [10 x Value / 256 = Voltage]
DIM v AS BYTE
DIM n AS BYTE

A = AD(6)
IF A > 148 AND A <150> 146 AND A <148> 144 AND A <146> 15, 148 --> 13, 146 --> 10. With this setting the led won’t blink at all. I tried other values as well, when I compare “A” with <25> 0 AND Rn <10> 10 AND Rn <= 20 THEN MUSIC “B”

RETURN

Sometimes RN won’t respond at all by this setting. Changing 10 to 20 and 20 to 30 will help sometimes, but not in all cases. I’ve experienced that 40 and 50 sometimes also do the job. I know the sensor readings can shift a bit when the battery is exhausting or temperature, but I also noticed this behavior when the battery is fully charged. So there seemed to be no relation between the inconsistent readings and the battery voltage.

From the tilt sensor I get the same inconsistent readings.

For me it looks like there no pattern in this behavior. Maybe it has to do with interference by other signals but often it’s a knowledge issue. Need some help with this...

Gerry
Hi,

Trying to get warnings on several voltage levels with this code. “robot_voltage” is called from MAIN by “GOSUB robot_voltage”

robot_voltage: ' [10 x Value / 256 = Voltage]
DIM v AS BYTE
DIM n AS BYTE

A = AD(6)
IF A > 148 AND A <150> 146 AND A <148> 144 AND A <146> 15, 148 --> 13, 146 --> 10. With this setting the led won’t blink at all. I tried other values as well, when I compare “A” with <25> 0 AND Rn <10> 10 AND Rn <= 20 THEN MUSIC “B”

RETURN

Sometimes RN won’t respond at all by this setting. Changing 10 to 20 and 20 to 30 will help sometimes, but not in all cases. I’ve experienced that 40 and 50 sometimes also do the job. I know the sensor readings can shift a bit when the battery is exhausting or temperature, but I also noticed this behavior when the battery is fully charged. So there seemed to be no relation between the inconsistent readings and the battery voltage.

From the tilt sensor I get the same inconsistent readings.

For me it looks like there no pattern in this behavior. Maybe it has to do with interference by other signals but often it’s a knowledge issue. Need some help with this...

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

Post by i-Bot » Fri Mar 07, 2008 8:34 pm

Post by i-Bot
Fri Mar 07, 2008 8:34 pm

It would be easier to help if you posted the actual code you have a problem with.

Also what are the components you have wired to input AD6 ?
It would be easier to help if you posted the actual code you have a problem with.

Also what are the components you have wired to input AD6 ?
i-Bot
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 1142
Joined: Wed May 17, 2006 1:00 am

Post by Gerry52 » Fri Mar 07, 2008 8:41 pm

Post by Gerry52
Fri Mar 07, 2008 8:41 pm

Sorry,

Copied the code from robobasic and pasted it in robosavvy but it all seemed to be messed up. Will try it again.

On AD(6) are no wires connected, guess thats my battery voltage problem, should I connect the battery voltage to the AD(6) pins?

Gerry
Sorry,

Copied the code from robobasic and pasted it in robosavvy but it all seemed to be messed up. Will try it again.

On AD(6) are no wires connected, guess thats my battery voltage problem, should I connect the battery voltage to the AD(6) pins?

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

Post by Gerry52 » Fri Mar 07, 2008 8:48 pm

Post by Gerry52
Fri Mar 07, 2008 8:48 pm

Trying to get warnings on several voltage levels with this code. “robot_voltage” is called from MAIN by “GOSUB robot_voltage”

robot_voltage: ' [10 x Value / 256 = Voltage]
DIM v AS BYTE
DIM n AS BYTE

A = AD(6)
IF A > 148 AND A <150> 146 AND A <= 148 THEN n = 2
IF A <146> 15, 148 --> 13, 146 --> 10. With this setting the led won’t blink at all. I tried other values as well, when I compare “A” with <25> 0 AND Rn <10> 10 AND Rn <= 20 THEN MUSIC “B”

RETURN

Sometimes RN won’t respond at all by this setting. Changing 10 to 20 and 20 to 30 will help sometimes, but not in all cases. I’ve experienced that 40 and 50 sometimes also do the job. I know the sensor readings can shift a bit when the battery is exhausting, but I also noticed this behavior when the battery is fully charged. So there seemed to be no relation between the inconsistent reading and the battery voltage.

From the tilt sensor I get the same inconsistent readings.

For me it looks like there no pattern in this behavior. Maybe it has to do with interference by other signals but often it’s a knowledge issue. Can someone help with this?
Gerry
Trying to get warnings on several voltage levels with this code. “robot_voltage” is called from MAIN by “GOSUB robot_voltage”

robot_voltage: ' [10 x Value / 256 = Voltage]
DIM v AS BYTE
DIM n AS BYTE

A = AD(6)
IF A > 148 AND A <150> 146 AND A <= 148 THEN n = 2
IF A <146> 15, 148 --> 13, 146 --> 10. With this setting the led won’t blink at all. I tried other values as well, when I compare “A” with <25> 0 AND Rn <10> 10 AND Rn <= 20 THEN MUSIC “B”

RETURN

Sometimes RN won’t respond at all by this setting. Changing 10 to 20 and 20 to 30 will help sometimes, but not in all cases. I’ve experienced that 40 and 50 sometimes also do the job. I know the sensor readings can shift a bit when the battery is exhausting, but I also noticed this behavior when the battery is fully charged. So there seemed to be no relation between the inconsistent reading and the battery voltage.

From the tilt sensor I get the same inconsistent readings.

For me it looks like there no pattern in this behavior. Maybe it has to do with interference by other signals but often it’s a knowledge issue. Can someone help with this?
Gerry
Gerry52
Robot Builder
Robot Builder
Posts: 20
Joined: Thu Feb 28, 2008 9:51 pm
Location: Netherlands

Post by Gerry52 » Fri Mar 07, 2008 8:50 pm

Post by Gerry52
Fri Mar 07, 2008 8:50 pm

Sorry again,

Guess I first have to find how to post a question you can read...

Gerry
Sorry again,

Guess I first have to find how to post a question you can read...

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

Post by Gerry52 » Fri Mar 07, 2008 8:54 pm

Post by Gerry52
Fri Mar 07, 2008 8:54 pm

Trying to get warnings on several voltage levels with this code. “robot_voltage” is called from MAIN by “GOSUB robot_voltage”

robot_voltage: ' [10 x Value / 256 = Voltage]
DIM v AS BYTE
DIM n AS BYTE

A = AD(6)
IF A > 148 AND A <150> 146 AND A <= 148 THEN n = 2
IF A <146> 15, 148 --> 13, 146 --> 10. With this setting the led won’t blink at all. I tried other values as well, when I compare “A” with <25> 0 AND Rn <10> 10 AND Rn <= 20 THEN MUSIC “B”

RETURN

Sometimes RN won’t respond at all by this setting. Changing 10 to 20 and 20 to 30 will help sometimes, but not in all cases. I’ve experienced that 40 and 50 sometimes also do the job. I know the sensor readings can shift a bit when the battery is exhausting, but I also noticed this behavior when the battery is fully charged. So there seemed to be no relation between the inconsistent reading and the battery voltage.

From the tilt sensor I get the same inconsistent readings.

For me it looks like there no pattern in this behavior. Maybe it has to do with interference by other signals but often it’s a knowledge issue. Can someone help with this?

Gerry
Trying to get warnings on several voltage levels with this code. “robot_voltage” is called from MAIN by “GOSUB robot_voltage”

robot_voltage: ' [10 x Value / 256 = Voltage]
DIM v AS BYTE
DIM n AS BYTE

A = AD(6)
IF A > 148 AND A <150> 146 AND A <= 148 THEN n = 2
IF A <146> 15, 148 --> 13, 146 --> 10. With this setting the led won’t blink at all. I tried other values as well, when I compare “A” with <25> 0 AND Rn <10> 10 AND Rn <= 20 THEN MUSIC “B”

RETURN

Sometimes RN won’t respond at all by this setting. Changing 10 to 20 and 20 to 30 will help sometimes, but not in all cases. I’ve experienced that 40 and 50 sometimes also do the job. I know the sensor readings can shift a bit when the battery is exhausting, but I also noticed this behavior when the battery is fully charged. So there seemed to be no relation between the inconsistent reading and the battery voltage.

From the tilt sensor I get the same inconsistent readings.

For me it looks like there no pattern in this behavior. Maybe it has to do with interference by other signals but often it’s a knowledge issue. Can someone help with this?

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

Post by Gerry52 » Fri Mar 07, 2008 8:57 pm

Post by Gerry52
Fri Mar 07, 2008 8:57 pm

Sorry, Guess I'm not be able to post my code the right way...
Sorry, Guess I'm not be able to post my code the right way...
Gerry52
Robot Builder
Robot Builder
Posts: 20
Joined: Thu Feb 28, 2008 9:51 pm
Location: Netherlands

Post by Gerry52 » Fri Mar 07, 2008 9:10 pm

Post by Gerry52
Fri Mar 07, 2008 9:10 pm

The message seemed to be ok evrey time, the code is messed up everytime. In the "post a reply" box the code seemed to be ok, in the preview it's messed up.

HELP!!!
The message seemed to be ok evrey time, the code is messed up everytime. In the "post a reply" box the code seemed to be ok, in the preview it's messed up.

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

Post by Gerry52 » Fri Mar 07, 2008 9:15 pm

Post by Gerry52
Fri Mar 07, 2008 9:15 pm

Once again...

Trying to get warnings on several voltage levels with this code. “robot_voltage” is called from MAIN by “GOSUB robot_voltage”

robot_voltage: ' [10 x Value / 256 = Voltage]
DIM v AS BYTE
DIM n AS BYTE

A = AD(6)
IF A > 148 AND A <150> 146 AND A <= 148 THEN n = 2
IF A <146> 15, 148 --> 13, 146 --> 10. With this setting the led won’t blink at all. I tried other values as well, when I compare “A” with <25> 0 AND Rn <10> 10 AND Rn <= 20 THEN MUSIC “B”

RETURN

Sometimes RN won’t respond at all by this setting. Changing 10 to 20 and 20 to 30 will help sometimes, but not in all cases. I’ve experienced that 40 and 50 sometimes also do the job. I know the sensor readings can shift a bit when the battery is exhausting, but I also noticed this behavior when the battery is fully charged. So there seemed to be no relation between the inconsistent reading and the battery voltage.

From the tilt sensor I get the same inconsistent readings.

For me it looks like there no pattern in this behavior. Maybe it has to do with interference by other signals but often it’s a knowledge issue. Can someone help with this?

Gerry
Once again...

Trying to get warnings on several voltage levels with this code. “robot_voltage” is called from MAIN by “GOSUB robot_voltage”

robot_voltage: ' [10 x Value / 256 = Voltage]
DIM v AS BYTE
DIM n AS BYTE

A = AD(6)
IF A > 148 AND A <150> 146 AND A <= 148 THEN n = 2
IF A <146> 15, 148 --> 13, 146 --> 10. With this setting the led won’t blink at all. I tried other values as well, when I compare “A” with <25> 0 AND Rn <10> 10 AND Rn <= 20 THEN MUSIC “B”

RETURN

Sometimes RN won’t respond at all by this setting. Changing 10 to 20 and 20 to 30 will help sometimes, but not in all cases. I’ve experienced that 40 and 50 sometimes also do the job. I know the sensor readings can shift a bit when the battery is exhausting, but I also noticed this behavior when the battery is fully charged. So there seemed to be no relation between the inconsistent reading and the battery voltage.

From the tilt sensor I get the same inconsistent readings.

For me it looks like there no pattern in this behavior. Maybe it has to do with interference by other signals but often it’s a knowledge issue. Can someone help with this?

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

Post by i-Bot » Fri Mar 07, 2008 10:29 pm

Post by i-Bot
Fri Mar 07, 2008 10:29 pm

While you look to the posting of the code.

The AD(x) command reads the voltage on the ADx pins. The value returned is between 0 and 256 over the input range 0 to 5Volts.

To measure the battery voltage which is greater than 5 Volts, you need to divide the battery voltage by two with a pair of resistors.

The battery voltage is on the connectors down the side of the board which feed the servos. Battrey voltage is on the middle pin. You need a pair of resistors in series between the battery voltage and ground ( the pin towards the edge of the board. The two resistors should be of equal value ( between 22K to 47K ohms each)

The point between the two resistors is at half the battery voltage and is fed to the AD6 connector (pin nearest center of the board). The middle pin of the AD connectors is not battery, it is regulated 5 Volts.

Now the value read by AD(6) will be the 256 * (battery voltage/ (5Volts * 2(voltage divider)), which is what you want.

Note when the battery voltage drops below about 5.5 volts, the reference in the processor starts to drop, since this is also driven by the battery, so values are no longer valid.
While you look to the posting of the code.

The AD(x) command reads the voltage on the ADx pins. The value returned is between 0 and 256 over the input range 0 to 5Volts.

To measure the battery voltage which is greater than 5 Volts, you need to divide the battery voltage by two with a pair of resistors.

The battery voltage is on the connectors down the side of the board which feed the servos. Battrey voltage is on the middle pin. You need a pair of resistors in series between the battery voltage and ground ( the pin towards the edge of the board. The two resistors should be of equal value ( between 22K to 47K ohms each)

The point between the two resistors is at half the battery voltage and is fed to the AD6 connector (pin nearest center of the board). The middle pin of the AD connectors is not battery, it is regulated 5 Volts.

Now the value read by AD(6) will be the 256 * (battery voltage/ (5Volts * 2(voltage divider)), which is what you want.

Note when the battery voltage drops below about 5.5 volts, the reference in the processor starts to drop, since this is also driven by the battery, so values are no longer valid.
i-Bot
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 1142
Joined: Wed May 17, 2006 1:00 am

Post by Gerry52 » Thu Mar 13, 2008 6:05 pm

Post by Gerry52
Thu Mar 13, 2008 6:05 pm

I did see the electrical scheme in the manual assuming it was already integrated on the board. Clear case, it isn't. I used two 48K resitors (both measured 48K5), they do the job. Thanks again!

Other inconsistant AD(x) readings I mentioned are caused by low battery voltage. At second tought I remembered that those NiMh packs (as well as NiCad) gain their full capacity after a few charge/discharge cycles.

At this moment I play with the tilt sensor input, want RN to react on back/forward tilting when he's moving. Code snippets in some posts are great help.

Gerry
I did see the electrical scheme in the manual assuming it was already integrated on the board. Clear case, it isn't. I used two 48K resitors (both measured 48K5), they do the job. Thanks again!

Other inconsistant AD(x) readings I mentioned are caused by low battery voltage. At second tought I remembered that those NiMh packs (as well as NiCad) gain their full capacity after a few charge/discharge cycles.

At this moment I play with the tilt sensor input, want RN to react on back/forward tilting when he's moving. Code snippets in some posts are great help.

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


11 postsPage 1 of 1
11 postsPage 1 of 1