Pic to pic connections


+ Reply to Thread
Results 1 to 10 of 10

Thread: Pic to pic connections29 days old

  1. #1
    Fanatical Contributor Tim's Avatar
    Join Date
    Jan 2003
    Posts
    7,666
    Thumbs Up
    Received: 47
    Given: 95
    Total Downloaded
    1.32 GB

    0 Not allowed!

    Default Pic to pic connections

    Hi,

    I have a need for one pic to talk to another pic. Simple right SPI, rs232 the protocols are endless. However in my case there is an issue

    Pic 1 is busy, I mean real busy. 64mhz busy. Sure it would have time to load the TX reg. But Pic 2 needs to be a SPI slave so the RX line is in use. And needs to be ready to talk as a slave to another board at the drop of the proverbial hat.

    So I'm thinking as the smallest pic that will do 64mhz is 20 pin I can use 10 for the data and the second pic does the same. Basically Pic 2 is talking to the outside world while Pic 1 does data collection. The data will be 2 10 bit numbers so if I use 10 bits for the data, Pic 1 can say this is data packet 1 or 2 by control of bit 11

    Ok My question now is what do I need to do to protect the lines. Cannot have 2 pics trying to pull one line high and the another low.

    I have I seem to options
    1 Never set the Pics 2 lines as outputs
    2 Put say a 10k resistor inline to control the current if that happens

    The later is the obvious option but thats 11 more resistors. I know they are dirt cheap and easy but they take up real estate and time to assemble.

    What about say Pic 2 having a resistor on the ground line and the 5v line so it cannot draw more than say 10ma. Stupid idea? Any better solutions?

    Thanks

    Tim
    Tim

Attention

This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

The advertisements we display are relevant to this web site and your browsing history

Please consider supporting us by disabling your ad blocker.


Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

If you can, please report issues in the forum area WebSite / Forum Issues


Thank you for your attention.

  • #2
    Prolific Poster rcurl's Avatar
    Join Date
    Mar 2002
    Posts
    1,823
    Thumbs Up
    Received: 30
    Given: 53
    Total Downloaded
    2.16 GB

    0 Not allowed!

    Default Re: Pic to pic connections

    Hi Tim-
    Are you saying you will use parallel data transfer between the chips?
    If so, does communication need to be bi-directional? If not, there's no need to ever set Pic2's pins to output.
    Even if both PICs are set to output and one is pulling high and the other low- you're not going to damage the PICS. They will just draw a lot of current and may get warm.
    I think putting a resistor in the ground line is a bad idea. If PIC2 tries to set an output pin high while PIC1 is holding it low, and you allow ground to rise, PIC2 will likely reset because it will have the effect of reducing supply voltage.

    If you do end up using resistors between the PICs, use a lower value. 1K will be better than 10K. You don't have to worry about capacitance on the input pins so much. If board real estate and assembly times are a big concern, use a resistor network. It costs more but is smaller and takes less time to assemble.

    -Rick

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #3
    Fanatical Contributor Tim's Avatar
    Join Date
    Jan 2003
    Posts
    7,666
    Thumbs Up
    Received: 47
    Given: 95
    Total Downloaded
    1.32 GB

    0 Not allowed!

    Default Re: Pic to pic connections

    Thanks Rick

    Yes it is parallel coms and it is only one way eg Pic 1 out. I need to spend as little time as possible on Pic 1 communicating data.
    I was thinking about adding another pin to say data is live as it will flip between the 2 10 bit numbers around 50x a second.

    But now I figured I just read the data 2 x and if it's the same its ok. That will mean no glitches reading a the data.

    Since there will be no code at all to set the port on Pic 2 to output I should be fine. I can set the direction periodically to read just fend off any glitches sent from the stars.

    Tim
    Tim

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #4
    Senior Member tumbleweed's Avatar
    Join Date
    May 2011
    Posts
    473
    Thumbs Up
    Received: 58
    Given: 0
    Total Downloaded
    330.54 MB

    0 Not allowed!

    Default Re: Pic to pic connections

    I was thinking about adding another pin to say data is live
    If you're going to do parallel data having an extra "data valid" line is probably a good idea.

    Otherwise you can run into issues as you update the outputs since it'll take at least two writes to set the 10-bit data.
    Think of the intermediate settings that get created. It's not fool-proof, but it helps mitigate the "who's faster than who" issue.

    Set DataValid=0, update the two port outputs, set DataValid=1. At least that way the only problem is pic#2 seeing the line high and reading just as pic#1 drops it to say data is invalid. I'd still read it twice before assuming it's ok.

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #5
    Prolific Poster towlerg's Avatar
    Join Date
    Mar 2012
    Posts
    2,157
    Thumbs Up
    Received: 74
    Given: 173
    Total Downloaded
    5.06 GB

    0 Not allowed!

    Default Re: Pic to pic connections

    And you can have an int on data valid pin edge.
    George.

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #6
    Junior Member keytapper's Avatar
    Join Date
    Jun 2019
    Posts
    57
    Thumbs Up
    Received: 2
    Given: 1
    Total Downloaded
    152.82 MB

    0 Not allowed!

    Default Re: Pic to pic connections

    I think you should review whether there are bottlenecks. Perhaps some more code optimization and polish out some of assembly for the crucial situations.
    Secondly you may need an extra pin, which the master uses to tell to the slave(s) when data are ready. If more than one slave uses the 10 bit reading, then it might involve a sort of negotiation and to add an overhead byte to address which slave is addressed to listen.

    There might be several protocols to get the handshaking style for transferring data.

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #7
    Fanatical Contributor Tim's Avatar
    Join Date
    Jan 2003
    Posts
    7,666
    Thumbs Up
    Received: 47
    Given: 95
    Total Downloaded
    1.32 GB

    0 Not allowed!

    Default Re: Pic to pic connections

    If you look at the code Proton produces its as good as it gets. I cannot write better ASM. There is no optimization to be had.

    Pic 1 is constantly reading data from another device. That devices never stops. The section that I need to analis means I have to run a loop. The loop runs so that if I see a signal 3 times in that loop its one state 6 x and its another state. It cannot be interrupted.
    There is a small section of time where I get some breathing space. In that time I could load a TX register. Another 50hz I get some more time so my 4 bytes could be sent. But like I said in my previous post. It needs the TX and RX lines as it its self is an SPI slave. When you are a spi slave you need to drop what you are doing instantly and service the interrupt. So replacing the hardware Serial port for a software one is a no no.
    As I said the pics have loads of spare pins just use them as a parallel port 10 bits for the data and bit 11 to say what info the 10 bits represent.

    Now on reading this port. Its really simple. Read Byte 1, read byte 2 = Word 1 . Repeat so you 2 words. If have different data because while after you read byte 1 Pic 1 changed to the second data packet then you can see it. They are not the same. Try again. Considering the changes in the data on the parallel port happen at 50hz its not a big deal.

    This enables Pic 2 to read the data, have plenty of time to do lookup and data conversions on that data and have it ready for when its gets asked via SPI to give a result.
    Tim

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #8
    Junior Member david's Avatar
    Join Date
    Jan 2019
    Posts
    43
    Thumbs Up
    Received: 3
    Given: 1
    Total Downloaded
    173.19 MB

    0 Not allowed!

    Default Re: Pic to pic connections

    Hi Tim,
    This might be a bit simplistic but do you need to read/analyze every frame? Could you analyze frame 1, send data during frame 2, analyze frame 3, send data during frame 4....
    I've followed this project for many months but still don't fully understand it. I keep thinking a line scan array seems more suited to your 1 dimensional "data" but yes it would need some optics, just as the camera needs optics but of course it comes included.
    10/10 for entertainment value and I wish you good luck with the project.

    Best regards,
    David

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #9
    Fanatical Contributor Tim's Avatar
    Join Date
    Jan 2003
    Posts
    7,666
    Thumbs Up
    Received: 47
    Given: 95
    Total Downloaded
    1.32 GB

    0 Not allowed!

    Default Re: Pic to pic connections

    Hi David

    Yes I could scan less frames, but there is the issue of coms still. I do not want to be disturbed by an interrupt asking me to reply on SPI. Sure if there was a cost implication I could set flags and if interrupted by the time I get to the end of the scan say well that's scrap ignore it and rescan.

    But its not worth the effort when I could have 2 pics to do it.

    To enlighten you:

    I have a tube with water in it. At the back of the tube there is a slot that light comes through. Where there is NO water its a thin slot of light, where there IS water the light is magnified so there is a wide slot of light.
    The camera looks at the tube and the light produced. As the camera scans (50hz pal) it looks at the tube and so light level. The camera sends out the signal in interlace timing. Odd even etc
    Each Horz scan takes around 63us. The signal is amplified from the 1v P-P to 5v P-P. A comparator with a threshold over the ambient light level is constantly triggering as the camera sees the light slit.
    My pic needs to wait via timing and level checking to get the start of the first H scan line (first image scan) At the right time in the H scan its tests the comparator signal for the light.
    3 counts thin slot, 6-8 the wide.
    I have two tubes I want to check to need to pay real close attention to the data coming in.

    Work with my scope has shown that with a dummy slit going thin fat I can detect the change really to one scan line to the next. I end up with a resolution in my tests of 0.2mm 5 x my required so enough for an uneven water level due to the meniscus.

    The PAL signal is really updating every 25hz so I can work out which line the change was on. I will be polling the board at around that freq to get the current level so I could end up getting a lot of lost scans.

    So I have decided to let Pic 2 do the coms work along with some other stuff.

    Tim
    Tim

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #10
    Junior Member david's Avatar
    Join Date
    Jan 2019
    Posts
    43
    Thumbs Up
    Received: 3
    Given: 1
    Total Downloaded
    173.19 MB

    0 Not allowed!

    Default Re: Pic to pic connections

    Hi Tim,
    Many thanks for the detailed explanation. Sounds like you will need a fairly fast amplifier and comparator to match the bandwidth your 'scope is probably offering but I'm sure they are out there. I always found comparators disappointing when I used them in high speed level detection and I hope you have better luck with your project. Keep us posted - it has been one of the more enduring projects and probably has a reasonable fan base by now.

    Best regards,
    David

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

    Thread Information

    Users Browsing this Thread

    There are currently 1 users browsing this thread. (0 members and 1 guests)

       

    Similar Threads

    1. Very High speed coms between Master Pic- Slave pic (needed)
      By Tim in forum Proton Plus Compiler v3
      Replies: 28
      Last Post: 27th April 2016, 15:25
    2. Pic 16F1937 to 6 Analog input in Pic basic
      By Habro in forum Absolute Beginners Section
      Replies: 17
      Last Post: 18th December 2014, 19:38
    3. Galva-Wisp PIC programmer can program more PIC devices now
      By Frizie in forum Proton Plus Compiler v3
      Replies: 0
      Last Post: 24th November 2006, 23:13
    4. Serial data between 1 master pic & 8 slave pic
      By Roshan in forum Proton Plus Compiler v3
      Replies: 2
      Last Post: 23rd September 2005, 11:21

    Members who have read this thread since 17th October 2019, 00:26 : 1

    Actions :  (Set Date)  (Clear Date)

    You do not have permission to view the list of names.

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts