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, July 20, 2008

[oopic] Re: Optimizing code

Thanx I'll try both of your suggestions (soon) and let you know what
I find.
Little tricks like using Byte rather than oByte, and better use of
VCs, that's the type of info I'm looking for.

I read somewhere in the docs that use of constants can save variable
memory, but if it ain't working I'll go with whatever is easier.

I have some 32k EEPROMs so I can go wild with programming and data
space. Now I have some work to do! Like I said, speed isn't a
priority (unless we are REALLY talking slow!) but I do want to try
coding some more advanced 'behavior' using the available variables
and objects.

Thanks again for the advice!

--- In oopic@yahoogroups.com, "rtstofer" <rstofer@...> wrote:
>
> --- In oopic@yahoogroups.com, "red71956" <kdwyer@> wrote:
> >
> > I uploaded a (not-yet-finished) file - OttoExplorer - that uses
79
> > bytes of RAM, close to the limit of 86. I made very liberal use
of
> > cut 'n paste so you may find many sections familiar. I tried to
keep it
> > well-commented.
> > I used: an LCD, sonar, IR, pan/tilt servos, 2 DC motors, and lots
of
> > Constants.
> > My understanding is that using constants will store values in
EEPROM,
> > freeing up limited system resources. I also know that using VCs
> > (virtual circuits) can help speed program execution.
> >
> > Is there a trick I am missing, or misusing? I'd luv some advice
on how
> > to optimize the code (esp. with VCs) so I can get the most out of
my
> > ooPIC. I tend to write sloppy code, so tightening up the code and
> > making best use of resources is important. Execution speed is not
as
> > important to me as maximizing use of limited ooPIC resources.
> >
> > The code is far from finished, but it is a good start, and
hopefully
> > easy to follow. It is for a B2.2+ ooPIC using V6 compiler.
> >
>
> Your resource limitation is object memory. Adding VS's won't
> necessarily improve that. In fact, the oBus or oWire objects will
> probably increase the usage.
>
> Sub explore() could probably be replaced by a VC that triggers an
> event and the event code would trigger avoid() function. But all
that
> would do is collapse the explore() function and eliminate the loop
in
> main().
>
> Using the named constants doesn't result in any less object memory
and
> may not really change the code space requirements either. Write a
> simple program like:
>
> dim a as new oByte
> const SixtyFour = 64
>
> sub main()
> a = 64
> a = SixtyFour
> end sub
>
> Then look at the emitted code and see if the two are different. I'm
> not on a Windows box at the moment so I can't really test this. I
> doubt they are different. YEARS ago, with interpreted Basic, named
> constants were faster that numeric constants; depending on the
> interpreter, of course.
>
> You might try using Byte instead of oByte and save a little object
memory.
>
> 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: