Show Posts
Pages: [1] 2
1  Using Arduino / Installation & Troubleshooting / Re: Arduino at 11.0592MHz. Modify Timer0, delay() ... functions on: January 01, 2014, 09:01:27 am
A short comment to the baud rate. Some UART devices needs 115200baud. This is not really nice at 16MHz because the error rate is too high. So I am using 11.0592MHz. Here a graphic from the ATmega328 datasheet:


I found a nice post about the topic of the millis function and the prescale. Still I don't know how to fix the issue for the 11.0592MHz. But this post is nice.
http://ucexperiment.wordpress.com/2012/03/16/examination-of-the-arduino-millis-function/

From the delaymicroseconds function you see, that a Arduino with a FCPU of 11.0592MHz uses the 8MHz delays. So 27.6% to fast.
2  Using Arduino / Installation & Troubleshooting / Re: Arduino at 11.0592MHz. Modify Timer0, delay() ... functions on: January 01, 2014, 08:22:48 am
Hi

To change the FCPU is the first step. After this you can use your Arduino sketch. But you have to hack some more code.

1. For example the SoftwareSerial library has to be modified because is is written for 8MHz, 16Mhz and 20MHz. Here I have a post about it: http://forum.arduino.cc/index.php?topic=201806.0

2. The timing functions are wrong as weel (about 27.6%) because they are also only written for 8MHz, 16Mhz and 20MHz. The file which is needed here is the following file: hardware/arduino/cores/arduino/wiring.c

This is a potencial intersting line:
Code:
#define MICROSECONDS_PER_TIMER0_OVERFLOW (clockCyclesToMicroseconds(64 * 256))

Then later in the delaymicrosecond() the bit shifts for the "us" variable.
Code:
/* Delay for the given number of microseconds.  Assumes a 8 or 16 MHz clock. */
void delayMicroseconds(unsigned int us)
{
// calling avrlib's delay_us() function with low values (e.g. 1 or
// 2 microseconds) gives delays longer than desired.
//delay_us(us);
#if F_CPU >= 20000000L
// for the 20 MHz clock on rare Arduino boards

// for a one-microsecond delay, simply wait 2 cycle and return. The overhead
// of the function call yields a delay of exactly a one microsecond.
__asm__ __volatile__ (
"nop" "\n\t"
"nop"); //just waiting 2 cycle
if (--us == 0)
return;

// the following loop takes a 1/5 of a microsecond (4 cycles)
// per iteration, so execute it five times for each microsecond of
// delay requested.
us = (us<<2) + us; // x5 us

// account for the time taken in the preceeding commands.
us -= 2;

#elif F_CPU >= 16000000L
// for the 16 MHz clock on most Arduino boards

// for a one-microsecond delay, simply return.  the overhead
// of the function call yields a delay of approximately 1 1/8 us.
if (--us == 0)
return;

// the following loop takes a quarter of a microsecond (4 cycles)
// per iteration, so execute it four times for each microsecond of
// delay requested.
us <<= 2;

// account for the time taken in the preceeding commands.
us -= 2;
#else
// for the 8 MHz internal clock on the ATmega168

// for a one- or two-microsecond delay, simply return.  the overhead of
// the function calls takes more than two microseconds.  can't just
// subtract two, since us is unsigned; we'd overflow.
if (--us == 0)
return;
if (--us == 0)
return;

// the following loop takes half of a microsecond (4 cycles)
// per iteration, so execute it twice for each microsecond of
// delay requested.
us <<= 1;
   
// partially compensate for the time taken by the preceeding commands.
// we can't subtract any more than this or we'd overflow w/ small delays.
us--;
#endif

// busy wait
__asm__ __volatile__ (
"1: sbiw %0,1" "\n\t" // 2 cycles
"brne 1b" : "=w" (us) : "0" (us) // 2 cycles
);
}
Furthermore in wiring_pulse.c the following line:
Code:
return clockCyclesToMicroseconds(width * 21 + 16);

Cheers
3  Using Arduino / Installation & Troubleshooting / Arduino at 11.0592MHz. Modify Timer0, delay() ... functions on: January 01, 2014, 07:34:33 am
Hello

I am using the Arduino Uno at 11.0592MHz. I recognized that the delayMicroseconds() function is about 27% to fast. The reason is, that the code in wiring.c assumes that the clock peed is now 8MHz.

Now I try to fix it. I found different posts but I am not sure what is the most Arduino compatible way. What can you recommend?

1. Multiply the variable "us" in wiring.c with 1.27 if the F_CPU is 11.0592MHz? Easy but only affects delayMicroseconds and not millis(), micros(), delay(), etc.
2. Change the prescale factor maybe from 64 to ???

Other ideas or guides?

Thank you in advance.
Felix
4  Topics / Device Hacking / Re: Arduino at 11.0592Mhz; Modify SoftwareSerial on: December 04, 2013, 08:22:33 pm
I found a formula which seems a little bit better (rxcenter + 2). At 57600 baud without errors.

Code:
rxcenter = rxstop/2 – 5;
rxintra = rxstop;
rxstop = 11059200/(6 * baudrate)-2 ;
tx = rxstop –3;
adjust = 5

Testscript
Code:
baudrate 115200: (rx=2, rxc=14, rxi=14, tx11 (ad: 5))
->000111000111 000111000111<- 000111000111 000q1â0À0bq1
->000111000111 000111000111<- 000111000111 000b01`0pqbb
->000111000111 000111000111<- 000111000111 0001p1`00ñ1Ä
->000111000111 000111000111<- 000111000111 000b010ppbb1
->000111000111 000111000111<- 000111000111 0001p1`00á1Ä
->000111000111 000111000111<- 000111000111 00`0b10à0bq1
->000111000111 000111000111<- 000111000111 0001qq0`0Â1b
->000111000111 000111000111<- 000111000111 000q1â0`p1Ã1
->000111000111 000111000111<- 000110000111 000q1â0`p1Â1
->000111000111 000111000111<- 000111000111 000q1â0`p1Â1
->000111000111 000111000111<- 000111000111 000q0b8p`bb1


baudrate 57600: (rxc=6, rxin=22, rxs=22, tx=19 (ad: 5))
->000111000111 000111000111<- 000111000111 000111000111
->000111000111 000111000111<- 000111000111 000111000111
->000111000111 000111000111<- 000111000111 000111000111
->000111000111 000111000111<- 000111000111 000111000111
->000111000111 000111000111<- 000111000111 000111000111
->000111000111 000111000111<- 000111000111 000111000111
->000111000111 000111000111<- 000111000111 000111000111

This are the magic numbers:
Code:
// 11.0592MHz support
#elif F_CPU == 11059200

static const DELAY_TABLE PROGMEM table[] =
{
  //  baud    rxcenter   rxintra    rxstop        tx
  { 115200,          2,       14,       14,       11, },
  {  57600,         10,       30,       30,       27, },
  {  38400,         18,       46,       46,       43, },
  {  31250,         24,       57,       57,       54, },
  {  28800,         26,       62,       62,       59, },
  {  19200,         42,       94,       94,       91, },
  {  14400,         58,      126,      126,      123, },
  {   9600,         90,      190,      190,      187, },
  {   4800,        186,      382,      382,      379, },
  {   2400,        378,      766,      766,      763, },
  {   1200,        762,     1534,     1534,     1531, },
  {    600,       1530,     3070,     3070,     3067, },
  {    300,       3066,     6142,     6142,     6139, },
};

const int XMIT_START_ADJUSTMENT = 5;

One thing I does not understand. Now my Serial send-> receive script works really nice. But when I make a simple mySerial.println("TEST") in the terminal with one single Arduino, I only receive garbage.
So the first magic numbers from my second post, seems to be the best solution for the general case.

Cheers
5  Topics / Device Hacking / Re: Arduino at 11.0592Mhz; Modify SoftwareSerial on: December 04, 2013, 07:47:45 pm
Hi

I was still not able to find out the problem. Finally I wrote a simple sender and receiver script on my own. The sender sends every second this line over Software Serial to the receiver.
 000111000111 000111000111
The receiver responds to the sender who is printing the output into the terminal

At the beginning I received a lot of wrong ECHOS. Then I started to write the two scripts very symmetrically (same number of serial.print commands) and connected both boards with ground. Then I realized, that my magic numbers must be wrong. I had a really high error rate. Then I started with your formulas. I tried a lot and not I ended with this:

Code:
rxcenter = rxstop/2 – 5;
rxintra = rxstop;
rxstop = 11059200/(6 * baudrate)-2 ;
tx = rxstop – 7;
adjust = 5

Here are two examples of 115200baud and 57600baud. I have still errors but small ones.
Code:
baudrate 115200:
->000111000111 000111000111<- 000111000111 000b1ñ00`b1b

->000111000111 000111000111<- 000111000111 0001ba0``1bb
->000111000111 000111000111<- 000111000111 000b1á00À11Ä
->000111000111 000111000111<- 00011Θ00111 0001ba00À11Ä
->000111000111 000111000111<- 000111000111 0001ba0``1bb
->000111000111 000111000111<- 000111000111 000b1á00À11Ä
->000111000111 000111000111<- 000111000111 000b1á00À11Ä
->000111000111 000111000111<- 000111000111 0001ba00À11Ä

baudrate 57600:
->000111000111 000111000111<- 000111000111 0001110001q1
->000111000111 000111000111<- 000111000111 0001110001q1
->000111000111 000111000111<- 000111000111 0001110001q1
->000111000111 000111000111<- 000111000111 0001110001q1
->000111000111 000111000111<- 000111000111 000111000111
->000111000111 000111000111<- 000111000111 0001110001q1


Do you have a hint how I could improve the results (formula improvement)?

Felix
6  Topics / Device Hacking / Re: Arduino at 11.0592Mhz; Modify SoftwareSerial on: December 03, 2013, 05:17:35 pm
Hi

My crystalls arrived and I tried to make the "performance" test. But I have some trouble.
I tried your code hint from this post http://forum.arduino.cc/index.php?topic=138497.0 (master, slave example).

Only to be sure.
The two Arduinos communicate through SoftwareSerial:
pin 2 slave = pin 3 master
pin 3 master = pin 2 slave

The debug report will printed on HardwareSerial of the master. Am I right? This has not worked in my case; I have not received anything.

But in general the SoftwareSerial output works at 11.0592MHz.

Felix
 
7  Topics / Device Hacking / Re: Arduino at 11.0592Mhz; Modify SoftwareSerial on: December 01, 2013, 01:51:50 pm
Yes, but I haven't tested into detail. I tried a short "HELLO WORLD" program  and it worked. I borrowed my board to a colleague so I can not do more tests right now. But I already ordered some more crystals and I will do some tests when they arrived and then I will report them here.

Can you recommend some testing scenario?
e.g. print hundreds of identical characters and look for errors?
8  Topics / Device Hacking / Re: Arduino at 11.0592Mhz; Modify SoftwareSerial on: November 29, 2013, 01:43:03 pm
Perfect!

With the posted script I received the following correction:
Code:
// 11.0592MHz support
#elif F_CPU == 11059200

static const DELAY_TABLE PROGMEM table[] =
{
  //  baud    rxcenter   rxintra    rxstop        tx
  { 115200,          1,       10,       10,        6, },
  {  57600,          4,       23,       23,       21, },
  {  38400,         11,       37,       38,       35, },
  {  31250,         16,       47,       47,       44, },
  {  28800,         20,       51,       51,       48, },
  {  19200,         33,       79,       79,       76, },
  {  14400,         47,      106,      106,      103, },
  {   9600,         74,      161,      161,      158, },
  {   4800,        157,      325,      325,      322, },
  {   2400,        322,      655,      655,      652, },
  {   1200,        651,     1313,     1313,     1310, },
  {    600,       1313,     2625,     2625,     2620, },
  {    300,       2625,     5263,     5263,     5260, },
};

const int XMIT_START_ADJUSTMENT = 4;

On Ubuntu 12.04 the following Ubuntu package had to be installed:
Code:
sudo apt-get install libtie-ixhash-perl

Cheers
9  Topics / Device Hacking / Arduino at 11.0592Mhz; Modify SoftwareSerial on: November 29, 2013, 10:08:46 am
Hello

I modified my Arduino Uno with a crystal at 11.0592MHz. This nice values will improve UART communication. I also modified boards.txt with this line:
uno11.build.f_cpu=11059200L

But now I realized that the SoftwareSerial is not working at this frequency. The delay table for this frequency is missing. Does somebody know how the delay table can be calculated?

I found a nice Perl script to calculate the table based on the values of 8Mhz and 16MHz, but the Perl script is not working on my computer (Perl V. 5.14.2). Does somebody knows a solution? Here is the script:
http://wiblocks.luciani.org/docs/app-notes/software-serial.html

Thank you for any hints!
Felix
10  Development / Other Software Development / SIM900: Command to identify if call is received (gsm shield arduino library) on: July 31, 2013, 10:25:44 am
Hello

I am using the SIM900 GSM module and want to identify if a call was received (established and accepted by the person who I called).

In the Open Electronics Library (https://code.google.com/p/gsm-shield-arduino/) is only a function implemented, to determine if the call was established (ringing). The function call is:
call.CallStatus() == CALL_ACTIVE_VOICE

The AT command is:
AT+CPAS
Return command: 4
This means: Call in progress (MT is ready for commands from TA/TE, but a call is in progress)


But I can not find any AT commands to check, if the call was accepted by the person who I called. Can anybody help?
I looked in "SIM900_AT Command Manual_ V1.03".

Thank you in advance.
Felix




 
11  Using Arduino / Installation & Troubleshooting / Re: SIM900: GSM-Module is no longer working. How to reset? on: July 30, 2013, 09:43:20 pm
I checked it and you gave me the solution. The things I had to do:

- disconnect the Arduino from the SIM900 RX/TX pins
- connect a Serial Adapter directly to the SIM900 RX and TX pins (pin 9 serial RX, pin 10 serial TX)
- by default (in my case) choose terminal baud rate to 28800 baud + break line command (CR)
- PULL DTR PIN TO HIGH!

To check if the serial communication is working start with command:
AT
the answer should be:
OK

Now I only had to type:
AT+CSCLK=0
OK
AT&W
OK

Ready.
Thank you for that great hint with DTR.
12  Using Arduino / Installation & Troubleshooting / Re: SIM900: GSM-Module is no longer working. How to reset? on: July 30, 2013, 06:07:47 am
This is a great idea. I will directly check it. With this hint I found the following information in the datasheet (file attached). This may also explain why I receive the information "ERROR: SIM900 doesn't answer. Check power and serial pins in GSM.cpp" from the SIM900 Library.

13  Using Arduino / Installation & Troubleshooting / SIM900: GSM-Module is no longer working. How to reset? on: July 27, 2013, 08:27:16 am
Hello

I am using a SIM900 GSM shield in combination with an Arduino Uno and the open electronics library (https://code.google.com/p/gsm-shield-arduino/).

Yesterday I send one new AT command in the GSM_GPSLibrary_AT example to the module. It was "AT+CSCLK=1" to disable slow clock which will cause, that the module will not go in the sleep mode.

But since then, my GSM library can not start the module. I tried a lot.  Now I connect my computer direct the the UART port of the SIM900 and I log the commands. I send the following to reset the module:
Code:
    gsm.SimpleWriteln(F("AT+CSCLK=0"));    //DISABLE SLOW CLOCK
    delay(2000);
    gsm.SimpleWriteln(F("ATZ"));                //RESET DEFAULT CONFIGURATION
    delay(2000);
    gsm.SimpleWriteln(F("AT&F"));              //FACTORY DEFINED CONFIGURATION
    delay(2000);
    gsm.SimpleWriteln(F("AT+CFUN=1"));     //FULL PHONE FUNCTIONALIY

But it is no solution. The module will no communicate with the Arduino any longer. If I power up the SIM900 through the power on impuls, it will start and show this:
Quote
AT
AT
AT
AT
AT
AT&F
ATE0
AT+CLIP=1
AT+CMEE=0
AT+CMEE=0
AT+CMEE=0
AT+CMEE=0
AT+CMEE=0
AT+CMGF=1
AT+CMGF=1
AT+CMGF=1
AT+CMGF=1
AT+CMGF=1
AT+CNMI=2,0
AT+CNMI=2,0
AT+CPMS="SM","SM","SM"
AT+CPMS="SM","SM","SM"
AT+CPMS="SM","SM","SM"
AT+CPMS="SM","SM","SM"
AT+CPMS="SM","SM","SM"
AT+CPMS="SM","SM","SM"
AT+CPMS="SM","SM","SM"
AT+CPMS="SM","SM","SM"
AT+CPMS="SM","SM","SM"
AT+CPMS="SM","SM","SM"
AT+CPBS="SM"
AT+CPBS="SM"
AT+CPBS="SM"
AT+CPBS="SM"
AT+CPBS="SM"
AT+CIPSHUT
AT+CIPSHUT
AT+CIPSHUT
AT+CIPSHUT
AT+CIPSHUT
ATE0
AT+CSCLK=0
AT+CSCLK=0
ATZ
AT&F
AT+CFUN=1


Is it destroyed? Or is it a bug of the firmware? I posted it as a bug in the Github->Issues of the library. Thank you for all hints:
https://code.google.com/p/gsm-shield-arduino/issues/detail?id=86



Felix
14  Using Arduino / Programming Questions / Ethernet Shield as DHCP server for UDP communication on: July 11, 2013, 12:28:49 pm
Hello

I am looking for some code to make the ethernet shield (W5100) a DHCP server. My aim is to connect a UDP device directly to the ethernet shield which gives the UDP device a IP.

I found the DHCPLite (https://github.com/pkulchenko/DHCPLite) but it will no work in my Arduino 1.0 environment.

Has anybody an idea, where I can find something to make the ethernet shield a DHCP server.

Thank you in advance.
Felix
15  Using Arduino / Project Guidance / Re: ATMega328P (Arduino Uno): Which pins can be used for software UART + pin mapping on: June 04, 2013, 09:24:07 am
Shorty the answer by myself.

Yes it is possible to use all Arduino PINs as a software UART.

And yes, ADC6 (hardware PIN 19) and ADC7 (hardware PIN 22) can not be used as digital input or output.
Pages: [1] 2