I have a robot based on a ER1 kit and I have added a ooPic-R
microcontroller to controll a 6DOF arm with servos and a pan/tilt
head for the camera. On the head I have mounted a Ping ultrasonic
range sensor made by Parallax and an Eltec PIR sensor. I also have a
Devantech compass sensor on the I2C interface. Another 3 Ping
sensors will be added to the ooPic-R. The project is a couple years
old but set aside for some reason. Now I'm trying to revive it but
run into some problems.
The problem I have is making the Ping sonar to do it's job. Since it
doesn't have a specific object defined, I have adapted the code
found in Dennis Clark's book (Programming and customising the ooPic
microcontroller - realy nice book!) for the older ooPic
microcontrollers, but it does not work for some reason. Here is the
test code, please take a look and let me know what can I do to make
it work. I am reading the CamValue from serial port using SCP
commands on my computer, but is allways 0 and the sonar's activity
LED does not turn on at all. With my multimeter I get a voltage of
0.3 volts on the signal line from time to time.
Dim Tics As New oTimer ' Create the sonar timer
Dim Son0 As New oDIO1 ' Create the camera sonar line
Dim conn0 As New oWire ' Create the wire link
Dim CamValue As New oWord ' Camera sonar distance
'
Sub Main()
ooPIC.Snode = 1
Call Setup()
ooPIC.Delay = 100
Do
Call ReadSonar()
ooPIC.Delay = 150
Loop
End Sub
'
'
Sub Setup() ' Setup the compass, servos, eltec...
Tics.PreScale = 2
Tics.Operate = cvFalse
Tics = 0
Son0.IOLine = 1
Son0.Direction = cvOutput
Son0 = cvLow
conn0.Input. Link(Son0. State)
conn0.Output. Link(Tics. Operate)
conn0.Operate = cvFalse
End Sub
'
Sub ReadSonar()
Tics = 0
Son0.Direction = cvOutput
Son0 = cvHigh
Son0 = cvLow
Son0.Direction = cvInput
conn0.Operate = cvTrue
Do 1 Times: Loop
While Son0 = cvHigh
Wend
CamValue = Tics/470 ' Get the distance in cm
conn0.Operate = cvFalse
End Sub
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:
No comments:
Post a Comment