encoder and tachometer class for EW3XX single board computer

Revision:
5:58b13292286e
Parent:
3:b05d231c9549
--- a/EW305sbc.h	Wed Sep 25 16:05:11 2019 +0000
+++ b/EW305sbc.h	Mon Aug 16 11:12:19 2021 +0000
@@ -43,9 +43,21 @@
 #define NONE_REG    0x07    //No Register Selected
 
 
+//=============================================================================
+// AD5293 Command Set - Table 11 of Datasheet Command Operation Truth Table
+//=============================================================================
+#define MAX_SCALE 0.9f
+#define NOP 0x0   // Do nothing
+#define WRDAC 0x1 // Write the contects of the serial register to the RDAC (D9 - D0)
+#define RRDAC 0x2 // Read the RDAC wiper setting from SDO in the next frame
+#define RESET 0x4 // Refresh the RDAC with midscale code
+#define WCON 0x6  // Write contents of serial reg to control reg (D2, D1)
+#define RCON 0x7  // Read control register from SDO output in the next frame
+#define PWDN 0x8  // Software power down (D0=0 normal mode, D0=1 shutdown mode)
+
 
 /**
- * Tach Interface.
+ * Tach and motor control Interface.
  */
 class EW305sbc
 {
@@ -93,7 +105,16 @@
      */
     void LS7366_reset_counter(int chan_num);
     
+    /**
+     * set input voltage to motor
+     */
+    void analog_input(float inp);
     
+    /**
+     * initialize digital potentiometer
+     */
+    void init_ad5293(void);
+    void reset_ad5293(void);
     
 private:
 
@@ -108,6 +129,8 @@
     SPI spi;//(PinName p5,PinName p6,PinName p7);
     DigitalOut ls7166_cs1;//(PinName p19,int tmp=1); //CS for LS7366-1 (U8)
     DigitalOut ls7166_cs2;//(PinName p20, int tmp=1); //CS for LS7366-2 (U9)
+    DigitalOut ad5293_sync; // (p12,1); //CS for Digital potentiometer AD5293
+    DigitalIn ad5293_rdy; // (p27); // data ready input pin from AD5293 digital pot
     
     long         count_;
     float        speed_;
@@ -135,6 +158,13 @@
      * update current speed estimate
      */
     void recalc(void);
+    
+    /**
+     * write data to digital potentiometer
+     */
+    void write_ad5293(int cmd, int data);
+    
+    
 };
 
 #endif /* TACH_H */
\ No newline at end of file