objects will allow you to debounce the buttons as well which will make
everything work better. Remember that an event will fire when the
Operate line moves from '0' to '1', it won't fire again until it moves
back to '0'. I'm not a fan of using ooPIC.delay in anything. I would
have a function that is periodically called that checks against a timer
so that processing can go on while something is awaiting a timeout. One
way to do that is to create a VC (virtual circuit) that is triggered by
the button press such that it will start a timer that will call an event
to shut a switch off when it times out. oCountdown is a good candidate
for that.
DLC
carson hoyt wrote:
> Well I decided on events rather than directly linking the buttons because I want the dio states to be able to change over time, which isn't shown in this version of the code.
> The actual events would look more like
>
> switch1.state = cvOff (Concerning these first two lines: is there a way to set
> switch2.state = cvOn up some sort of protocol where for instance it was a
> oopic.delay = 25 given that if switch1 was on then switches 2, 3, 4
> switch2.state = cvOff would be off?)
> switch1.state = cvOn
> oopic.delay = 20
> and on and on for a little while
>
> This program is eventually going to be incorporated into a larger program where the events are controling servos and other objects as well.
> In effect what I'm trying to do is set up each event as a short control program which is triggered by a single external button.
> Am I going about this the wrong way, is there another way?
>
> On a related subject if such programs were written how long could they be before the oopic would run out of disk space?
>
> Thanks
>
> Carson
>
>
>
>
>
>
>
>
> bobhedges9 <bhmtr@mindspring.com> wrote: looks like oflipflop would be easier than the events.
>
> --- In oopic@yahoogroups.com, carson hoyt <carr6565@...> wrote:
> >
> > I recently wrote this code to toggle some solid state analog
> switches, but am unsure if the code is bad or if I am screwing
> something else up all together. I have a feeling I got some of the
> hardware wrong, anyone have any suggestions.
> > Oh secondarily, is there some way to sync output signals or does
> that happen automatically. Thanks for the help.
> >
> >
> > Dim switch1 As New oDIO1
> > Dim switch2 As New oDIO1
> > Dim switch3 As New oDIO1
> > Dim switch4 As New oDIO1
> >
> > Dim button1 As New oDIO1
> > Dim button2 As New oDIO1
> >
> > Dim wire1 As New oWire
> > Dim wire2 As New oWire
> >
> > Dim routerstate1 As New oEvent
> > Dim routerstate2 As New oEvent
> >
> > Sub Main()
> >
> > ooPIC.Delay = 250
> >
> > switch1.IOLine = 1
> > switch1.Direction = cvOutput
> > switch1.State = cvOn
> >
> > switch2.IOLine = 2
> > switch2.Direction = cvOutput
> > switch2.State = cvOff
> >
> > switch3.IOLine = 3
> > switch3.Direction = cvOutput
> > switch3.State = cvOff
> >
> > switch4.IOLine = 4
> > switch4.Direction = cvOutput
> > switch4.State = cvOff
> >
> > button1.IOLine = 6
> > button1.Direction = cvInput
> >
> > button2.IOLine = 7
> > button2.Direction = cvInput
> >
> >
> > wire1.Input.Link(button1)
> > wire1.Output1.Link(routerstate1.Operate)
> > wire1.InvertIn = cvTrue
> > wire1.Operate = cvTrue
> >
> > wire2.Input.Link(button2)
> > wire2.Output1.Link(routerstate2.Operate)
> > wire2.InvertIn = cvTrue
> > wire2.Operate = cvTrue
> >
> > End Sub
> >
> > Sub routerstate1_Code()
> > switch1.State = cvOn
> > End Sub
> >
> > Sub routerstate2_Code()
> > switch1.State = cvOff
> >
> >
> > End Sub
> >
> >
> >
> > ---------------------------------
> > Don't let your dream ride pass you by. Make it a reality with
> Yahoo! Autos.
> >
> > [Non-text portions of this message have been removed]
> >
>
>
>
>
>
>
> ---------------------------------
> Be a better Heartthrob. Get better relationship answers from someone who knows.
> Yahoo! Answers - Check it out.
>
> [Non-text portions of this message have been removed]
>
>
>
>
> 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:
No comments:
Post a Comment