>
> BLINK_code is supposed to be an *event handler* that does something
> fast and gets out, not a piece of code that takes its sweet time
> doing whatever it feels like.
>
> If you want to play around with event handling, do something fast,
> like toggle the LED's state (LED = 1 - LED)
>
> At 02:23 PM 2/15/2008, 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.
>
Andrew,
Thanks for the reply.
I agree with you fully. In the original program I am merely flipping
a bit flag. I was just trying a test where I could see some activity
in the handler. I went back and changed the code to be like this:
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.Toggle
End Sub
When I run it like this, the led flashes so fast, I'm beginning to
think that ooPic.Hz1 alternates ten time a second instead of one.
But at least it works. As pointed out in another branch, the
original handler took a little over a second to run.
Now for the bigger question. If I comment out the Call statement,
the handler never fires and the led stays dark. Why would I need to
call the handler like a subroutine first to make it work correctly?
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:
No comments:
Post a Comment