Show Posts
Pages: 1 ... 15 16 [17] 18
241  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: Xmega on: December 23, 2009, 08:22:15 am
Quote
The Arduino Source for Mac is already an XCode project, and compiled pretty cleanly last time I tried...
Could you give precise link & instructions on how I dowload teh ful XCode project from arduino web server ?

Right now, I've developped a specific java GUI (jar application generated by XCode & ant) which communicate both ways with my Mega board using RXTXcomm.jar for USB management. When I modify my sketch, I compile then download. After, i run from Mac OS the GUI jar application hence outside of IDE context. Do you think it would be easy to slightly modify the arduino IDE so I can from same shell compile & download my sketch but also run my specific GUI ?

Quote
I'm not sure why you'd want to use Arduino instead of "your favorite editor" in conjunction with avr-gcc, avr-g++, and avrdude, which are the tools that Arduino IDE uses to do most of the work.  (I suppose to make it easier for others to use it, eh?)
My actual strategy is not clear because i'm in steep learning curve, discovering java, XCode, arduino sketch development being the only part i'm more confident but I don't have any experience with AVR studio or other SDK in general even outside of arduino context. I'm really more plug & play in the Mac spirit.

Quote
The most likely roadblock is to find to you need a new version of avr-gcc/etc tools that have other problems withthe rest of the arduino environment.
Do you mean i'll run into many problems & issues in trying to get  running on my Mac the ATXmega128A3 board being developped by my friend in another country?
242  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: Xmega on: December 23, 2009, 03:34:08 am
hey westfw,

I remember you've a Mac, isn't ?

Maybe you can understand & help me go through http://code.google.com/p/arduino/wiki/BuildingArduino where it talk about XCode so does this mean I could generate myself an Arduino IDE & slightly modifiy it, add a button to launch my own java application, add submenu to interact with my partner's Xmega board,... via java programming ?

All,

I've discovered lately XCode & java but would appreciate any support if really it is not complex to make a personalized arduino IDE in case you use XCode on Mac.

Thank you in advance, Albert

243  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: Xmega on: December 21, 2009, 10:26:49 pm
One of my partner is considering to develop a ATXmega128A3 board for our projects but he has PC, I've Macintosh.

Since ATXmega shares same instructions set as AVR family except the ports numbering are different & specific, can you tell me if it would be difficult, feasible for me to modify arduino 15 IDE & associated lib to get TOOLS>BOARD>XMEGA available running on my Mac hence not use AVR Studio ?

Any insights, advices, suggestions, critics would be appreciated !
244  Forum 2005-2010 (read only) / Frequently-Asked Questions / Xmega on: December 19, 2009, 11:22:52 pm
Do you know if arduino company plans to develop a borad based on ATXmega128A3 which has very enhanced features (multiple DAC, many timers mode, 32MHz, AVR instructions compatible...) http://www.atmel.com/dyn/products/product_card.asp?part_id=4302
245  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: Maximum pin toggle speed on: December 24, 2009, 02:53:53 am
I don't understand
Quote
and I get 584128.
, what does it mean 584218 ?
246  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: Maximum pin toggle speed on: October 27, 2009, 11:00:43 pm
hey Circuitsville,

it took me a while to understand timers but then, it is a peace of cake to generate any PWM frequency from a few Hz up to hundreds of KHz or even more.

Here is another example showing the basic timer programmation (from post #5 to the end of thread):
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1252073278

please note you can have different ways to generate same frequency by playing with clock scaling, using a 8bit or 16bit Atmega timer along with TOP value but each way might have not same PW resolution.
247  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: Maximum pin toggle speed on: October 26, 2009, 11:09:57 pm
About the first example, then you might want to try
- PWM, Phase & frequency correct
- PWM, Phase correct
because I gave you the code for fast PWM which goes higher freq but is less jitter stable.

For Fast PWM and OCR1A=3, timer1 frequency=16MHz/(1+TOP)=16MHz/3

For PWM phase and/or frequency correct, timer1 frequency is 16MHz/(2*TOP). Since your initial sofwtare controlled code was producing 2,667 MHz, you could choose OCR1A=TOP=2 in order to get 4MHz and setting OCR1B=1 to get 50% PWM. The phase and/or frequency correct does not provide maximum frequency but does provide very stable jitter due to its counting up-down timer construction.

Anyway, we're clearly pushing the limits of Atmega toggling outputs frequency  smiley-wink

In any case, you need good external fast drivers otherwise signal distorsion will occur.

248  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: Maximum pin toggle speed on: October 22, 2009, 10:08:57 pm
Quote
The timer output to arduino pin mapping is different on Mega vs Diecimila; the signal shows up on pin 10 of the Diecimila.  Once I corrected for that I did indeed get 5.33MHz on pin 10.
Glad it worked on your side.  smiley-wink

Yes about pin, there are a bit different depending diecemila / duamilanove or mega eventhough the core sketch I gave you works on both.

I suggest you try my second sketch to find out ultimate case of 8 MHz on pin9 of diecemila instead of pin 11 of mega.

This is very useful doc from mem arduino member http://spreadsheets.google.com/pub?key=rtHw_R6eVL140KS9_G8GPkA&gid=0

Quote
Not a square wave, though; high for twice as long as it is low.
I'm sure you know this already but to not create confusion, the timers really work at correct frequencies but what happens is the arduino drivers and/or Atmega drivers are not enough fast to generate sharp PW waves. You might want to plug an external fast speed driver IC then you'll get nice waveform on your scope.


249  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: Maximum pin toggle speed on: October 18, 2009, 02:17:59 am
Here is the sketch for a mega board or duamilove, don't know which you have but I have both which should generate 5.333MHz on Pin12
Code:
#include <util/delay_basic.h>

int outputPsuB = 12;  // Timer1-B

void setup()
{
// outputs via timer1
  pinMode(outputPsuB, OUTPUT);  // select Pin as ch-B

  TCCR1A = B00100011; // Fast PWM change at OCR1A
  TCCR1B = B11001;  // System clock
  OCR1A = 2; // 5.333 MHz
  OCR1B = 1; // 50% PWM
}

void loop()
{
// do what ever you want with full 100% CPU
}

If it works on your scope, you might then try OCR1A=5 and should get your initial case of 2.667MHz and choose different PW via OCR1B value from 0 to OCR1A !

This other sketch should give 8MHz toggling on Pin11 but only 50%PW that cannot be changed
Code:
#include <util/delay_basic.h>

int outputPsuA = 11;  // Timer1-A

void setup()
{
// outputs via timer1
  pinMode(outputPsuA, OUTPUT);  // select Pin as ch-A

  TCCR1A = B01000011; // Fast PWM change at OCR1A
  TCCR1B = B11001;  // System clock
  OCR1A = 0; // 8 MHz
}

void loop()
{
// do what ever you want with full 100% CPU
}

There are many other possibilities if you have a mega board
250  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: Maximum pin toggle speed on: October 18, 2009, 12:07:30 am
Quote
Code:
  cli();
  while (1) {
    PORTD |= 0x8;
    PORTD &= ~0x8;
  }

on the same board runs at 2.667MHz.  (This does produce the minimal sbi/cbi/rjmp loop that you'd expect, BTW.)
(so that's about a 20x penalty for the arduino library code; sounds about right: the overhead of abstracting IO to "pin number" is pretty substantial: a subroutine call, lookup table to get the port, another lookup table to get the bit, a third to check whether analogWrite is in use, and then less efficient instructions to access the port "indirectly")

I don't know if this is of any interest but i've lately figure out how to generate fast PWM, phase correct PWM using 8bits and 16 bits timers hence freeing CPU for my project.

Could be wrong but if setting a timer in fast PWM mode and TOP=OCRnA=2, you can reach max frequency of 16MHz/(1+TOP) hence 5.333MHz and OCRnB=1. There seems to be a specific auto-toggling mode in the timer providing a 50% PWM at 8MHz.

The advantage is ultra fast PWM and freeing CPU.

The disavantage is only limited timers in duamilanove, a bit more on mega so if one needs many pins fast toggling, the quoted method is the best.
251  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: Maximum pin toggle speed on: June 16, 2009, 11:53:51 am
Many many many thanks westfw.

I've tried & benchmarked delay_loop_1 and delay_loop_2 per your explanation in the other thread. Works fine as you predicted: 3N cycles for delay_loop_1 and 4 cycles for delay_loop_2.

I don't know if it is important but it seems delay_loop_1(0) or delay_loop_2(0) do not work giving extremely long return time but that is OK for my application which forces a non-negative value to not blow up my MOSFET.

It is really interesting to note that for(i=0;i<n;i++) NOP will give average 7 cycles per iteration if i UNSIGNED but average 8 cycles per iteration if i SIGNED as you mentionned.

Anyway, calling x unsigned or signed delay_loop_x(n) gives same running time plus I really save a lot of timing hence i'll be able to go PWM higher precision than using for(i=0;i<n;i++) NOP.

Amicalement, Albert
252  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: Maximum pin toggle speed on: June 16, 2009, 12:31:23 am
Hey westfw,

i'm still having difficulties running AVR MacPack:
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1245125011

so can you confirm this math model on how many extra cycles (overhead, surroundings,...) because I can only for the moment inspect by benchmarking or cycle-counting as I explain yesterday  :'(

Q1: While(true) only uses 2 cycles ?

Q2: For(i:=0;i<n;i++) uses 2 cycles to initialize then 6 cycles to either jump loop or leave the loop once completed ?

Q3: About your suggestion to decrement loop, do you confirm initialization will also take 2 cycles (starting from i=0 might not require same cycle as starting from i= non zero value).

Sorry for all this questions but I feel you understand what i'm trying to do: have precise math model of every cycle, every instructions to generate high speed multi PWM requiring reverse-engineer to set up parameters of for(), while(),...
253  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: Maximum pin toggle speed on: June 15, 2009, 10:15:08 pm
hello westfw and condemned,

ok, from my Mac, i can see & go to /Applications/arduino-0015/hardware/tools/avr/bin/avr-objdump but how do I launch avr-objdump - S on my sketch.elf which is stored on another directory ?

About max toggling, does goto instead of while(true) has same assembly code & overhead / duty cycle time at each run ?
Code:
 while (true) {
    PORTD |= B1000;
    PORTD &= B11110111;
  }
Code:
m:  PORTD |= B1000;
    PORTD &= B11110111;
    goto m;
  }



254  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: Maximum pin toggle speed on: June 15, 2009, 01:42:47 am
Oups, you're entirely right :smiley

I did benchmark with only
Code:
 for (int i=0; i < N; i++){
    PORTD = B1000;
    PORTD = B11110111;
  }
Many thanks, you helped found me a bug smiley-wink

So about my code, in particular last PORT call (extract_off), how many cycles the while(true) will use ?

Please note that I TDMA frame my pulses so i'm not using while() to toggle but rather tune parameters with cycle offset corrections to get proper timing.

Worthwhile noting if 2 pins belong same port, we can set or clear within same cycle two outputs.

Again many thanks for all your support on this thread & the other one about scaning USB activity in 2 cycles.
255  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: Maximum pin toggle speed on: June 14, 2009, 10:13:06 pm
ok, i'm totally new with arduino plus I don't have a debugger, compiler or any other tool for the moment so I just play with my Macintosh, ATmega1280 board & official SDK arduino 15 downloaded from arduino website.

As you may have found in other thread, i'm working on very fast PWM for my power electronics inverters....

The average poor man's method I use to measure real CPU cycle is as follows
Code:
#define NOP __asm__("nop\n\t")

int N = 0;
// long N=0;
unsigned long time, time1, time2;

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

void loop{
  if (Serial.available()) {
    val = Serial.read();
    if (val == '+') {
      N += 1000;
    }
    if (val == '-') {
      N -= 1000;
      if (N<0) N = 0;
    }
  }
  
  time1 = micros();
  
  for (int i=0; i < N; i++){
//    __asm__("nop\n\t");
    PORTD |= B1000;
    PORTD &= B11110111;
//   if (UCSR0A & _BV(RXC0)) {
//    }
  }
  
  time2 = micros();

  Serial.print("N: ");
  time=time2-time1;
  Serial.print(time);
  Serial.print(" / ");
  Serial.println(N);
  delay(1000);
}
so with big N value, it converges with average ns measurement for whatever set of instruction I have inside for(i=0;i<;N;i++). For example, 444/1000 print output means 444ns or roughly 7 cycles at 16MHz.

This is how I observed a NOP was really 1 cycle, PORTD |= B1000 (setting bit 3 of PORTD) was 1 cycle,... 6 cycles for INT i and 10 cyles for LONG i overhead or surrounding management of for(i=0;i<;N;i++).

About my project, please note what i'm doing to generate high speed PWM
Code:
void loop()
{
 cli();  // turn off interrupts
 while (true) {
// Turns ON coil charging opto-coupler #1
    PORTH |= B10000;
    for(i=0;i<charge_on;i++) NOP;

// Turns OFF coil charging opto-coupler #1
    PORTH &= B11101111;
    for(i=0;i<charge_off;i++) NOP;
  
// Turns ON coil FE extracting opto-coupler #2
    PORTA |= B1;
    for(i=0;i<extract_on;i++) NOP;

// Turns OFF coil FE extracting opto-coupler #2
    PORTA &= B11111110;
    for(i=0;i<extract_off;i++) NOP;

    if (UCSR0A & _BV(RXC0)) { // check uart  (register name changes per port)
      break;  // looks like there is data.  Break out of loop to handle it
    }
  } // end of time critical loop
  sei();  // interrupts back on
  delay(10); // wait for some characters to arrive
  while (Serial.available()) {
// Macintosh serial monitor parameter management to update 4 loops
  }
}
so which is why I need to know while(true) overhead to compensate the computation of charge_on, charge_off, extract_on & extra_off values to get precise duty cycle. Please note I already compensated by including 1 cycle for PORTX writing along with 2 cycles for USB RX from if (UCSR0A & _BV(RXC0)) and 6+1 cycles  for local for(i=0;i<...) NOP
Pages: 1 ... 15 16 [17] 18