Friday, June 10, 2016

Angle Encoder




The first thing we want to do is clone the repository:
1. Create a new folder in zynquser where you want to store your new files: zynquser > Angle_Encoder
2. In the terminal, type sudo yum install git in order to install github.
3. Find the directory where you want your files to be save: cd Angle_Encoder
4. In this file, type git clone https://github.com/mf06engl/Angle_Encoder
This clones the files that Mike posted on github into the folder you created.


5. Open Vivado > Open Project > zynquser > Angle_Encoder > Angle_Encoder > Encoder Hardware > Encoder_Hardware.xpr
(Automatically upgrade to current version if need be).
6. If your IP blocks need to be upgraded, click the Show IP Status button near the top of the page, select all the blocks and upgrade them. If there are any warnings click OK.
7. Run synthesis and run implementation.
8. Generate the bitstream.
9. File > Export > Export Hardware to Local Project (include bitstream). If a warning comes up asking if you would like to overwrite a previously made hardware click YES.
10. File > Launch SDK.



Once you open SDK, you should see the application project, board support package, and the hardware platform.
The software code should be located under Encoder Software > src


Next, we need to make sure GTKterm is open in order to read the values that we read from the encoder. 

1. In the terminal, make sure GTKterm is downloaded. If not, go to  http://dl.fedoraproject.org/pub/epel/6/i386/ and search for  epel-release-6-8.noarch.rpm.
2.  Once you locate the previous link, download and install the application. 
3. In the terminal, type sudo yum install gtkterm.
4. Then type the following: 
                       cd ..
                       cd ..
                       cd dev (in zynquser)
                       ls -l ttyACM0
   If the permission are denied (it does not show crw-rw-rw) then type:  
                       sudo chmod 666 ttyACM0


 To connect the angle encoder, we need to use a breadboard and connect wires from the encoder to the pin outs on the PMOD. Using the previous blog post from Sam, 'Connecting the ALPHA Angle Encoder to the Zedboard,' we can see exactly how it's connected. We use pins JA1 and JA2 connected to Prong 1 and 3 respectively while the 2nd Prong is connected to ground.  

Once everything is properly connected to the Zedboard, we can program the Zedboard in SDK and launch the hardware to the board. 

In the GTKterm we can see that it reads an Encoder Value as well as the value of the Angle. We can conclude that each turn either increases or decreases by 7.5 degrees, depending on whether it is turning clockwise or counterclockwise. Each click of a turn on the angle encoder is equivalent to 4 values, so in order to read each single value you must turn the encoder very slowly and carefully.  The Angle Encoder value is the number of clicks that it has turned from its starting position, which should be zero. When it turns clockwise, this value is negative, and when it turns counterclockwise this value is positive.

The values are shown by the lighting of the LEDs, which only light 4 at a time, having the first 2 bits reading the outputs of Pin 1 and Pin 2 respectively, and the 3rd and 4th bits act as place holders. It acts through a process called 'bit shifting,' where it will read the values through Pin 1 and Pin 2 and then for the next turn it will move the previous measurement to the place holder and read another set of values. 

For example, let's say the four bits are numbered 4  3  2  1  , and the first read measurement is 01. The 01 would be placed in spots 2 and 1 and would look like the following: 
0  0  0  1 .  If the next read value is 11, the previous measurement (01) would be shifted from spots 2 and 1 and into spots 4 and 3, while the current measurement replaces it in spots 2 and 1. That would look like the following:  0  1  1  1 . This pattern would continue with every new read value.  

When it is turned clockwise, the LEDs rotate in the following rotation:
                                0 1 1 1 
                                1 1 1 0
                                1 0 0 0 
                                0 0 0 1
 When it is turned counterclockwise, the LED's 
                                1 0 1
                                1 1 0 1
                                0 1 0 0
                                0 0 1 0 





Part 1: The following video is of the angle encoder being rotated counterclockwise

https://www.youtube.com/watch?v=quktJql8WBI


Part 2: The following video is of the angle encoder being rotated clockwise.

https://www.youtube.com/watch?v=kSy4wF8xKa8&spfreload=5











 

1 comment:


  1. I am a university student, I am developing a project in the reading of an encoder from Nexys4 plate in Xilinks platform. I was reading your work and are similar to what I intend . Will could help me ?

    ReplyDelete