Pwm sample does work with channel 0 only with pca9685

Hi,

I am trying to test pwm sample code under /apps/samples/pwm folder. I needed to make some modifications to the code to make the servo run.

I changed pwm.app.json as below as I connected the pca9685 to bus1 of the jetson tx2

“config”: {
“pwm”: {
“PwmDriver”: {
“tick_period”: “1s”
},
“PwmController”: {
“i2c_device_num”: 1
}
},

I have changed the pwmdriver.cpp code as follows:

void PwmDriver::tick() {
int channel;
float duty_cycle;
char infoStr[500] = “”;
channelToggle_ = !channelToggle_;
LOG_INFO(“pwm - test”);
channel = 0;
duty_cycle = 0.25;
auto proto = tx_set_duty_cycle().initProto();
proto.setChannel(channel);
sprintf(infoStr,“channel: %d dutycycle = %.3f channeltoggle: %d”, channel,duty_cycle,channelToggle_);
LOG_INFO(infoStr);
proto.setDutyCycle(duty_cycle);
proto.setDisable(channelToggle_); // varies between true and false
tx_set_duty_cycle().publish();
}

I have 2 problems:

  1. I expect the servo to run for 1 second and rest for 1 second (at least that is what I got from the sample code), but it turns forever.

  2. If I connect the servo to another channel except channel 0 , and set the channel number proto.setChannel(channel); respectively, the servo dont work.

What could be the problem ?

Notes: I am using continous servos for testing, (Tower pro micro servos) and obviously I use pca9685 board connected to bus1 of jetson tx2