Show Posts
Pages: 1 2 [3] 4 5 ... 32
31  Products / Arduino Due / Re: i2c + DUE don't talk!! on: March 17, 2014, 09:06:15 am
psycho82,
I tested a MPU-6050 (borrowed) with Arduino DUE (TWI0) using one example of Jeff Rowberg library (MPU6050_DMP6) and it worked OK. I only had to comment the following line:
Quote
//TWBR = 24; // 400kHz I2C clock (200kHz if CPU is 8MHz)

Again, I can bear witness to the fact that the Wire library for DUE works OK with four different gyros. If you still having troubles, post your code, schematics, etc.
32  Products / Arduino Due / Re: i2c + DUE don't talk!! on: March 16, 2014, 10:01:44 pm
psycho82,
I think your GY-521 is the same MPU-6050. Am I right? Thus, you shouldn't have problems using GY-521 with 3.3V. It should be useful if you post the whole code you are using.

The whole Wire (I2C) code of DUE is clean and handles both Wire(I2C) peripherals inside SAM3X8E. I ran several tests the past weeks with three gyros (none of them MPU-6050) and all of them ran OK with both DUE's I2Cs. The team Atmel/Arduino did a good job.

A couple of things to be considered when using gyros with DUE:
1. Use pull-up resistors only for the TWI1 (SCL1/SDA1). And like Chris said, you don't need pull-up resistors with TWI0 (20-21).
2. Maximium I/O voltage is 3.3v

One of my gyros tests: Parallax Gyroscope Module 3-Axis L3G4200D.

PIN CONNECTION:
DUE--------- GYRO
3.3V----------VIN
GND-----------GND
SDA(20)-------SDA
SCL(21)-------SCL

Here the code I used for the L3G4200D.

Code:
#include <Wire.h>

#define CTRL_REG1 0x20
#define CTRL_REG2 0x21
#define CTRL_REG3 0x22
#define CTRL_REG4 0x23

int Addr = 105;                 // I2C address of gyro 0x69
int x, y, z;

void setup(){
  Wire.begin();
  Serial.begin(9600);
  writeI2C(CTRL_REG1, 0x1F);    // Turn on all axes, disable power down
  writeI2C(CTRL_REG3, 0x08);    // Enable control ready signal
  writeI2C(CTRL_REG4, 0x80);    // Set scale (500 deg/sec)
  delay(100);                   // Wait to synchronize
}

void loop(){
  getGyroValues();              // Get new values
  // In following Dividing by 114 reduces noise
  Serial.print("Raw X:");  Serial.print(x / 114); 
  Serial.print(" Raw Y:"); Serial.print(y / 114);
  Serial.print(" Raw Z:"); Serial.println(z / 114);
  delay(500);                   // Short delay between reads
}

void getGyroValues () {
  byte MSB, LSB;

  MSB = readI2C(0x29);
  LSB = readI2C(0x28);
  x = ((MSB << 8) | LSB);

  MSB = readI2C(0x2B);
  LSB = readI2C(0x2A);
  y = ((MSB << 8) | LSB);

  MSB = readI2C(0x2D);
  LSB = readI2C(0x2C);
  z = ((MSB << 8) | LSB);
}

int readI2C (byte regAddr) {
    Wire.beginTransmission(Addr);
    Wire.write(regAddr);                // Register address to read
    Wire.endTransmission();             // Terminate request
    Wire.requestFrom(Addr, 1);          // Read a byte
    while(!Wire.available()) { };       // Wait for receipt
    return(Wire.read());                // Get result
}

void writeI2C (byte regAddr, byte val) {
    Wire.beginTransmission(Addr);
    Wire.write(regAddr);
    Wire.write(val);
    Wire.endTransmission();
}
teI2C (byte regAddr, byte val) {
    Wire.beginTransmission(Addr);
    Wire.write(regAddr);
    Wire.write(val);
    Wire.endTransmission();
}

Regards,
Palliser
33  Products / Arduino Due / Re: Arduino Due and Arduino GSM - Any Experiences? on: March 16, 2014, 06:53:08 pm
The heart of the GSM shield-the M10 module-can work at 3.4V thus, more than a matter of voltage tolerance, the bottleneck of porting the GSM library from AVR to SAM is the fact that it was built as a 'state machine' which is a peculiar case given that most of the microcontroller libraries are built with the traditional scheme of a main class as parent of different small classes. This means a great time spend (months not weeks).
34  Products / Arduino GSM Shield / Transparent bridge between Arduino terminal and the M10 on: March 15, 2014, 10:20:48 am
I don't know if the following have been discussed/noted here but I considered useful to share it.

For small applications that only require a few AT commands, I use a simple sketch that allows me to access the M10 using AT commands. In other words, the sketch will provide a transparent bridge between the Arduino terminal (with Newline) and M10. It means that you will be able to type AT commands on the terminal and the modem will reply accordingly.

Here the sketch:

Code:
#include <SoftwareSerial.h>
 
SoftwareSerial GPRS(2, 3);
unsigned char buffer[64];
int count=0;

void setup()
{
  GPRS.begin(9600);
  Serial.begin(9600);
 
}
 
void loop()
{
  if (GPRS.available())
  {
    while(GPRS.available())
    {
      buffer[count++]=GPRS.read();
      if(count == 64)break;
  }
    Serial.write(buffer,count);
    clearBufferArray();
    count = 0;
  }
  if (Serial.available())
    GPRS.write(Serial.read());
}
void clearBufferArray()
{
  for (int i=0; i<count;i++)
    { buffer[i]=NULL;}         
}

Regars, Palliser
35  Products / Arduino Due / Re: Building a CAN API for Arduino DUE on: March 14, 2014, 08:51:32 pm
Hello Mike,

It might be considered a note on page 4 of the TI ISO1050 specs doc:
http://www.ti.com/lit/ds/symlink/iso1050.pdf

Quote
"TXD is very weakly internally pulled up to VCC1. An external pull up resistor should be used to make sure that TXD is biased to recessive (high) level to avoid issues on the bus if the microprocessor doesn't control the pin and TXD floats. TXD pullup strength and CAN bit timing require special consideration when the device is used with an open-drain TXD output on the microprocessor's CAN controller. An adequate external pullup resistor must be used to ensure that the TXD output of the microprocessor maintains adequate bit timing input to the input on the transceiver".
36  Products / Arduino Due / Re: Building a CAN API for Arduino DUE on: March 12, 2014, 07:12:01 pm
Hello Mike,
Have you tried the two can modules (CAN0/CAN1) in the same DUE as initially intended in the examples? I tested the EchoTest, ExtendedPingPong and TrafficSnooper and they worked OK on the same original DUE (also with Taijiuino). I haven't tried with two DUEs but Collin's examples should work. It is just about to be careful with the interconnection of the modules. I.e. CAN0 on Due1 with CAN1 on Due2 or CAN1 on Due1 with CAN0 on Due2...or depending on your code, therefore, it would be good if you post your code if differs from the original Collin's examples.

Regards, Palliser     
37  Products / Arduino Due / Re: WORKING WITH GY-87.... EVERYTHING OK BUT HMC5883L NOT WORKING AT ALL on: March 04, 2014, 09:29:18 pm
Hello pistolero992000,
Have you used Nick Gammon's I2C scanner to confirm that DUE recognize the address of the magnetometer?
here the code just in case:

Code:
// --------------------------------------
// i2c_scanner
//
// Version 1
//    This program (or code that looks like it)
//    can be found in many places.
//    For example on the Arduino.cc forum.
//    The original author is not know.
// Version 2, Juni 2012, Using Arduino 1.0.1
//     Adapted to be as simple as possible by Arduino.cc user Krodal
// Version 3, Feb 26  2013
//    V3 by louarnold
// Version 4, March 3, 2013, Using Arduino 1.0.3
//    by Arduino.cc user Krodal.
//    Changes by louarnold removed.
//    Scanning addresses changed from 0...127 to 1...119,
//    according to the i2c scanner by Nick Gammon
//    http://www.gammon.com.au/forum/?id=10896
// Version 5, March 28, 2013
//    As version 4, but address scans now to 127.
//    A sensor seems to use address 120.
//
//
// This sketch tests the standard 7-bit addresses
// Devices with higher bit address might not be seen properly.
//

#include <Wire.h>


void setup()
{
  Wire.begin();

  Serial.begin(9600);
  Serial.println("\nI2C Scanner");
}


void loop()
{
  byte error, address;
  int nDevices;

  Serial.println("Scanning...");

  nDevices = 0;
  for(address = 1; address < 127; address++ )
  {
    // The i2c_scanner uses the return value of
    // the Write.endTransmisstion to see if
    // a device did acknowledge to the address.
    Wire.beginTransmission(address);
    error = Wire.endTransmission();

    if (error == 0)
    {
      Serial.print("I2C device found at address 0x");
      if (address<16)
        Serial.print("0");
      Serial.print(address,HEX);
      Serial.println("  !");

      nDevices++;
    }
    else if (error==4)
    {
      Serial.print("Unknow error at address 0x");
      if (address<16)
        Serial.print("0");
      Serial.println(address,HEX);
    }   
  }
  if (nDevices == 0)
    Serial.println("No I2C devices found\n");
  else
    Serial.println("done\n");

  delay(5000);           // wait 5 seconds for next scan
}

I have used a different I2C magnetometer ADXL345 but at the moment I don't have the code at hand. 

Regards, Palliser 
38  Products / Arduino Due / Re: Trouble interfacing servo to Arduino Due on: March 04, 2014, 10:58:23 am
I'd recommend you to start powering the servo alone (no load) with 3.3V (low torque) from DUE.
Then, run the following 'test code' to determine the behavior of the servo. Take note of the values when the servo slow down, stop, CW , CCW, etc. Then, you can map your output according to your needs.

Code:
#include <Servo.h>
Servo myservo;
int potpin = 0;
int val;

void setup()
{
 Serial.begin(9600);
 myservo.attach(9);
}

void loop()
{
  val = analogRead(potpin);
  val = map(val, 0, 1023, 700, 2300);
  myservo.writeMicroseconds(val);
  delay(15);
  Serial.println(val);
  delay(500);
}

Good luck!
39  Products / Arduino Due / Re: Trouble interfacing servo to Arduino Due on: March 04, 2014, 09:39:59 am
Hello AB08,

Could you tell us which servo you are using? How are you connecting the servo with Due? Are you using a servo shield?
DUE is tolerant to 3.3V. Most of the servos work with higher voltages (4.8-6). It is very important to consider voltage and current operation of your servo before connect it to DUE to avoid damage it. Also read the manufacturer's specs.
Some servos needs specific outputs to drive their clockwise, counter clockwise and stop functions.

regards
40  Products / Arduino Due / Re: Building a CAN API for Arduino DUE on: March 03, 2014, 10:38:31 pm
One crucial question for me: is there any quick way of determining if the frame in a mailbox has already been read? CAN.mailbox_read(0, &canframe) doesn't seem to clear the mailbox.

Hello MarkOne,

The mailbox_get_status function checks the status of the mailbox and it can be used in conjunction with a mailbox status register (CAN_MSR_MRDY) to determine whether a mailbox has received a data frame. For example, the mailbox 4 of the CAN controller 2 receives data when the following condition is TRUE:

Quote
CAN2.mailbox_get_status(4) & CAN_MSR_MRDY

I borrowed the above condition from the CANX_Handler of the original Atmel ASF CAN library.

Also, the function mailbox_int_handler will handle a mailbox interrupt but, I've not try that yet.

Regards, Palliser
41  Products / Arduino Due / Re: is it possible to get a keyboard input and pass it to a PC running win 7 or 8 on: March 01, 2014, 08:05:22 am
Hola hola123,

Arduino DUE has USB host behavior (native USB port). The IDE has a library and example to read a USB keyboard.
I am not sure if the library handle the functions you need but it could help you to start.
File->Example->USBHost->KeyboradController.

You also shall need a OTG cable to connect the keyboard with the DUE. You can also share what exactly you are pursuing
or an example of your application.

Regards,
Palliser
42  Topics / Science and Measurement / Measuring time lapses on: February 27, 2014, 11:49:47 pm
The following code allows for the measurement of the time interval in milliseconds between two button pressing (without debouncing).

Code:
const int buttonPin = 2;
unsigned long buttonTimer, timeInterval;
boolean counting = false;

void setup ()
  {
    Serial.begin(9600);
  }

void loop ()
  {
    if (digitalRead (buttonPin) == HIGH && counting ==  false)
    {
     Serial.println("Start lapse...");
     buttonTimer = millis ();
     counting = true;
     delay(200);
    }
   
    if (digitalRead (buttonPin) == HIGH && counting ==  true)
    {
      timeInterval = millis () - buttonTimer;
      Serial.print("Stop. Time elapsed: ");
      Serial.print(timeInterval);
      Serial.println(" msec");
      counting = false;
      delay(200);
    }
}

I used the same circuit from the Arduino debounce tutorial
http://arduino.cc/en/Tutorial/Debounce#.UxAUDvldWSo

Regards, Palliser
43  Products / Arduino Due / Re: Arduino Due and 1602 LCD keypad shield modification on: February 21, 2014, 04:24:29 pm
i was thinking of using this part

https://www.sparkfun.com/products/9052

-phil


Hi Phil,
I think that should be a right choice (3.3V and HD44780). I must say that so far I have not used DUE with an LCD.
May be someone here in the forum could tell us about it.
-P
 
44  Products / Arduino Due / Re: Arduino Due and 1602 LCD keypad shield modification on: February 21, 2014, 02:32:11 pm
Do you think I can take the Sain smart board and pull the TC1602 and replaced it with a HD44780 from sparkfun electronics?

I don't see how you can do that. AFAIK, most of the 1602s are glued (epoxied) directly onto the board and for sure both prints (TC1602 and HD44780) will not match. I'd rather recommend you to get a new 3.3v LCD board.
Palliser
 
45  Products / Arduino Due / Re: Arduino Due Dac configuration on: February 21, 2014, 12:59:38 pm
As a reference, here a BareMinimum sketch that generates a decent 1.4kHz sinewave (120 samples) using DUE's DAC1.

Code:
int i = 0;
void setup() {
  analogWriteResolution(12);
}

static int sine[] = {
    0x7ff, 0x86a, 0x8d5, 0x93f, 0x9a9, 0xa11, 0xa78, 0xadd, 0xb40, 0xba1,
    0xbff, 0xc5a, 0xcb2, 0xd08, 0xd59, 0xda7, 0xdf1, 0xe36, 0xe77, 0xeb4,
    0xeec, 0xf1f, 0xf4d, 0xf77, 0xf9a, 0xfb9, 0xfd2, 0xfe5, 0xff3, 0xffc,
    0xfff, 0xffc, 0xff3, 0xfe5, 0xfd2, 0xfb9, 0xf9a, 0xf77, 0xf4d, 0xf1f,
    0xeec, 0xeb4, 0xe77, 0xe36, 0xdf1, 0xda7, 0xd59, 0xd08, 0xcb2, 0xc5a,
    0xbff, 0xba1, 0xb40, 0xadd, 0xa78, 0xa11, 0x9a9, 0x93f, 0x8d5, 0x86a,
    0x7ff, 0x794, 0x729, 0x6bf, 0x655, 0x5ed, 0x586, 0x521, 0x4be, 0x45d,
    0x3ff, 0x3a4, 0x34c, 0x2f6, 0x2a5, 0x257, 0x20d, 0x1c8, 0x187, 0x14a,
    0x112, 0xdf, 0xb1, 0x87, 0x64, 0x45, 0x2c, 0x19, 0xb, 0x2,
    0x0, 0x2, 0xb, 0x19, 0x2c, 0x45, 0x64, 0x87, 0xb1, 0xdf,
    0x112, 0x14a, 0x187, 0x1c8, 0x20d, 0x257, 0x2a5, 0x2f6, 0x34c, 0x3a4,
    0x3ff, 0x45d, 0x4be, 0x521, 0x586, 0x5ed, 0x655, 0x6bf, 0x729, 0x794
};

void loop() {
  analogWrite(DAC1, sine[i]);
  i++;
  if(i == 120)
    i = 0;
}

Regards, palliser
Pages: 1 2 [3] 4 5 ... 32