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.

Thursday, July 31, 2008

[oopic] 2 microswitch

Please help me out of this problem..

I have two microswitch that will control the direction of the motor.
if one microswitch was pushed, the motor will turn clockwise
continously until the other microswitch was pushed to change the
direction of the motor. please check my code:

Dim speedMotor1 As New oKnob
Dim speedMotor2 As New oKnob
Dim motor1 As New oDCMotor
Dim motor2 As New oDCMotor
Dim switchClockwise As New oButton
Dim switchCounter As New oButton

Sub Main
speedMotor1.IOLine = 1
speedMotor1.Operate = cvOn

speedMotor2.IOLine = 2
speedMotor2.Operate = cvOn

motor1.IOLineP = 17
motor1.IOLineD = 27
motor1.IOLineB = 25
motor1.Unsigned = 0

motor2.IOLineP = 18
motor2.IOLineD = 26
motor2.IOLineB = 24
motor2.Operate = 1

switchClockwise.IOLine = 8
switchClockwise.Mode = 1
switchClockwise.Position = cvOff

switchCounter.IOLine = 9
switchCounter.Mode = 1
switchCounter.Position = cvOff

Do
If switchClockwise.IsOn Then
switchCounter.Position = cvOff
Call motorClockwise()
End If

If switchCounter.IsOn Then
switchClockwise.Position = cvOff
Call motorCounter()
End If

motor2.Speed = speedMotor2.Position

Loop
End Sub


Sub motorClockwise()
motor1.Direction = 0
Do
motor1.Speed = speedMotor1.Position
Loop
End Sub

Sub motorCounter()
motor1.Direction = 1
Do
motor1.Speed = speedMotor1.Position
Loop
End Sub


------------------------------------

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: