Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 21, 2024, 03:40:41 03:40


Login with username, password and session length


Pages: [1]
Print
Author Topic: can help solve?  (Read 3349 times)
0 Members and 1 Guest are viewing this topic.
kctan
Guest
« on: March 14, 2006, 04:57:09 16:57 »

i using the proton to write this code and i have the problem of the delay time cannot put at the if else statement and i want write the emergency stop button when the button is close (voltage is off) the condition stop when button is open (voltage on) it will resume  
 '**************************************************************** 
Device 16F877A

XTAL = 20 ' 
crystal 20 Mhz

ALL_DIGITAL 
TRUE ' set all input output in digital form

PORTB_PULLUPS = TRUE ' 
enable the portb have a pullups resistance

Dim i 
As Byte

TRISA 
= %000000 ' set the port A as ouput

TRISB = %11111111 ' 
set the port B as output

TRISC 
= %00000000 ' set the port C as input

TRISD = %11111111 ' 
set the port D as input

TRISE 
= %000 ' set the port E as input

INTCON = %10010000 ' 
Enable RB0 interrupt

PORTB 
0

ON_INTERRUPT 
GoTo emergency 

main
:

Disable

PORTC 
= %01100100

If PORTB.6 And PORTB.7 And PORTD.1 1 Then 

PORTC 
= %00100010 'motor base ccw

EndIf

If PORTD.3 = 1 And PORTB.7 = 1 Then

PORTC = %00001100 '
arm motor clock wise base brake

EndIf

If 
PORTD.2 And PORTD.3 1 Then 

PORTC 
= %10100100 'break base and arm and extrude cylinder

EndIf

If PORTB.5 = 1 And PORTB.7 = 1 And PORTD.3 = 1 Then

PORTC = %10100100 '
break base and arm and extrude cylinder 

Set PORTA.0 
'gripper grip

EndIf

If PORTB.1 = 1 And PORTD.3 = 1 Then

PORTC = %10010100 '
gripper grip arm motor up and cylinder in extrude

EndIf

If 
PORTD.1 And PORTB.1 And PORTD.3 1 Then

PORTC 
= %01100100 'cylinder retract in

EndIf

If PORTB.4 = 1 And PORTD.1 = 1 And PORTB.1 = 1 Then

PORTC = %01100001 ' 
move left

EndIf

If 
PORTB.1 And PORTD.4 And PORTB.4 1 Then

PORTC 
= %01001100 ' arm move down, cylinder in retract condition

EndIf

If PORTB.1 =1 And PORTD.4 = 1 And PORTD.2 = 1 Then

PORTC = %10100100 ' 
arm stop and cylinder extract

EndIf

If 
PORTB.5 And PORTD.4 And PORTD.2 1 Then

PORTC 
= %10100100 'extrude sensor on and at left and at limit arm up

Clear PORTA.0 '
gripper release

EndIf

If 
PORTD.0 And PORTD.2 And PORTD.4 1 Then

PORTC 
= %10010100 'arm motor turn ccw and extract valve on

EndIf

If PORTD.1 = 1 And PORTD.4 = 1 And PORTD.0 = 1 Then

PORTC = %01100100 '
motor arm turn off and cylinder retract

EndIf

If 
PORTD.1 And PORTB.1 And PORTB.4 1 Then main

emergency
:

INTCON.7 'disable all interrputs

While PORTB.0 = 0 ' 
waiting untill

PORTC
= %00100100 ' reset output to PORTC

Wend ' 
push-button is release

DelayMS 100 
' debounce time 

INTCON = %10010000 ' 
Enable RB0 interrupt

' reset RB0 interrupt flag

Context Restore

Resume ' 
Return to main program

Enable 
' Enable interrupts after handler

Sad
Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright © 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC