Library for MAX14871 Shield, MAXREFDES89#

Dependencies:   MAX5387 MAX7300

Dependents:   MAXREFDES89_MAX14871_Shield_Demo MAXREFDES89_Test_Program Line_Following_Bot Line_Following_Bot_Pololu

MAXREFDES89# Component Page

Revision:
2:9b50d36d69c8
Parent:
1:7e9b864ddacf
Child:
3:89bf07b855e5
--- a/max14871_shield.cpp	Sun Jul 26 22:19:50 2015 +0000
+++ b/max14871_shield.cpp	Tue Jul 28 03:42:06 2015 +0000
@@ -45,7 +45,7 @@
 
 #include "max14871_shield.h"
 
-#define MIN_PERIOD (0.00002) //50KHz
+#define MIN_PERIOD (0.00002f) //50KHz
 
 //Motor Driver control inputs
 #define MD_EN    (0x01)
@@ -53,7 +53,7 @@
 #define MD_MODE0 (0x04)
 #define MD_MODE1 (0x08)
 
-#define MAX_VREF (2.0)
+#define MAX_VREF (2.0f)
 
 //GPIO Expander Default Configurations
 #define MAX7300_ALL_OUTPUTS    (0x55)
@@ -252,7 +252,7 @@
     {
         vref = MAX_VREF;
     }
-    local_vref = ((uint8_t) ((vref * 255) / 3.3));
+    local_vref = ((uint8_t) ((vref * 255.0f) / 3.3f));
     
     //determine the low port of an 8 bit register to read/write 
     //and digipot associated with motor driver
@@ -469,9 +469,10 @@
     _p_io_expander->enable_transition_detection();
     _p_io_expander->enable_ports();
     
-    //set Vref pin of all motor drivers to 2.0V
-    _p_digi_pot1->write_ch_AB(MAX_VREF);
-    _p_digi_pot2->write_ch_AB(MAX_VREF);
+    //set Vref pin of all motor drivers to 0V, 
+    //internal vref used for current regulation
+    _p_digi_pot1->write_ch_AB(0);
+    _p_digi_pot2->write_ch_AB(0);
     
     //set switching frequency of all motor drivers to 50KHz
     _p_pwm1->period(MIN_PERIOD);