Show Posts
Pages: [1] 2
1  Products / Arduino Due / Re: Adafruit SSD1306 128x32 OLED, I2C pull up resistors? on: March 07, 2014, 01:09:22 pm
Chris,

thank you for posting the schematics of the "SSD1306 Monochrome 128x32 I2C OLED graphic display break out board", that clarifies my question very accurately.

I have to download the Eagle program to be able to look at schematics and board layout files. The schematics you posted are available at the Adafruit web site (as I found out just now), but one needs the Eagle program to display it.

Thanks to your answers I am now understanding the I2C pull up resistor issue. I already found steel tweezers with the correct gripper size to remove the offending 1 K pull up resistors from the Arduino Due board. I plan to heat the tweezers with the soldering iron (holding the tweezers with gloves to protect my fingers). Need to do some trials before manhandling the Arduino Due board.

It is not easy to find a practical little LCD or OLED display for the Arduino Due, they are often sold out.

I also found this I2C LCD display http://at.farnell.com/midas/mccog21605b6w-fptlwi/lcd-cog-16x2-i2c-fstn-schw-weiss/dp/2218942?Ntt=2218942
which is not expensive and does not seem to difficult to drive. It allows to define 10 custom icons, which could be used to display "bars".

Well, display and keyboard are still the most expensive part of any microprocessor project.

Greetings, Conrad
2  Products / Arduino Due / Adafruit SSD1306 128x32 OLED, I2C pull up resistors? on: March 07, 2014, 06:29:03 am
I want to use this monochrome 128x32 I2C OLED graphic display from Adafruit: http://www.adafruit.com/products/931

It can be connected to the Arduino Due via standard I2C (pins 20 and 21) and the Adafruit library https://github.com/adafruit/Adafruit_SSD1306 seems to support the Arduino Due.


Question 1:

The Arduino Due standard I2C on pins 20 and 21 has the well known 1 K pull up resistor problem. Would this OLED display work with the 1 K pull ups on pins 20 and 21?

Or do I have to remove the 1 K pull up resistors from the Arduino Due board? If I remove the 1 K pull ups, what pull up values does this OLED display need on SDA and SCL?

I checked the Adafruit documentation of this OLED display and it does not say anything about pull up resistors for SDA and SCL.


Question 2:

Has anybody successfully used this OLED display with an Arduino Due?

Greetings, Conrad
3  Products / Arduino Due / Re: I2C (Wire) pull up resistors, Arduino Due, 20 (SDA0-3), 21 (SCL0-3) on: March 06, 2014, 02:41:32 pm
Hello Chris,

thank you again, you are solving my problems in real-time.

I like the idea to use hot tweezers for removal of the pull up resistors from the Arduino Due board. Have to build up courage to do it.

What I am aiming for is to connect this 3-axis compass via I2C to the Arduino Due:

http://at.mouser.com/ProductDetail/Olimex-Ltd/MOD-HMC5883L/?qs=%2fha2pyFadugIcApImewx497gG5mUfdX%2ftp9xN8EFA%252bOhLLPFn4VYKg%3d%3d

It is in the mail and will arrive soon. I just wanted to clear the I2C issues with the 12-Bit DAC (which I had available).

Greetings, Conrad
4  Products / Arduino Due / Re: I2C (Wire) pull up resistors, Arduino Due, 20 (SDA0-3), 21 (SCL0-3) on: March 06, 2014, 01:23:46 pm
Hello Chris,

thank you for your reply.

I could connect a MCP4725 Breakout Board (12-Bit DAC) with an I2C Interface ( http://www.adafruit.com/products/935 ) via SCL1 and SDA1 (Wire1.xxx) to an  Arduino Due.

If some one is interested I will post the code once I have a more intelligent sketch (e.g. dimming and increasing the light output of a red LED)  than the stupid first version which just tested the I2C connection to the 12-Bit DAC (reading it and setting a few DAC values).

The "MCP4725 Breakout Board" has 10 K pull up resistors for SCL and SDA which made it necessary to use the SCL1 nad SDA1 on the Arduino Due (because SCL1 and SDA1 have no pull up resistors on the Arduino Due board).

It is a shame that the standard I2C interface ( SCL = pin 21  and SDA = pin 20) has 1 K pull up resistors on the Arduino Due board, which makes it pretty much useless for most I2C ICs (because they can not pull down 3.3 mA).

My question: Where are these 1 K pull up resistors (RN5D and RN5C) on the Arduino Due board? I might try to remove them.

Greetings, Conrad
5  Products / Arduino Due / I2C (Wire) pull up resistors, Arduino Due, 20 (SDA0-3), 21 (SCL0-3) on: March 05, 2014, 02:59:05 am
The I2C bus needs pull up resistors.

I looked at the Arduino Due schematics and saw that there are pull up resistors RN5A (1K5) and RN5B (1K5) for the I2C pins 20 (SDA0-3), 21 (SCL0-3).

pin 20 (SDA0-3) = TWD1
pin 21 (SCL0-3) = TXCK1

My first question:

Is it true that I do not need additional pull up resistors if I connect an I2C slave to pins 20 (SDA0-3), 21 (SCL0-3) of the Arduino Due? (On the Arduino Due schematics it is noted as "I2C Voltage Translator".)

My second question:

If I use the Wire-Library the I2C communication is via pins 20 and 21 ?

My third question:

How do I do (which library) I2C communication via pins 9 (SDA1 = TWD0)  and 10  (SCL1 = TWCK0) ? There are no pull up resistors for pin 9 and 10?

Greetings, Conrad
6  Products / Arduino Due / Re: Hardware Servo: Example Code on: January 31, 2013, 06:57:43 pm
In attachment a zip with a copy of the files. Unzip it into hardware/arduino/sam/libraries.


Thank you, I did that, and the example Sweep compiled.

How about using pins 26, 28 and 30 for a Servo?

Does it have to be pin 9?

Greetings, Conrad

P.S.: I tried with pins 26, 28 and 30. There seems to be something going on, because I see the LEDs connected (via a 1 K resistor to GND) to these pins dimming and getting brighter as the Servo example Sweep should do. Seems I am set up, thank you C.

P.S.: Servo works on pin 30. So, download the library (ZIP-File) from cmaglie's post above this post, and you are set to use Servos with the Arduino Due.
7  Products / Arduino Due / Re: Hardware Servo: Example Code on: January 31, 2013, 06:04:32 pm

I've pushed a first porting of the Servo library (the one distributed with Arduino IDE) for the Due, you can find it on the latest revision of the ide-1.5.x branch.

https://github.com/arduino/Arduino/commit/db81f52c3a27784fb44ca1ad6c77f9b1f0a4ef7d

I did some rapid tests, and it seems to work.


I can see the code at https://github.com/arduino/Arduino/commit/db81f52c3a27784fb44ca1ad6c77f9b1f0a4ef7d

but I do not know how to get these files and how to put them in my Arduino Due IDE?

Please have mercy with a beginner!

Can I drive a servo with pins 26, 28 and 30 ?

Greetings, Conrad
8  Products / Arduino Due / Re: Native USB port, keyboard, how to toggle VBOF (5V native USB) at PB10 UOTGVBOF on: December 05, 2012, 01:35:08 pm
The proper thing to do is to write code which detects and resets the fault condition but I don't have the right sort of USB cable so can't help.

@stimmer: thank you for the reply.

By "fault condition" you probably mean "there is no 5V at the native USB port". How can this be sensed? Or, at which pin does one have to look in order to find out?

May be by "fault condition" you mean that the device at the native USB port and the power supply are providing 5V to the native USB port. Again, how and where could this be sensed?

Or, by "fault condition" you mean, that the 5V from the native USB are shorted at the other end (where the USB cable leads to, e.g. a faulty keyboard or mouse). Once more, how could this be detected by a program?

Greetings, Conrad
9  Products / Arduino Due / Re: Native USB port, keyboard, how to toggle VBOF (5V native USB) at PB10 UOTGVBOF on: December 05, 2012, 10:34:14 am
The same problem occurs of course with a mouse on the native USB port (USBHost).

And the same code cures the problem.

Put the following code in the setup() function:

void setup(){
 
  // --------------------------------------------------------------------------------------
  // This will set 5V to the native USB port even if an external power supply is connected.

  PIOB->PIO_PER |= 1<<10;      // Never do this once Serial.begin() is called,
  PIOB->PIO_OER |= 1<<10;      // it will disconnect the programming USB port from the PC.
  PIOB->PIO_SODR |= 1<<10;     // UOTGVBOF HIGH

  // --------------------------------------------------------------------------------------
 
  Serial.begin(9600);
}

I use this mouse: http://www.conrad.at/ce/de/product/916448

The mouse should be a straight forward Microsoft compatible USB mouse with three buttons, or two buttons and a wheel which can act as a button. The wheel function can not be used with the USBHost library.

The mouse I got has a LED (near the wheel) which will indicate whether there is 5V at the USB or not.

I hope that this problem (5V at the native USB port while on an external power supply) will be solved in the USBHost and Serial Class. Who will do that? Whom shall I contact?

Greetings, Conrad

This code works:

Code:
/*
 Mouse Controller Example

 Shows the output of a USB Mouse connected to
 the Native USB port on an Arduino Due Board.
 */

// Require mouse control library
#include <address.h>
#include <adk.h>
#include <confdescparser.h>
#include <hid.h>
#include <hidboot.h>
#include <hidusagestr.h>
#include <KeyboardController.h>
#include <MouseController.h>
#include <parsetools.h>
#include <Usb.h>
#include <usb_ch9.h>

USBHost usb;                  // Initialize USB Controller
MouseController mouse(usb);   // Attach mouse controller to USB

boolean leftButton = false;   // variables for mouse button states
boolean middleButton = false;
boolean rightButton = false;

char inByte = 0;              // incoming character from PC

void setup()
{
  // --------------------------------------------------------------------------------------
  // This will set 5V to the native USB port even if an external power supply is connected.

  PIOB->PIO_PER |= 1<<10;      // Never do this once Serial.begin() is called,
  PIOB->PIO_OER |= 1<<10;      // it will disconnect the programming USB port from the PC.
  PIOB->PIO_SODR |= 1<<10;     // UOTGVBOF HIGH

  // --------------------------------------------------------------------------------------
 
  Serial.begin(9600);
}

void loop()
{
 
  if (Serial.available() > 0) {
     inByte = Serial.read();
     Serial.print("from PC : ");
     Serial.println(inByte);

     if (inByte == 'h') {
           
       PIOB->PIO_PER |= 1<<27;
       PIOB->PIO_OER |= 1<<27;
       PIOB->PIO_SODR |= 1<<27; // LED HIGH, direct access to Pin 27 at I/O PortB
       
       Serial.println("from PC LED ON");
       }

     if (inByte == 'l') {
       
       PIOB->PIO_PER |= 1<<27;
       PIOB->PIO_OER |= 1<<27;     
       PIOB->PIO_CODR |= 1<<27; // LED LOW, direct access to Pin 27 at I/O PortB
             
       Serial.println("from PC LED OUT");     
       }

     }
       
  usb.Task();   // Process USB tasks
}

// This function intercepts mouse movements
void mouseMoved() {
  Serial.print("Move: ");
  Serial.print(mouse.getXChange());
  Serial.print(", ");
  Serial.println(mouse.getYChange());
}

// This function intercepts mouse movements while a button is pressed
void mouseDragged() {
  Serial.print("DRAG: ");
  Serial.print(mouse.getXChange());
  Serial.print(", ");
  Serial.println(mouse.getYChange());
}

// This function intercepts mouse button press
void mousePressed() {
  Serial.print("Pressed: ");
  if (mouse.getButton(LEFT_BUTTON)){
    Serial.print("L");
    leftButton = true;
  }
  if (mouse.getButton(MIDDLE_BUTTON)){
    Serial.print("M");
    middleButton = true;
  }
  if (mouse.getButton(RIGHT_BUTTON)){
    Serial.print("R");
    Serial.println();
    rightButton = true;
  }
}

// This function intercepts mouse button release
void mouseReleased() {
  Serial.print("Released: ");
  if (!mouse.getButton(LEFT_BUTTON) && leftButton==true) {
    Serial.print("L");
    leftButton = false;
  }
  if (!mouse.getButton(MIDDLE_BUTTON) && middleButton==true) {
    Serial.print("M");
    middleButton = false;
  }
  if (!mouse.getButton(RIGHT_BUTTON) && rightButton==true) {
    Serial.print("R");
    rightButton = false;
  }
  Serial.println();
}
10  Products / Arduino Due / Re: Native USB port, keyboard, how to toggle VBOF (5V native USB) at PB10 UOTGVBOF on: December 04, 2012, 02:47:46 pm
I found a solution! May be there are better solutions, but the Arduino Due super programmers seem to be absent from this forum, so we will never know.

Put the following code in the setup() function:

void setup(){
 
  // --------------------------------------------------------------------------------------
  // This will set 5V to the native USB port even if an external power supply is connected.

  PIOB->PIO_PER |= 1<<10;      // Never do this once Serial.begin() is called,
  PIOB->PIO_OER |= 1<<10;      // it will disconnect the programming USB port from the PC.
  PIOB->PIO_SODR |= 1<<10;     // UOTGVBOF HIGH

  // --------------------------------------------------------------------------------------
 
  Serial.begin(9600);
}

The solution code conflicts with the Serial() methods, but if one does it before calling a Serial() method, it will work.

Here a short sketch which shows (in the Serial Monitor) the keys pressed on the keyboard connected to the native USB port.

And the Arduino Due LED can be switched on/off by pressing h or l on the keyboard attached to the native USB port or by pressing h or l on the PC keyboard in case the Serial Monitor is running.

The LED is also switched by directly accessing the registers in the SAM3X8E ARM Cortex-M3 CPU.

Code:
/*
 Keyboard Controller

 Shows the output of a USB Keyboard connected to the
 native USB controller of an Arduino Due Board.
 */
 
#include <address.h>
#include <adk.h>
#include <confdescparser.h>
#include <hid.h>
#include <hidboot.h>
#include <hidusagestr.h>
#include <KeyboardController.h>
#include <MouseController.h>
#include <parsetools.h>
#include <Usb.h>
#include <usb_ch9.h>

char inByte = 0; // incoming character from PC
char Key = 0;    // incoming character from keyboard
int rawKey = 0;  // incomming key as integer from keyboard

USBHost usb;     // USB Controller

KeyboardController keyboard(usb);  // Attach Keyboard controller to USB


void setup(){
 
  // --------------------------------------------------------------------------------------
  // This will set 5V to the native USB port even if an external power supply is connected.

  PIOB->PIO_PER |= 1<<10;      // Never do this once Serial.begin() is called,
  PIOB->PIO_OER |= 1<<10;      // it will disconnect the programming USB port from the PC.
  PIOB->PIO_SODR |= 1<<10;     // UOTGVBOF HIGH

  // --------------------------------------------------------------------------------------
 
  Serial.begin(9600);
}


void loop(){
 
  if (Serial.available() > 0) {
     inByte = Serial.read();
     Serial.print("from PC : ");
     Serial.println(inByte);

     if (inByte == 'h') {
           
       PIOB->PIO_PER |= 1<<27;
       PIOB->PIO_OER |= 1<<27;
       PIOB->PIO_SODR |= 1<<27; // LED HIGH, direct access to Pin 27 at I/O PortB
       
       Serial.println("from PC LED ON");
       }

     if (inByte == 'l') {
       
       PIOB->PIO_PER |= 1<<27;
       PIOB->PIO_OER |= 1<<27;     
       PIOB->PIO_CODR |= 1<<27; // LED LOW, direct access to Pin 27 at I/O PortB
             
       Serial.println("from PC LED OUT");     
       }

     }
     
   usb.Task();
}


void keyPressed() {

  Serial.print("Raw Key: ");
  rawKey = keyboard.getKey();
  Serial.print(rawKey);
  Serial.print(" - Character: ");
  Key = rawKey;
  Serial.print(Key);
  Serial.print(" - OEM: ");
  Serial.print(keyboard.getOemKey());
  Serial.print(" - mod: ");
  Serial.print(keyboard.getModifiers());
  Serial.println();
 
  if (Key == 'h') {
           
    PIOB->PIO_PER |= 1<<27;
    PIOB->PIO_OER |= 1<<27;
    PIOB->PIO_SODR |= 1<<27; // LED HIGH, direct access to Pin 27 at I/O PortB
       
    Serial.println("from KB LED ON");
    }
       
  if (Key == 'l') {
       
    PIOB->PIO_PER |= 1<<27;
    PIOB->PIO_OER |= 1<<27;     
    PIOB->PIO_CODR |= 1<<27; // LED LOW, direct access to Pin 27 at I/O PortB
             
    Serial.println("from KB LED OUT");     
    }
}


In the directory (on Winows PCs)  C:\arduino-1.5.1r2\hardware\arduino\sam\system\CMSIS\Device\ATMEL\sam3xa\html one finds many very useful register references and explications.

Greetings, Conrad
11  Products / Arduino Due / Re: Native USB port, keyboard, how to toggle VBOF (5V native USB) at PB10 UOTGVBOF on: December 03, 2012, 01:30:34 pm
Try this
Code:
UOTGHS->UOTGHS_CTRL = ~UOTGHS_CTRL_VBUSPO;

@Markus: I tried this code and it does not work. While on an external power supply the keyboard does still not get +5V from the native USB port.

There are two possibilities, either the code is wrong or the +5V can not be switched to the native USB port while on an external power supply.

Code:
UOTGHS->UOTGHS_CTRL = UOTGHS_CTRL_VBUSPO;  while on USB power from PC, switches off 5V at native USB

UOTGHS->UOTGHS_CTRL = ~UOTGHS_CTRL_VBUSPO;  while on USB power from PC, does not bring back 5V at native USB

//while on an external power supply there never is 5V at native USB, and the above code does nothing
 

I guess the code is wrong, because looking at the schematics of the Arduino Due board, it should be possible to switch on the 5V at the native USB with UOTGHS_CTRL_VBUSPO while on an external power supply. And it should be possible to turn on and off the 5V at the native USB programmatically again and again independently of power from the PC (via the programming USB port) or from an external power supply.

I hope that some person versed in the art of Arduino Due programming can answer this question, but so far no luck.

The question can be rephrased:

Please state some code that safely toggles  UOTGHS_CTRL_VBUSPO (PB10 UOTGVBOF) ?

Greetings, Conrad
12  Products / Arduino Due / Re: Native USB port, keyboard, how to toggle VBOF (5V native USB) at PB10 UOTGVBOF on: December 03, 2012, 10:13:28 am
@Markus:

Wow, your code

UOTGHS->UOTGHS_CTRL = UOTGHS_CTRL_VBUSPO;

turns off the+5V at the native USB port (while the Arduino Due is getting power from the programming USB port). We are on the right track.

Now, please tell me how to toggle the UOTGVBOF the other way.

Thank you, Conrad

13  Products / Arduino Due / Re: Native USB port, keyboard, how to toggle VBOF (5V native USB) at PB10 UOTGVBOF on: December 03, 2012, 09:32:33 am
May it helps take a look at Page 1108 from the full SAM3xa Manuel

Thank you Markus, this is exactly the right place to look.

My problem: I am such a beginner, that I can not write code to toggle UOTGVBOF. It dose not work with digitalWrite().

From page 1108 of the full SAM3xa user manual:

• VBUSPO: VBus Polarity Off
0: The UOTGVBOF output signal is in its default mode (active high).
1: The UOTGVBOF output signal is inverted (active low).

Greetings, Conrad
14  Products / Arduino Due / Native USB port, keyboard, how to toggle VBOF (5V native USB) at PB10 UOTGVBOF on: December 03, 2012, 07:50:00 am
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
A solution has been found, see my last post in this topic! Reply #7
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

I connected a keyboard to the native USB port of the Arduino Due. It only works with the power coming from the PC over the programming USB port.

The moment I use an external power supply (plugged into the Arduino Due power plug), the keyboard does not work any more (because the 5V at the native USB port are switched off).

Is it possible to turn the 5V for the native USB port on by pulling PB10 UOTGVBOF high or low?

Could someone show me some code which toggles UOTGVBOF at PB10.

Attached is an example code, but the keyboard is off (the 5V at the native USB port are off) the moment I connect an external power supply.

I want to use a keyboard or a mouse to control something on the various digital and analogue ports of the Arduino Due while it is on its own power supply (e.g. a 12 V battery and not connected to a PC via its programming port).

I attached the relevant part of the Arduino Due schematics, where the 5V to the native USB are switched off when connected to an external power supply (VIN).

Greetings, Conrad

Quote
/*
 Keyboard Controller

 Shows the output of a USB Keyboard connected to the
 native USB controller of an Arduino Due Board.
 */
 
#include <address.h>
#include <adk.h>
#include <confdescparser.h>
#include <hid.h>
#include <hidboot.h>
#include <hidusagestr.h>
#include <KeyboardController.h>
#include <MouseController.h>
#include <parsetools.h>
#include <Usb.h>
#include <usb_ch9.h>

char inByte = 0; // incoming character from PC
char Key = 0;    // incoming character from keyboard
int rawKey = 0;  // incomming key as integer from keyboard
int led = 13;    // yellow LED on Arduino Due Board

USBHost usb;     // USB Controller
KeyboardController keyboard(usb);  // Attach Keyboard controller to USB

void setup(){
  
  pinMode(led, OUTPUT);    
  digitalWrite(led, LOW);  // turn LED off

  Serial.begin(9600);

  establishContact();      // establish contact with PC until a byte is received from PC
}

void loop(){
  
  if (Serial.available() > 0) {
    inByte = Serial.read();
    Serial.print("from PC : ");
    Serial.println(inByte);

   if (inByte == 'w') {
     // ?????????????????????????
     // set VBOF at PB10 UOTGVBOF ????
     // turn +5V at native USB off/on ?????
     // PIOB->PIO_SODR=PIO_PB10A_UOTGVBOF;  //sets UOTGVBOF ???
     PIOB->PIO_CODR=PIO_PB10A_UOTGVBOF;     //clears UOTGVBOF ???
     // ???????????????????????????????????????

     Serial.println("UOTGVBOF LOW");
   }
    digitalWrite(led, LOW);  // turn LED off
  }
  usb.Task();
}

void keyPressed() {
  Serial.print("Raw Key: ");
  rawKey = keyboard.getKey();
  Serial.print(rawKey);
  Serial.print(" - Character: ");
  Key = rawKey;
  Serial.print(Key);
  Serial.print(" - OEM: ");
  Serial.print(keyboard.getOemKey());
  Serial.print(" - mod: ");
  Serial.print(keyboard.getModifiers());
  Serial.println();

  digitalWrite(led, HIGH);   // turn LED on

}

void establishContact() {
  while (Serial.available() <= 0) {
    Serial.println("Send a character!");   // send an initial string to PC
    delay(1000);
  }
}

15  Products / Arduino Due / Re: Where can one find the source code e.g. pins_arduino.h on: December 03, 2012, 07:36:53 am
Thank you to the two kind souls who pointed me to the right folders. I now use the  Windows 7 search function, which allows to find "words" in files. In this way I can look up the important declarations and definitions.

Greetings, Conrad
Pages: [1] 2