View previous topic :: View next topic |
Author |
Message |
bungee-
Joined: 27 Jun 2007 Posts: 206
|
OT: Sanity check |
Posted: Tue May 25, 2010 5:50 am |
|
|
I'm working on project where three PIC's will be used. One will be master and two of them will be sending some data back to master. For master PIC I'll use one with two HW UART's.
Now the question, is it possible to receive the data from both slaves at once (not synchronously), or I have to build in some flow control so the slaves will send only when the master is ready to receive. I expect that HW UART is capable of that, but I could be mistaken.
Thanks for brainstorm. |
|
|
MikeW
Joined: 15 Sep 2003 Posts: 184 Location: Warrington UK
|
|
Posted: Tue May 25, 2010 5:58 am |
|
|
you dont give any info on data speed, or amount.
I would look at using either SPI or I2C hardware in the PIC rather than UART.
since its a master/slave situation, its always better to have a control pin from the master to signal to the slaves " its time for you to get/send"
Mike |
|
|
Wayne_
Joined: 10 Oct 2007 Posts: 681
|
|
Posted: Tue May 25, 2010 6:55 am |
|
|
Using a PIC with 2 MSSPs and I would look at using SPI, your master would be able to receive 1 byte from both slaves at the same time.
Esentially the hardware will receive 1 byte from each and store it in buffers and whilst you copy that from the hardware buffer to an array it will be clocking in another byte from each.
I would then use the SSP_ISR to copy the data from the hardware buffers to 2 arrays for processing later on.
but as stated, speed and amount will play an important part in how well this will work. |
|
|
bungee-
Joined: 27 Jun 2007 Posts: 206
|
|
Posted: Tue May 25, 2010 12:04 pm |
|
|
Thank's for reminder....
Data from slaves will be sent twice per second, packet will be 8bytes long, communication speed will probably be 28kbps. I didn't consider SPI or I2C because PIC's will be separated by optocouplers, ground will not be common.
Master will be sending occasional commands to slaves. To that slaves would confirm the command and then they would continue with sending data back. |
|
|
MikeW
Joined: 15 Sep 2003 Posts: 184 Location: Warrington UK
|
|
Posted: Tue May 25, 2010 2:31 pm |
|
|
Analog Devices have some great chips which give galvanic isolation of KV's, they are not optical, but use micro transformers.
I have used them to isolate I2c bus, they just drop in, and work.
otherwise, if you need optical, say for medical, then try
googling " spi optical isolation", you will get loads of hits
Dallas/maxim gave an app note which optically isolates the SPI, see
Isolating USB - AN3891
Mike |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
Posted: Tue May 25, 2010 9:16 pm |
|
|
SPI is easy to optically couple..
I played with it in the past using the 1000uM stuff from industrial fiber.
They make some fun stuff that uses cheap plastic fiber.
-Ben _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19545
|
|
Posted: Wed May 26, 2010 2:02 am |
|
|
Yes.
SPI, is 'easier' to opto-couple than I2C. With modern 'logic level' opto-couplers, it really couldn't be much simpler.
I2C, is harder, because of the bi-directional nature of the signals, but can be done. Have a look at the P82B96, which is a I2C buffer designed to provide much better galvanic protection and support operations at different voltage levels. On it's own, it makes I2C, a much more 'useable' interface for going between units, but as one of it's 'other features', it allows the two directions to be separated, and opto-coupled.
Best Wishes |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
Posted: Wed May 26, 2010 6:45 am |
|
|
I did an opto-coupled I2C design in SCH one time.. it wasn't that bad. It just requires 3 opto lines because of the nature of I2C...
But using OpenCollector parts, should have worked just fine.... I just never built it and tested in.
-Ben _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
John P
Joined: 17 Sep 2003 Posts: 331
|
|
Posted: Wed May 26, 2010 6:56 am |
|
|
But to address the original question--yes, you can send totally asynchronous data to a chip with dual UARTs. Just don't spend too long in interrupts (or any routine that locks out one data source).
If I were writing the program, I'd have the processor interrupted by a fixed-frequency clock at say 5KHz, in which it would poll the two UARTS for incoming data, with the data put in circular buffers to be processed in the main() routine. But there are various ways to do it. |
|
|
bungee-
Joined: 27 Jun 2007 Posts: 206
|
|
Posted: Thu May 27, 2010 10:43 am |
|
|
Thank's for all replies. I'll test I2C and uart and I'll see the results. Thank you for this brainstorm. |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
Posted: Thu May 27, 2010 10:59 am |
|
|
Was this for work or school project?
-Ben _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
|
Posted: Thu May 27, 2010 12:02 pm |
|
|
Just another possibility I see:
Put the 3 pics in a ring configuration..... PIC1->PIC2->PIC3->PIC1
You would need 2 bytes though, to identify the sender.... and then each PIC needs to decide if its necessary to forward the message or execute the command....
I understand there are issues with "ring type networks".... but I'm just suggesting a possible solution...
gabriel _________________ CCS PCM 5.078 & CCS PCH 5.093 |
|
|
bungee-
Joined: 27 Jun 2007 Posts: 206
|
|
Posted: Thu May 27, 2010 12:22 pm |
|
|
bkamen: Neither...
I'm working on digital workbench power supply. It will be two channel that will be electrically separated, so you can then connect them together for dual operation. One PIC will be "UI" and then each channel will have own PIC for actual voltage/current regulation.
@Gabriel: possible, but not in this situation. |
|
|
|