Saturday, December 22, 2007

[oopic] SRF02 on an OOpic-R

Hi Folks,

Am new here ( and to robotics ) so please bear with me :)

I recently got an OOPic-R board and have so far had no problems with
a few small programs ( switching LED's / buzzing / running servos and
running a Motor controller ) But I am now trying to connect an SRF02
Ultasonic range finder ( http://www.robot-
electronics.co.uk/htm/srf02techI2C.htm ).

The simple program I have is :

Dim Sonar As New oI2CM 'Sonar object
Dim Servo As New oServo 'Servo object
Dim Range As New oByte ' Range variable

Sub Main()
ooPIC.Delay = 500 ' 5 sec delay before start

'~~~~~~~~~~~~ Set Up Sonar~~~~~~~~~~~~~~~~
Sonar.Node = 112 ' Decimal of Hex address 0xE0 shifted by 1
Sonar.Mode = cv10Bit ' I2C mode as 10-Bit addressing.
Sonar.Width = cv8Bit ' 1 byte wide transfer
Sonar.NoInc = 1 ' Don't increment


'~~~~~~~~~~~~~ Set up Servo ~~~~~~~~~~~~~~~~
Servo.IOLine = 31 ' Use line 31
Servo.Adjust = 28 ' Center
Servo.Operate =cvTrue ' Start servo

Do ' Continuous loop
Sonar.Location = 0 ' Command register
Sonar = 81 ' Set ranging to cm
ooPIC.Delay = 7 ' Wait to give sonar time
Sonar.Location = 2 ' Just get high Byte
Range = Sonar ' Get Range
Servo = Range ' Move servo
ooPIC.Delay = 50 ' Wait 500ms
Loop

End Sub

Did this just to try and read the high byte and move a servo to show
I'm getting a signal every half second.

When this runs the servo moves slightly forward and back at half
second intervals but the sonar does not seem to be firing ( no led
blink, only the long blink on power up ).

I'm sure this will be the first of many questions :)

Wishing you all the best.

Richard


Yahoo! Groups Links

<*> To visit your group on the web, go to:

http://groups.yahoo.com/group/oopic/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:

http://groups.yahoo.com/group/oopic/join

(Yahoo! ID required)

<*> To change settings via email:
mailto:oopic-digest@yahoogroups.com
mailto:oopic-fullfeatured@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
oopic-unsubscribe@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:

http://docs.yahoo.com/info/terms/

No comments:

Post a Comment