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

srf04 on rn

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

srf04 on rn

Post by dragbot » Sat Aug 25, 2007 4:34 pm

Post by dragbot
Sat Aug 25, 2007 4:34 pm

Hy all!
I have some troubles putting an srf04 ultrasonic devantech on my rn1, i always have values = 0. I saw all the topics about this but on the end could not fix this problem and really the suggestion i found didn't solve it. Some body can help me ?

thx
Hy all!
I have some troubles putting an srf04 ultrasonic devantech on my rn1, i always have values = 0. I saw all the topics about this but on the end could not fix this problem and really the suggestion i found didn't solve it. Some body can help me ?

thx
dragbot
Newbie
Newbie
Posts: 1
Joined: Sat Aug 25, 2007 4:31 pm

Post by davidalecmcinnes » Sat Sep 08, 2007 10:50 am

Post by davidalecmcinnes
Sat Sep 08, 2007 10:50 am

Hi there,

I've actually been using an SRF05, a low current version connected to the 5V.

It behaves erratically though, detecting nothing at random and not responding to objects when it should.

I took a scope to it and found that the input trigger is activated every 12ms continuously, according to my measurements for a duration of 1.5ms.

The input trigger is arriving at the SRF05 and the echo comes back about 750us later, the positive width of the echo is directly proportional to distance so the SRF05 is working.

However, the time between the end of the echo and the next input trigger pulse is relatively short, sometimes as low as 2-3ms.

The timing diagram for the SRF04 indicates that the delay before the end of the echo and the next input trigger must be at least 10ms but the SRF05 is giving a valid response every time.

This is the code I used.

DIM son1 AS INTEGER

MOTOROFF 10
MOTOROFF 11

son1=SONAR(5)
DELAY 500

IF son1<10 THEN son1=500
IF son1<250 THEN GOSUB grab

I have a query in with hitec on this problem at the moment but I am thinking to use a 3rd order filter low pass filter on the output to produce a dc level instead. My colleague is looking at setting up a timer in robobasic and triggering it manually.
Hi there,

I've actually been using an SRF05, a low current version connected to the 5V.

It behaves erratically though, detecting nothing at random and not responding to objects when it should.

I took a scope to it and found that the input trigger is activated every 12ms continuously, according to my measurements for a duration of 1.5ms.

The input trigger is arriving at the SRF05 and the echo comes back about 750us later, the positive width of the echo is directly proportional to distance so the SRF05 is working.

However, the time between the end of the echo and the next input trigger pulse is relatively short, sometimes as low as 2-3ms.

The timing diagram for the SRF04 indicates that the delay before the end of the echo and the next input trigger must be at least 10ms but the SRF05 is giving a valid response every time.

This is the code I used.

DIM son1 AS INTEGER

MOTOROFF 10
MOTOROFF 11

son1=SONAR(5)
DELAY 500

IF son1<10 THEN son1=500
IF son1<250 THEN GOSUB grab

I have a query in with hitec on this problem at the moment but I am thinking to use a 3rd order filter low pass filter on the output to produce a dc level instead. My colleague is looking at setting up a timer in robobasic and triggering it manually.
davidalecmcinnes
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 33
Joined: Tue Jun 26, 2007 12:51 pm
Location: UK

Post by i-Bot » Sat Sep 08, 2007 5:35 pm

Post by i-Bot
Sat Sep 08, 2007 5:35 pm

What you are seeing are servo pulses, 1.5 ms (centre) every 12ms (no Gyro enabled).

There is a problem with the motor on/off commans in Robobasic. I have not checked which versions this relates to, though there is mention in the release notes. The MOTOROFF actually turns the servo on !

Try with removing the MOTOROFF commands.

Don't bother trying to use Robobasic for timing, it is too slow.
What you are seeing are servo pulses, 1.5 ms (centre) every 12ms (no Gyro enabled).

There is a problem with the motor on/off commans in Robobasic. I have not checked which versions this relates to, though there is mention in the release notes. The MOTOROFF actually turns the servo on !

Try with removing the MOTOROFF commands.

Don't bother trying to use Robobasic for timing, it is too slow.
i-Bot
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 1142
Joined: Wed May 17, 2006 1:00 am

Post by i-Bot » Sun Sep 09, 2007 1:34 pm

Post by i-Bot
Sun Sep 09, 2007 1:34 pm

I am using Robobasic V2.5e, which shows in the about window as 2.5.61. This still appears to compile the MOTOROFF to a MOTOR instruction. Even though it says here, that MOTOROFF was fixed in the previuos version.

- 2006/11/29 : Add PC direct motor control function in roboScript v2.6
- 2006/10/26 : Bug fix of MOTOROFF command.
- 2006/10/12 : Bug fix in ROBONOVA zero value setting window.
- 2006/01/26 : Bug fix of left/right motors control in ROBONOVA motor control window.
- 2006/01/26 : Add command "OFFSET" for zero value modification in real time.

Does anyone have a version which works ?
I am using Robobasic V2.5e, which shows in the about window as 2.5.61. This still appears to compile the MOTOROFF to a MOTOR instruction. Even though it says here, that MOTOROFF was fixed in the previuos version.

- 2006/11/29 : Add PC direct motor control function in roboScript v2.6
- 2006/10/26 : Bug fix of MOTOROFF command.
- 2006/10/12 : Bug fix in ROBONOVA zero value setting window.
- 2006/01/26 : Bug fix of left/right motors control in ROBONOVA motor control window.
- 2006/01/26 : Add command "OFFSET" for zero value modification in real time.

Does anyone have a version which works ?
i-Bot
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 1142
Joined: Wed May 17, 2006 1:00 am

Post by davidalecmcinnes » Mon Sep 10, 2007 7:52 am

Post by davidalecmcinnes
Mon Sep 10, 2007 7:52 am

HI there, thanks for your response, I removed the motoroff commands to no avail, the servo pulses are still there continuously. Is there any command which turns them off, otherwise you wont be able to use digital outputs? I have Robobasic 2.5.17 at the moment, I'll check for updates.
HI there, thanks for your response, I removed the motoroff commands to no avail, the servo pulses are still there continuously. Is there any command which turns them off, otherwise you wont be able to use digital outputs? I have Robobasic 2.5.17 at the moment, I'll check for updates.
davidalecmcinnes
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 33
Joined: Tue Jun 26, 2007 12:51 pm
Location: UK

Post by i-Bot » Mon Sep 10, 2007 8:13 am

Post by i-Bot
Mon Sep 10, 2007 8:13 am

The motors should be off by default on power up. So if you avoid any MOTOR or MOTOROFF for those port, either individually or as part of a group , they should not have any pulses.

It should be possible to turn them off with a POKE. I will check the memory locations and let you know.
The motors should be off by default on power up. So if you avoid any MOTOR or MOTOROFF for those port, either individually or as part of a group , they should not have any pulses.

It should be possible to turn them off with a POKE. I will check the memory locations and let you know.
i-Bot
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 1142
Joined: Wed May 17, 2006 1:00 am

Post by i-Bot » Mon Sep 10, 2007 2:55 pm

Post by i-Bot
Mon Sep 10, 2007 2:55 pm

The 24 Motor enable bits are at memory locations $H4EB, &H4EC, and &H4ED, with bits representing enabled or not.

Motors 10 and 11 should be bits 2 and 3 of &H4EC. So try:

POKE &H4EC, &HF3

This should clear the enables and turn off those motors. If this doesn't work, let me know and I will dig out my SRF04 to try.
The 24 Motor enable bits are at memory locations $H4EB, &H4EC, and &H4ED, with bits representing enabled or not.

Motors 10 and 11 should be bits 2 and 3 of &H4EC. So try:

POKE &H4EC, &HF3

This should clear the enables and turn off those motors. If this doesn't work, let me know and I will dig out my SRF04 to try.
i-Bot
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 1142
Joined: Wed May 17, 2006 1:00 am

Post by davidalecmcinnes » Mon Sep 10, 2007 5:18 pm

Post by davidalecmcinnes
Mon Sep 10, 2007 5:18 pm

Hi there,

Thanks for the information, sounds promising. Unfortunately the darn program wont compile with an address higher than 255, it reports:

Error 20 : [POKE] Can't use integer-type

I have tried all the variations I can think of such as decimal, declaring integers, etc.

Any thoughts?
Hi there,

Thanks for the information, sounds promising. Unfortunately the darn program wont compile with an address higher than 255, it reports:

Error 20 : [POKE] Can't use integer-type

I have tried all the variations I can think of such as decimal, declaring integers, etc.

Any thoughts?
davidalecmcinnes
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 33
Joined: Tue Jun 26, 2007 12:51 pm
Location: UK

Post by i-Bot » Mon Sep 10, 2007 5:29 pm

Post by i-Bot
Mon Sep 10, 2007 5:29 pm

I just tried it. Mine compiles and works fine:

DIM rr AS byte
DIM echo AS INTEGER
loop:
echo = SONAR(5)
POKE &H4ec,&hf3
PRINT &HFE
PRINT &H01
PRINT "Distance ="
PRINT FORMAT(echo,DEC,4)
DELAY 100
GOTO loop
I just tried it. Mine compiles and works fine:

DIM rr AS byte
DIM echo AS INTEGER
loop:
echo = SONAR(5)
POKE &H4ec,&hf3
PRINT &HFE
PRINT &H01
PRINT "Distance ="
PRINT FORMAT(echo,DEC,4)
DELAY 100
GOTO loop
i-Bot
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 1142
Joined: Wed May 17, 2006 1:00 am

Post by davidalecmcinnes » Tue Sep 11, 2007 8:09 am

Post by davidalecmcinnes
Tue Sep 11, 2007 8:09 am

Thank you for all your help, it is much appreciated. I am still stuck with this non compiling problem unfortunately which I will have to resolve, could be a version issue.
Thank you for all your help, it is much appreciated. I am still stuck with this non compiling problem unfortunately which I will have to resolve, could be a version issue.
davidalecmcinnes
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 33
Joined: Tue Jun 26, 2007 12:51 pm
Location: UK

Post by davidalecmcinnes » Tue Sep 11, 2007 8:34 am

Post by davidalecmcinnes
Tue Sep 11, 2007 8:34 am

The ROMPOKE did compile but didn't make any difference to the operation. Ah well
The ROMPOKE did compile but didn't make any difference to the operation. Ah well
davidalecmcinnes
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 33
Joined: Tue Jun 26, 2007 12:51 pm
Location: UK

Post by i-Bot » Tue Sep 11, 2007 8:51 am

Post by i-Bot
Tue Sep 11, 2007 8:51 am

My code snip works just fine with the SRF04.

I see the MOTOR command turning on the servo pulses. The MOTOOFF command also turns on the servo pulses, this is the bug.

The Poke turns off the servo pulses.

I am using Robobasic 2.5e, 2.5.61. Download from

http://www.robonova.de/store/support/in ... 95&nav=0,6

Can you post your full code ? You must be turning the motors on somewhere. Maybe as part of a group
My code snip works just fine with the SRF04.

I see the MOTOR command turning on the servo pulses. The MOTOOFF command also turns on the servo pulses, this is the bug.

The Poke turns off the servo pulses.

I am using Robobasic 2.5e, 2.5.61. Download from

http://www.robonova.de/store/support/in ... 95&nav=0,6

Can you post your full code ? You must be turning the motors on somewhere. Maybe as part of a group
i-Bot
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 1142
Joined: Wed May 17, 2006 1:00 am

Post by davidalecmcinnes » Tue Sep 11, 2007 2:34 pm

Post by davidalecmcinnes
Tue Sep 11, 2007 2:34 pm

I upgraded my robobasic, that cured that problem, the SRF04 is now only firing when I call it from basic which is cool, I suspected it was a version problem.

However, now I'm getting zeroes all the time, I will get a scope on it alter and check that the SRF04 is doing its thing. I'll get an LCD or RS232 link on to look at the data aswell.

Thanks so much
I upgraded my robobasic, that cured that problem, the SRF04 is now only firing when I call it from basic which is cool, I suspected it was a version problem.

However, now I'm getting zeroes all the time, I will get a scope on it alter and check that the SRF04 is doing its thing. I'll get an LCD or RS232 link on to look at the data aswell.

Thanks so much
davidalecmcinnes
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 33
Joined: Tue Jun 26, 2007 12:51 pm
Location: UK

Post by davidalecmcinnes » Wed Sep 12, 2007 1:13 pm

Post by davidalecmcinnes
Wed Sep 12, 2007 1:13 pm

Hi there,

I have setup an RS232 link and can send data to hyper terminal, the IR sensor works ok on AD(0) using this program but the sonar is giving me 000 all the time. Here is the complete program:

DIM rr AS BYTE
DIM echo AS INTEGER

DIM hundreds AS BYTE
DIM tens AS BYTE
DIM ones AS BYTE

loop:
echo = SONAR(5)
POKE &H4ec,&hf3

hundreds=48
tens=48
ones=48

loop2:
IF echo>100 THEN hundreds=hundreds+1
IF echo>100 THEN echo=echo-100
IF echo>100 THEN GOTO loop2

IF echo>10 THEN tens=tens+1
IF echo>10 THEN echo=echo-10
IF echo>10 THEN GOTO loop2

IF echo>1 THEN ones=ones+1
IF echo>1 THEN echo=echo-1
IF echo>1 THEN GOTO loop2


ETX 9600,hundreds
ETX 9600,tens
ETX 9600,ones

ETX 9600,13
ETX 9600,10

DELAY 100
GOTO loop

The scope reveals that the SRF04 is doing it's thing, the activation pulse is just over 10us and the echo varies between 0.2ms to 7ms. Any ideas?
Hi there,

I have setup an RS232 link and can send data to hyper terminal, the IR sensor works ok on AD(0) using this program but the sonar is giving me 000 all the time. Here is the complete program:

DIM rr AS BYTE
DIM echo AS INTEGER

DIM hundreds AS BYTE
DIM tens AS BYTE
DIM ones AS BYTE

loop:
echo = SONAR(5)
POKE &H4ec,&hf3

hundreds=48
tens=48
ones=48

loop2:
IF echo>100 THEN hundreds=hundreds+1
IF echo>100 THEN echo=echo-100
IF echo>100 THEN GOTO loop2

IF echo>10 THEN tens=tens+1
IF echo>10 THEN echo=echo-10
IF echo>10 THEN GOTO loop2

IF echo>1 THEN ones=ones+1
IF echo>1 THEN echo=echo-1
IF echo>1 THEN GOTO loop2


ETX 9600,hundreds
ETX 9600,tens
ETX 9600,ones

ETX 9600,13
ETX 9600,10

DELAY 100
GOTO loop

The scope reveals that the SRF04 is doing it's thing, the activation pulse is just over 10us and the echo varies between 0.2ms to 7ms. Any ideas?
davidalecmcinnes
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 33
Joined: Tue Jun 26, 2007 12:51 pm
Location: UK

Post by i-Bot » Fri Sep 14, 2007 11:15 am

Post by i-Bot
Fri Sep 14, 2007 11:15 am

I tried your code and it worked for me,if rather slow.

I made a couple of changes, first because I put my POKE in an ugly place, and so you did too. Also results can be over 1000, so I added another digit.

The POKE is not needed really, since the motors had not been on since power up.

Results range from around 30 to 2500
SRF04 is a bit sensitive to local reflecting surfaces. I have foam around the sides of the transducers, and any close surfaces.

I have the SRF04 powered from the PWM2 pins. Servo 10 signal goes to middle hole in SRF04, Servo 11 signal to pin between middle and +5V. ERX is connected to a FTDI TTL to usb cable


DIM rr AS BYTE
DIM echo AS INTEGER

DIM thousands AS BYTE
DIM hundreds AS BYTE
DIM tens AS BYTE
DIM ones AS BYTE

POKE &H4ec,&hf3

loop:
echo = SONAR(5)

thousands = 48
hundreds=48
tens=48
ones=48

loop2:

IF echo>1000 THEN thousands=thousands+1
IF echo>1000 THEN echo=echo-1000
IF echo>1000 THEN GOTO loop2

IF echo>100 THEN hundreds=hundreds+1
IF echo>100 THEN echo=echo-100
IF echo>100 THEN GOTO loop2

IF echo>10 THEN tens=tens+1
IF echo>10 THEN echo=echo-10
IF echo>10 THEN GOTO loop2

IF echo>1 THEN ones=ones+1
IF echo>1 THEN echo=echo-1
IF echo>1 THEN GOTO loop2

ETX 9600,thousands
ETX 9600,hundreds
ETX 9600,tens
ETX 9600,ones

ETX 9600,13
ETX 9600,10

DELAY 100
GOTO loop
I tried your code and it worked for me,if rather slow.

I made a couple of changes, first because I put my POKE in an ugly place, and so you did too. Also results can be over 1000, so I added another digit.

The POKE is not needed really, since the motors had not been on since power up.

Results range from around 30 to 2500
SRF04 is a bit sensitive to local reflecting surfaces. I have foam around the sides of the transducers, and any close surfaces.

I have the SRF04 powered from the PWM2 pins. Servo 10 signal goes to middle hole in SRF04, Servo 11 signal to pin between middle and +5V. ERX is connected to a FTDI TTL to usb cable


DIM rr AS BYTE
DIM echo AS INTEGER

DIM thousands AS BYTE
DIM hundreds AS BYTE
DIM tens AS BYTE
DIM ones AS BYTE

POKE &H4ec,&hf3

loop:
echo = SONAR(5)

thousands = 48
hundreds=48
tens=48
ones=48

loop2:

IF echo>1000 THEN thousands=thousands+1
IF echo>1000 THEN echo=echo-1000
IF echo>1000 THEN GOTO loop2

IF echo>100 THEN hundreds=hundreds+1
IF echo>100 THEN echo=echo-100
IF echo>100 THEN GOTO loop2

IF echo>10 THEN tens=tens+1
IF echo>10 THEN echo=echo-10
IF echo>10 THEN GOTO loop2

IF echo>1 THEN ones=ones+1
IF echo>1 THEN echo=echo-1
IF echo>1 THEN GOTO loop2

ETX 9600,thousands
ETX 9600,hundreds
ETX 9600,tens
ETX 9600,ones

ETX 9600,13
ETX 9600,10

DELAY 100
GOTO loop
i-Bot
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 1142
Joined: Wed May 17, 2006 1:00 am

Next
16 postsPage 1 of 21, 2
16 postsPage 1 of 21, 2