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.

Running two PICs in parallel sharing a common RX

Status
Not open for further replies.

bsodmike

New Member
Hi :)

I am looking to control three motors via PWM and have with me a 16F877 as the main PIC. I also have a spare 16F88 so an idea dawned on me.

I can connect the OSC1 pin from the 16F877 to the OSC1 pin on the 16F88, leaving the OSC2 pin open on the 16F88. If mounted close enough, they should run in sync from a single oscillator which is connected to the OSC1 and OSC2 pins of the 16F877.

Since the host (a PC) will be sending commands to the PIC to drive the PWM signal, it is a one way direction of communication, and therefore could tie the RX line of the 16F877 and 16F88 together.

If both of them were to run with an interrupt on the RX receive, but each PIC scans for an 'identification' code within the stream of data - I could potentially be able to utilize the CCP1/CCP2 on the 16F877 to drive two motors and the CCP1 on the 16F88 to drive the third motor.

The alternative would be to dump the 16F88 and run two motors via the CCP1/CCP2 and use a regular I/O and software to control the third motor. However, I would like to run all the PWM using the on-board hardware peripherals if possible.

Does anyone think this is a good or bad idea? Any comments would be extremely appreciated - thanks!
 
Last edited:
The 18F1330 is a motor controler with 6 PWM channels. It is also a fast chip with a 8MHz internal osc and a PPL to bump it to to 32.

Wow, that one is definitely in my next sample list.

Mike.
 
Thanks for the advice guys, but the reason I thought of this is because I have these two chips with me and am operating on a limited budget.

I have not worked with the 18F PICs before, and therefore would like to know what I would need in terms of programmers/compilers?

I have the HITECH PICC and PICC18 compilers and this Olimex MPLAB Compatible ICD2 with USB and RS232 and this JDM Serial Port Programmer.

Can 18F's be programmed with WinPic? The 1330 is not listed on the software page.
 
Microchip has a free compiler for the 18's called the C18. The only restriction is that you can not do some optimizations after 60 days and you code get larger. Not a problem most of the time.

I think and ICD2 clone should be able to program the 18F1330 under MPLAB.

Thanks for the advice guys, but the reason I thought of this is because I have these two chips with me and am operating on a limited budget.

I have not worked with the 18F PICs before, and therefore would like to know what I would need in terms of programmers/compilers?

I have the HITECH PICC and PICC18 compilers and this Olimex MPLAB Compatible ICD2 with USB and RS232 and this JDM Serial Port Programmer.

Can 18F's be programmed with WinPic? The 1330 is not listed on the software page.
 
Thanks 3V0, I've just ordered some samples of the 1330 - that's just what I've been looking for.

Nigel, thanks to you as well :)
 
Isn't the "six" channels actually 3 channels with the other 3 being the inverse of the first three ?

I know I'm using the 18F4431 which has 4 channels and another 4 "complimentary" channels.
 
Seems that in the independent mode, the signal of PWM0 is duplicated on PWM1. However, in complementary mode, PWM1 would be the compliment of PWM0 after an OFF period called “dead time” between the going OFF of one pin to the going ON of the complementary pin of the paired pins.

Thanks picbits; luckily I only have three motors to control :)

bit 2-0 PMOD2:pMOD0: PWM Output Pair Mode bits
For PMOD0:
1 =PWM I/O pin pair (PWM0, PWM1) is in the Independent mode
0 =PWM I/O pin pair (PWM0, PWM1) is in the Complementary mode
For PMOD1:
1 =PWM I/O pin pair (PWM2, PWM3) is in the Independent mode
0 =PWM I/O pin pair (PWM2, PWM3) is in the Complementary mode
For PMOD2:
1 =PWM I/O pin pair (PWM4, PWM5) is in the Independent mode
0 =PWM I/O pin pair (PWM4, PWM5) is in the Complementary mode
 
Last edited:
Isn't the "six" channels actually 3 channels with the other 3 being the inverse of the first three ?

I know I'm using the 18F4431 which has 4 channels and another 4 "complimentary" channels.

I think that is OK because the OP is using three motors.

FIGURE 13-3 shows that each pair still shares a duty cycle register in the independant mode.

EDIT: You figured it out while I was editing....
 
Last edited:
I spent some time trying to work it out as well ;)

Would be nice to have six independent PWMs though (or even 8 for that matter)
 
I spent some time trying to work it out as well ;)

Would be nice to have six independent PWMs though (or even 8 for that matter)
I agree.

Given the speed of these chips one could use a loop like this. It would allow one to use many output as a PWM.

Code:
forever { 
   turn on all that are active
   set timer for time to first off
   wait for timer
   turn off first
   set timer for time from 1st to 2nd off
   wait for timer
   turn off second
   ...
   ...
   turn off last
   set timer for time from last off to end of duty cycle.
   wait for timer
}

convert it to use interrupts and it might work fairly well. One would need to pick a granularity that allowed enough time between interrupts.
I have never tried it.
 
Last edited:
Following the link brings up " RGB LED & PIC 18F876"
then it goes on to say,
"Decided to play with an RGB LED I got in one of my last orders. I happened to have a 16F876 on a breadboard for some reason, so it got used."
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top