I am trying to use the mc33926 library to drive 2 motors. Right now the library is not working with my arduino because my project includes radio modules that use Timer 1 on the Arduino (Timer 1 is used in the mc33926 library). This is creating conflict between the 2 libraries.
Would it be possible to modify the MC33926 library to use Timer 2 instead? If so is there any instruction available to do so? Also could this change introduce additional problems?
I believe that I will have to change the following sections of the library to get it working:
I think those pins need to be changed to 3 and 11 on the Arduino UNO for timer 2.
This statement sets up timer one. I believe TCCR1A and TCCR1B are registers that configure timer 1 but I have been unable to find the configuration registers for timer 2. If anyone is familiar the registers for timer 2 or could point me to the correct portion of the data sheet that would be great.
TCNT2, OCR2A and OCR2B look like they may be useful but I’m not sure.
Here’s what I changed. I was able to figure out that TCCR2A and TCCR2B control timer 2. Also the ICR1 register is not available for timer 2 so I was not able to set a user-defined “top” and just had to go with 0xFF (255)
However, after the modifications were done via a fork of the original from github, I tried to include the library to my arduino and got an error. I then tried with the original pololu library and got another error. Any ideas on why not even the original library could be uploaded? I am haven’t added my own library to arduino before so any advice on that would be appreciated.
I was able to get around my issue of including the library by pasting the cpp and .h files straight into the program folder on my arduino. There were no compile errors. The following screenshot gives the error I was receiving
However when I ran the following example program, the fault function returned a fault and subsequently entered the infinite loop.
It sounds like you did not install the libraries correctly, but moving them into the same folder as your sketch worked for you. If you want to get the library installed normally, let me know, and I can help you with that.
Yes, since you remapped the PWM pins in the MC33926 library, you will have to modify the MC33926 shield to connect your new PWM pins to the proper inputs on the drivers. The “Remapping the Arduino Connections” section you linked to has instructions on how to do that.
I do not think that a wiring error would produce a fault like what you are seeing. The MC33926 reports a fault when it is experiencing an over-temperature condition or short-circuit across its outputs. (You can learn more about the fault inside the datasheet for the MC33926, which we link to under the “Resources” tab of its product page.)
Does the fault still occur if the motor is disconnected? If so, and if you have a multimeter, can you check for a short across the motor outputs while the shield is powered? Can you also remove your shield from your Arduino and post pictures that clearly show both sides of it?
After remapping the board I was able to get it to drive motors properly. It was more difficult to sever the connections than the description made it seem like it would be. I believe that may have been the issue that was causing the faults.
I still was not able to get the library to include as a .zip file but that is not important to me any longer. Below is a link to the modified library I created to use timer 2 in case anyone is interested in how to configure the registers.
If you can find my error that is preventing it from downloading let me know.
The dual-mc33926-motor-shield-master zipped library folder is not intended to be used as-is, though we might update it in the future to work better with the Arduino IDE library manager. We have a short set of instructions that describe how to install that library under the Software section of the shield’s GitHub page. If that is not what you are doing, can you try that method and see if you can get the library to be recognized? If it is not being recognized, can you post pictures that clearly show your Arduino/libraries directory? (For reference, the location of mine is “C:\Users\jon\Documents\Arduino\libraries”.)
I am glad you are able to drive motors from your modified library; thanks for sharing it.