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.

Friday, February 15, 2008

[oopic] Re: events again

--- In oopic@yahoogroups.com, "rtstofer" <rstofer@...> wrote:
>
> --- In oopic@yahoogroups.com, "dogulas" <dogulas@> wrote:
> >
> >
> > Dennis,
> >
> > OOPic III+ Ver C.1.1+ Compiler 6.1.1
> >
> > I'm seeing similar squirrly behavior. I have a complex program
that
> > used an event triggered by a bumper switch. When the switch was
> > activated the event handler did not execute but the main loop
> stopped
> > executing as well. To track down what is wrong, I started out
with
> the
> > sample code in "Chapter 9 - Event Driven ProgrammingC". It
didn't
> work.
> > I was reading this thread and I wrote the following test program
> which
> > is very similar to your test:
> >
> > Dim BLINK As New oEvent
> > Dim WIRE As New oWire
> > Dim LED As New oDIO1
> >
> > Sub Main()
> > LED.IOLine = 20
> > LED.Direction = cvOutput
> > ' Call BLINK_Code()
> > WIRE.Input.Link(ooPIC.Hz1)
> > WIRE.Output.Link(BLINK.Operate)
> > WIRE.Operate = cvTrue
> > Do
> > Loop
> > End Sub
> >
> > Sub BLINK_Code()
> > LED = cvOn
> > ooPIC.Delay = 500
> > LED = cvOff
> > ooPIC.Delay = 500
> > End Sub
> >
> >
> > When I run it as is, nothing happens. The led does not light
up.
> I put
> > in the extra line to prove to myself that the problem was not in
> the led
> > and wierd behavior ensued. The led flashed on and off exactly
ten
> times
> > with a little pause during the eighth off period. The tenth on
> period
> > stays on contiuously. After the tenth flash, one of the servos
> moves
> > slightly. At this point, I have to reset the OOPic to reprogram
> it.
> > This behavior is repeatable.
> >
> > In my original complex program, everything execpt the event works
> fine.
> >
>
> Yes but... Do you know if event code is reentrant? Assuming your
> version of the compiler has OOPic.Delay in mS (it used to be 0.01
> second in V5) then your event code COULD take longer than the
> OOPic.1Hz trigger interval.
>
> I haven't made the transition to V6 so I don't know a lot about the
> issues but if I were doing the code above, I would start by cutting
> the delays to 250 to be absolutely certain the event code was
> complete before the next trigger.
>
> Richard
>

Richard,

Thanks for the reply.

Excellent point! The event must be taking slightly longer than one
second. I changed the delays to 250 and guess what? It now flashes
in one second cycles indefinately.

While that mystery is solved, the bigger question is: Why do I have
to call the BLINK_Code() as a subroutine first? Remember, when I
have that call statement commented out, the event handler is not
firing. Any thoughts on that?

Thanks,
Dogulas



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: