not take advantage of the ooPIC in high speed mode and will have
terrible resolution. The ooPIC book shows how to trigger and disable
the oTimer to get a SONAR timing. You'll need to do this here as well.
Because the Ping is designed for the Parallax Stamp it really doesn't
work all that well on the ooPIC since you have to switch an IO line from
output to input, which is very slow in ooPIC scripting.
I haven't tried this, but you might be able to switch an ooPIC IOline
from input to output using a oWire, but I'm not sure since I don't know
if .Direction is a linkable flag. Try it and see, I'll experiment with
that as well.
Next, I recommend that you put a pullup resistor on the IOline to the
Ping so that when you flip it to be an input it will automatically pull
high initiating a SONAR ping. In this way you can start the ping and be
ready to look for a low value on the IOline by just setting .Direction =
cvInput.
Next I strongly recommend that to get any kind of useful timing
information that you make sure that the oTimer object is linked to the
virtual circuit and NOT done as a script language loop. See how this is
done in the book for the SRF04 SONAR, it will be very similar.
DLC
robotxro wrote:
> Hello group,
>
> 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
>
--
------------------------------------------------------
Dennis Clark ooPIC Tech Support
www.oopic.com
------------------------------------------------------
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