Unless all
specify that are a beginner to the first arms with picbasic pro
I intezione an engine to move step by step with classical schedina STEP and DIR
and there are successful but when you want to see a given (acceleration) on LCD
the frequency of work decreases paurosamente
Almost as I understood the pic can not 'make girasre the engine and at the same time see a given
and so?
there is' a way around the obstacle?
I thank you for helping me understand you can afford
this and 'what I could do with a 16F877
Code:
Code:
DEFINE OSC 20
DEFINE LCD_DREG PORTD ' Define LCD connections
DEFINE LCD_DBIT 4
DEFINE LCD_RSREG PORTD
DEFINE LCD_RSBIT 2
DEFINE LCD_EREG PORTD
DEFINE LCD_EBIT 3
DEFINE LCD_LINES 4
DEFINE LCD_DATAUS 50
VEL VAR WORD ' Velocita''
VELOCITA VAR WORD
ACC VAR WORD ' Accellerazio/decellerazione
ACCELL VAR WORD
servo1 VAR PORTC.1 ' Uscita step motore 1
TRISA = 255 ' Enable first button row
PORTA = %11111111
ADCON1 = 7 ' PORTA and PORTE to digital
Low servo1 ' Servo output low
Main:
READ 0 ,VEL
'read 1, VELOCITA
READ 2, ACC
READ 3, ACCELL
LCDOut $fe, $80, "VEL = ", #VEL
'LCDOut $fe, $c0, "VELOCITA = ", #VELOCITA
LCDOut $fe, $94, "ACC = ", #ACC
LCDOut $fe, $D4, "ACCELL = ", #ACCELL
GOTO MAINLOOP
UNO:
IF PORTA.0 = 1 THEN
ACC= ACC+1
PAUSE 10
ENDIF
IF PORTA.1 = 1 THEN
ACC = ACC-1
PAUSE 10
ENDIF
Lcdout $fe, 1 ' Clear screen
LCDOut $fe, $94, "ACC = ", #ACC
WRITE 2, ACC
IF PORTA.2 = 1 THEN GOTO DUE
GOTO UNO
DUE:
IF PORTA.0 = 1 THEN
VEL= VEL+1
PAUSE 10
ENDIF
IF PORTA.1 = 1 THEN
VEL = VEL-1
PAUSE 10
ENDIF
Lcdout $fe, 1 ' Clear screen
LCDOut $fe, $80, "VEL = ", #VEL
WRITE 0 , VEL
IF PORTA.3 = 1 THEN
GOTO MAINLOOP
ENDIF
GOTO DUE
Mainloop:
TRISB = $fe
PORTB = 1
IF PORTB.1 = 1 Then
GoSUB MOTOR
ELSE
GOSUB MOTOR2
ENDIF
IF PORTA.2 = 1 THEN
Lcdout $fe, 1 ' Clear screen
LCDOut $fe, $c0, "ENTRATA SETUP "
PAUSE 1000
GOTO UNO
ELSE
GOTO MAINLOOP
ENDIF
MOTOR:
IF VELOCITA < VEL THEN
VELOCITA = VEL
ENDIF
servo1 = 1 ' Start servo pulse
PauseUs VELocita
servo1 = 0 ' End servo pulse
PauseUs VELOCITA
velocita = velocita - 1
Lcdout $fe, 1 ' Clear screen
LCDOut $fe, $c0, "VEL ",#VELOCITA
RETURN
GOTO MAINLOOP
MOTOR2:
IF VELOCITA < (VEL*3) THEN
servo1 = 1 ' Start servo pulse
PauseUs VELocita
servo1 = 0 ' End servo pulse
PauseUs VELOCITA
ELSE
VELOCITA = (VEL * 3)
LOW SERVO1
ENDIF
velocita = velocita + 1
RETURN
GOTO MAINLOOP
END
Bookmarks