Is there any real problem in using the propeller pins as inputs when sending data to other components that use 5v logic?
I've tried it with success but after reading some of the posts above I'm not sure I've been doing the right thing.
Here's the set-up: propeller is sending data to another chip (actually the ECU out of my motorcycle) ... I tie the line high to 5v with a 1k resistor, and use dira to send the 1s and 0s: the pin is configured as an output (and I set outa := 0) to send a zero, and configured as an input (and therefore high impedance?) to effectively send a 5v logic 1.
Mark, in that scheme where you toggle dira, the impedance in the input state with a pullup resistor to 5 volts is not really a high impedance. There is a substrate diode in the Prop, and that will clamp the voltage on the signal line at around 4.3 volts in the high state. Current from the 5 volt supply will flow through the pullup resistor and the substrate diode back into the Prop 3.3 volt supply. If it happens that the 3.3 volt supply is turned off, while the 5 volt supply remains on, then parasite power can be supplied to the Prop from the 5 volt system, and that might be bad.
Many 5 volt systems have 1.4 volt (ttl level) input thresholds and can work okay on 0 to 3.3 volt signals. Protection from noise and spikes is always necessary, so I agree with Mike that something like the optoisolator would be good insurance.
Rayman said...
Note that I2C is a special case and you can interface to the DS1307 and some other I2C chips with no resistors at all. This is because I2C devices only pull-down on the signal lines. As long as they recognize 3.3 V as a logic high, as the DS1307 happens to do, it will work. But unfortunately, there are plenty of other I2C chips that do not recognize the 3.3V as logic high...
I have been unable to get the DS1307 to respond to commands from the Propeller. Basically it (ds1307) is wired at +5v and gnd for the chip power, and the SCL,SDA lines are wired directly to the propeller: SCL on DS1307 -> Propeller Pin 35 (P26) and SDA on DS1307 -> Propeller Pin 36 (P27).
I am using James Burrows i2cObject library. It detects the presence of the chip (the object returns true) but the chip does not take a time or return a time it was sent.
Any ideas on further debugging of this. It is a simple wired circuit but not sure if it is an i2c problem or scl/sda problem. Do I need any pullup or other resistors on the i2c bus?
You have to have a pullup resistor on SDA at least (10K to +5V would do). Strictly speaking, you should have a pullup on SCL as well. You also need to have 1K protective resistors in series with P26 and P27 from the Propeller. You could probably do without these, but they're a good idea to have when there's 5V "floating around".
Mike Green said...
You have to have a pullup resistor on SDA at least (10K to +5V would do). Strictly speaking, you should have a pullup on SCL as well. You also need to have 1K protective resistors in series with P26 and P27 from the Propeller. You could probably do without these, but they're a good idea to have when there's 5V "floating around".
Let me see if that works. I was using the i2cobject library and it was indicating the device was present even though the chip was disconnected from the propeller-not sure if there is a bug in the library or what...
Mike thanks for the input. It seems my 1307 chip was bad and when I replaced it with another all went well.
It is strange once in awhile (e.g. after resetting the propeller chip) that the value returned from the chip is 165 for all the
time values like it had a read error. After a couple of 165's it goes back to the right time. Not sure if the reset on the propeller jams the i2c bus but it only happens on the
third or so read after the reset....
The·FET cct. for 3.3v to 5.0v signal conversion shown above is available from http://www.hvwtech.com, stock code SKU# 50550 and is called a Logic Level Converter for a couple of bucks each.·I have not tried it.· If anyone has let me know how it worked out. ·
As for the I2C discussions I think·if they are true I2C devices then they do not supply voltage (passive device)·and the associated current. They only drain to ground or pull down the voltage on the line when chatting.· If· 3.3 volts·is the pull up voltage and that happens to be high enough·to be recognizes as a 1 then it really what else it needed?· The propeller should be used carefully·because communicating with the output as an active supplier of voltage to a·device, which is sinking current, may cause·some troubles with the Prop output cct. and the receiver of the·Prop current.· It should really alternate between open (input which is 1) and sinking pull up voltage (zero)·as an output only.· I am working with some of these devices now and I will let you know if I run into problems.· It does seem prudent to put a series resistor in the I2C lines just in case something wants to supply power to your Prop output·or if you programmed and decided to make a "1" active from your end.· There is a good little write up about· I2C at: http://www.best-microcontroller-projects.com/i2c-tutorial.html·· ·
So when coding I would think that something like: ·
repeat 8··························· ' Output data to SDA ····· outa[noparse][[/noparse]SDA] := (data <-= 1) & 1 ····· outa[noparse][[/noparse]SCL]~~····················· ' Toggle SCL from LOW to HIGH to LOW ····· outa[noparse][[/noparse]SCL]~ ·
May not be the best without series resistors.· Instead, keep the output low and toggle between input and output to allow the pull up resisters to do their job.· Like I said earlier I will give it a try and let you know if I run into trouble.
Thanks for your posts they have been quite informative.
Post Edited (Octahedron) : 11/29/2009 6:11:00 PM GMT
This family of Philips/NXP chips allows bi-directional translation from 1-5v to 1-5v without needing bi-directional control. And it's fast enough to work with the Prop2
In case the pdf gets moved, search for GTL2000 at NXP.
The most important thing to remember when using a series resistor to interface a 5V to the Propeller is that the current must be limited. The Propeller I/O pins contain clamping diodes on the I/O pins. These clamping diodes attempt to limit the incoming voltage to 3.3V. Clamping diodes are pretty robust, however they are not meant to continuously sink large amounts of current. The series resistor limits the current across the clamping diode so that it is not permanently damaged.
Figure 1 shows a series resistor interfacing a 5V devices to the Propeller chip. The value of R1 could vary if you know the current capability of the clamping diodes. To be safe you could use a 10k resistor, however larger resistors limit the bandwidth of the signal across them. With higher bandwidth signals you will need to reduce the size of the resistor.
Figure 1
Without the series resistor a 5V signal on the Propeller input will damage the clamping diodes over time. While the connection may appear to function, it will eventually fail from electrical stress.
The Propeller chip contains clamping diodes, however the clamping diodes are rated at ±500 µA. These diodes also have a forward voltage drop of 0.4V. This means the diodes will conduct at 3.7V. To ensure the current limit of the diodes is not exceeded when providing 5V to an input pin we must use a minimum resistor value of 2600Ω.
5V input signal minus the point at which the diodes conduct (3.7) gives a voltage difference of 1.3V. Solving for ohms law 1.3V divided by 500uA gives 2600 ohms.
(5V 3.7V) / 0.0005A = 2600Ω
To allow for some safety margin and the fact that 2.6k is not a standard resistor value it is recommend to use a 3.3k (minimum) or 4.7k resistor. Both values are common. Remember, it is not necessary to use a resistor on a Propeller output going into a 5V input. The bidirectional port tags show that the signal can travel in each direction, but the resistor is only required when the signal is bidirectional or an output from the 5V device.
Hi Chris,
Where did that 500 µA figure come from? Yes, I know it is in the data sheet. But... It is a rather low figure compared with other microprocessors, for example, the PIC typically specifies 20 mA for the clamp diodes. The MSP430, 2mA continuous. Coincidentally (or maybe not?) the SX like the Prop is 500 µA DC. I'd agree that it is not good practice to rely on the clamp diodes, nonetheless, it is important to know for reliability considerations in addition to KISS interfacing tricks.
What the clamp diodes can handle on a DC continuous basis should be less than what it can handle on an impulse basis. Did someone (Paul Baker?) actually test with established criteria of self heating of the diodes or some such? There are usually separate tests for DC continuous current, input and output short term clamp current, and latchup current, as well as ESD expressed as an impulse of current from a capacitor thru a controlled impedance. The data sheet I think is missing a couple of those figures.
In early threads, Chip spoke about the diodes, to quote for example:
"Those diodes can handle probably 50ma, but that much current could have the unintended consequence of lifting VDD above 3.3V. What you've done is fine."
I've pushed it up to 15mA for testing, and wonder if that, if even for a short time, could in some way damage or affect the long-term survival of the prop. Knowing how Chip (and Beau) design things, I doubt it. The issue of raising Vdd is separate--That could even occur with a 500µA substrate current if the Prop is running unloaded at low frequency .
We use a 2.2K series resistor for higher speed 5v signals and 4.7K for slower signals. The 2.2K resistors also work well
for the pull ups on the I2C bus to 3.3v. The problem with larger value resistors is that they form a RC circuit with the
acmos I/O drivers in the prop chip, this can alter the rise & fall times of the signals.
Hi Chris,
Where did that 500 µA figure come from? Yes, I know it is in the data sheet. But... It is a rather low figure compared with other microprocessors, for example, the PIC typically specifies 20 mA for the clamp diodes. The MSP430, 2mA continuous. Coincidentally (or maybe not?) the SX like the Prop is 500 µA DC. I'd agree that it is not good practice to rely on the clamp diodes, nonetheless, it is important to know for reliability considerations in addition to KISS interfacing tricks. What the clamp diodes can handle on a DC continuous basis should be less than what it can handle on an impulse basis. Did someone (Paul Baker?) actually test with established criteria of self heating of the diodes or some such? There are usually separate tests for DC continuous current, input and output short term clamp current, and latchup current, as well as ESD expressed as an impulse of current from a capacitor thru a controlled impedance. The data sheet I think is missing a couple of those figures. In early threads, Chip spoke about the diodes, to quote for example:
"Those diodes can handle probably 50ma, but that much current could have the unintended consequence of lifting VDD above 3.3V. What you've done is fine." I've pushed it up to 15mA for testing, and wonder if that, if even for a short time, could in some way damage or affect the long-term survival of the prop. Knowing how Chip (and Beau) design things, I doubt it. The issue of raising Vdd is separate--That could even occur with a 500µA substrate current if the Prop is running unloaded at low frequency .
Tracy,
You are correct in that the figures are from the datasheet. In these early threads that discussed these issues we didn't even have a datasheet and many items had not yet been characterized. At some point a fixed safe value for the rating of the diodes had to be set and that value is 500uA. If/when we revisit these characteristics again then these values are subject to change. For now though they are a safe bet.
From this I would understand that the Propeller will run at voltages higher than 3.6, even if not recommended? I am NOT suggesting any one make a habit of it, though based on the chart in the Data Sheet, it seems that at least to a point the maximum clock improves with an increase in Vcc. And I am (as we speak) setting up a test to see how the Propeller runs at 128Mhz with Vcc = 3.8V, then pushing it up to its limits for a full 7 days increasing the clock (by 2MHz [increasing Xin by 0.125MHz]), every week, till it fails, and redoing it all at Vcc = 4.0V, and Vcc = 4.2V. Once I have the first test running for over 24Hours I will start a thread on this. The first clock freq tested may end up being higher than 128Mhz depending on the testing of today (wee shall see).
To input from a 5V system, a series resistor in the 1k-100k range is probably·the best approach.·There are parasitic catch diodes on every pin of the device which will clamp incoming out-of-range voltages to within ~0.4V of the VSS and VDD rails. This will force the resistor to drop 1.3V (5.0V-(3.3+0.4)) for an incoming high signal.
This (the existence of a parasitic catch diode) is true about the XI pin as well? Since the chip doesn't need capacitors on the XI and XO pins, do these pins have higher inherent capacitance than the average Prop pin? Does this impact the selection of the resistor used to drive XI from an external 5V oscillator? (Referring here to the inherent low-pass filter such a config represents.)
Also, the Prop clock is specified from DC to 80 MHz. So I can bring VDD and RESn to 3.3V and only after five or ten seconds provide a signal to the XI pin, and everything will be copacetic? The PLL will fire up reliably?
Since the chip doesn't need capacitors on the XI and XO pins, do these pins have higher inherent capacitance than the average Prop pin?
The capacitance on these pins appears to be programmable, depending upon the clock mode. I would suspect that, for an external clock, the internal caps are disabled. No clue about any parasitic diodes on XI, though. You could always drive the XI pin via a divider or through a 74LVCxxxx buffer.
Since the chip doesn't need capacitors on the XI and XO pins, do these pins have higher inherent capacitance than the average Prop pin?
Another approach would be to select XTAL mode (self biasing) and use a simple series R-C to couple.
Place the R very close to the OSC to soften the edges a little, and choose the C to make a voltage divider with the Chip Caps. 30~50pF region.
If you change the OSC in future to 3.3V or less, you can use a larger series C (1000pF)
ALL of the pins have ESD protection, which means they all have a back EMF diode.
... and although it may "work" to clamp the voltage to within -0.3V or -0.4V above or below ground, you are point blank injecting unnecessary noise either to the substrate or supply voltage to the Propeller or any other IC. This is not good practice folks. Simply use a resistor divider or an Emitter follower transistor arrangement<- so there is no inversion that takes place.
I use the HEF40106 Schmitt trigger you can power it from the prop 3.3 supply and connect the outputs from the HEF40106 directly to the PXX pins of the prop. On the input side of the HEF40106 I use a 10K resistor. So your square wave from your device connects to the 10K resistor and then to the input of the HEF40106. I use it all the time for counters if I want to read frequency from a sensor etc. I have not read all the post so I don't know if anyone else has mentioned it.
Please don't overcomplicate what should be simple but also please don't abuse what should be simple either. The constant references to minimum recommended value is an "abuse" as that minimum is the same as an ABSOLUTE MAXIMUM and when you are running more than one input at that kind of current you are injected unnecessary current into the substrate which can destabilize substrate-well isolation potentials leading to all kinds of quirks way before the chip is ever damaged by "excessive" current.
I've pointed out that a 100k resistor is fine for most inputs and even 1M too but perhaps 10k for high-speed signals, and 100kHz is NOT high-speed. Saying "just to be safe" doesn't make it so, just do your sums.
But if you must have a low value resistor then consider making a voltage divider as Beau pointed out, very easy to do when you use resnets as they take up very little space and you can put them in series/parallel to get the values that you need. Using external CMOS gates or boards to drive internal CMOS gates is over the top for most applications.
I use the HEF40106 Schmitt trigger you can power it from the prop 3.3 supply and connect the outputs from the HEF40106 directly to the PXX pins of the prop. On the input side of the HEF40106 I use a 10K resistor. So your square wave from your device connects to the 10K resistor and then to the input of the HEF40106.
40106 class devices are good for some apps, but not so good for a Clock-buffer as they are very slow.
That slow speed and low current, makes them good for sub MHz sensor signals.
There are also 1G versions if you need smaller units eg BU4S584G2-TR, or TC4S584F,LF
I just go with what works I did not see any specs in the original question. The post asked for a 5 volt interface. The one I seggested works perfect in the lower hz range and the unused inputs can be pulled low. And as I said earlier you can buy a 8 ch board for 8 bucks on adafruit product I'd 395 that one uses a TI TXB0108
Great point but we are all just giving our input and it is up to the original poster to determine what the best course of action is and what fits their budget.
Comments
I've tried it with success but after reading some of the posts above I'm not sure I've been doing the right thing.
Here's the set-up: propeller is sending data to another chip (actually the ECU out of my motorcycle) ... I tie the line high to 5v with a 1k resistor, and use dira to send the 1s and 0s: the pin is configured as an output (and I set outa := 0) to send a zero, and configured as an input (and therefore high impedance?) to effectively send a 5v logic 1.
I hope this isn't a stoopid question?
Cheers,
MArk
Many 5 volt systems have 1.4 volt (ttl level) input thresholds and can work okay on 0 to 3.3 volt signals. Protection from noise and spikes is always necessary, so I agree with Mike that something like the optoisolator would be good insurance.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Later!
kenjj
I have been unable to get the DS1307 to respond to commands from the Propeller. Basically it (ds1307) is wired at +5v and gnd for the chip power, and the SCL,SDA lines are wired directly to the propeller: SCL on DS1307 -> Propeller Pin 35 (P26) and SDA on DS1307 -> Propeller Pin 36 (P27).
I am using James Burrows i2cObject library. It detects the presence of the chip (the object returns true) but the chip does not take a time or return a time it was sent.
Any ideas on further debugging of this. It is a simple wired circuit but not sure if it is an i2c problem or scl/sda problem. Do I need any pullup or other resistors on the i2c bus?
Thanks,
Tony
Let me see if that works. I was using the i2cobject library and it was indicating the device was present even though the chip was disconnected from the propeller-not sure if there is a bug in the library or what...
It is strange once in awhile (e.g. after resetting the propeller chip) that the value returned from the chip is 165 for all the
time values like it had a read error. After a couple of 165's it goes back to the right time. Not sure if the reset on the propeller jams the i2c bus but it only happens on the
third or so read after the reset....
Your advice on the pullups was very helpful.
Tony
·
As for the I2C discussions I think·if they are true I2C devices then they do not supply voltage (passive device)·and the associated current. They only drain to ground or pull down the voltage on the line when chatting.· If· 3.3 volts·is the pull up voltage and that happens to be high enough·to be recognizes as a 1 then it really what else it needed?· The propeller should be used carefully·because communicating with the output as an active supplier of voltage to a·device, which is sinking current, may cause·some troubles with the Prop output cct. and the receiver of the·Prop current.· It should really alternate between open (input which is 1) and sinking pull up voltage (zero)·as an output only.· I am working with some of these devices now and I will let you know if I run into problems.· It does seem prudent to put a series resistor in the I2C lines just in case something wants to supply power to your Prop output·or if you programmed and decided to make a "1" active from your end.· There is a good little write up about· I2C at: http://www.best-microcontroller-projects.com/i2c-tutorial.html··
·
So when coding I would think that something like:
·
repeat 8··························· ' Output data to SDA
····· outa[noparse][[/noparse]SDA] := (data <-= 1) & 1
····· outa[noparse][[/noparse]SCL]~~····················· ' Toggle SCL from LOW to HIGH to LOW
····· outa[noparse][[/noparse]SCL]~
·
May not be the best without series resistors.· Instead, keep the output low and toggle between input and output to allow the pull up resisters to do their job.· Like I said earlier I will give it a try and let you know if I run into trouble.
Thanks for your posts they have been quite informative.
Post Edited (Octahedron) : 11/29/2009 6:11:00 PM GMT
In case the pdf gets moved, search for GTL2000 at NXP.
http://www.nxp.com/documents/data_sheet/GTL2000.pdf
Resistor (series) Interface
The most important thing to remember when using a series resistor to interface a 5V to the Propeller is that the current must be limited. The Propeller I/O pins contain clamping diodes on the I/O pins. These clamping diodes attempt to limit the incoming voltage to 3.3V. Clamping diodes are pretty robust, however they are not meant to continuously sink large amounts of current. The series resistor limits the current across the clamping diode so that it is not permanently damaged.
Figure 1 shows a series resistor interfacing a 5V devices to the Propeller chip. The value of R1 could vary if you know the current capability of the clamping diodes. To be safe you could use a 10k resistor, however larger resistors limit the bandwidth of the signal across them. With higher bandwidth signals you will need to reduce the size of the resistor.
Without the series resistor a 5V signal on the Propeller input will damage the clamping diodes over time. While the connection may appear to function, it will eventually fail from electrical stress.
The Propeller chip contains clamping diodes, however the clamping diodes are rated at ±500 µA. These diodes also have a forward voltage drop of 0.4V. This means the diodes will conduct at 3.7V. To ensure the current limit of the diodes is not exceeded when providing 5V to an input pin we must use a minimum resistor value of 2600Ω.
5V input signal minus the point at which the diodes conduct (3.7) gives a voltage difference of 1.3V. Solving for ohms law 1.3V divided by 500uA gives 2600 ohms.
(5V 3.7V) / 0.0005A = 2600Ω
To allow for some safety margin and the fact that 2.6k is not a standard resistor value it is recommend to use a 3.3k (minimum) or 4.7k resistor. Both values are common. Remember, it is not necessary to use a resistor on a Propeller output going into a 5V input. The bidirectional port tags show that the signal can travel in each direction, but the resistor is only required when the signal is bidirectional or an output from the 5V device.
(However, you need to make sure that the 5V I2C device will recognise 3.3V as a logic 1. Otherwise, you will need a series resistor.)
Where did that 500 µA figure come from? Yes, I know it is in the data sheet. But... It is a rather low figure compared with other microprocessors, for example, the PIC typically specifies 20 mA for the clamp diodes. The MSP430, 2mA continuous. Coincidentally (or maybe not?) the SX like the Prop is 500 µA DC. I'd agree that it is not good practice to rely on the clamp diodes, nonetheless, it is important to know for reliability considerations in addition to KISS interfacing tricks.
What the clamp diodes can handle on a DC continuous basis should be less than what it can handle on an impulse basis. Did someone (Paul Baker?) actually test with established criteria of self heating of the diodes or some such? There are usually separate tests for DC continuous current, input and output short term clamp current, and latchup current, as well as ESD expressed as an impulse of current from a capacitor thru a controlled impedance. The data sheet I think is missing a couple of those figures.
In early threads, Chip spoke about the diodes, to quote for example:
"Those diodes can handle probably 50ma, but that much current could have the unintended consequence of lifting VDD above 3.3V. What you've done is fine."
I've pushed it up to 15mA for testing, and wonder if that, if even for a short time, could in some way damage or affect the long-term survival of the prop. Knowing how Chip (and Beau) design things, I doubt it. The issue of raising Vdd is separate--That could even occur with a 500µA substrate current if the Prop is running unloaded at low frequency .
for the pull ups on the I2C bus to 3.3v. The problem with larger value resistors is that they form a RC circuit with the
acmos I/O drivers in the prop chip, this can alter the rise & fall times of the signals.
Tracy,
You are correct in that the figures are from the datasheet. In these early threads that discussed these issues we didn't even have a datasheet and many items had not yet been characterized. At some point a fixed safe value for the rating of the diodes had to be set and that value is 500uA. If/when we revisit these characteristics again then these values are subject to change. For now though they are a safe bet.
This (the existence of a parasitic catch diode) is true about the XI pin as well? Since the chip doesn't need capacitors on the XI and XO pins, do these pins have higher inherent capacitance than the average Prop pin? Does this impact the selection of the resistor used to drive XI from an external 5V oscillator? (Referring here to the inherent low-pass filter such a config represents.)
Also, the Prop clock is specified from DC to 80 MHz. So I can bring VDD and RESn to 3.3V and only after five or ten seconds provide a signal to the XI pin, and everything will be copacetic? The PLL will fire up reliably?
-Phil
Meanwhile I think I'll use a voltage divider and keep the resistor values relatively low.
Another approach would be to select XTAL mode (self biasing) and use a simple series R-C to couple.
Place the R very close to the OSC to soften the edges a little, and choose the C to make a voltage divider with the Chip Caps. 30~50pF region.
If you change the OSC in future to 3.3V or less, you can use a larger series C (1000pF)
... and although it may "work" to clamp the voltage to within -0.3V or -0.4V above or below ground, you are point blank injecting unnecessary noise either to the substrate or supply voltage to the Propeller or any other IC. This is not good practice folks. Simply use a resistor divider or an Emitter follower transistor arrangement<- so there is no inversion that takes place.
I've pointed out that a 100k resistor is fine for most inputs and even 1M too but perhaps 10k for high-speed signals, and 100kHz is NOT high-speed. Saying "just to be safe" doesn't make it so, just do your sums.
But if you must have a low value resistor then consider making a voltage divider as Beau pointed out, very easy to do when you use resnets as they take up very little space and you can put them in series/parallel to get the values that you need. Using external CMOS gates or boards to drive internal CMOS gates is over the top for most applications.
40106 class devices are good for some apps, but not so good for a Clock-buffer as they are very slow.
That slow speed and low current, makes them good for sub MHz sensor signals.
There are also 1G versions if you need smaller units eg BU4S584G2-TR, or TC4S584F,LF
If you check the dates, the post that refreshed this old thread. asked about external 5V oscillator drive.