Home \ Help \ Search \ Login RSS

Welcome, Guest. Please Login

This forum is now READ-ONLY! Please visit http://forum.wiring.co/ for the new forum.

Wiring ForumWiring HardwareTroubleshooting › PWM Problem in 12?

Page Index Toggle Pages: 1
PWM Problem in 12? (Read 5494 times)
08/06/07 at 18:22:33

CSMotionControl   Offline
YaBB Newbies
Hey, did you get any mail
for Willie Nelson?

Posts: 16
*
 
All, I am currently using this code:

int value = 0;                  
int motorpin = 0;                           
int dirpin = 35;

void setup()
{
//analogWrite(motorpin, 125);
  pinMode(dirpin, OUTPUT);
}

void loop()
{
  digitalWrite(dirpin, HIGH);
  analogWrite(motorpin, 50);
}

The output one PWM pin 0 is no good (I scoped it, and am getting mv noise out).

If I uncomment the line out in setup(), I get an output on the PWM pin corresponding with 125/255 PWM, not 50/255 PWM as I'd expect?

Thoughts?!
 
IP Logged
 
Reply #1 - 08/08/07 at 22:57:35

CSMotionControl   Offline
YaBB Newbies
Hey, did you get any mail
for Willie Nelson?

Posts: 16
*
 
int value = 0;                  
int motorpin = 5;
int dirpin = 13;

int homepin = 15;
int homeswitch;

int i = 1;      //Homing Iteration Variable

void setup()
{
  analogWrite(0,255);
  pinMode(dirpin, OUTPUT);
  pinMode(homepin, INPUT);
}

void loop()
{
  analogWrite(0,0);        //Initialize PWM (I Shouldn't have to do this to make PWM WORK!)
  analogWrite(1,0);
  analogWrite(2,0);
  analogWrite(3,110);
  analogWrite(4,110);
  analogWrite(5,110); 

  homeswitch = digitalRead(homepin);

while(i>0)
{
  while(homeswitch == HIGH)    //Plow into homeswitch.
  {
//    digitalWrite(dirpin, HIGH);
    analogWrite(0, 20);
    homeswitch = digitalRead(homepin);   
  }
  analogWrite(0,0);
  i--;
}
}

This is currently the code I'm using, if you uncomment out the digitalpin write in the while loop, the wiring board craps out.  Commented, it works as expected.  This is from 11, the sample above was from 12.  Any thoughts? 

Any way to iron this out for future versions?  It is a really big pain in the but to troubleshoot stuff like this.
 
IP Logged
 
Reply #2 - 08/09/07 at 00:51:41

barragan   Offline
YaBB Administrator

Posts: 939
*****
 
hi, yes this was a bug from 11

analogWrite(0,0);        //Initialize PWM (I Shouldn't have to do this to make PWM WORK!)
analogWrite(1,0);
analogWrite(2,0);
analogWrite(3,110);
analogWrite(4,110);
analogWrite(5,110);


This bug was fixed for 12, I am going to check on the first post you made.
 
IP Logged
 
Page Index Toggle Pages: 1