Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC to PIC communication

Not open for further replies.


New Member
Using 16F628's. PIC-1 opens RB0 as output and PIC-2 opens RB0 as input. Will connecting PIC-1's output (RB0) to PIC-2's input (RB0) be the same as connecting some other device to PIC-2?


Which other device? Are you using PIC 1 to simulate the output behaviour of another digital device?

If you just want to know whether they are compatible, it should be fine. They can source or sink 25ma each (I think, without looking at data sheets) so as long as both are set up correctly, you shouldn't have a problem.

Again. I haven't looked at a data sheet recently.

If you're looking for fast and accurate information tranfser between the two though, why not make use of the USART? see the data sheet and Nigels tutorials...

Nigel Goodwin

Super Moderator
Most Helpful Member
The pins are standand logic, TTL and CMOS compatible, you can very easily connect one to another - in fact, if required, you can do bi-directional comms between single pins.


New Member
Thanks Nigel :D


Thanks for your input. The other devices are 2 Ultrasonic Range Finders, each on their own Printed Circuit Board (PCB). I won't need to send data streams between the 3 PICs so don't need the USART. Just need a logic (yes/no) connection.

I.E. The PCB with PIC1 and the PCB with PIC2 send/receive Ultrasonic. The timing from send to receive adjusts Pulse Width Modulation (PWM) to their respective motor. The PCB with PIC3 senses Infrared (IR) and needs to know whether PIC1 or PIC2 was adjusting the PWM at the time it detected the IR signal.

This is my first atempt to design an autonomous robot using PIC µControllers. The PCB with PIC1 will be mounted on the left, controlling the motor on the right and the PCB with PIC2 will be mounted on the right controlling the motor on the left. The Ultrasonic Range Finder (URF) adjusts the PWM, slowing down the motor according to the distance (ultrasonic send/receive timing) to the object detected. The closer the object, the slower the motor runs, thus steering away from the object. The URF has a range of about 24 inches. In the event it is unsuccessful at steering around an object the Infrared PCB with PIC3, which has a range of about 6 inches, will stop the robot before it runs into the object. PIC3 needs to know which way the robot was being steered so that when it processes the STOP and TURN it will know which way to turn. In the event both PIC1 and PIC2 are slowing down their respective motor when the IR detects an object straight ahead then it will need to process a STOP, turn 180° and reset PICs 1/2 so it operates as though it had just been turned on.

For instance, if it were going down a hallway. When it gets close to the end, both URFs would "see" the end of the hallway slowing the robot untill the IR detects that the wall is within 6 inches. Because both URFs were adjusting the PWM the robot (PIC3) would know to turn 180°.

Hi AZDave,

Somehow I've only just noticed your reply! Sorry about that. Why are you using three PICs? It seems to me that you may be over complicating the matter somewhat?

If it is for the PWM that you are using PICs 1 & 2, you could consider other methods of control. For instance, if 8 bit resolution would be needed for the speed control, you could use three pins to convey the speed, through D/A converter to give an analogue reference for a motor controller? You could do this for both motors. You can still connect IR and Ultrasonics up and get all of the functionality from one uC, saving the need for three way comms?

This is just what popped into my head as a first solution to the comms thing. I'd be interested to find out how you get along, regardless which method you use!


New Member

I've learned a lot about µC's since I started this thread. :eek:

PIC1/2, 16F88's, are dedicated Tx/Rx ultrasonic signal, they then compile the data to get distance from object and send the 2-byte result via USART to PIC3, 16F877A, the master system controller. PIC3 has several other enviromental inputs both analog and logic. PIC3 uses all these data inputs to adjust PWM to the motors.


New Member
Hi there,

I've also got to do something similar. (i think) I'm trying to use 2 PICs to measure the time between sending and receiving of data in order to measure the distance between the 2 nodes. :?

Have no idea where to start though! Am a complete idiot(at the moment) with PICs...

I figure i have to use USART? have looked at nigel's tutorial thing.. but it doesn't really make sense to me... hellllppppp!



New Member
I started with... Paul's Cheap Sonar Range Finder Design

Although my design has been through many changes, I hope this will shed some light on it for you. The theory of comparing signal send/return timing should be the same.
Not open for further replies.

Latest threads

EE World Online Articles