Slew Rate Code Help

Hey everyone,
So I decided to try out a slew rate code for my drivetrain this year (making it decelerate to a stop instead of the motors stopping all of a sudden). I tried to use the jpearman’s smart motor code library to use its slew rate function in my code. However when I type the include statement and compile the program,:
#include “Libraries\SmartMotorLib.c”
I get this error message : Couldn’t open ‘#include’ file ‘Libraries\SmartMotorLib.c’
I even checked all the files in the Robot C includes folder but the Smart Motor Library was not there. Do I need to download it from somewhere or is this just a programming error?
Thanks guys!

That means if could not find the directory where the file lives. The PATH variable sets the directories that the file can be found.

Try sticking the library file contents in the same directory with the program you are working on and use the following


#include "SmartMotorLib.c"

Hey there,
Thanks! I have included it successfully now. But, there are a whole bunch of errors popping up within the smart motor library code and most of them are:
Error:Functions must be defined at main scope level
and
Error:Task ‘SmartMotorTask’ is not defined at global scope level

There are about 54-60 errors in total within this code.
Is there any way to get rid of those errors?
Thanks!

Make sure you did not include that file inside a function, it should go near the top of your code just below the #pragma statements.

The issue is resolved. It turns out that as I included the smart motors library, RobotC automatically put the smart motor code under task main(). Getting rid of task main () made it work and everything is sorted now :slight_smile: Thanks to @jpearman and @Team80_Giraffes for helping :slight_smile: