Continue to Site

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.

16F628 2-2-1

Status
Not open for further replies.

AZdave

New Member
I'm not sure how to do it...

I need three 16F628's communicating. Two of the PICs would each control there own motor via ultrasonic range finder, creating PWM for motor speed control and the third PIC would be connected to IR detectors and a relay.

Theroy: PIC1/PIC2 will normally control motor speed to there respective motor. PIC3 will be connected to an IR detector and relay. When PIC3 detects an object I need it to cut the PWM signals from PIC1/2 and take control of both motors to do a PAUSE, STOP, REVERSE, reset all, then release the relay so PIC's 1/2 will start over as though it had just been powered up.

I have the program for the range finder PWM control and the program for the IR stop/reverse. I currently have 3 independent modules. PIC1/MOTOR1 speed only, PIC2/MOTOR2 speed only and PIC3 which controls 2 motors independently forward and/or reverse.


What I think I will need...

Is to have PIC3 control a latching relay to cut PWM control from PIC1/2 and allow the PWM signals from PIC3 to take over. PIC3 will also need to know which PIC (1 or 2) that was last controlling it's motor. I.e. if PIC1 doesn't "see" an object then it will not be actively sending a PWM signal to it's motor and needs to let PIC3 know (set/unset a bit in PIC3). PIC3 will need to have registers updated to tell it whether PIC1 or PIC2 was active when it takes over.

What I'm not sure how to do... (or even if it's possible)

1. How do I get PIC's 1/2 to communicate with PIC3 to keep registers in PIC3 updated with an on/off bit, i.e. whether PIC1/2 is currently sending PWM signals or not? PIC3 is currently using 4 data lines for motor control and 2 lines for relay control.

2. How do I get PIC3 to control a latching relay. The relay needs a 5 volt signal to pin 1 to latch one way and a 5 volt signal to pin 2 to latch it the other way. I.e signal 1 sets the relay to position 1 so PIC's 1/2 have control and signal 2 sets the relay to position 2 so PIC3 has control.

Additional info: The range finder's PIC16F628 sends PWM in relation to the reflected ultrasonic signal send/recieve timing (currently set to 38kHz). The IR's PIC16F628 simply stops the motors forward motion, pauses then reverses motor direction.

If a picture is worth a thousand words...

Then sample code would be of tremendous help as I am relatively new to 16F628's instruction set.

Thanks in advance for any help...

Dave, (the Arizona Desert Dog)
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top