Author Topic: PWM aka. analogWrite on the Digispark Pro  (Read 10605 times)

McLenin

  • Newbie
  • *
  • Posts: 4
PWM aka. analogWrite on the Digispark Pro
« on: December 21, 2014, 09:44:00 am »
So I'we been playing around a bit with my new Digisaprk Pro's and after finally getting the IDE to work on Linux I've stumbled upon some further problems that I am not sure how to resolve. Specifically the issue seems to be with the PWM outputs. To my understanding the PWM outputs should work on pins 0-5 and 8. However for me (on all 3 Digispark Pro's that I currently own), only pins 0 and 1 work as advertised. I've used the following code to test the pins:

Code: [Select]
int p=0;

void setup() {
  pinMode(p, OUTPUT);

}

void loop() {
 analogWrite(p,255);
 delay(5000);
 analogWrite(p,250);
 delay(5000);
 analogWrite(p,200);
 delay(5000);
 analogWrite(p,150);
 delay(5000);
 analogWrite(p,100);
 delay(5000);
 analogWrite(p,50);
 delay(5000);
 analogWrite(p,0);
 delay(5000);
}

I changed the values of p and messured the results with an osciloscope and multimeter

0 -> works fine as expected
1 -> works fine voltages a tiny bit lower
2 -> acts almost like  digital pin switching from 4.5V when analogWrite value is above 100, to 0V when at 100 or less
3 -> same as 2
4 -> same as 2
5 -> same as 2
8 -> same as 2

The results don't change much when powering the board via USB or with a standalone power supply.

digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
Re: PWM aka. analogWrite on the Digispark Pro
« Reply #1 on: December 21, 2014, 02:16:33 pm »
Yes -currently 0 and 1 have PWM - we're still working out the best way to setup PWM channels - because PWM is allowed on 0-5 and 8 but only 3 channels of it are allowed at one time. Expect this in oru next release - we wanted to get all platforms supported and the major bugs out before we break Arduino conventions and such.

Linuxing binaries are now up too - sorry you had to do it manually!

McLenin

  • Newbie
  • *
  • Posts: 4
Re: PWM aka. analogWrite on the Digispark Pro
« Reply #2 on: December 21, 2014, 09:26:50 pm »
Thank you for uploading the Linux binaries (most of the problems with those were completely my fault anyway as I tried to add digispark pro functionality to the 1.0.6 IDE instead of the 1.5.8). As for the PWM I'm glad that the issue is known and not a hardware malfunction on my boards. I realise you're probably really busy with the roll-out of all the cool new things, but perhaps a list of features still in need of implementing could be added to the wiki or git page?

Keep up the good work.

tozz88

  • Newbie
  • *
  • Posts: 15
Re: PWM aka. analogWrite on the Digispark Pro
« Reply #3 on: January 05, 2015, 11:36:00 am »
Any update on when the PWM libraries will support pins other than 0 and 1? I am quickly running into an issue where I need 2 PWM channels for motor control as well as 2 external interrupts which also need to be pins 0 and 1 (I need programmable edge triggered not GPIO interrupts).

digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
Re: PWM aka. analogWrite on the Digispark Pro
« Reply #4 on: January 12, 2015, 03:36:20 pm »
More PWM functions are included in the upcoming release (this week) 1.5.8C - they are in the github and wiki now:

https://github.com/digistump/DigistumpArduino/commit/02c36dfd60158b4b44be5bc36c33b49498f617fc

http://digistump.com/wiki/digispark/tutorials/propwm

McLenin

  • Newbie
  • *
  • Posts: 4
Re: PWM aka. analogWrite on the Digispark Pro
« Reply #5 on: January 13, 2015, 04:35:26 am »
So the third PWM channel on PIN 8 is now removed from the specifications?

digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
Re: PWM aka. analogWrite on the Digispark Pro
« Reply #6 on: January 13, 2015, 11:14:44 am »
It will be there in the next release this week - we removed it while we figured out how to get it to play well if everything else and I've just finished fixing it.

McLenin

  • Newbie
  • *
  • Posts: 4
Re: PWM aka. analogWrite on the Digispark Pro
« Reply #7 on: January 14, 2015, 10:36:36 pm »
That's awesome, thank you. Sorry if I'm being annoying, but I'm doing a project that requires 3 different analog out signals, so this issue is of particular importance to me.

Keep up the good work!

digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
Re: PWM aka. analogWrite on the Digispark Pro
« Reply #8 on: January 15, 2015, 09:01:32 am »
No problem - Nothing annoying about asking for the promised features!

This is in version 1.5.8C coming out right now!
https://github.com/digistump/DigistumpArduino/releases/tag/v1.5.8C
« Last Edit: January 15, 2015, 09:03:55 am by digistump »

marcmerlin

  • Newbie
  • *
  • Posts: 15
Re: PWM aka. analogWrite on the Digispark Pro
« Reply #9 on: May 13, 2015, 05:35:01 pm »
No problem - Nothing annoying about asking for the promised features!

This is in version 1.5.8C coming out right now!
https://github.com/digistump/DigistumpArduino/releases/tag/v1.5.8C

Howdy.
http://digispark.s3.amazonaws.com/DigisparkProDiagram2.png
shows that pin 8 in PWM on channel C, but there is no channel C.

So, is PWM on pin 8 supported, and if so, what channeld is it supposed to be on?

Thanks,
Marc

marcmerlin

  • Newbie
  • *
  • Posts: 15
Re: PWM aka. analogWrite on the Digispark Pro
« Reply #10 on: May 19, 2015, 04:55:21 pm »
Hi, are you still around?  Any update on PWM on pin 8?

digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
Re: PWM aka. analogWrite on the Digispark Pro
« Reply #11 on: June 23, 2015, 01:46:27 pm »
Sorry I had this on my bug list, but in looking at fixing it for the upcoming release I found that it is working, just not clear:

Pin 8 has its own channel, so pwmWrite pwmConnect pwmDisconnect are not used, since you don't need the ability to connect and disconnect it from a shared channel - just use good old analogWrite() for pin 8 and it should work just fine.

marcmerlin

  • Newbie
  • *
  • Posts: 15
Re: PWM aka. analogWrite on the Digispark Pro
« Reply #12 on: June 23, 2015, 04:34:35 pm »
Cool, that makes sense, thanks.