Interface the RenBed with a simple optical linear encoder, using X1 encoding.

Dependencies:   SevenSegmentDisplay mbed

This is an example of a copper strip-board design for an optical linear encoder (IRED), and how it is wired up to the Renbed on a breadboard:

/media/uploads/elijahorr/encoderwiring.png

The trimmer potentiometer is used to vary the current through the IRED LEDs, in order to balance out the two output signals.

Files at this revision

API Documentation at this revision

Comitter:
elijahorr
Date:
Thu Sep 08 07:15:57 2016 +0000
Parent:
0:c71cc517659b
Commit message:
first issue

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Mon Sep 05 13:17:15 2016 +0000
+++ b/main.cpp	Thu Sep 08 07:15:57 2016 +0000
@@ -1,11 +1,41 @@
+/*******************************************************************************
+* Program to interface RenBed to a simple optical linear encoder               *
+* Copyright (c) 2016 Elijah Orr                                                *
+*                                                                              *
+* Permission is hereby granted, free of charge, to any person obtaining a copy *
+* of this software and associated documentation files (the "Software"), to deal*
+* in the Software without restriction, including without limitation the rights *
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell    *
+* copies of the Software, and to permit persons to whom the Software is        *
+* furnished to do so, subject to the following conditions:                     *
+*                                                                              *
+* The above copyright notice and this permission notice shall be included in   *
+* all copies or substantial portions of the Software.                          *
+*                                                                              *
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR   *
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,     *
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE  *
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER       *
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,*
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN    *
+* THE SOFTWARE.                                                                *
+*                                                                              *
+* Encoder                                                                      *
+*                                                                              *
+* V1.0 08/09/2016 First issue of code                      Elijah Orr          *
+*******************************************************************************/
+
 #include "mbed.h"
 #include "SevenSegmentDisplay.h"
 
-// define values for high and low analog signals, used to compare to ADC values. 0.56 indicates that the low level is set to 56% of 3.3V.
+/* define values for high and low analog signals, used to compare to ADC values. 0.56 indicates that the low level is set to 56% of 3.3V.
+* you will likely need to change these values for your particular encoder */
 #define SIGNAL_LOW 0.56
 #define SIGNAL_HIGH 0.60
 
 class Encoder{
+
+//public functions and variables can be accessed from anywhere
 public:
     
 /****************************************************************************************************************
@@ -38,7 +68,8 @@
     int get_count(void){
         return count;
     }
-        
+
+//private functions and variables are only accessable from within the encoder class        
 private:
     AnalogIn SignalA;           //analog input for signal A
     AnalogIn SignalB;           //analog input for signal B