resetting chip/shield/sample code issue

For Adafruit customers who seek help with microcontrollers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
SFARRELL6
 
Posts: 11
Joined: Sat Aug 15, 2015 9:23 pm

resetting chip/shield/sample code issue

Post by SFARRELL6 »

hey guys,

so when i Got the 16 x12 servo shield I loaded the library and compiled the sample code and it worked fine. I've been doing 10 of problem solving to try to get the shield to work with my mega 2560 chip and I unfortunately have not been successful. So I just decided start from the beginning and to start working forward again. Went to go upload the sample code and it will compile and upload fine but when you actually run it "servo sample code" in the serial monitor it will display "16 channel servo test!" and thats it. The first time when I uploaded it it would originally give in That prompt and then count from 0 to 15 as it moved from one servo to the next. I didn't change anything at the sample code, tried uninstalling and reinstalling the library, have the 2 power sources as required, and everything is soldered properly to the best
knowledge it seems as if everything is in place correctly it's just not running. Read the support information on the shield numerous times but unfortunately I'm having lots of issues even doing very simple tasks with it. I don't know if the shield is bad? Maybe you can get some insight. Typical below

Code: Select all

/*************************************************** 
  This is an example for our Adafruit 16-channel PWM & Servo driver
  Servo test - this will drive 16 servos, one after the other

  Pick one up today in the adafruit shop!
  ------> http://www.adafruit.com/products/815

  These displays use I2C to communicate, 2 pins are required to  
  interface. For Arduino UNOs, thats SCL -> Analog 5, SDA -> Analog 4

  Adafruit invests time and resources providing this open source code, 
  please support Adafruit and open-source hardware by purchasing 
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries.  
  BSD license, all text above must be included in any redistribution
 ****************************************************/

#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>

// called this way, it uses the default address 0x40
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();
// you can also call it with a different address you want
//Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x41);

// Depending on your servo make, the pulse width min and max may vary, you 
// want these to be as small/large as possible without hitting the hard stop
// for max range. You'll have to tweak them as necessary to match the servos you
// have!
#define SERVOMIN  150 // this is the 'minimum' pulse length count (out of 4096)
#define SERVOMAX  600 // this is the 'maximum' pulse length count (out of 4096)

// our servo # counter
uint8_t servonum = 0;

void setup() {
  Serial.begin(9600);
  Serial.println("16 channel Servo test!");

  pwm.begin();
  
  pwm.setPWMFreq(60);  // Analog servos run at ~60 Hz updates
}

// you can use this function if you'd like to set the pulse length in seconds
// e.g. setServoPulse(0, 0.001) is a ~1 millisecond pulse width. its not precise!
void setServoPulse(uint8_t n, double pulse) {
  double pulselength;
  
  pulselength = 1000000;   // 1,000,000 us per second
  pulselength /= 60;   // 60 Hz
  Serial.print(pulselength); Serial.println(" us per period"); 
  pulselength /= 4096;  // 12 bits of resolution
  Serial.print(pulselength); Serial.println(" us per bit"); 
  pulse *= 1000;
  pulse /= pulselength;
  Serial.println(pulse);
  pwm.setPWM(n, 0, pulse);
}

void loop() {
  // Drive each servo one at a time
  Serial.println(servonum);
  for (uint16_t pulselen = SERVOMIN; pulselen < SERVOMAX; pulselen++) {
    pwm.setPWM(servonum, 0, pulselen);
  }
  delay(500);
  for (uint16_t pulselen = SERVOMAX; pulselen > SERVOMIN; pulselen--) {
    pwm.setPWM(servonum, 0, pulselen);
  }
  delay(500);

  servonum ++;
  if (servonum > 15) servonum = 0;
}
[img]

[/img]

Again this should be the exact code in the sample from what i understand.
Attachments
IMG_2532.jpg
IMG_2532.jpg (344.75 KiB) Viewed 411 times

User avatar
adafruit_support_bill
 
Posts: 88092
Joined: Sat Feb 07, 2009 10:11 am

Re: resetting chip/shield/sample code issue

Post by adafruit_support_bill »

What kind of Mega are you using? If it is an R3 Mega 2560, you should not need those jumpers.

If you run the i2c Scanner, what is the output? http://playground.arduino.cc/Main/I2cScanner

User avatar
SFARRELL6
 
Posts: 11
Joined: Sat Aug 15, 2015 9:23 pm

Re: resetting chip/shield/sample code issue

Post by SFARRELL6 »

I am using a sunfounder mega 2560 board.

I used the i2c scanner and it didn't return anything ......

thank for the heads up on the jumpers


:/

Sean

User avatar
adafruit_support_bill
 
Posts: 88092
Joined: Sat Feb 07, 2009 10:11 am

Re: resetting chip/shield/sample code issue

Post by adafruit_support_bill »

I am using a sunfounder mega 2560 board.
I'm not familiar with that board. Does it have R3-compliant headers?

User avatar
SFARRELL6
 
Posts: 11
Joined: Sat Aug 15, 2015 9:23 pm

Re: resetting chip/shield/sample code issue

Post by SFARRELL6 »

i believe it does from what i read.... see the link below for the specs... let me know.

http://www.sunfounder.com/index.php?c=s ... ega%202560

User avatar
adafruit_support_bill
 
Posts: 88092
Joined: Sat Feb 07, 2009 10:11 am

Re: resetting chip/shield/sample code issue

Post by adafruit_support_bill »

Assembly looks fine and it should be able to work with that processor. We can try replacing the shield. Please contact [email protected] with a link to this thread.

User avatar
SFARRELL6
 
Posts: 11
Joined: Sat Aug 15, 2015 9:23 pm

Re: resetting chip/shield/sample code issue

Post by SFARRELL6 »

Thanks guys I really do appreciate it. Things like this are what separate you from the rest!

:)

Sean

Locked
Please be positive and constructive with your questions and comments.

Return to “Microcontrollers”