PDA

View Full Version : computer controlled car



elios115
- 16th December 2005, 10:24
hey
can anyone help!
i m using PIC16F84 to control a car
i need to send a byte through A0 and get it out on port b(b0...B7)
can anyone help with the code?
thx

Luciano
- 16th December 2005, 10:49
Hi,

You can have my source code but there is still a bug in the
subroutine for sensing the distance of the car ahead....

http://www.andrew.cmu.edu/user/rkeane/Vertical%20Car%20Crash%20-%20KGTV.jpg

Luciano

keithdoxey
- 16th December 2005, 12:03
ROTFLMAO :)

I think its a stack error :)

chuck
- 16th December 2005, 13:15
G wiz that's some bug in that software. It was a shame you could have not done a dummy run on the run way and not the highway you don't seee many like that, that sure is a fine balancing act.

On that note i think i forget my idea on controlling a car with a pic LOL

chuck

Luciano
- 16th December 2005, 13:16
... i need to send a byte through A0 .....

Do you mean the PIC16F84 receives the data through RA0?
If yes, could you please describe the device sending the data?

Luciano

elios115
- 16th December 2005, 23:39
in fact a vb code sends 4 bytes for controlling the for direction of the car!
the byte goes out from the serial port of the pc and goes into the PIC through A0.
then this byte should be outputed on port b of the pic(b0...b7)!

the algorithm is as follows: the pic receives the byte bit by bit through A0.
it stores the byte in a register and then output it on port B

the problem is teh code! can anyone help?

Luciano
- 17th December 2005, 08:10
Hi,


From the PicBasic Manual "SERIN"

While single-chip RS-232 level converters are common and
inexpensive, the excellent I/O specifications of the PICmicro
MCU allow most applications to run without level converters.
Rather, inverted input (N300..N9600) can be used is conjunction
with a current limiting resistor.

* * * *

Q1: Are you using a RS-232 level converter like the chip
MAX232 (RS232>TTL & TTL>RS232) or just a current limiting resistor?


Q2: What is the used baud rate? (1200, 2400, 9600)

* * * *

Best regards,

Luciano

Example of circuit using a MAX232:
http://web.ukonline.co.uk/j.winpenny/pic/rs232x.gif

elios115
- 17th December 2005, 13:35
yea i m using the max232 chip and i m using the 9600 baud rate!
the serin can be modified for my purpose but i need how?

Luciano
- 17th December 2005, 15:33
Hi,

========================================
5.68. SERIN

SERIN
Pin,Mode,{Timeout,Label,}{[Qual...],}{Item...}

Receive one or more Items on Pin in standard asynchronous format
using 8 data bits, no parity and one stop bit (8N1). SERIN is similar to
the BS1 Serin command with the addition of a Timeout. Pin is
automatically made an input. Pin may be a constant, 0 - 15, or a
variable that contains a number 0 - 15 (e.g. B0) or a pin name (e.g.
PORTA.0).
========================================

With the SERIN command you can receive one or more Items.
Declare four variables for your four bytes. These four
variables will be the "Items" of the SERIN command.

Read the PicBasic Pro manual, search this forum.
If you need help, post your code and the members of this
forum will help you to fix your code.


Best regards,

Luciano

Ioannis
- 17th December 2005, 19:29
the algorithm is as follows: the pic receives the byte bit by bit through A0. it stores the byte in a register and then output it on port B

the problem is teh code! can anyone help?

Maybe something like this?

SERIN 1,N2400,[“A”],B0 'Wait until the character “A” is received serially
'on Pin1 and put next character into B0
portb=B0

This is on the manual, page 99.

Ioannis