Skip to content

Due TWI+TWI1 pins : are there integrated pullups on-board or not? if yes: how to disable? #4007

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
shiftleftplusone opened this issue Oct 21, 2015 · 70 comments
Assignees
Milestone

Comments

@shiftleftplusone
Copy link

hello,
1st question:
about Due TWI1 pins (2nd i2c port): are there integrated pullups on-board or not?
if yes: how to disable?

@shiftleftplusone shiftleftplusone changed the title Due TWI1 pins (2nd i2c port): are there integrated pullups on-board or not? Due TWI1 pins (2nd i2c port): are there integrated pullups on-board or not? if yes: how to disable? Oct 21, 2015
@shiftleftplusone
Copy link
Author

why is there no one who can comment and fix this effing issue?

@mikaelpatel
Copy link

Seems like you need some help to search info. I found this (in 10 us :-) here: https://www.arduino.cc/en/Main/ArduinoBoardDue

TWI 1: 20 (SDA) and 21 (SCL)
TWI 2: SDA1 and SCL1.
Support TWI communication using the Wire library. SDA1 and SCL1 can be controlled using the
Wire1 class provided by the Wire library. While SDA and SCL have internal pullup resistors, SDA1
and SCL1 have not. Adding two pullup resistor on SDA1 and SCL1 lines is required for using Wire1.

Cheers!

@shiftleftplusone
Copy link
Author

thank you, but then I wonder why the Mega with disabled pullup resistors works as an i2c slave (to a Lego Mindstorms EV3 master) and the DUE don't - neither by Wire not by Wire1.

http://www.mindstormsforum.de/viewtopic.php?f=25&t=8673#p67709

In this case it must be a hardware bug which needs to be fixed pls CMIIW).

@mikaelpatel
Copy link

Can you get the Due to work as an I2C slave at all? For instance with a Mega as master. It does not necessary have to be a hardware issue. Have you tried debugging the Due I2C code? Checking the state machine etc.

Thanks for the poetry :)

@mikaelpatel
Copy link

BW: Is there a difference in voltage? The pullup resistors on the Lego Mindstorm might be to large and/or expects 5V? What is the spec? The Due is a 3V3 board. Is it not?

http://forums.adafruit.com/viewtopic.php?f=31&p=191092 (Goggle 42 us)
http://www.dexterindustries.com/howto/connect-the-arduino-and-the-lego-mindstorms-together/ (Another 42 us :)
http://playground.arduino.cc/Main/I2CBi-directionalLevelShifter
Cheers!

@shiftleftplusone
Copy link
Author

According to Lego company specs, the EV3 is at 3.3V level but has a 5V protection. All new EV3 sensors also work at 3.3V level (ADC, UART, I2C).

2 DUEs work by i2c by a simple test, 1 as a master, 1 as a slave (Wire-Wire, Wire-Wire1, Wire1-Wire).
(did not try Wire1-Wire1).

By having internal pullups activated also the Mega fails to work with either Lego brick.
by disabled pullups the Mega always worked with either Lego brick.

The dexter industries example works with an Uno, basically it's similar to my approach using a Mega.
Note that the EV3 needs 2x 47k pullups (actually 32k...82k work) because of it's weird bitbang i2c implementation. Either lower resistor in that line breaks the i2c transmission.

@mikaelpatel
Copy link

@vogonjeltz

Good work! You will need a scope or at least a logic analyzer for the next step. So far this looks like a hardware problem in your setup. There is no evidence that there is a problem with the Due board or the software then.

Have you tried a level shifter with the correct pullups on both side?

Cheers!

@shiftleftplusone
Copy link
Author

no, I dont have level shifters and I also don't have a scope, I am not experienced in electrical stuff. Just plugging wires from one header to the other is ok of course.

@mikaelpatel
Copy link

@vogonjeltz
I think that this issue is answered now and should be closed. Good luck with your project!

@shiftleftplusone
Copy link
Author

I'm not quite sure if everything is answered.
First of all I would like to try to disable the internal Due pullups on Wire by software, like I did for the Mega (patch in ...\avr\twi.c ) .
How can I do this for the Due?

@NicoHood
Copy link
Contributor

This is not a support forum. It really looks like a hardware issue, so arduino IDE developers cannot really help you. You might want to ask in the forums or chat about this specific project question.

A Level shifter (logic level converter) is 1$ and a logic analyzer (salae china clone) is 8$. Both can be really useful at any time/project.

@shiftleftplusone
Copy link
Author

the design of twi.c in the avr subfolder is there by default, but it can only enable (or disable by outcommenting) AVR pullups, no ARM pullups.

// file: twi.c           
//  activate internal pullups for twi.
 //  digitalWrite(SDA, 1);
 //  digitalWrite(SCL, 1);

So there has to be changed something in the ARM libs, and this is a question or a request to the developers, not to end users in either user forum.

@NicoHood
Copy link
Contributor

As said above from @mikaelpatel we do not have your hardware and cannot help you debugging your hardware. Grab a logic level converter and a logic analyzer and provide us more information.

And if you need to change the "arm" lib, go ahead, its open source. The due is SAM by the way, no ARM.

The forums are still a better place, since mostly noone checks the github issues, except some interrested developers. You have a better change to ask there or in the IRC chat. From time to time there are very experienced users.

Another idea would be to ask @sandeepmistry who created a lot of PRs with TWI fixes. He is the guy to ask I guess.

Good luck.

@shiftleftplusone
Copy link
Author

which part was ununderstandable?
my question was not about hardware debugging,
it is simply about disabling Due-pullups on Wire by a software command.
Just like for AVRs.
But *** there is not a single twi.c file in either \arm... subdirectory. *** // << why does the editor erase the 2nd backslash?

So how to do it?

If not implemented FTM: please implement it for the future release.
Architecture: SAM
Library: Wire
Type: improvement

This is my issue.

@mikaelpatel
Copy link

@vogonjeltz
I took a few minutes to browse through the SAM TWI code. I was a bit curious to how it was done as I mainly work on my own framework (https://github.com/mikaelpatel/Cosa)

Actually I could not find anything that looked like enabling of pullup - that assumption seems to be wrong for the SAM. In any case you could write a few lines of code and check the pin mode after initiating as TWI slave. I don't have an Arduino Due so I am sorry that I cannot help with that. I would also like to suggest that you check the ATMEL SAM documentation for the TWI. Guess there is some interesting info there.

Keep up the poetry!

@NicoHood
Copy link
Contributor

SDA/SCL0-3 are connected to a pullup by hardware. (pin 7/8).
The default pins (above D13/AREF)for I2C dont seem to be connected to any HW pullup.

Just use a multimeter or @mikaelpatel s suggestion.

@shiftleftplusone
Copy link
Author

yes, also on the Mega SDA/SCL are connected to hardware pullup resistors, but they can be enabled or diasbled by software command in twi.c.

The feature request to the developers was:
If not implemented FTM: please implement it for the future release.
Architecture: SAM
Library: Wire
Type: improvement

@NicoHood
Copy link
Contributor

Well it has in chip pullups and on PCB. Maybe the volt level is a problem or the Pullup is too strong/too weak.

The devs have recognized your issue and will respond if they feel to respond.

@mikaelpatel
Copy link

Now I think there is some confusion about hardware pullup resistors (internal or external). On the Mega (https://www.arduino.cc/en/uploads/Main/arduino-mega2560_R3-sch.pdf) there are 10K external hardware pullup resistors. The AVR device driver code uses the internal port pullup resistors to protect the pins in TWI mode. These are large 20-50K but apparently affect the Lego Mindstorm when in parallel with the external pullups (6-8K when in parallel).

The Due (https://www.arduino.cc/en/uploads/Main/arduino-Due-schematic.pdf) on the other hand has external pullup resistors on Wire0 1K5 to VCC (3.3V). There are no external pullup resistors on Wire1.

@vogonjeltz I think you have got this mixed up. Please check the schematics and the device driver code.

@NicoHood
Copy link
Contributor

Of course there are! RNB1 and RNC1, 10k pullup to 5V top middle next to the isp header (and the 16u2 has no I2C at all)

Maybe you DO need pullups, but stronger pullups.

@mikaelpatel
Copy link

@NicoHood
Found them! But they are hardly controlled by software as @vogonjeltz claims :-). With the internal pullup in parallel this gives approx. 6-8K. Deactivating the internal pullup gives these 10K pullups to 5V which seems to work with the Lego Mindstorm. But this does not help much with the Due? It puts the record straight with Mega though.

Cheers!

@shiftleftplusone
Copy link
Author

to be honest, I now don't understand any more what you're saying... too many "there is not" ...."there is though"...."no there is not, but something different"..."no, there is also not" ...."no, of course there is!"... "no, they are not, but does not help..."
???

so can you confirm that there are DUE-pullups both on Wire and Wire1 (either if internal or external would not matter)?

That would explain the issue, because pullups on the bus have to be at least 32k... up to 82k.
just 1.5k-10k is too low for EV3, it pulls up the wires too strongly.
If not disabled and replaced e.g. by 47k's, no communication to EV3 will be possible.

remark:
on the Mega instead, I once was told that there are no "chip-internal" but "extra-on-board" pullups on the board, somewhere in the corner close to pins 18-22 in the vicinity of the SPI header - but actually that does not matter because they can be disabled by software completely (enough) which makes the Mega work with additional "extra-external" 47k resistors

anyway, again, this following would be the crucial question:
can one confirm that there are DUE-pullups both on Wire and Wire1 (either if internal or external would not matter)?

@shiftleftplusone shiftleftplusone changed the title Due TWI1 pins (2nd i2c port): are there integrated pullups on-board or not? if yes: how to disable? Due TWI+TWI1 pins : are there integrated pullups on-board or not? if yes: how to disable? Oct 24, 2015
@shiftleftplusone
Copy link
Author

next,
if there indeed are pullups anywhere on the Due board

  • how can you disable by software
  • pullups on Wire (definitely confirmed there must be some)
  • pullups on Wire1 (questionable whether there are any)
    ?

if not possible FTM:

  • please add to DUE lib improvements!

@peabo7
Copy link

peabo7 commented Oct 24, 2015

On October 24, 2015 at 1:40 AM VogonJeltz notifications@github.com wrote:

next,
if there indeed are pullups anywhere on the Due board

  • how can you disable by software
    pullups on Wire
    pullups on Wire1
    ?

What does this have to do with the Arduino IDE?

You need to consult the schematic and data sheets (noted previously IIRC).

Try something out. You are not as simple as you claim. If you find something
relevant to Arduino, find out how to submit a pull request.

@shiftleftplusone
Copy link
Author

which part of this thread didn't you understand?
Come on, you are not as simple as you claim

in the Arduino-IDE/API (system installation folder) there is a file called twi.c for avr as I already repeatedly had posted, and with a twi.c patch it worked, search the post above!

Now the request is about a similar API functionalty for the Due, is that so hard to understand?

@NicoHood
Copy link
Contributor

But we cant help you debugging your hardware problem without any hardware. You need to give us some information, as requested here:
#4007 (comment)
#4007 (comment)

@peabo7
Copy link

peabo7 commented Oct 24, 2015

Now the request is about a similar API functionalty for the Due, is that so hard to understand?

Not a problem, can you work on it?

We're all volunteers here: help yourself.

@shiftleftplusone
Copy link
Author

peabo,
Man, if I could I had not asked.
I am a simple Arduino beginner and hobby programmer, I have no idea of electonics or C compilers underneath, I just use the Arduino Sketch because it's so simple and I dont have to care about all this technic and gpp and make mess.

(honestly, I think Arduino would be better off if there were professional, full-time paid employees to care about all board issues and improvements.)

@cmaglie
Copy link
Member

cmaglie commented Oct 26, 2015

1st question: about Due TWI1 pins (2nd i2c port): are there integrated pullups on-board or not?

Pins "SDA" and "SCL" (number 20 and 21) have pull-up resistor on board.
Pins "SDA1" and "SCL1" does NOT have pull-up resistors on board.

This is explained here: https://www.arduino.cc/en/Main/ArduinoBoardDue

Support TWI communication using the Wire library. SDA1 and SCL1 can be controlled using the Wire1 class provided by the Wire library. While SDA and SCL have internal pullup resistors, SDA1 and SCL1 have not. Adding two pullup resistor on SDA1 and SCL1 lines is required for using Wire1.

They can not be disabled via firmware because there are two physical resistors on board (you should de-solder the components from the board to physically remove the pull-ups).

The CPU on the Due board has pin pull-ups that can be controlled via firmware, but they are too weak (100KOhm) to be used in I2C bus.

@shiftleftplusone
Copy link
Author

cmaglie,
thank you very much for clarification. So after all, the way the on-board-hardware-pullups on the Mega appear to be constructed in another way, because they actually can be disabled by software - but this would absolutely not be possible for the Due, is this irrefutable?

@matthijskooijman
Copy link
Collaborator

The internal pullups on the Mega (and most other AVR-chips) are smaller, typically just over 20k, which is usually small enough for I2C comunication.

For the Due, the current resistors are soldered in place, so no, there is nothing you can do in software to disable them. A future revision could have a transistor added to enable/disable the pullups, but it seems unlikely that that extra complexity will be added.

I'm not sure why you actually want to disable these pullups, though? They are required for I2c operation, so unless you're running I2c with another device that runs at < 3.3V, I can't see any reason not to have these pullups?

@shiftleftplusone
Copy link
Author

they have to be disabled to be interfaced as a slave to a "very special master device" (see posts above).
On the Mega the board-pullups can be deactivated be patching the twi.c file (see above)
without deactiving the board-pullups Mega don't work as a slave (see above),
after deactivating the board-pullups by software it works (see above).

Now my question was,
why is it possible to deactivate the board-pullups on the Mega by software via twi.c
and is it possible or is it _absolutely irrefutably impossible_ to do this on the Due in a similar way?

@PaulStoffregen
Copy link
Contributor

@vogonjeltz You are wasting the very valuable and limited time of many software developers with your selfish requests. Please stop using Arduino's Github issue tracker for your personal project tech support.

DO NOT ask for improvements here regarding issues you do not understand. Ask on the forum first. You should never make these sorts of requests, without knowledge and experience, until other experienced people have confirmed the true nature of the problem. The forum is meant for exactly that type of conversation.

For example, you should conduct this query on the forum. Solicit experts to answer your questions regarding what is and is not possible by the hardware. DO NOT POST HERE until after you have received confirmation from experts on the forum for your technical questions.

You are selfishly wasting precious time from people who do contribute to Arduino. Please stop being so selfish and unproductive.

@shiftleftplusone
Copy link
Author

Paul,
I didn't expect anything else than that from you.
Let people answer who wish to contribute something worthy, and better walk along.

@shiftleftplusone
Copy link
Author

my question was,
why is it possible to deactivate the board-pullups on the Mega by software via twi.c
and is it possible or is it absolutely irrefutably impossible to do this on the Due in a similar way?

If it's possibly in principal, please add this to the Arduino IDE.

@matthijskooijman
Copy link
Collaborator

I answered your questions a few comments ago, so I'm closing this issue. I'm with Paul on this one - please stop expecting other people to do your homework for you. This is not the place to ask questions, only to report bugs or suggest specific improvements.

@shiftleftplusone
Copy link
Author

no, you wrote something which was not the answer to my question and what I already knew and you asked things which already had been widly explained in posts above yours.
You surely missed lot of things which was already written, please read before you write.

my question was,
why is it possible to deactivate the hardware board-pullups on the Mega by software via twi.c
and is it possible or is it absolutely irrefutably impossible to do this on the Due in a similar way?

If it's possibly in principal, please add this to the Arduino IDE.
It's a feature request.

This issue is NOT resolved !!

@matthijskooijman
Copy link
Collaborator

If you did not understand my answers, or think I misunderstood your questions, it is up to you to explain why you think this is so. Simply repeating your questions isn't going to help, since AFAICS I answered those questions exactly (though I'll likely stop investing time in you entirely...).

@shiftleftplusone
Copy link
Author

no, you didn't, please read closely what has been written!
closing this issue now as you didn't understand anything is really outrageous !!

Reopen this issue immediately !!
(and I'd really appreciate if you didn't ever interfere to my issues again, just the same about Paul Stoffregen and peabo7 !!)

@NicoHood
Copy link
Contributor

I love those type of people <3

@shiftleftplusone
Copy link
Author

@shiftleftplusone
Copy link
Author

now what?

@mikaelpatel
Copy link

@vogonjeltz
Why did you not simply leave the issue closed the first time and contact me on the forum if you needed details on how I got it to work? Instead you just kept on "barking-up-the-wrong-tree".

I will give you a final reference to all you need to know to get it working; http://stefanshacks.blogspot.se/2015/03/how-to-connect-lego-mindstorms-nxt_84.html
This is what I followed. This page (http://www.lego.com/de-de/mindstorms/downloads) has links to the schematics of all the Lego boards. Here you can see why the EV3 is "special".

Please understand that you cannot disable hardware resistors on the board in software. You will need to remove them from the board. You did not disable the hardware resistors on the Mega. You disabled the internal pullup resistors.

Have a nice day!

@shiftleftplusone
Copy link
Author

mikael,
thanks, your post was really helpful indeed, although it didn't work with my EV3 nevertheless, even when using level shifters.

I finally abandoned all my tries to interface an EV3 to a DUE, it really makes no sense. (The EV3 is really a complete misconstruction for having to be interfaced to standard devices.)

But I need to de-activate all pullups on all DUE i2c ports nevertheless, for different issues, even on SDA and SCL (the 1st i2c port). I actually don't want to specify the reasons more detailed, I simply want to deactivate them by software.

That's why I've asked about completely deactiviating pullups even on the first I2c.
SDA1 and SCL1 is out of interest in this respect as they already don't have any from the start.

After Wire SDA+SCL pullups appear to be hardware pullups on board, just like for the Mega, I would assume that it must be possible to deactivate in a similar software manner on the Due, just like it's possible for the Mega.

As it seems, this is not possible already right in the moment,
so this is a feature request to make it possible for the future.

I really don't know how to make it more clear in English, regrettably.

@ffissore ffissore modified the milestone: Release 1.6.6 Oct 28, 2015
@NicoHood
Copy link
Contributor

So wie ich es verstanden habe, gibt es keine option bei dem DUE. Der chip kann das einfach nicht, also können Sie es auch nicht implementieren. Also wird es auch in zukunft nicht möglich sein die Pullups zu deaktivieren, da sie Hardwareseitig verhanden sind. Die kannst sie allerhöchstens von der Platine entfernen. So ist die limitierung.

Wenn dein english wirklich pur aus google translator kommt, muss ich sagen: nicht schlecht. Durchaus sehr gut und verständlich.

@shiftleftplusone
Copy link
Author

ich dachte, es ginge grundsätzlich, da peabo7 ja so großspurig behauptet hatte, ich müsse mich quasi nur hinsetzen und es selber versuchen, dann ginge es auch, und ich müsse niemand anderes damit behelligen. War dann aber wohl doch nur hohles Geschwätz.
Aber verstehen möchte ich es dennoch:
wie macht es der mega, dass er seine Hardware-Board-Pullups softwaremäßig enabled/disabled per
// file: twi.c
// activate internal pullups for twi, outcomment for disabling:
digitalWrite(SDA, 1);
digitalWrite(SCL, 1);

es sind schließlich exakt genau die gleichen, aufgelöteten Pullups bei Mega wie bei Due.

Sollte es aber dennoch, unzweifelhaft und unumstößlich nicht funktionieren mit dem Due, dann kann dieser Fall tatsächlich geschlossen bleiben.
Aber DAS möchte ich von einem absoluten professionellen (!) Due-Hardware- und Software-Experten hier hören.

(Das Englisch kommt aus Google translate, aber ich bearbeite es immer zwangsweise nach, sonst kommt nur Quatsch raus. Oder ich frage meine Tochter, die lebte eine Zeitlang in Louisiana. ;) )

@NicoHood
Copy link
Contributor

Sieht so aus als kannst du keine Disablen, weil sie nie aktiviert werden. Sie haben doch geschrieben, dass sie zu schwach sind und deswegen hardwareseitige nochmal verwendet wurden.

Ansonsten sind die links zum evo da oben doch sicherlich nützlich. Und für weitere Hilfe frag besser im Forum, da bekommst du wirklich hilfreicheren support, von Leuten die das eventuell auch schonmal gemacht haben. @mikaelpatel hat dir doch geschrieben, dass du Ihn einfach auch im forum hättest fragen können ohne hier groß tausend mal auf der gleichen Frage rumzureiten, die geklärt war. Also nimm den mega oder frag ihn im forum am besten ;)

@shiftleftplusone
Copy link
Author

neinnein, das scheint anders rum zu sein - zumindest auf dem Mega:
hier gibt es welche auf der Platine, die können softwaremäßig disabled werden, und interne im AVR chip, die können nicht disabled werden, aber die können drin bleiben, weil sie so schwach = hochohmig sind, und so funktioniert es dann trotzdem.
Es sind beim Mega also die aufgelöteten auf der Platine, die disabled werden können, so wie ich es verstanden habe.

Der Mega kommt als Board nicht in Frage, es ist bei weitem zu leistungsschwach: viel zu langsam, und viel zu wenig RAM. Nachdem der EV3 aber inzwischen Geschichte ist, ist auch das Forum kein Thema.

Hier geht es um eine Erweiterung der DUE-IDE/API, da hilft auch kein Forum mit noch mehr Laien, Besserwissern und Klugscheißern, das ist reine Github-Entwickler-Angelegenheit für Leute, die wirklich wissen wovon sie reden. Oder zumindest wissen sollten, wenn ich mir hier einige Posts so anschaue.

@NicoHood
Copy link
Contributor

Die beim Mega kannst du die auch nicht deaktivieren, nicht die auf der Platine. Nur die internen. Siehst du am Schaltplan. Ich hab nur ehrlich keine Ahnung davon, also halte ich mich da zurück weitere Aussagen zu treffen.
https://www.arduino.cc/en/uploads/Main/arduino-mega2560_R3-sch.pdf

@shiftleftplusone
Copy link
Author

ach sooo...dann bleiben also auch beim Mega die Board-Pullups nach wie vor aktiv ....
ok, dann sieht die Sache anders aus.

Dann ist aber auch der DUE gestorben, denn ich kann ihn nicht mit 2 NXTs als slave verwenden, auch hier müssten dann die Board-Pullups komplett auf beiden i2c-Leitungen weg (das war der Sinn dahinter).

Dann muss ich auf den TRE warten, oder es mit einem Raspberry Pi plus 1x Arduino Due versuchen.
Langsam wird es ärgerlich mit den Due - und EV3- Eigenheiten.

@mikaelpatel
Copy link

At last!

@NicoHood
Copy link
Contributor

Du kannst auch einen kleinen pro mini verwenden, den du über einen <Microcontroller/PC/Raspberry etc> deiner Wahl ansteuerst. Z.B. über den seriellen port, spi oder ebenso als I2C slave, wobei letzteres vllt nicht so sinnvoll ist.

@shiftleftplusone
Copy link
Author

ok, danke, aber das ist jetzt kein Due-Problem mehr.
Alle Due-Pullups komplett abschalten: das war halt das Ziel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants