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.

Saturday, January 5, 2008

Re: [oopic] help with event driven bumper switches

w1.Operate = cvTrue
w2.Operate = cvTrue

DLC

dldlhfd@aol.com wrote:
> I hope you can help.
> I am using C.1.1+ board and version 6.1.1 compiler
> I have pared the program down to just include a simple event. the whole
> project is a robot with two bumper switches, one front one back.
> 1. The robot goes forward as it should no problem
> 2. if I call any of the routines from the main program it executes as they
> should.
> 3. I have two bumper switches set up
> 4. both switches supply 5 volts to their respective IO line normally
> 5. when the switch is bumped the switch voltage supplied to the IO line goes
> to 0 volts
> 6. The program ignores the bumper switches.
> 7. I physically read the voltages and they are changing when the switched is
> pressed.
> 8. I tried putting a do loop around the last four lines of the main sub but
> it ignored the switches then also
>
> Here is what I think should be happening with the values:
>
> switch1.IOLine = 13 'assign bumper sw 1 to line 13
> normal bumped
> w1.Input.Link(switch1.Position) 'read bump sw1 assign to wire b1
> 5 0
> w1.Output.Link(bumprd1.Operate) 'assign to on/off of event
> 5 0
> w1.InvertOut = cvTrue '5v is normal 0v is bumped
> 0 5
> I think he last one should give a transition from 0 to 5 and the 5(true)
> should when copied to the operate property of the event cause the program to go
> to the event_code.
> Can you give me a clue as to why this won't execute the event code? I have
> also tried reading I/O lines instead of a switch object.
> Kind of a side question but can I run the OOPIC connected to the PC and have
> it read the values or run the program as if it were connected to a virtual
> robot and switches. As it is if it does not work the dumb thing just sits
> there. No indication if it is working or not.
> Dim led7 As New oLED 'red
> Dim led6 As New oLED 'yellow
> Dim led5 As New oLED 'green
> Dim bumprd1 As New oEvent 'if bumped forward
> Dim bumprd2 As New oEvent 'if bumped backward
> Dim w1 As New oWire
> Dim w2 As New oWire
> Dim switch1 As New oSwitch
> Dim switch2 As New oSwitch
> Sub Main()
> led7.IOLine=7
> led7.Operate=cvOn
> led6.IOLine=6
> led6.Operate=cvOn
> led5.Operate=cvOn
> led5.IOLine=5
> 'physically the switch has normally 5 V
> 'physically when it is bumped the value is 0 volts
> switch1.IOLine = 13 'assigh bumper sw 1 to line 13
> w1.Input.Link(switch1.Position) 'read bump sw1 assign to wire b1
> w1.Output.Link(bumprd1.Operate) 'assign to on/off of event
> w1.InvertOut = cvTrue '5v is normal 0v is bumped
> 'switch two
> 'physically the switch has normally 5V
> 'physically when it is bumped the value is 0 volts
> switch2.IOLine = 14 'assign bumper sw 2 to line 14
> w2.Input.Link(switch1.Position) 'read bump sw2 assign to wire 2
> w2.Output.Link(bumprd2.Operate) 'output of bumper 2
> w2.InvertOut = cvTrue '5v is normal 0v is bumped
> 'do
> led5.TurnOnBright 'bright green light says I am here
> ooPIC.Delay=1000 'SLOW IT DOWN SO I CAN SEE
> led5.TurnOff 'one loop of main
> ooPIC.Delay=1000
> 'loop
> End Sub
> Sub bumprd1_Code() 'event code if bumper 1 = 0v
> led6.TurnOnBright 'yellow
> ooPIC.Delay = 5000 'wait 5 seconds to see
> led6.TurnOff 'turn yellow back off
> End Sub
> Sub bumprd2_Code() 'evnet code if bumper 2 = 0v
> led7.TurnOnBright 'yellow
> ooPIC.Delay = 5000
> led7.TurnOff 'turn the yellow off
> End Sub
>
>
>
>
> **************Start the year off right. Easy ways to stay in shape.
> http://body.aol.com/fitness/winter-exercise?NCID=aolcmp00300000002489
>
>
> [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:

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

No comments: