Show Posts
Pages: 1 2 3 [4] 5 6 ... 37
46  Products / Arduino Due / Re: Any experiences with Due and Sparkfun 9DOF sensor stick? on: May 08, 2014, 03:45:47 pm
I have read a couple of posts and it looks like given the MCU library was built for AVR 8-bit and that Due is an ARM 32-bit, the difference between architectures could oblige the programmer (us) to consider to implement a solution (changes in the library) to make Due to correctly interpret the MCU data. I mean, a common 16 bit-based system instead of misreadings of standard 32-bit integers that will result in the 16 bit signed data coming out all positive and over 65000 for negatives. Thus, here could be the mystery. Let's grasp a bit about it.

p
47  Products / Arduino Due / Re: Any experiences with Due and Sparkfun 9DOF sensor stick? on: May 08, 2014, 12:02:47 am
Let's put aside for a moment the wiring subject. I want you to try another code (it seems to be the same I gave you). I think we miss nothing if you make a try running it. Here the sketch:
Code:
#include <Wire.h>
#define DEVICE (0x53)    //ADXL345 device address
#define TO_READ (6)        //num of bytes we are going to read each time (two bytes for each axis)

byte buff[TO_READ] ;    //6 bytes buffer for saving data read from the device
char str[512];                      //string buffer to transform data before sending it to the serial port

void setup()
{
  Wire.begin();        // join i2c bus (address optional for master)
  Serial.begin(9600);  // start serial for output
 
  //Turning on the ADXL345
  writeTo(DEVICE, 0x2D, 0);     
  writeTo(DEVICE, 0x2D, 16);
  writeTo(DEVICE, 0x2D, 8);
}

void loop()
{
  int regAddress = 0x32;    //first axis-acceleration-data register on the ADXL345
  int x, y, z;
 
  readFrom(DEVICE, regAddress, TO_READ, buff); //read the acceleration data from the ADXL345
 
   //each axis reading comes in 10 bit resolution, ie 2 bytes.  Least Significat Byte first!!
   //thus we are converting both bytes in to one int
  x = (((int)buff[1]) << 8) | buff[0];   
  y = (((int)buff[3])<< 8) | buff[2];
  z = (((int)buff[5]) << 8) | buff[4];
 
  //we send the x y z values as a string to the serial port
  sprintf(str, "%d %d %d", x, y, z); 
  Serial.print(str);
  Serial.write(10);
 
  //It appears that delay is needed in order not to clog the port
  delay(15);
}

void writeTo(int device, byte address, byte val) {
   Wire.beginTransmission(device); //start transmission to device
   Wire.write(address);        // send register address
   Wire.write(val);        // send value to write
   Wire.endTransmission(); //end transmission
}

void readFrom(int device, byte address, int num, byte buff[]) {
  Wire.beginTransmission(device); //start transmission to device
  Wire.write(address);        //sends address to read from
  Wire.endTransmission(); //end transmission
 
  Wire.beginTransmission(device); //start transmission to device (initiate again)
  Wire.requestFrom(device, num);    // request 6 bytes from device
 
  int i = 0;
  while(Wire.available())    //device may send less than requested (abnormal)
  {
    buff[i] = Wire.read(); // receive a byte
    i++;
  }
  Wire.endTransmission(); //end transmission
}

p
48  Products / Arduino Due / Re: Any experiences with Due and Sparkfun 9DOF sensor stick? on: May 07, 2014, 09:32:42 pm
I have several MCUs but all of them are SPI. Anyway, to determine what is going on with your Due-9DOF Stick, I'd recommend you to start trying to communicate with one of the sensors, let's say the accelerometer, and then with the other two. I assume that you know how accelerometers work. Just in case remember, under steady-state, all the values (x,y,z) should be zero. When the stick is in motion, the values change.

Here a sketch that I have built just for the accelerometer after the chionophilous' tutorial that you have followed. It should work (theoretically). I assume, also, that you have connected 3.3V, GND, SDA and SCL between the stick and due.

Code:
#include <Wire.h>
#define ADXL345_ADDRESS (0xA6 >> 1)
#define ADXL345_REGISTER_XLSB (0x32)
#define ADXL_REGISTER_PWRCTL (0x2D)
#define ADXL_PWRCTL_MEASURE (1 << 3)
int accelerometer_data[3];

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

  for(int i = 0; i < 3; ++i) {
    accelerometer_data[i] = 0;
  }
  init_adxl345();
}

void loop() {
   read_adxl345();
   Serial.print("ACCEL: ");
   Serial.print(accelerometer_data[0]);
   Serial.print("\t");
   Serial.print(accelerometer_data[1]);
   Serial.print("\t");
   Serial.print(accelerometer_data[2]);
   Serial.print("\n");
   delay(100);
}
 
void init_adxl345() {
  byte data = 0;
  i2c_write(ADXL345_ADDRESS, ADXL_REGISTER_PWRCTL, ADXL_PWRCTL_MEASURE);
  i2c_read(ADXL345_ADDRESS, ADXL_REGISTER_PWRCTL, 1, &data);
  Serial.println((unsigned int)data);
}


void read_adxl345() {
  byte bytes[6];
  memset(bytes,0,6);
  i2c_read(ADXL345_ADDRESS, ADXL345_REGISTER_XLSB, 6, bytes);
  for (int i=0;i<3;++i) {
  accelerometer_data[i] = (int)bytes[2*i] + (((int)bytes[2*i + 1]) << 8);
  }
}

void i2c_write(int address, byte reg, byte data) {
  Wire.beginTransmission(address);
  Wire.write(reg);
  Wire.write(data);
  Wire.endTransmission();
}

void i2c_read(int address, byte reg, int count, byte* data) {
 int i = 0;
 Wire.beginTransmission(address);
 Wire.write(reg);
 Wire.endTransmission();
 Wire.beginTransmission(address);
 Wire.requestFrom(address,count);
 while(Wire.available()) {
   char c = Wire.read();
   data[i] = c;
   i++;
 }
 Wire.endTransmission();
}

Let me know how it goes.

p

EDIT: Try to make shorter the wires between Due and the stick.


49  Products / Arduino Due / Re: Small-footprint Due on: May 07, 2014, 08:04:59 am

Yes, I have these exact pins broken out. I looked at the BOM for Micrel-based shield and I think we could offer a ETH MicroShield at $15-20 pricing point

Man, that would be a good deal considering that some Micrel distributors sell the KSZ8051MNL small eval board for more than US$100.

p
50  Products / Arduino Due / Re: Problem when Due receives datas from serial port on: May 06, 2014, 07:16:53 pm
Code:
String inputString = "";         // a string to hold incoming data
boolean stringComplete = false;  // whether the string is complete

void setup() {
  // initialize serial:
  Serial.begin(9600);
  Serial1.begin(9600);
  // reserve 200 bytes for the inputString:
  inputString.reserve(200);
}

void loop() {
  // print the string when a newline arrives:
Serial1.print("REQUESTDATA\r");
delay(1000);
  if (stringComplete) {
    Serial.print(inputString);
    // clear the string:
    inputString = "";
    stringComplete = false;
  }
}

Is that snippet code? The example sketch from File->Examples->04.Communication->serialEvent comes with the serialEvent function in it. I don't see it in yours.

p
51  Products / Arduino Due / Re: Small-footprint Due on: May 06, 2014, 01:44:58 pm
P - if you come up with schematics to connect to my RMII pinout, I promise I will make the shield ;-)

No problem Val. I kept running DM9161 and KSZ8051MNL PHY chips with DUE some months ago without problems but the sketches and libraries still raw. I needed ten pins from the DUE but I believe MMI pins (MDC/MDIO) are not necessary (I need to verify that). Anyway, please, confirm to me the broken out EMAC pins of your DUE-based board as follows:

 PIN NAME                              DUE PIN
-EREFCK: Reference clock pin-----------113 ETX_CLK
-ECRSDV: Carrier Sense/Data Valid------119 ERX_DV
-ERX0: bit Receive Data----------------120 ERXD0
-ERX1: bit Receive Data----------------121 ERXD1
-ERXER: Receive Error------------------122 ERX_ER
-ETXEN: Transmit Enable----------------114 ETX_EN
-ETX0: bit Transmit Data---------------115 ETXD0
-ETX1: bit Transmit Data---------------118 ETXD1

Thanks,
p
52  Products / Arduino Due / Re: Small-footprint Due on: May 05, 2014, 07:31:23 pm
P - I have read your thread on ETH in its entirety a few days ago. You are doing truly amazing work for the community (ETH, CAN, etc...).

Sadly I can't figure out sourcing for DM9161 chip...

Val- In case that you decide to add the EMAC peripheral to one of your boards, I'd rather recommend to use one Micrel PHY like KSZ8051MNL given Micrel's better hardware integration and available documentation.

http://www.micrel.com/_PDF/Ethernet/datasheets/ksz8051mnl-rnl.pdf

p
53  Products / Arduino Due / Re: Small-footprint Due on: May 05, 2014, 08:29:31 am

1. is CAN termination resistor (120R) needed on this board? If it's connected to fully configured CAN bus, one would have to desolder 0402 part from the board...

2. As you saw in the video (https://www.youtube.com/watch?v=kPL8APZyh4A), the idea is to have a separate landing board in the UNO format. That board would provide micro-USB connection, ability to power from 7-12V source, etc. The question is what else we should provide on that board. For now, we have added a second CAN tranceiver - after all, most of our own uses will be automotive-related. What else?

3. If you were really paying attention to the video, you could spot a few MicroShields on the PCB array. At the moment, we have a WiFi MicroShield and a LCD MicroShield. What else could be interesting?


Hi Val.

My answers:
1. Yes. A termination resistor 120R is necessary. Normally, a select jumper is used in series with it to select it or not.

2 & 3. Think about adding an Ethernet PHY as a separate module (similar to the one from elechouse) or soldered in your UNO landing board.

http://www.elechouse.com/elechouse/index.php?main_page=product_info&products_id=2229

See also replies 66 and 92 for schematic and example.

http://forum.arduino.cc/index.php?topic=142908.0

I am also adding an 2.8 LCD TFT to Due but need ebi.

Regards!

p
54  Products / Arduino Due / Re: Small-footprint Due on: May 04, 2014, 12:33:54 am
 smiley-eek-blue Wow. Awesome video! One small foot-step for eMotorWerknstein, one giant leap for the Arduino Due based-kind!

p
55  Using Arduino / Programming Questions / Re: Arducam-F REV.C and Arduino Uno R3 - Empty Image in SD card on: May 02, 2014, 05:44:10 pm
Hello Alban01,
Is your ArduCam working via SPI? regards!

p
56  Products / Arduino Due / Re: Arduino Due not in sync on: May 01, 2014, 07:40:56 pm
Hello gidmark,
I am sorry your first encounter with DUE was not the best (as it should be).

Every time I see the word AVR instead of ARM in the Arduino Due's world it means to me that in some way I am trying to mix (or mess) both architectures. It can be a software issue (like trying to access AVR libraries) or a hardware issue (like trying to config an AVR board (UNO, LEO, MEGA, etc). See if you are using the correct board: Tools->Board->Arduino Due (programming or native). May be you are trying to run a sketch that use a similar AVR library. If that is the case, clean for a moment your: ...\Documents\Arduino\libraries. Regards!

p
57  Products / Arduino Due / Re: direct manipulation port for DUE on: April 30, 2014, 11:11:53 pm
Hi Mikistromar,
So your code works fine with Arduino Mini but it doesn't work with Arduino Due. Hmm, as I use to say: Arduino Due is a different monster. Let's talk about the hardware:
Before you try to make the code run (even when it runs OK with your Mini), you should make sure you hardware, in this case, your I/O devices are the right ones for Due.
Question: -Are your stepper motor and encoder designed to operate at 3.3V?
 Remember that Due operates at 3.3V and the Mini at 5V. If your answer is yes, so far so good but if you answer is no, you have two options:
1. Replace them for 3.3 similar ones.
2. Use voltage converter means between them and Due.

Some encoders are pure mechanical but others have chips that depend on the input voltage (3.3V, 5V). Similarly, some step motors operate at 3.3V or 5V. I recommend you to use only 3.3V I/O devices, basically, to protect Due.

Let's talk about software.
Your code is relatively simple but it is not quite clear to me what you want to do with it. It looks like you want to control the step motor with the encoder using interruptions. Am I right? If so, why to migrate from Mini to Due? better time response I guess?
Regarding interrupts, one good news about Due is that you can attach an interrupt function on all its pins.
Continuing with your code, only for debugging purposes, you should use the serial function to determine if your code is running or not.

Anyway, I'd recommend you to start testing your I/O devices and Due using simple example sketches separately. For example, try the example 1 of the Arduino playground (rotary encoder) and see if the encoder counts OK or not. Then you can move to another example with interrupts, etc...and please, keep us posted about your progress. regards!

p
58  Products / Arduino Due / Re: MISO, MOSI and SCK pins on Arduino Due on: April 30, 2014, 12:31:45 pm
You better look at here:
http://forum.arduino.cc/index.php?topic=132130.0

p
59  Products / Arduino Due / Re: direct manipulation port for DUE on: April 30, 2014, 09:30:04 am
Yep. You can also look at the pin definitions in the variant.cpp file:
Quote
....\arduino-1.5.6-r2\hardware\arduino\sam\variants\arduino_due_x\

Lines 153 (pin 17) and 160 (pin 20). Also, to manipulate your pin, you should consider some definitions. For example:

-If pin will be used as pure output, use PIO_OUTPUT_O instead of PIO_DEFAULT.
-If pin will be used as pure input, use PIO_INPUT instead of PIO_DEFAULT.
-If pin needs internal pull-up, use PIO_PULLUP instead of PIO_DEFAULT, etc..

and depending of the nature of your application, you will need to choose the right peripheral (function). For example,
by default, pin A5 works as:
- Analog input if configured with peripheral X1 (extra function).
- Timer clock if configured with peripheral A.
- Input external wait signal with peripheral B.

CAVEAT: I use to catalog the info above as part of Due's 'deep waters', so be very careful if you decide to use it and mess with it.

p
60  Products / Arduino Due / Re: direct manipulation port for DUE on: April 28, 2014, 01:55:38 pm
You can look for PORT PIN (pale yellow) of Graynomad's Arduino Due pinout diagram as a reference.
http://forum.arduino.cc/index.php?topic=132130.0

Pages: 1 2 3 [4] 5 6 ... 37