I posted an update to the SmartMotorLibrary today, V1.03.
Change log
Due to the imminent release of ROBOTC V3.60 I had to change some conditional compilation that was based on the version number. V3.60 and greater was originally going to be a version that included PID, the motor types changed in that version to differentiate between port 1 & 10 motors and those on the MC29. ROBOTC with PID is delayed until later this year (although still available as a beta download), however, CMU is probably going to bump the next non-PID version to 3.60 as 3.59 beta has been out for a while now.
I added the ability (although it’s mostly untested) to use a potentiometer as feedback for the rpm calculation. A new function was added, this is from the documentation.
[FONT=“Courier New”]void SmartMotorSetRpmSensor( tMotor index, tSensors port, float ticks_per_rev, bool reversed = false )[/FONT]
This function can be used to assign any sensor to a motor for calculating rpm, the most likely situation would be a potentiometer. The parameter ticks_per_rev is the sensor change for one revolution of the motor, for example, a potentiometer with 1:1 gearing has about 6000 ticks_per_rev, if the gearing was 7:1 then this would be reduced to about 857. Set reversed to true if the potentiometer value decreases with positive motor command values.
it might be used something like this.
// Init the speed and current functions
SmartMotorsInit();
SmartMotorCurrentMonitorEnable();
// set pot1 as sensor for port4
SmartMotorSetRpmSensor( port4, pot1, SMLIB_TPR_POT/8.33, true );
// Run smart motors
SmartMotorRun();
This sets the potentiometer I had called “pot1” to be the rpm sensor for the motor on port4. Ticks per rev were set to SMLIB_TPR_POT/8.33 (SMLIB_TPR_POT is defined as 6000 and 8.33:1 was my gear ratio). I had the pot reversed so set that flag true. Again, this feature is mostly untested so if anyone tries it and it works let me know. You will have to tweak the ticks_per_rev to get accurate results.
version 1.03 include file is here SmartMotorLib.c
updated documentation (it very minor) is here SmartMotorLib_Ed1rev2.pdf
I notice that occasionally the original v1.00 is being downloaded, it has minor bugs so try and avoid using it, I will kill the links sometime but for now they are still valid.