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

Autonomous RN1 or Spare Head 2

Hitec robotics including ROBONOVA humanoid, HSR-8498HB servos, MR C-3024 Controllers and RoboBasic
30 postsPage 2 of 21, 2
30 postsPage 2 of 21, 2

Post by subpilot » Fri Mar 24, 2006 5:50 am

Post by subpilot
Fri Mar 24, 2006 5:50 am

I found that my sonar does work. I was an idiot and was using a Byte varible while the sonar sub spits out integers.
Rubic, I am also using the etx command to send data over my Bluetooth link. Rather than divide the value by 64 and lose resolution, you could right shift by 8 to get the upper byte.

a16 = SONAR(5)
ETX 9600,a16 ' Sends lower byte
a16=a16>>8
ETX 9600,a16 ' Sends upper byte
I found that my sonar does work. I was an idiot and was using a Byte varible while the sonar sub spits out integers.
Rubic, I am also using the etx command to send data over my Bluetooth link. Rather than divide the value by 64 and lose resolution, you could right shift by 8 to get the upper byte.

a16 = SONAR(5)
ETX 9600,a16 ' Sends lower byte
a16=a16>>8
ETX 9600,a16 ' Sends upper byte
subpilot
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 146
Joined: Sat Feb 25, 2006 1:00 am
Location: Lake Arrowhead, Ca,USA

Post by ucrobots » Fri Mar 24, 2006 9:33 am

Post by ucrobots
Fri Mar 24, 2006 9:33 am

My sonar does not work. The SFR04 is realy ok.
I tried all your tips but with no succsess.

Another funny thing is that SONAR(8) does not generate any triggerpulse on Port#16, but PULSE(16) does. :?:

So what Firmware version do you have ?
My sonar does not work. The SFR04 is realy ok.
I tried all your tips but with no succsess.

Another funny thing is that SONAR(8) does not generate any triggerpulse on Port#16, but PULSE(16) does. :?:

So what Firmware version do you have ?
ucrobots
Robot Builder
Robot Builder
User avatar
Posts: 12
Joined: Mon Mar 20, 2006 1:00 am
Location: Essenrode near Braunschweig, Germany

Post by RubikCube » Fri Mar 24, 2006 2:50 pm

Post by RubikCube
Fri Mar 24, 2006 2:50 pm

Thanks for the tip Subpilot.

I see you are from California. Did you know that you can buy the Vex ultrasonic sonar sensor from RadioSahck for $19.00 and it will work the same way as the SRF04?

Just connect sonar sensor input to MRC-3024 output port and sonar output to MRC-3024 input. It worked for me.


Firmware Version is 2.5
Thanks for the tip Subpilot.

I see you are from California. Did you know that you can buy the Vex ultrasonic sonar sensor from RadioSahck for $19.00 and it will work the same way as the SRF04?

Just connect sonar sensor input to MRC-3024 output port and sonar output to MRC-3024 input. It worked for me.


Firmware Version is 2.5
RubikCube
Robot Builder
Robot Builder
User avatar
Posts: 23
Joined: Mon Mar 06, 2006 1:00 am

Post by RubikCube » Fri Mar 24, 2006 4:32 pm

Post by RubikCube
Fri Mar 24, 2006 4:32 pm

ucrobots,

I don't know if you know this already, let me try to explain what is happening to your code. ROBOBASIC is not a fully synchronous language, if you read the explanation of WAIT statement, you coud conclude that some of the commands in ROBOBASIC does not wait for the previous command to finish before it executes the next one. So on your code below SONAR comand will execute before SONAR finishes the PRINT command will be executed as well. That is why your readings are inconsistent or better yet always zero. You also need to give SRF04 time to process the bounced ping if you listen to your SRF04, and it is ticking very fast you might want to slow it down with DELAY=500


DIM I AS BYTE
DIM B AS INTEGER


PTP SETON
PTP ALLON

'============================
MAIN:

TEMPO 230
MUSIC "o23ggaagg"
DELAY 1000

MOTOR 6
MOTOR 8
MOTOR 9

LCDINIT

loop1:

A = AD(6)
wait
I = I+1

L2:
DELAY 50
Increase your delay

B = SONAR(5) 'SRF04
put a WAIT here

'IF B = 0 THEN GOTO L2

PRINT "Analog Input 6: "
put a WAIT here
PRINT FORMAT(A, DEC)
put a WAIT here
PRINT "Sonar(5): "
put a WAIT here
PRINT FORMAT(B, DEC)
put a WAIT here
PRINT " I= "
put a WAIT here
PRINT FORMAT(I, DEC)
put a WAIT here


PRINT 13, 10

GOTO loop1
GOTO MAIN
ucrobots,

I don't know if you know this already, let me try to explain what is happening to your code. ROBOBASIC is not a fully synchronous language, if you read the explanation of WAIT statement, you coud conclude that some of the commands in ROBOBASIC does not wait for the previous command to finish before it executes the next one. So on your code below SONAR comand will execute before SONAR finishes the PRINT command will be executed as well. That is why your readings are inconsistent or better yet always zero. You also need to give SRF04 time to process the bounced ping if you listen to your SRF04, and it is ticking very fast you might want to slow it down with DELAY=500


DIM I AS BYTE
DIM B AS INTEGER


PTP SETON
PTP ALLON

'============================
MAIN:

TEMPO 230
MUSIC "o23ggaagg"
DELAY 1000

MOTOR 6
MOTOR 8
MOTOR 9

LCDINIT

loop1:

A = AD(6)
wait
I = I+1

L2:
DELAY 50
Increase your delay

B = SONAR(5) 'SRF04
put a WAIT here

'IF B = 0 THEN GOTO L2

PRINT "Analog Input 6: "
put a WAIT here
PRINT FORMAT(A, DEC)
put a WAIT here
PRINT "Sonar(5): "
put a WAIT here
PRINT FORMAT(B, DEC)
put a WAIT here
PRINT " I= "
put a WAIT here
PRINT FORMAT(I, DEC)
put a WAIT here


PRINT 13, 10

GOTO loop1
GOTO MAIN
RubikCube
Robot Builder
Robot Builder
User avatar
Posts: 23
Joined: Mon Mar 06, 2006 1:00 am

Post by robosavvy » Fri Mar 24, 2006 6:01 pm

Post by robosavvy
Fri Mar 24, 2006 6:01 pm

Got the following from Hitec/Multiplex, hope you find it useful:
Regarding Sonar, the pin connection on the manual is described invertedly.
Trigger and echo should be changed. The second issue is the delay time.
We will put the test source on our download site.
Got the following from Hitec/Multiplex, hope you find it useful:
Regarding Sonar, the pin connection on the manual is described invertedly.
Trigger and echo should be changed. The second issue is the delay time.
We will put the test source on our download site.
robosavvy
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 157
Joined: Thu Oct 14, 2004 1:00 am

Post by subpilot » Fri Mar 24, 2006 7:44 pm

Post by subpilot
Fri Mar 24, 2006 7:44 pm

Radioshack has dis-continued the Vex line due to poor sales. It's turning into a cell phone store with over-priced "universal" chargers.
Radioshack has dis-continued the Vex line due to poor sales. It's turning into a cell phone store with over-priced "universal" chargers.
subpilot
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 146
Joined: Sat Feb 25, 2006 1:00 am
Location: Lake Arrowhead, Ca,USA

Post by RubikCube » Fri Mar 24, 2006 10:45 pm

Post by RubikCube
Fri Mar 24, 2006 10:45 pm

Yeah they are discontinuing it that is why it is 50% off at the stores, not the websites.
Yeah they are discontinuing it that is why it is 50% off at the stores, not the websites.
RubikCube
Robot Builder
Robot Builder
User avatar
Posts: 23
Joined: Mon Mar 06, 2006 1:00 am

Testing SRF04

Post by ucrobots » Sat Mar 25, 2006 4:20 pm

Post by ucrobots
Sat Mar 25, 2006 4:20 pm

Today I found this message on the Hitec support page :

Please check the trigger and echo pins are connected correctly.
If it is connected to port combination 0, as manual describes, then
with the following source code, you can check if sonar does the job.
In case it works, then head LED will blink.

'================================

dim a a s integer

10:

a = sonar(0)
out 52,0
out 8,0
delay a

a = sonar(0)
out 52,1
out 8,1
delay a

goto 10
'===================================
Today I found this message on the Hitec support page :

Please check the trigger and echo pins are connected correctly.
If it is connected to port combination 0, as manual describes, then
with the following source code, you can check if sonar does the job.
In case it works, then head LED will blink.

'================================

dim a a s integer

10:

a = sonar(0)
out 52,0
out 8,0
delay a

a = sonar(0)
out 52,1
out 8,1
delay a

goto 10
'===================================
Last edited by ucrobots on Sat Mar 25, 2006 10:39 pm, edited 1 time in total.
ucrobots
Robot Builder
Robot Builder
User avatar
Posts: 12
Joined: Mon Mar 20, 2006 1:00 am
Location: Essenrode near Braunschweig, Germany

Post by ucrobots » Sat Mar 25, 2006 10:24 pm

Post by ucrobots
Sat Mar 25, 2006 10:24 pm

I tried the source code below.
With this code the sonar is working and the LED is blinking.

But the measured distance isn't correct.

delay a takes about 700ms, this means a=700 and distance = 700mm.
But the real distance was about 190cm.

For details have look on http://robosavvy.com/Builders/ucrobots/
file: srf04-diagnostic.doc


================================
dim a as integer

10:

a = sonar(5)
out 52,0
out 9,0
delay a

a = sonar(5)
out 52,1
out 9,1
delay a
goto 10

'===================================
I tried the source code below.
With this code the sonar is working and the LED is blinking.

But the measured distance isn't correct.

delay a takes about 700ms, this means a=700 and distance = 700mm.
But the real distance was about 190cm.

For details have look on http://robosavvy.com/Builders/ucrobots/
file: srf04-diagnostic.doc


================================
dim a as integer

10:

a = sonar(5)
out 52,0
out 9,0
delay a

a = sonar(5)
out 52,1
out 9,1
delay a
goto 10

'===================================
ucrobots
Robot Builder
Robot Builder
User avatar
Posts: 12
Joined: Mon Mar 20, 2006 1:00 am
Location: Essenrode near Braunschweig, Germany

Post by ucrobots » Sun Mar 26, 2006 7:06 pm

Post by ucrobots
Sun Mar 26, 2006 7:06 pm

With the following source code the sonar is working, and printing is also possible.

But the measured distance isn't correct.

I think the sonar() command is only working if the echoline is high when (before) sonar() is executed.

For details have look on http://robosavvy.com/Builders/ucrobots/
file: srf04-diagnostic.doc


================================
dim a as integer
LCDINIT

main:
a = sonar(5)
a = sonar(5)
delay 100

if a=0 then goto main

print "SONAR(5): "
print format(a, dec)
print 10, 13

goto main
With the following source code the sonar is working, and printing is also possible.

But the measured distance isn't correct.

I think the sonar() command is only working if the echoline is high when (before) sonar() is executed.

For details have look on http://robosavvy.com/Builders/ucrobots/
file: srf04-diagnostic.doc


================================
dim a as integer
LCDINIT

main:
a = sonar(5)
a = sonar(5)
delay 100

if a=0 then goto main

print "SONAR(5): "
print format(a, dec)
print 10, 13

goto main
ucrobots
Robot Builder
Robot Builder
User avatar
Posts: 12
Joined: Mon Mar 20, 2006 1:00 am
Location: Essenrode near Braunschweig, Germany

Re: Autonomous RN1 or Spare Head 2

Post by H3dude » Thu May 04, 2006 10:46 am

Post by H3dude
Thu May 04, 2006 10:46 am

Pev wrote:The servo is attached to port 9 and accessed using the servo command, format SERVO 9, {degree} where {degree} is a value from 10 to 190.


Pev, this syntax doesn't seem to do anything in my standard pose block nor in my zero settings:

standard_pose:
SERVO 11, 98
MOVE G6A, 100, 76, 145, 93, 100, 100
MOVE G6D, 100, 76, 145, 93, 100, 100
MOVE G6B, 100, 30, 80, 100, 100, 100
MOVE G6C, 100, 30, 80, 100, 100, 100
WAIT
RETURN


I also tried a simple move

head_turn_no:
SPEED 5
SERVO 11,98
SERVO 11,30
SERVO 11,160
SERVO 11,98
GOSUB standard_pose
RETURN


alas, again I am clueless. Any ideas?
Pev wrote:The servo is attached to port 9 and accessed using the servo command, format SERVO 9, {degree} where {degree} is a value from 10 to 190.


Pev, this syntax doesn't seem to do anything in my standard pose block nor in my zero settings:

standard_pose:
SERVO 11, 98
MOVE G6A, 100, 76, 145, 93, 100, 100
MOVE G6D, 100, 76, 145, 93, 100, 100
MOVE G6B, 100, 30, 80, 100, 100, 100
MOVE G6C, 100, 30, 80, 100, 100, 100
WAIT
RETURN


I also tried a simple move

head_turn_no:
SPEED 5
SERVO 11,98
SERVO 11,30
SERVO 11,160
SERVO 11,98
GOSUB standard_pose
RETURN


alas, again I am clueless. Any ideas?
H3dude
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 50
Joined: Thu Apr 20, 2006 1:00 am
Location: Redmond, WA

Re: Autonomous RN1 or Spare Head 2

Post by Pev » Fri May 05, 2006 7:29 am

Post by Pev
Fri May 05, 2006 7:29 am

H3dude wrote:
Pev wrote:The servo is attached to port 9 and accessed using the servo command, format SERVO 9, {degree} where {degree} is a value from 10 to 190.


Pev, this syntax doesn't seem to do anything in my standard pose block nor in my zero settings:

standard_pose:
SERVO 11, 98
MOVE G6A, 100, 76, 145, 93, 100, 100
MOVE G6D, 100, 76, 145, 93, 100, 100
MOVE G6B, 100, 30, 80, 100, 100, 100
MOVE G6C, 100, 30, 80, 100, 100, 100
WAIT
RETURN


I also tried a simple move

head_turn_no:
SPEED 5
SERVO 11,98
SERVO 11,30
SERVO 11,160
SERVO 11,98
GOSUB standard_pose
RETURN


alas, again I am clueless. Any ideas?


Hi,

Looking at your code you have the additional servo plugged into port 11, but your not calling your head_turn_no routine in the code snippet you have posted. If you want him to turn his head every time he enters standard pose I'd go for something like this:

standard_pose:
SERVO 11, 98
MOVE G6A, 100, 76, 145, 93, 100, 100
MOVE G6D, 100, 76, 145, 93, 100, 100
MOVE G6B, 100, 30, 80, 100, 100, 100
MOVE G6C, 100, 30, 80, 100, 100, 100
WAIT
GOSUB head_turn_no
RETURN

head_turn_no:
SPEED 5
SERVO 11,98
deley 500
SERVO 11,30
delay 500
SERVO 11,160
delay 1000
SERVO 11,98
delay 500
RETURN

I've added the delays just to ensure that servo has time to move. I was using a standard non-digital non feedback servo so if I wasn't careful the servo didn't move as it never had time to.

Hope this makes sense

Pev

PS - if it helps when I was using the sharp IR sensor attached to AD port 1 I used the following code to move the head servo and check the sensor:

SERVO 9, 30 'move head servo to left position
DELAY 3000
LEFT = AD(1) 'Read Sonar on Sonar Port 5

'Check Right
SERVO 9, 190 'move head servo to right position
DELAY 4000
RIGHT = AD(1)

SERVO 9, 108 'move head to center position
DELAY 1000

So he looked left and checked the sesor then looked right and checked the sensor.
H3dude wrote:
Pev wrote:The servo is attached to port 9 and accessed using the servo command, format SERVO 9, {degree} where {degree} is a value from 10 to 190.


Pev, this syntax doesn't seem to do anything in my standard pose block nor in my zero settings:

standard_pose:
SERVO 11, 98
MOVE G6A, 100, 76, 145, 93, 100, 100
MOVE G6D, 100, 76, 145, 93, 100, 100
MOVE G6B, 100, 30, 80, 100, 100, 100
MOVE G6C, 100, 30, 80, 100, 100, 100
WAIT
RETURN


I also tried a simple move

head_turn_no:
SPEED 5
SERVO 11,98
SERVO 11,30
SERVO 11,160
SERVO 11,98
GOSUB standard_pose
RETURN


alas, again I am clueless. Any ideas?


Hi,

Looking at your code you have the additional servo plugged into port 11, but your not calling your head_turn_no routine in the code snippet you have posted. If you want him to turn his head every time he enters standard pose I'd go for something like this:

standard_pose:
SERVO 11, 98
MOVE G6A, 100, 76, 145, 93, 100, 100
MOVE G6D, 100, 76, 145, 93, 100, 100
MOVE G6B, 100, 30, 80, 100, 100, 100
MOVE G6C, 100, 30, 80, 100, 100, 100
WAIT
GOSUB head_turn_no
RETURN

head_turn_no:
SPEED 5
SERVO 11,98
deley 500
SERVO 11,30
delay 500
SERVO 11,160
delay 1000
SERVO 11,98
delay 500
RETURN

I've added the delays just to ensure that servo has time to move. I was using a standard non-digital non feedback servo so if I wasn't careful the servo didn't move as it never had time to.

Hope this makes sense

Pev

PS - if it helps when I was using the sharp IR sensor attached to AD port 1 I used the following code to move the head servo and check the sensor:

SERVO 9, 30 'move head servo to left position
DELAY 3000
LEFT = AD(1) 'Read Sonar on Sonar Port 5

'Check Right
SERVO 9, 190 'move head servo to right position
DELAY 4000
RIGHT = AD(1)

SERVO 9, 108 'move head to center position
DELAY 1000

So he looked left and checked the sesor then looked right and checked the sensor.
Carl
-------------------------
www.alt-view.co.uk
Pev
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 547
Joined: Sun Feb 26, 2006 1:00 am
Location: UK

Re: Autonomous RN1 or Spare Head 2

Post by H3dude » Fri May 05, 2006 5:56 pm

Post by H3dude
Fri May 05, 2006 5:56 pm

Pev wrote:Looking at your code you have the additional servo plugged into port 11, but your not calling your head_turn_no routine in the code snippet you have posted.


I am calling it from a remocon button press, I just didn't include it in my post.

The DELAY command however, is most likely the solution as I'm using the same servo (s3004) as you. I'll try that now. Thanks for your help!
Pev wrote:Looking at your code you have the additional servo plugged into port 11, but your not calling your head_turn_no routine in the code snippet you have posted.


I am calling it from a remocon button press, I just didn't include it in my post.

The DELAY command however, is most likely the solution as I'm using the same servo (s3004) as you. I'll try that now. Thanks for your help!
H3dude
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 50
Joined: Thu Apr 20, 2006 1:00 am
Location: Redmond, WA

Post by H3dude » Mon May 08, 2006 7:03 am

Post by H3dude
Mon May 08, 2006 7:03 am

I got it working, thanks so much. It was the Delay command, just like you pointed out.
I got it working, thanks so much. It was the Delay command, just like you pointed out.
H3dude
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 50
Joined: Thu Apr 20, 2006 1:00 am
Location: Redmond, WA

Post by Pev » Mon May 08, 2006 12:32 pm

Post by Pev
Mon May 08, 2006 12:32 pm

Excellent -

have you put some sort of sensor onto your servo? Do you plan too?

Would love to see what your new Head for RN1 looks like

Pev
Excellent -

have you put some sort of sensor onto your servo? Do you plan too?

Would love to see what your new Head for RN1 looks like

Pev
Carl
-------------------------
www.alt-view.co.uk
Pev
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 547
Joined: Sun Feb 26, 2006 1:00 am
Location: UK

Previous
30 postsPage 2 of 21, 2
30 postsPage 2 of 21, 2