Show Posts
Pages: 1 ... 4 5 [6] 7 8 ... 16
76  Products / Arduino Due / Re: arduino due rtc and unixtime ? on: March 01, 2013, 08:42:23 am
WOW!   smiley  What fast service!  Thank you!  I would definitely like to try it but i have to leave for work.  I will try it tonight when i get home.
No not for that, I needed an reason to get an hand on it thanks, it's my pleasure if someone used it, btw there is an new version online.
77  Products / Arduino Due / Re: arduino due rtc and unixtime ? Update to the Update on: February 28, 2013, 05:32:25 am
Did you have a link to the Adafruit library if I find some time I will convert it. It's my fault I hadn't any use for the unixtime so i don't implement it sorry...

So the use of the compiletime is implemented, sort of this to use it:
Code:
 rtc_clock.set_time(__TIME__);
  rtc_clock.set_date(__DATE__);
re-used the code from Lady Ada, unixtime will be the next.

So unixtime implemented like the Adafruit library solved the problem:
Code:
rtc_clock.unixtime()
gives you the time in unixtime style.

Sample and Updated code will follow...

And now completed.

Sample for this:
Code:
#include <rtc_clock.h>

// Select the Slowclock source
//RTC_clock rtc_clock(RC);
RTC_clock rtc_clock(XTAL);

char* daynames[]={"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"};

void setup() {
  Serial.begin(9600);
  rtc_clock.init();
  rtc_clock.set_time(__TIME__);
  rtc_clock.set_date(__DATE__);
}

void loop() {
  Serial.print("Unixtime: ");
  Serial.println(rtc_clock.unixtime());
  Serial.println("And in plain for everyone");
  Serial.print("Time: ");
  digitprint(rtc_clock.get_hours(), 2);
  Serial.print(":");
  digitprint(rtc_clock.get_minutes(), 2);
  Serial.print(":");
  digitprint(rtc_clock.get_seconds(), 2);
  Serial.println("");
  Serial.print("Date: ");
  Serial.print(daynames[rtc_clock.get_day_of_week()-1]);
  Serial.print(" ");
  digitprint(rtc_clock.get_days(), 2);
  Serial.print(".");
  digitprint(rtc_clock.get_months(), 2);
  Serial.print(".");
  Serial.println(rtc_clock.get_years());
  Serial.println("");
}

void digitprint(int value, int lenght){
  for (int i = 0; i < (lenght - numdigits(value)); i++){
    Serial.print("0");
  }
  Serial.print(value);
}

int numdigits(int i){
  int digits;
  if (i < 10)
    digits = 1;
  else
    digits = (int)(log10((double)i)) + 1;
  return digits;
}

New library is attached, tevroc would you like to test it.
78  Products / Arduino Due / Re: Due I2C not working on: February 27, 2013, 01:34:06 am
Actually, it's my code which was bad, I modified it and all worked fine for me smiley Sorry for disturbing.
It would be nice if you share your new code with us.
79  Products / Arduino Due / Re: Do not follow Simple Audio Player example - DAC0 now non-functional on DUE on: February 26, 2013, 02:37:33 pm
DAC0 is the one you learn on, DAC1 is the one you then take care of.

Duane B

destructive testing  smiley-confuse
80  Products / Arduino Due / Re: I/O loading on Due on: February 14, 2013, 04:35:31 am
does it only refer to TST, ERASE and JTAGSEL select pins ?
In reference to the Atmel paper I would say so only on this pins
81  Products / Arduino Due / Re: OneWire in Due on: February 13, 2013, 05:40:05 am
Interrupts are disabled for a very good reason.  There's absolutely no way OneWire will return to the buggy pre-2.0 days where interrupts could lengthen the timing and cause random communication errors.
Ok, I understand that (I do know what are interrupts for and why they are disabled in time critical sections). I do not understand why delayMicroseconds acts differently depending on interrupts being disabled or enabled. Declaration of delayMicrosections for SAM is quite simple (from wiring.c):
Code:
void delayMicroseconds( uint32_t us )
{
    uint32_t start = micros();
    while ((micros() - start) < us)
        ;
}
It did not change since 1.5.1r2.

Do you have an idea, what the solution could be?

Leo

PS if I can contribute in any way, let me know.

So the problem must be somewhere behind the micros the function delayMicroseconds is realy open so the problem musst be somewhere there

Code:
uint32_t micros( void )
{
uint32_t ticks ;
uint32_t count ;

SysTick->CTRL;
do {
  ticks = SysTick->VAL;
  count = GetTickCount();
} while (SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk);

return count * 1000 + (SysTick->LOAD + 1 - ticks) / (SystemCoreClock/1000000) ;
}

its in the wiring.c
82  Products / Arduino Due / Re: Building a CAN communication protocol interface for Arduino DUE on: February 02, 2013, 09:10:31 am
They explained to me that if we include any ASF based file in the project, there will be needed to add thousand others. I know you did a great job with your RTC Library but in the case of the CAN class, more references need to be considered.
Thanks for the laurels, but the RTC stuff isn't as half as big as the CAN stuff you did and btw. there was an "component_rtc.h" file that was waiting for me and begged me to make an userfriendly (under arduino law-standing) Library. For you there was nothing from arduino to work above it.
83  Products / Arduino Due / Re: Building a CAN communication protocol interface for Arduino DUE on: February 01, 2013, 02:18:11 am
Hola Lufe.

Your CAN experience will surely be very useful. As I mentioned in my first CAN post, my humble role is to channel the efforts to let the CAN API be completed. So far, I must say, it has been more a behind-the-forum work between Arduino, Atmel and me. Tests are in progress; the CAN library is working using the IDE directly (no makefile) and we are close.

From all of this, we have learned a big lesson: DO NOT (I repeat) DO NOT try to build something from Atmel Studio ASF and introduce it into Arduino. Both software architectures are entirely different and it shall be a pain to remove unneeded references. This experience is helping us to understand better how to create a Due library. The updated libsam will be solid ground for future developments for Due.  Saludos!
Some good news some bad news, good to hear but can you explain the part from "Not trying to port Atmel Studio ASF to Arduino Software architecture a little bit more for me for better understanding.
84  Products / Arduino Due / Re: Arduino due + SPI setClockDivider() function on: January 31, 2013, 04:25:03 am
Hello,

Firstly, I use an unofficial ethernet shield (with W5200 chip) with the new arduino due.

I modified the W5100 library for the W5200 chip and all the exemple sketches run very well.

Witch one?
85  Products / Arduino Due / Re: Pin protection on Arduino Due on: January 23, 2013, 08:44:43 am
Quote
How do you protect your pins ?
I don't connect them to anything silly.  smiley-wink

Yes like, thinking, planing, think again, (may correct it), wiring it, control it, powering it. But in hurry: wire it, power it (crossing fingers and hope the best), use it or get a new one...

True is the Due cost more than the other boards, the SAM3X is way more sensitive and it's nearly impossible for some beginner to change the ┬ÁC in an safe way. For the "NO RISK, NO FUN" section would be an UNO with DIP and an USBAsp the best option, on this combination there would not so much tears generate if something went horrible wrong. Change Burn and Ready.
86  Products / Arduino Due / Re: Arduino Due libraries (official and 3rd party) on: January 23, 2013, 04:15:04 am
First release of the RTC Library for the Arduino Due.

2 examples included.

I would call it final for the moment.

And on github: https://github.com/MarkusLange/Arduino-Due-RTC-Library

I hope the library is self explaining.

Markus

Update new library with unixtime and compilertime support

Update Version 1.2 now support for Date & Time in one operation for BKM.

And some changes all in the changelog

Update Version 1.3 now unixtime with timezone support with Example for it, for tevroc

Update Version 1.4 now support for geman timezone with Summertime.

Update Version 1.5 some changes in the Summertime Sketch, and updates at this point only on git

Update Version 1.6 added rtc_clock.timing to detect when the time was set in summer- or wintertime
(mostly helpfully for the german member)

Update Version 1.7 added rtc_clock.date_already_set() to proof if date is allready set, to prevent setting time again for Paul Stoffregen

Update Version 1.8 added rtc_clock.set_clock() to set __Time__,__Date__ in one line fixed bug in unixtime() and summertime() thanks to Paul Stoffregen for the hint
87  Products / Arduino Due / Re: New UTFT Libray with Arduino ARM spport on: January 22, 2013, 11:11:30 am
Would say the new one is faster.
88  Products / Arduino Due / Re: Disabling UART on Due? on: January 16, 2013, 05:31:26 am
I am working with K-line that is similar to yours. My code starts the bit-bang before activating the UART1.
I am using UART0 for debug. This is on a 1284 chip.

Code:
 digitalWrite (TX, HIGH); // makes K-line high 3
  digitalWrite(ledPin,HIGH);
  delay(2000);       // wait for K-line to be clear 3
  digitalWrite (TX, LOW); // makes K-line low  3
  delay(25);
  digitalWrite (TX, HIGH); // makes K-line high  3
  delay(25);        //last delay before first message
  Serial1.begin(10400);


 Also, I think there is a function called Serial.end() to stop serial comms.. I am not positive about it though.

Hi I used this code on the Leonardo for Lin,

Code:
int ledState = LOW;             // ledState used to set the LED
long previousMillis = 0;        // will store last time LED was updated

long interval = 250;

//Lin Initailisation
#define linspeed                19200
unsigned long Tbit = 1000000/linspeed;

#define uartlenght                 10

//Tbits Header
#define breakfield                 13
#define breakdelimiter              1
#define breakfieldinterbytespace    2

int frameerrordelay = ((breakfield + breakdelimiter) - uartlenght)*Tbit;
//int frameerrordelay = (breakfield + breakdelimiter + breakfieldinterbytespace) - uartlenght;

#define syncfield                  uartlenght
#define PIDfield                   uartlenght
#define syncfieldPIDinterbytedelay  0
int syncfieldPIDinterbytespace = syncfieldPIDinterbytedelay*Tbit;

//Tbit Response
#define responsedelay               8
int responsespace = responsedelay*Tbit;
#define interbytedelay              0
int interbytespace = interbytedelay*Tbit;

#define numbers  4
byte message[numbers],sending[numbers];
byte linb,sync,PID,checksum;
int n = 0;

void setup() {
  // initialize serial port and LIN:
  Serial.begin(19200);
  Lininit();
  pinMode(13, OUTPUT);
}

void loop() {
  blinking();
  LinReading();
//  LinWriting();
}

void LinReading() {
  LinRead();
  PrintlnLin();
  ClearFrame();
}

void LinWriting() {
  LinWrite(sending);
  Answer();
  delay(1000);
}

void Lininit() {
  Serial1.begin(linspeed);
  pinMode(0,INPUT_PULLUP);
}

void Answer() {
  for (int i=0;i<numbers;i++) {
     sending[i] = n;
  }
  n++;
  n = n % 256;
  Serial.println(n,HEX);
}

void LinRead() {
  if (1<<FE1) {
    delayMicroseconds(frameerrordelay);               //after Frame Error Tbit to Sync Field
    if (Serial1.available() > 0) {
      sync = Serial1.read();
      if (sync != 0x55) {
        sync = 0x00;
      }
      delayMicroseconds(syncfieldPIDinterbytespace);  //Interbyte Space
      if (Serial1.available() > 0) {
        PID = Serial1.read();
      }
      delayMicroseconds(responsespace);               //after PID Tbit space
      for (int i=0;i<numbers;i++) {
        message[i] = Serial1.read();
        if (interbytespace == 0) {                    //Interbyte Space
          delayMicroseconds(1);
        } else {
          delayMicroseconds(interbytespace);
        }
      }
      checksum = Serial1.read();
    }
  } else {
    Serial.println("NO Break");
  }
}

void LinResponse(byte* sending) {
  if (1<<FE1) {
    delayMicroseconds(frameerrordelay);                 //after Frame Error Tbit to Sync Field
    if (Serial1.available() > 0) {
      sync = Serial1.read();
      if (sync == 0x55) {
        delayMicroseconds(syncfieldPIDinterbytespace);  //Interbyte Space
        if (Serial1.available() > 0) {
          PID = Serial1.read();
          if (PID == 0x11) {
            delayMicroseconds(responsespace);           //after PID Tbit space
            for (int i=0;i<numbers;i++) {
              Serial1.write(sending[i]);
              if (interbytespace == 0) {
                delayMicroseconds(1);
              } else {
                delayMicroseconds(interbytespace);
              }
              Serial1.write(MessageCRC(message,0));
            }
          }
        }
      }
    }
  }
}

void LinWrite(byte* sending) {
  Serial1.end();
  pinMode(0,OUTPUT);
  digitalWrite(1, LOW);
  delayMicroseconds(breakfield*Tbit);                 //after Frame Error Tbit to Sync Field
  digitalWrite(1, HIGH);
  delayMicroseconds(breakdelimiter*Tbit);
  Serial1.begin(linspeed);
  Serial1.write(0x55);
  Serial1.write(0x03);
  delayMicroseconds(responsespace);
  for (int i=0;i<numbers;i++) {
    Serial1.write(sending[i]);
    if (interbytespace == 0) {
      delayMicroseconds(1);
    } else {
      delayMicroseconds(interbytespace);
    }
  }
  Serial1.write(MessageCRC(sending,0));
}
 
void PrintlnLin() {
  if(sync != 0) {
//    Serial.print("Break Field   Sync:  ");
//    Serial.print(sync,HEX);
    Serial.print("PID:  ");
    Serial.print(PID & 0x3F,HEX);            //PID without CRC
    Serial.print("   CRC:  ");
    Serial.print(PIDCRC(PID));
    Serial.print("  Message:  ");
    for (int i=0;i<numbers;i++) {
      Serial.print(message[i],HEX);
      Serial.print(";");
    }
    Serial.print("  Checksum:  ");
    Serial.print(checksum,HEX);
    Serial.print("  ChecksumCRC:  ");
    Serial.println(MessageCRC(message,0),HEX);
  }
}

void ClearFrame() {
  sync = 0;
  PID = 0;
  for (int i=0;i<numbers;i++) {
    message[i] = 0;
  }
  checksum = 0;
}

void blinking() {
  unsigned long currentMillis = millis();
  if(currentMillis - previousMillis > interval) {
    // save the last time you blinked the LED
    previousMillis = currentMillis;
    // if the LED is off turn it on and vice-versa:
    if (ledState == LOW)
      ledState = HIGH;
    else
      ledState = LOW;
    // set the LED with the ledState of the variable:
    digitalWrite(13, ledState);
  }
}

int PIDCRC(int PID) {
  int P0 = ((PID>>0) + (PID>>1) + (PID>>2) + (PID>>4)) & 1;
  int P1 = ~((PID>>1) + (PID>>3) + (PID>>4) + (PID>>5)) & 1;
  return (P0 | (P1<<1));
}

byte MessageCRC(byte* message, uint16_t sum) {
  for (int i=0;i<numbers;i++) {
    sum += message[i];
  }
  while(sum>>8)  // In case adding the carry causes another carry
    sum = (sum&255)+(sum>>8);
  return (~sum);
}

And for the Due I have Isolated and changed the Atmel Framework Examplecode. I will attach it but I have at the moment not the time for tests also I had also to comment out the USART1_Handler in the variant.cpp to let it complie proper.

B.R.
Markus
89  Products / Arduino Due / Re: unconnected SPI performance -- library vs DMA on: January 13, 2013, 11:39:50 am
I added performance results for the DUE's "extended" SPI mode.  For the unconnected tests, the extended mode is faster than the older SPI  API.  See  SPIperf.txt on the git site below

   https://github.com/manitou48/DUEZoo

Hi mantoui,

did you have an standalone version of the "extended" SPI-Lib as an replacement of the "regular" SPI-Lib as an 1 for 1 version to use all the benefits of the DMA support?

Would be very nice, thanks.

Markus
90  Products / Arduino Due / SSL/TLS on Arduino Due on: January 13, 2013, 08:38:56 am
Hello Guys,

I was thinking about SSL connections for the Due because there is more space and speed for that I have searched fot it but I found nothing only some parts about the CyaSSL and integration in LwIP for RTOS, and I have no idea how to integrate it, but this feature would be nice. Think the Due has the power for that.

And all the possibiltys, HTTPS, SSL/TLS for eMail connections and lots more...

Or PolarSSL looks comfortable for it https://github.com/polarssl/polarssl/blob/master/programs/ssl/ssl_mail_client.c
And I see Atmel puts allready some examples from it in the ASF but for the same uC that are worked in the Wifi-Shield.

Depends on this https://polarssl.org/discussions/platform-specific/atmel-microcontroller-wiznet-and-polarssl and this https://www.brainspark.nl/kb/how-to/polarssl-tutorial it should be possible to do this.

B.R.

Markus
Pages: 1 ... 4 5 [6] 7 8 ... 16