shiftPWM Incompatibility

I’m trying to use the shiftPWM library in a project and I can’t get it to compile. I have it working on its own but when I add it to my project I got, “Error compiling for board Arduino/Genuino Uno”.

The other Libraries in the document are Software Serial and NanoPB, I think the issue is it isn’t compatible with Software Serial, but not sure?

I’ve attached the error message.

baperino33:
I've attached the error message.

No, you've attached a picture of the error message ---- useless.

And, you haven't shown us your code at all.

Really, can't help much given what you haven't shown us.

Well no need to be a dick about it :confused:
I have no idea how to use the forum so I’ll copy and paste the lot in.

Code:

#include <trial.pb.h>
#include <pb.h>
#include <pb_common.h>
#include <pb_decode.h>
#include <pb_encode.h>
#include <SoftwareSerial.h>
SoftwareSerial HM10(2, 3); //HM10(Receive Pin, Transmit Pin) 

uint8_t buffer[200];        // Buffer for protobuff message
int j = 0;                  //Variable for number of bytes in message
bool status;

const int shift_RCK = 10;   //Latch Pin
// data pin, MOSI (Master Out Slave In) – master line for sending data, pin 11
// clock pin, is SCK (Serial Clock) – clock pulses which synchronize data transmission, pin 13
const bool ShiftPWM_invertOutputs = false;
const bool ShiftPWM_balanceLoad = false;
#include <ShiftPWM.h>
unsigned char maxPower = 255;
unsigned char pwmFrequency = 75;
unsigned int numRegisters = 2;

float dutyCycle;            //For PWM

void setup(){
 Serial.begin(9600);  // Begin the Serial Monitor connection at 57600bps
 HM10.begin(9600);  // Begin the HM-10 connection at 57600bps

//  ShiftPWM.SetAmountOfRegisters(numRegisters);
//  ShiftPWM.Start(pwmFrequency,maxPower);
 
 setupRoutine();                   //Sync up send and receive programs
}


void loop(){
 while (HM10.available()<10){}      //Wait for whole message to be sent to Bluetooth module
 for (j = 0; j<10; j++){            //Store each byte of the message to the buffer
   buffer[j] = HM10.read();
 }
 
 trial message = trial_init_zero;
 pb_istream_t istream = pb_istream_from_buffer(buffer, sizeof(buffer));      //input stream for writing from the buffer
 status = pb_decode(&istream, trial_fields, &message);                   //decode function
 Serial.println(message.Duty);
 Serial.println(message.button);
 Serial.println("");
 
 dutyCycle = message.Duty * maxPower;
//  ShiftPWM.SetOne(1, dutyCycle);
}


/************************************************************************************************************/
void setupRoutine(){
 Serial.println("Connecting");
 char stat = 'f';
 char state = 'a';
 while (state == 'a'){
   HM10.write(stat);
   delay(50);
   if (HM10.available()){
     state = HM10.read();
     if (state != stat){
       state = 'a';
     }
   }
 }
 Serial.println("Start Main");
}

Error Message:

C:\Users\seanm\AppData\Local\Temp\ccQsk3W6.ltrans0.ltrans.o: In function `ShiftPWM_handleInterrupt':

C:\Users\seanm\Documents\Arduino\libraries\ShiftPWM-master/ShiftPWM.h:110: undefined reference to `ShiftPWM_latchPin'

C:\Users\seanm\Documents\Arduino\libraries\ShiftPWM-master/ShiftPWM.h:110: undefined reference to `ShiftPWM_latchPin'

C:\Users\seanm\AppData\Local\Temp\ccQsk3W6.ltrans0.ltrans.o: In function `global constructors keyed to 65535_0_Receive_Update_ShiftPWM.ino.cpp.o.2418':

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/wiring_digital.c:159: undefined reference to `ShiftPWM_latchPin'

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/wiring_digital.c:159: undefined reference to `ShiftPWM_latchPin'

collect2.exe: error: ld returned 1 exit status

Multiple libraries were found for "trial.pb.h"
Used: C:\Users\seanm\Documents\Arduino\libraries\trial_lib
Multiple libraries were found for "SoftwareSerial.h"
Used: C:\Program
Multiple libraries were found for "ShiftPWM.h"
Used: C:\Users\seanm\Documents\Arduino\libraries\ShiftPWM-master
exit status 1
Error compiling for board Arduino/Genuino Uno.

At the top of this forum page are 3 sticky posts. They are in bold, but I guess, still hard to see. The 1st and 3rd will have information on how to use this forum, how to ask a good question and how to properly post code and error messages. Please read them.

Fixed my last comment to be a little more reader-friendly, any Idea what might be causing this?

Please post a link (using the chain links icon on the forum toolbar to make it clickable) to where you downloaded the ShiftPWM and trial_lib libraries from. Or if you installed it using Library Manger (Sketch > Include Library > Manage Libraries in the Arduino IDE or Libraries > Library Manager in the Arduino Web Editor) then say so and state the full name of the library.

Is the ShiftPWM

The trial library is the Protocol Buffer files

After I install those libraries, compilation of your sketch fails:

sketch_jan12a:1:10: error: trial.pb.h: No such file or directory

 #include <trial.pb.h>

What is the deal with this trial.pb.h file? I can see that you have it installed at C:\Users\seanm\Documents\Arduino\libraries\trial_lib. I need to be able to reproduce your installation before I can investigate the problem you’re having. So please help me to get the libraries I need.

They are files I created using protocol buffers, I don't believe they are the issue here. All they do is encode variables into binary for efficient serial communication between devices.

My question was more wondering if ShiftPWM used timers or interrupts that are incompatible with Software Serial. I suspect that is the problem and was hoping someone might know.

The problem is that you haven't defined ShiftPWM_latchPin in your sketch. This is a global variable the ShiftPWM library uses. Please check the example sketches at File > Examples > ShiftPWM to understand how to use the library.

Hahahaha damn yup fixed it straight away, I had that in my practice code for shiftPWM but must have missed it when merging it into my project. It's always the silly errors that get you.
Good spot, thanks for the help :slight_smile:

Well, much better a silly simple problem than something tricky like an interrupt conflict! I'm glad to hear it's working now. Enjoy!
Per

(deleted)