This Forum is Dedicated For all The Object Oriented PIC Lovers .......... The concept behind OOPic is straight forward. Use preprogrammed multitasking Objects from a library of highly optimized Objects to do all the work of interacting with the hardware. Then write small scripts in Basic, C, or Java syntax styles to control the Objects. During operation, the Objects run continuously and simultaneously in the background while the scripts run in the foreground telling the objects what to do.

Sunday, August 5, 2007

Re: [oopic] I need a some help with the folloowing program.

Try using oCompare to check the two values. When you are subtracting
one from the other you can get negative values which look weird because
0-1 = 128, which you certainly don't expect to see! My usual would be
to feed each SONAR value to an oMath to strip off the lower two bits of
resolution, or perhaps bottom 3 bits (0-7), then feed those results to
oCompare. It will operate very fast and be a bit easier to understand.

DLC

gravito_magnetics wrote:
> Hi,
>
> I have problem with the following program.
> The problem is that I want to compare the subtract value between
> Rsonar and Lsonar values, so first I did this
>
> sonar1 = Rsonar - Lsonar
>
> But it gave me some strange value when I use the debugger to display
> the value of sonar1. As an example, when the value of Rsonar and
> Lsonar were 27, the value for sonar1 was 117 (sometime, it displays
> different number) while I expected 0 (zero), so I changed to oMath,
> but still the value of sonar1 dosen't make any sense to me.
>
> My experience with oopic is limited, so please help me.
>
> Thank you,
>
> TS
>
>
> Dim Lsonar as New oA2D 'Left Sonar Sensor
> Dim Rsonar as New oA2D 'Right Sonar Sensor
> Dim Rmotor as New oServo 'Move the Right motor
> Dim Lmotor as New oServo 'Move the Left motor
> Dim Add1 as New oMath
> Dim sonar1 as New oByte
> Dim sonar2 as New oByte
>
> Sub Main()
>
> OOPic.Node = 1 'For debugging
>
> Rsonar.IOLine = 6 'IOLine 6 for sensor
> Lsonar.IOLine = 7 'IOLine 7 for sensor
> Rsonar.Operate = cvTrue
> Lsonar.Operate = cvTrue
>
> Rmotor.IOLine = 21 'IOLine 21 for Right
> Rmotor.Center = 22 'The "standard" center value
> Rmotor.Operate = cvTrue
>
> Lmotor.IOLine = 26 'IOLine 26 for Left
> Lmotor.Center = 22 'The "standard" center value
> Lmotor.Operate = cvTrue
>
> Add1.Input1.Link(Rsonar) 'Get right sonar data
> Add1.Input2.Link(Lsonar)
> Add1.Output.Link(sonar1)
> Add1.Mode = cvSubtract
> Add1.Operate = cvTrue
>
>
> Do
> If sonar1 > 7 Then
> Rmotor.Value = 26
> Lmotor.Value = 26
>
> Else
> Rmotor.Value = 38
> Lmotor.Value = 38
>
> End If
>
> Loop
>
> End Sub
>
>
>
>
>
>
> Yahoo! Groups Links
>
>
>

--
------------------------------------------------------
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:

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

No comments: