--- In oopic@yahoogroups.com, "richard6406" <richard@...> wrote:
>
> 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
>
Do you have it wired like: http://www.robot-
electronics.co.uk/htm/srf08oopic-r.htm ? It should be quite similar
if not identical.
It would be worth reading register 1 to be certain you get 0x80
back. If not, you aren't communicating.
So, the unit measures to 6 meters or 600 cm. Then 600 cm / 256
(masking out the low byte) means the upper byte only varies between
0 and 2. That won't make much of a movement.
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/