Show Posts
Pages: 1 [2] 3
16  Products / Arduino Due / Re: IDE 1.51 installation problem into W7 on: November 09, 2012, 02:03:15 pm
I'm not a windows user but you could try another unpacker. 7zip is a great small app that can unpack almost everything.
http://www.7-zip.org/
17  Products / Arduino Due / Re: DUE PWM Frequency on: November 09, 2012, 01:58:55 pm
Okay. So I figured out why it dosen't work if you set the register. It turns out that not all the pwm pins is actually pwm pin, some are timer pins. So for example doing:
'PWM->PWM_CLK = 0b00001010111111110000101011111111;'
Works for pin 6, but not pin 2. (Tho you need to do it after every analogWrite as analogWrite insist on the 1k freq)
Another easier way to change the freq is to do:
'PWMC_ConfigureClocks(whatever_freq_you_want * 255 , 0, VARIANT_MCK);'


From variants.cpp:
Code:
 ....
  ....
  // 0 .. 53 - Digital pins
  // ----------------------
  // 0/1 - UART (Serial)
  { PIOA, PIO_PA8A_URXD,     ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT,  PIN_ATTR_DIGITAL,                 NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // URXD
  { PIOA, PIO_PA9A_UTXD,     ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT,  PIN_ATTR_DIGITAL,                 NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // UTXD

  // 2
  { PIOB, PIO_PB25B_TIOA0,   ID_PIOB, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NOT_ON_PWM,  TC0_CHA0     }, // TIOA0
  { PIOC, PIO_PC28B_TIOA7,   ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NOT_ON_PWM,  TC2_CHA7     }, // TIOA7
  { PIOC, PIO_PC26B_TIOB6,   ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NOT_ON_PWM,  TC2_CHB6     }, // TIOB6

  // 5
  { PIOC, PIO_PC25B_TIOA6,   ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NOT_ON_PWM,  TC2_CHA6     }, // TIOA6
  { PIOC, PIO_PC24B_PWML7,   ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM),   NO_ADC, NO_ADC, PWM_CH7,     NOT_ON_TIMER }, // PWML7
  { PIOC, PIO_PC23B_PWML6,   ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM),   NO_ADC, NO_ADC, PWM_CH6,     NOT_ON_TIMER }, // PWML6
  { PIOC, PIO_PC22B_PWML5,   ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM),   NO_ADC, NO_ADC, PWM_CH5,     NOT_ON_TIMER }, // PWML5
  { PIOC, PIO_PC21B_PWML4,   ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM),   NO_ADC, NO_ADC, PWM_CH4,     NOT_ON_TIMER }, // PWML4
  // 10
  { PIOC, PIO_PC29B_TIOB7,   ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NOT_ON_PWM,  TC2_CHB7     }, // TIOB7
  { PIOD, PIO_PD7B_TIOA8,    ID_PIOD, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NOT_ON_PWM,  TC2_CHA8     }, // TIOA8
  { PIOD, PIO_PD8B_TIOB8,    ID_PIOD, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NOT_ON_PWM,  TC2_CHB8     }, // TIOB8

  // 13 - AMBER LED
  { PIOB, PIO_PB27B_TIOB0,   ID_PIOB, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NOT_ON_PWM,  TC0_CHB0     }, // TIOB0

  // 14/15 - USART3 (Serial3)
  { PIOD, PIO_PD4B_TXD3,     ID_PIOD, PIO_PERIPH_B, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // TXD3
  { PIOD, PIO_PD5B_RXD3,     ID_PIOD, PIO_PERIPH_B, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // RXD3
   ....
   ....
  

As you can see only pin 6, 7, 8 and 9 is a PWM_CH pin.
You can surely change the freq on the timer pins too but I'm too tired to dig into that.

I'd say that the analogWrite need to be changed so that it allows easier change of the freq.

Edit:
If you don't want to set the freq for every analogWrite you could use 'PWMC_SetDutyCycle(PWM_INTERFACE, PWM_CH7, your_analog_write_value);' instead.
So a fading led sketch with 4k pwm freq on pin 6 would be:
Code:
void setup()  {
  pinMode(6, OUTPUT);
  analogWrite(6, 64);
  PWMC_ConfigureClocks(4000 * PWM_MAX_DUTY_CYCLE , 0, VARIANT_MCK);
}

void loop()  {
        for (int i = 0; i < 253; i++) {
            PWMC_SetDutyCycle(PWM_INTERFACE, PWM_CH7, i);
            delay(10);
}
for (int i = 255; i > 1; i--) {
            PWMC_SetDutyCycle(PWM_INTERFACE, PWM_CH7, i);
            delay(10);
}                
}
18  Products / Arduino Due / Re: DUE PWM Frequency on: November 09, 2012, 10:13:57 am
Had a quick look at it and I can confirm that changing PWM_FREQUENCY in
https://github.com/arduino/Arduino/blob/ide-1.5.x/hardware/arduino/sam/variants/arduino_due_x/variant.h#L182 does change the freq. So if you just need the 4k freq it'll work fine. Still, a way to change the freq in the sketch would be preferred.
19  Using Arduino / Microcontrollers / Re: Shrinkify Arduino Project on: November 09, 2012, 07:53:55 am
nice!..

wher are all the other components?

I never used an ATtiny2313 before...

(still need the caps/crystal...etc?)

There is no need for any external components, and no attiny/atmega dosen't even need a crystal. They (atleast all I've used) have an 8MHz internal crystal. All you need is voltage and ground.
20  Using Arduino / Microcontrollers / Re: Shrinkify Arduino Project on: November 09, 2012, 06:53:07 am
Was bored so I tried to make a tiny attiny2313 (DIP) board with ISP headers. Here is what I got:
21  Products / Arduino Due / Re: DUE PWM Frequency on: November 09, 2012, 02:32:51 am
Impressive project! Would be sad to see you giving up the due for such a basic thing as changing the pwm frequency. The IDE does set the freq in some library, you could try to look for it and change the freq the same way the arduino guys have done. But I'm sure someone already have tried to change the freq and can show you how, it's just hope that such a person shows up smiley. I might give it a go tonight if I find some free time.
22  Products / Arduino Due / Re: IDE 1.5.1 on: November 08, 2012, 04:20:18 am

Try "ant clean" first.


Thank you, it worked. smiley

... but now I feel stupid. Got any ant argument for that?
23  Products / Arduino Due / Re: IDE 1.5.1 on: November 07, 2012, 01:05:14 pm
Not fun. (Newest from git, linux64)
24  Products / Arduino Due / Re: Which one is the working Due version? on: November 01, 2012, 03:33:35 pm
I think a missing crystal is a huge difference. Especially for people who wanted to use the SAMs RTC.

Yes, well if they added the crystal I'd have to agree that it makes a difference, but they have removed it so there will not be any support for using it. Has someone actually gotten a board with the crystal? If then it's just a very small number of boards that has it.

(Don't get me wrong, I'd like the crystal too. But I'm sure they had their reasons for removing it.)
25  Products / Arduino Due / Re: Which one is the working Due version? on: November 01, 2012, 02:50:28 pm
and why they sold out this board??? We bought all together at the same prize, the SAME board... but they are different...

The differences are so small that it doesn't matter.
26  Products / Arduino Due / Re: Which one is the working Due version? on: November 01, 2012, 06:16:48 am
My Due has the chip on the same place as 'the current one'. If you live in EU this place got 3 Due in stock http://www.robomaa.com/index.php?main_page=product_info&cPath=1001_1020&products_id=1245
27  Products / Arduino Due / Re: Python for Arduino Due on: October 30, 2012, 05:26:01 am
Python is a scripting language...                               No.
28  Using Arduino / Project Guidance / Re: cycling 4 LEDs at varrying speeds on: October 08, 2012, 11:37:08 am
Great to see new people getting interested in microcontrollers smiley.
First, you have resistors in there too right?

Anyway.
You can change 'timer' in the loop as you like. For example:

Code:
void loop() {
  // loop from the lowest pin to the highest:
  for (int thisPin = 2; thisPin < 6; thisPin++) {
    // turn the pin on:
    digitalWrite(thisPin, HIGH); 
    delay(timer);
           
    // lower the delay if timer >= 20       
    if (timer >= 20) {
      timer = timer - 10;
    }

    // turn the pin off:
    digitalWrite(thisPin, LOW);   
  }
}

This will lower 'timer' by 10 each time the loop runs until 'timer' is 10 (milliseconds).
Have fun!
29  Using Arduino / Programming Questions / Re: The Pin 13 can't output High Level on: October 03, 2012, 02:57:38 pm
Since you are just using voltage[i-1] and voltage you don't need N to be bigger that 2. Get rid of the for loop and do 'voltage[1] = voltage[0];' and then 'voltage[0] = analogRead...' and so on.
30  Using Arduino / Programming Questions / Re: The Pin 13 can't output High Level on: October 03, 2012, 02:49:03 pm
"if (voltage-voltage[i-1]>=0.1)" in a loop with voltage constantly updating would result in a blink that you would probably not even notice.
Pages: 1 [2] 3