0

Need help for #1411 16-Channel 12-bit PWM/Servo Driver - I2C
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Need help for #1411 16-Channel 12-bit PWM/Servo Driver - I2C

by archnir on Sat Feb 09, 2019 8:20 am

I am starting a project in which saw-dust blast gates in my workshop are controlled by using multiple (7-9) servos hooked up to the Adafruit 16-Channel 12-bit PWM/Servo Driver - I2C interface (#1411) and an Arduino Uno R3. I also purchased an Adafruit numeric key pad (3x4, phone-style) to be used to [toggle] control each servo.

Library-included Servo>Example code executed with no problem and I am trying to include the <keypadEvent> sketch to control each servo-linked blast gate.
I am rather new to coding Arduino C/C+.

What I’d like to know is if there is a function in the servo library, equivalent to the Arduino’s “digitalRead ()” to check the current state (ON/OFF) of a certain servo (pin).
Maybe it’s only me, but the references and example codes have been hard to find. Kind assistances would be much appreciated!

archnir
 
Posts: 4
Joined: Sat Feb 09, 2019 7:31 am

Re: Need help for #1411 16-Channel 12-bit PWM/Servo Driver -

by adafruit_support_bill on Sat Feb 09, 2019 8:25 am

The PCS9685 PWM chip is an output-only device. There is no way to read the state of the pins. If you can explain what you are attempting to do with that pin state information, we may be able to suggest an alternative approach.

adafruit_support_bill
 
Posts: 72764
Joined: Sat Feb 07, 2009 10:11 am

Re: Need help for #1411 16-Channel 12-bit PWM/Servo Driver -

by archnir on Sat Feb 09, 2019 8:46 am

Thank you so much for the immediate reply.
I practiced with mutiple LED’s with num keypad [without using the servo shield yet]; In that code I used,

Code: Select all | TOGGLE FULL SIZE
< void keypadEvent (KeypadEvent key);
 switch (keypad.getState () {
   case PRESSED:
      if (key = ‘1’) {
        digitalWrite (9, !digitalRead (9)) ;
      {
     if (key = ‘2’) {
       digitalWrite (10, !digitalRead (10)) ;
      {
//and so on...
    break;

   case RELEASED:
     if (key = ‘#’) {
 //and so on.....    >

This way.
I am thinking of case HOLD statement, if all else doesn’t work out to toggle ON/OFF the servos.

I am new to i2c and pwm.

Thanks for your kind help
Last edited by archnir on Mon Feb 11, 2019 1:27 am, edited 3 times in total.

archnir
 
Posts: 4
Joined: Sat Feb 09, 2019 7:31 am

Re: Need help for #1411 16-Channel 12-bit PWM/Servo Driver -

by archnir on Sat Feb 09, 2019 8:56 am

Addendum; FYI

Each blast gate is controlling saw dust extraction from a particular woodworking machine,
so only one gate should be open and all others are supposed to be closed in order to maintain proper CFM (cubic feet per min) of the line.
Thanks so much.
Looking forward to an expert suggestion.

archnir
 
Posts: 4
Joined: Sat Feb 09, 2019 7:31 am

Re: Need help for #1411 16-Channel 12-bit PWM/Servo Driver -

by adafruit_support_bill on Sat Feb 09, 2019 9:26 am

Servos are not controlled with an ON or OFF signal. They are controlled by sending a series of pulses, where the pulse width controls the position of the servo. A typical servo signal would send pulses at 50 Hz with a 1000uS corresponding to 0 degrees and 2000uS corresponding to 180 degrees.

When using the PWM/Servo shield, the PCS9685 PWM chip will be generating the pulses for you. The "setPWM" function in the PWM-Servo library is used to control the pulse width.
http://adafruit.github.io/Adafruit-PWM- ... river.html

There is a "Servo" example included with the library : https://github.com/adafruit/Adafruit-PW ... /servo.ino

You could keep track of which blast gates are open using variables in your program. But a simpler approach is to just iterate through all the channels and send a signal to close for all channels except the one you want to open.

adafruit_support_bill
 
Posts: 72764
Joined: Sat Feb 07, 2009 10:11 am

Re: Need help for #1411 16-Channel 12-bit PWM/Servo Driver -

by archnir on Sat Feb 09, 2019 7:05 pm

Thanks again.

As I mentioned in the first post, included example sketch “Servo” worked without an issue in my setup.
I will try to tweak that sketch further using variables and setPWM ( ) function, as you suggested.

archnir
 
Posts: 4
Joined: Sat Feb 09, 2019 7:31 am

Please be positive and constructive with your questions and comments.