Log in

View Full Version : Hello Atodos a happy 2013 to all can someone help me



cesar35
- 2nd January 2013, 14:08
Hello Atodos a happy 2013 to all
I made a small program to drive a robot using the PicBasic program I made ​​in visual basic 6
I'm with a difficulty of making the robot motors stop when I release the button on the keyboard.
I need the pic reset all ports without using VISULA basic.Eu program could do more on own pic is connecting the engine and deligando

The program's pic is here.
A hug to everyone
Include "modedefs.bas"
TRISA=1 'PORT A input
TRISB=%00001111 'PORT B output
PORTB=0
RX VAR BYTE

PROG:
SERIN PORTA.0,T9600,RX
IF RX = "A" THEN FRT
IF RX = "B" THEN TRA
IF RX = "C" THEN DIR
IF RX = "D" THEN ESQ
GOTO PROG

FRT:
HIGH 4
HIGH 6
GOTO PROG

TRA:
HIGH 5
HIGH 7
GOTO PROG

DIR:
HIGH 5
HIGH 6
GOTO PROG

ESQ:
HIGH 4
HIGH 7
GOTO PROG

Jerson
- 2nd January 2013, 16:38
How about adding another case
IF RX = "S" THEN StopAll

StopAll:
LOW 4
LOW 5
LOW 6
LOW 7
goto PROG

cesar35
- 2nd January 2013, 18:00
hello Jerson
in this case the letter s has to come from vb6
has another way to do this pic
thanks for the reply

Jerson
- 3rd January 2013, 01:08
Unfortunately, there is no way you can know when the key has stopped. So, you have 2 alternatives

1 - Let each command run for a small fraction of time before going back to prog
example


FRT:
HIGH 4
HIGH 6
pause 100
LOW 4
LOW 6
GOTO PROG


2 - Put a timeout. So, if Serin does not give you a character, turn off all outputs
SERIN PORTA.0,T9600, 1000, Timeout, RX

Timeout:


LOW 4
LOW 5
LOW 6
LOW 7
goto PROG

This is from the manual
An optional Timeoutand Labelmay be included to allow the program
to continue if a character is not received within acertain amount of time.
Timeoutis specified in 1 millisecond units. If the serial input pin stays in
the idle state during the Timeouttime, the program will exit the SERIN
command and jump to Label

cesar35
- 4th January 2013, 08:47
Hello Jerson
Thanks for the reply
I made the example 2 it more of a lock works very well.
look at the video http://www.youtube.com/watch?v=I-_4rKRnYQI&feature=youtu.be
thank you

Jerson
- 4th January 2013, 13:35
Nice video.