Code: Select all
cannot lock /var/run/pigpio.pid
running this command does indeed delete that pigpio.pid, BUT the first program which had already runYou can delete the pid file so you don't need to reboot.
sudo rm /var/run/pigpio.pid
Code: Select all
gpioInitialize();
gpioPWM(....);
gpioTerminate();
Code: Select all
initInitialise: Can't lock /var/run/pigpio.pid
Code: Select all
unsigned sampleRateUs = 1; // default = 5!
unsigned configPeripheral = PI_CLOCK_PCM; // changing this does not result in any changes // PI_CLOCK_PWM (0) or PI_CLOCK_PCM (1, default)
if (gpioCfgClock(sampleRateUs, configPeripheral, 0)< 0) // last argument unused
{
std::cout"GpioInit - gpioCfgClock < 0";
}
// this line below also does not matter much in terms of changing behavior, I can comment it out and still see similar issues
gpioCfgDMAchannels(14, 6); //12);
if (gpioInitialise() < 0)
{
//initialization failed
gpioTerminate();
std::cout<< " gpioInitialise < 0\n";
}
gpioSetMode(20, PI_OUTPUT);
// set PWM to zero at the beginning
gpioPWM(20, 0);
// set frequency
gpioSetPWMfrequency(20, 500);
// set PWM range such that gpioPWM below is in us
gpioSetPWMrange(20, 1e6/500);
// this value should not spin the motor
gpioPWM(20, 950);
// at this point, the motor should not spin
/*
// spin motor if desired, but not for htis test
while (1) {
gpioPWM(20, 1500);
}
*/
Code: Select all
//*********************************** in a separate terminal
raspivid -t 600000 -o v.h264 -fps 30 -w 1920 -h 1080
Code: Select all
uint8 sampleRateUs = 1; // default = 5!Code: Select all
#include <pigpio.h>
#include <stdio.h>
#include <unistd.h> // for usleep
int main(){
unsigned sampleRateUs = 1; // default = 5!
unsigned configPeripheral = PI_CLOCK_PCM; // changing this does not result in any changes // PI_CLOCK_PWM (0) or PI_CLOCK_PCM (1, default)
if (gpioCfgClock(sampleRateUs, configPeripheral, 0)< 0) // last argument unused
{
printf("GpioInit - gpioCfgClock < 0\n");
}
// this line below also does not matter much in terms of changing behavior, I can comment it out and still see similar issues
gpioCfgDMAchannels(14, 6); //12);
if (gpioInitialise() < 0)
{
//initialization failed
gpioTerminate();
printf(" gpioInitialise < 0\n");
}
gpioSetMode(20, PI_OUTPUT);
// set PWM to zero at the beginning
gpioPWM(20, 0);
// set frequency
gpioSetPWMfrequency(20, 500);
// set PWM range such that gpioPWM below is in us
gpioSetPWMrange(20, 1e6/500);
while (1){
// this value should not spin the motor
gpioPWM(20, 950);
// at this point, the motor should not spin
/*
// spin motor if desired, but not for htis test
gpioPWM(20, 1500);
*/
usleep(1000);
}
}
Code: Select all
#include <pigpio.h>
#include <stdio.h>
#include <unistd.h>
int main()
{
int retval;
retval = gpioCfgClock(2, PI_CLOCK_PCM, 0);
if (retval < 0)
{
printf("gpioCfgClock failed (%d)\n", retval);
return 1;
}
else printf("gpioCfgClock sampling set to 2us okay\n");
retval = gpioInitialise();
if (retval < 0)
{
printf(" gpioInitialise failed (%d)\n", retval);
return 1;
}
gpioSetMode(20, PI_OUTPUT);
// set PWM to zero at the beginning
gpioPWM(20, 0);
// set frequency
retval = gpioSetPWMfrequency(20, 500);
printf("frequency %d set\n", retval);
// set PWM range such that gpioPWM below is in us
retval = gpioSetPWMrange(20, 1e6/500);
printf("range %d set\n", retval);
gpioPWM(20, 950);
printf("pulse width of 950us on GPIO 20 set\n");
while (1)
{
sleep(1);
}
}