Shop OBEX P1 Docs P2 Docs Learn Events
Propeller Interface to Atmega Processor at 5 Volts — Parallax Forums

Propeller Interface to Atmega Processor at 5 Volts

Chuck DavisChuck Davis Posts: 23
edited 2015-02-19 18:06 in Propeller 1
Sorry if this has been asked and answered previously, but I searched and did not find a specific answer to this question.

I'm wanting to interface the OUTPUT of the propeller to an Input of an Atmel processor (Atmega1284) running at 5 volts. According to the two data sheets, the high output of the propeller and the required minimum required input for the Atmel input port are very close, but looks to be marginal. However the Atmel has "weak pull ups" available on the inputs, that switch in a resistor (of about 40K, I think) to pull it up to 5 volts.

Don't need to interface the other direction, so there is no 5 volt input to the Propeller.

Has anyone ever done this, and is it safe and reliable? I could run the Atmega at 3.3 volts, but I have a need for speed, and I'd have to slow it down quite a bit at that voltage.

Thanks for any help.

Chuck

Comments

  • Duane DegnDuane Degn Posts: 10,588
    edited 2015-02-18 13:31
    What is this going to be used on? If it's something that always has to work you probably want to use some sort of level shifter but in most cases 5V devices read the 3.3V logic from a Prop just fine.

    I have lots of projects where I interface the Propeller with 5V devices and the only 5V device I've had some trouble with are the WS2812 LEDs.
  • Chuck DavisChuck Davis Posts: 23
    edited 2015-02-18 13:36
    It's a control system that has to run reliably 7x24 for a long period of time. Not doing life support or rocket launches, but erratic operation would not be acceptable.
  • tonyp12tonyp12 Posts: 1,951
    edited 2015-02-18 13:52
    As it have mid-strength pull-up, you could communicate with it only using Props DIRA-output low vs DIRA-input
    e.g open drain signaling system, as long you never by mistake put the atmega pin as output-high it will work forever.

    You could communicate bi-directional this way too as by mistake both sides do hard-pulls low at the same time no harm done.
    maybe using a external 20K pull-up resistor to 5v as the 40K internal you have go a little slower, should not go above 50Kbits/s
    As you are putting continues drain through Props protection diode, I would not go to down 10K
    I would also put a 2K series resistor, as to get slighlty higher pull-up voltage as protection diode will continues trying to stop it from going above 3.6v
  • kwinnkwinn Posts: 8,697
    edited 2015-02-18 13:55
    I would use a single transistor if you can invert the signal out of the propeller, or a level translator if that is a problem.
  • jmgjmg Posts: 15,173
    edited 2015-02-18 14:00
    It's a control system that has to run reliably 7x24 for a long period of time. Not doing life support or rocket launches, but erratic operation would not be acceptable.

    Use an XMega ?
    How close are the Prop / Mega ? If they are on the same Board, adjacent, you may be ok.
    As #2 alludes,if you have long cables and current added into the mix, then level shifters are better.

    Your risk case is a combined error of worst-case LOW on Prop Vcc and worst case HIGH on ATMega, if you can ratio the supplies or ensure they are tight specs (not +/- 10%) you buy some margin.
    You can also run Prop at 3.4V and Mega at 4.6V, to still meet Mega MHz and buy more margin.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2015-02-18 14:35
    Sorry if this has been asked and answered previously, but I searched and did not find a specific answer to this question.

    I'm wanting to interface the OUTPUT of the propeller to an Input of an Atmel processor (Atmega1284) running at 5 volts. According to the two data sheets, the high output of the propeller and the required minimum required input for the Atmel input port are very close, but looks to be marginal. However the Atmel has "weak pull ups" available on the inputs, that switch in a resistor (of about 40K, I think) to pull it up to 5 volts.

    Don't need to interface the other direction, so there is no 5 volt input to the Propeller.

    Has anyone ever done this, and is it safe and reliable? I could run the Atmega at 3.3 volts, but I have a need for speed, and I'd have to slow it down quite a bit at that voltage.

    Thanks for any help.

    Chuck

    5V pull-ups don't really pullup to 5V as the Prop I/O is standard CMOS and even if it was driven open-drain it will still look like a CMOS input and current would flow from the pullup to the Prop's 3.3V supply. However since there is a voltage drop from the pin to the supply and also effective series resistance you will find that the pin will still float up above 3.6V somewhat. Just measuring this with a 39K pullup to 5V reveals that it floats up to 3.67V if you do drive it open-drain (releasing DIR when driving pin high).

    You could also put a diode in the line (anode to 5V pullup) so that the ATMEGA sees around 4.3V high and 0.6V low but logic gates are cheap too and I would use 74HCT powered from 5V as the inputs accept 2V and higher as a logic high.
  • Chuck DavisChuck Davis Posts: 23
    edited 2015-02-18 17:55
    5V pull-ups don't really pullup to 5V as the Prop I/O is standard CMOS and even if it was driven open-drain it will still look like a CMOS input and current would flow from the pullup to the Prop's 3.3V supply. However since there is a voltage drop from the pin to the supply and also effective series resistance you will find that the pin will still float up above 3.6V somewhat. Just measuring this with a 39K pullup to 5V reveals that it floats up to 3.67V if you do drive it open-drain (releasing DIR when driving pin high).

    You could also put a diode in the line (anode to 5V pullup) so that the ATMEGA sees around 4.3V high and 0.6V low but logic gates are cheap too and I would use 74HCT powered from 5V as the inputs accept 2V and higher as a logic high.

    I guess I'm confused by that. I was thinking that if the output pin on the Prop were set to input, it was basically floating, and then the external pull up would take it all the way up to 5 volts. I better go back to school on my cmos logic. I'm basically a programmer, not an electronics guy. Thoughts???.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2015-02-18 18:10
    I guess I'm confused by that. I was thinking that if the output pin on the Prop were set to input, it was basically floating, and then the external pull up would take it all the way up to 5 volts. I better go back to school on my cmos logic. I'm basically a programmer, not an electronics guy. Thoughts???.

    Simplified electrical path:
    +5V
    RESISTOR
    [ATMEGA IO]
    [PROP INPUT]
    [+DIODE-]
    [ESR]
    3.3V
    The IO pins in this diagram are not in series, simply nodes.

    So the voltage at the Prop input would be always try to conduct because +5V is higher than 3.3V and conventional current would flow from the ATMEGA pullup through the CMOS "diode" to 3.3V. Since the diode drop is around 0.3V this means the voltage at the Prop input would be clamped to around 3.6V. If the Prop were run from 3.6V then that input voltage would be 3.9V etc. Once you make the Prop pin a high output then the pin is effectively clamped directly to 3.3V which is why we float the pin to get the 3.6V instead.

    EDIT: that's why inserting a diode between the two devices will "boost" the logic high by another 0.6V and the logic low is still well within limits too.
  • tonyp12tonyp12 Posts: 1,951
    edited 2015-02-18 18:13
    >external pull up would take it all the way up to 5 volts.

    It would if it was not for the Protection Diodes the Prop have on its pins, anything over 3.6V gets channeled it to the Vcc rail to be used up.
    You could use an external mosfet to isolate the Prop Pin from this dilemma, of course the signal will be inverted but it's easy fix in software.

    http://www.scienceprog.com/using-current-limiting-resistors-on-avr-io-pins/
  • Chuck DavisChuck Davis Posts: 23
    edited 2015-02-19 07:50
    Thanks to all for the timely replies. I think I now understand the situation much better.

    Rather than engage in any "un-natural acts", I believe I will resort to running the Atmega processor at 3.3 volts. At this voltage, it will still run at 13 Mhz - not the 20 Mhz I had hoped for, but should be more than fast enough. It actually simplifies the design a bit by only needing one voltage regulator instead of two, and should allow me to connect the Prop and the Atmega directly to each other. The board design is very tight, so I don't really have room to put any level-shifting circuitry in between.

    Thanks again!
  • Mike GreenMike Green Posts: 23,101
    edited 2015-02-19 08:02
    You can directly connect the Prop and Atmega pins if you never ever make coding errors where the Prop and Atmega I/O pins are both set to output mode and they're in opposite states (0 / 1). In other cases (of lesser perfection), it's advisable to put a 330 Ohm (more or less) between the Prop and Atmega pins to limit the fault current (to 10mA with 330 Ohms). The Prop I/O pin structures have been designed very robustly and have been tested shorted to ground or Vdd and seem to be able to withstand that indefinitely ... no guarantees with the Atmega though.
  • tonyp12tonyp12 Posts: 1,951
    edited 2015-02-19 08:20
    >Atmega processor at 3.3 volts. At this voltage, it will still run at 13 Mhz - not the 20 Mhz

    Why not a compromise, run it at 4.3V
    As with most cmos devices guaranteed input-as-high is 70% of its Vcc = 3v in this case (but if it have schmitt trigger you have to read the specs in its manual)

    The Prop pins ouput will be at 3.2 to 3.3v (under load it little lower, but there is no load on this trace here)
  • jmgjmg Posts: 15,173
    edited 2015-02-19 12:39
    ... I believe I will resort to running the Atmega processor at 3.3 volts. At this voltage, it will still run at 13 Mhz - not the 20 Mhz I had hoped for, but should be more than fast enough.
    If you do find you need more speed, the XMega's are 3.3V and 32MHz
  • Chuck DavisChuck Davis Posts: 23
    edited 2015-02-19 16:33
    Yes, I'd love to do that, but I build everything by hand and I'm not comfortable with trying to do surface mount devices at this point. The Atmega 1284 is the biggest thing I can get in a DIP. I'll definitely look at the xmega when the time comes to build in quantity and I can get the boards professionally built.. I'll throw in the surface mount propeller and other chips and probably shrink the board quite a bit. Actually, if I had a processor with 5 serial ports, I probably wouldn't use the Propeller at all - I'm basically using it as a communications processor to run 5 serial lines simultaneously.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2015-02-19 18:06
    Yes, I'd love to do that, but I build everything by hand and I'm not comfortable with trying to do surface mount devices at this point. The Atmega 1284 is the biggest thing I can get in a DIP. I'll definitely look at the xmega when the time comes to build in quantity and I can get the boards professionally built.. I'll throw in the surface mount propeller and other chips and probably shrink the board quite a bit. Actually, if I had a processor with 5 serial ports, I probably wouldn't use the Propeller at all - I'm basically using it as a communications processor to run 5 serial lines simultaneously.

    Never be afraid to get into SMD, it's a lot easier than you think. We have had plenty of discussions here on how easy it is and lots of tips too. I do a lot of my protos just with a cheap toaster oven and a syringe of solder paste. Sure beats soldering all those TH components by hand.

    I'm also sure you could do away with the Atmega altogether and just use the Prop chip.
Sign In or Register to comment.