This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
beginhere [2020/10/02 21:34] bob |
beginhere [2020/10/03 21:36] (current) bob |
||
---|---|---|---|
Line 10: | Line 10: | ||
==== Needed Parts and Wiring Connection ==== | ==== Needed Parts and Wiring Connection ==== | ||
- | It was not immediately clear to me that Demand Peripherals peripherals and cards were distinct. Peripherals are what is loaded into the FPGA and what your application sees. Cards are circuit boards that attach to the FPGA via ribbon cables. The out4 peripheral makes four FPGA pins outputs and controls their value. The cards that could attach to the out4 peripheral include a quad relay card, a quad open-drain driver, and a general purpose IO card. In my case, I used the dual DC motor controller, dc2, and the dual H-bridge card, the D7Hb. It is easy to think they are the same but they are not. The H-bridge card is also use with the bipolar stepper motor controller. Some peripherals work with only only one cards. For example, the lcd6 peripheral only works with the LCD6 card. | + | It was not immediately clear to me that Demand Peripherals peripherals and cards were distinct. Peripherals are what is loaded into the FPGA and what your application sees. Cards are circuit boards that attach to the FPGA via ribbon cables. The out4 peripheral makes four FPGA pins outputs and controls their value. The cards that could attach to the out4 peripheral include a quad relay card, a quad open-drain driver, and a general purpose IO card. In my case, I used the dual DC motor controller, dc2, and the dual H-bridge card, the D7HB. It is easy to think they are the same but they are not. The H-bridge card is also use with the bipolar stepper motor controller. Some peripherals work with only only one cards. For example, the lcd6 peripheral only works with the LCD6 card. |
For this tutorial, the following parts or devices are used: | For this tutorial, the following parts or devices are used: | ||
- | | + | == Raspberry Pi == |
RPi can be purchased from Amazon and many other websites. I will recommend the latest version of RPi to avoid the current limit problems associated with earlier versions of the RPi. | RPi can be purchased from Amazon and many other websites. I will recommend the latest version of RPi to avoid the current limit problems associated with earlier versions of the RPi. | ||
{{ : | {{ : | ||
- | | + | == FPGA board == |
The project does the quadrature decoding of two motors, and we will use an FPGA to measure the quadrature counts and period. This board can actually control up to 8 different devices simultaneously but we will use only 4 devices in this project. The link of the board is at [[https:// | The project does the quadrature decoding of two motors, and we will use an FPGA to measure the quadrature counts and period. This board can actually control up to 8 different devices simultaneously but we will use only 4 devices in this project. The link of the board is at [[https:// | ||
{{ : | {{ : | ||
- | | + | == Dual DC Motor controller card == |
The Linux API and FPGA parts of the motor controllers are described here: [[https:// | The Linux API and FPGA parts of the motor controllers are described here: [[https:// | ||
+ | {{ :: | ||
- | XXXXXX d7hb photo here XXXXXX | + | == Two motors with quadrature encoders == |
- | - Two motors with quadrature encoders | ||
- | There are various types of motors encoders out there. You can start with inexpensive ones from Amazon or ebay, such as the ones shown below that have Hall effect gear motor encoders. | + | There are various types of motors encoders out there. You can start with inexpensive ones from Amazon or ebay, such as the ones shown below that have Hall effect gear motor encoders. |
- | {{: | + | |
+ | {{: | ||
+ | {{: | ||
One important thing is to do the wire connections correctly. Below image shows the pin number or the wiring of these types of encoder motors. | One important thing is to do the wire connections correctly. Below image shows the pin number or the wiring of these types of encoder motors. | ||
- | {{: | + | {{: |
+ | {{: | ||
Line 48: | Line 50: | ||
The output of wire 3 and 4 are connected to the FPGA-based dual quadrature decoder to measure the rotation speed and distance | The output of wire 3 and 4 are connected to the FPGA-based dual quadrature decoder to measure the rotation speed and distance | ||
- | | + | == Dual Quadrature Decoder |
As a continuation from the previous section, let's look at how to connect the motor encoders to the quadrature decoders. I am using the dual quadrature decoder peripheral at this link [[https:// | As a continuation from the previous section, let's look at how to connect the motor encoders to the quadrature decoders. I am using the dual quadrature decoder peripheral at this link [[https:// | ||
Line 58: | Line 60: | ||
{{: | {{: | ||
- | | + | == LCD screen |
For this project, we will use two LCD displays from this link https:// | For this project, we will use two LCD displays from this link https:// | ||
- | | + | == Connections of all cards and LCD with interface board == |
The images below show the connections between the FPGA card, the dual quadrature decoder interface card, the dual H-bridge card, and two LCD displays. The cards can be connected to different slots according to your personal preferences, | The images below show the connections between the FPGA card, the dual quadrature decoder interface card, the dual H-bridge card, and two LCD displays. The cards can be connected to different slots according to your personal preferences, | ||
Line 76: | Line 79: | ||
Before the installation of dpdaemon, we need to check the available USB devices on RPi. Do not connect the FPGA board yet. Instead open a terminal, and run the command shown below | Before the installation of dpdaemon, we need to check the available USB devices on RPi. Do not connect the FPGA board yet. Instead open a terminal, and run the command shown below | ||
- | '' | + | |
{{ : | {{ : | ||
Line 86: | Line 89: | ||
With known USB device, we will install dpdaemon with following commands. The first line “git clone ….” is to clone the repository into the directory “dpdaemon”, | With known USB device, we will install dpdaemon with following commands. The first line “git clone ….” is to clone the repository into the directory “dpdaemon”, | ||
{{ : | {{ : | ||
- | '' | ||
- | cd dpdaemon | + | git clone https:// |
- | + | | |
- | make | + | make |
- | + | sudo make install | |
- | sudo make install**'' | + | |
Linux binaries are placed in / | Linux binaries are placed in / | ||
Line 108: | Line 109: | ||
Within a short time, you shall receive the image file “DPcore.bin” from the company, and with the file, we can can download the image to the FPGA card with following commands. You shall be able to see one LED turn green as shown image below. | Within a short time, you shall receive the image file “DPcore.bin” from the company, and with the file, we can can download the image to the FPGA card with following commands. You shall be able to see one LED turn green as shown image below. | ||
- | **sudo chmod 666 / | + | |
- | + | stty -F / | |
- | stty -F / | + | cat DPCore.bin > / |
- | + | / | |
- | cat DPCore.bin > / | + | / |
- | + | ||
- | / | + | |
- | + | ||
- | / | + | |
- | **'' | + | |
{{ : | {{ : | ||
+ | {{ : | ||
==== Some photos of my Robot ==== | ==== Some photos of my Robot ==== | ||
Line 139: | Line 135: | ||
With the DPCore.bin image loaded into the FPGA and the green LED lit, you can test everything is working by changing the LEDs on the FPGA card. Try the following commands: | With the DPCore.bin image loaded into the FPGA and the green LED lit, you can test everything is working by changing the LEDs on the FPGA card. Try the following commands: | ||
- | **/ | + | |
- | + | / | |
- | / | + | |
Test the buttons by starting a stream of button data with the commands: | Test the buttons by starting a stream of button data with the commands: | ||
- | **/ | + | |
Press and release the buttons on the FPGA card. You'll see that the buttons are given values of 1, 2, and 4. Use Ctrl^C to return to the command prompt. | Press and release the buttons on the FPGA card. You'll see that the buttons are given values of 1, 2, and 4. Use Ctrl^C to return to the command prompt. | ||
== Test of LCD display. == | == Test of LCD display. == | ||
- | Test the six digit displays with the following commands:** | + | Test the six digit displays with the following commands: |
- | / | + | / |
- | + | / | |
- | / | + | / |
- | + | / | |
- | / | + | |
- | + | ||
- | / | + | |
- | **'' | + | |
== Test of dual quadrature encoders and dual motor controller == | == Test of dual quadrature encoders and dual motor controller == | ||
- | Start by testing the motors with the following commands:** | + | Start by testing the motors with the following commands: |
- | '' | + | / |
- | + | / | |
- | / | + | / |
- | + | / | |
- | / | + | |
- | + | ||
- | / | + | |
At this point both motors should be spinning. If not, verify that there is power to the V+ and V- terminals. Also verify that the H-bridge card is connect to Slot #4. Once the motors are running you can test the quadrature decoders. Open up another terminals window and in that window enter the following commands: | At this point both motors should be spinning. If not, verify that there is power to the V+ and V- terminals. Also verify that the H-bridge card is connect to Slot #4. Once the motors are running you can test the quadrature decoders. Open up another terminals window and in that window enter the following commands: | ||
- | '' | + | |
- | + | / | |
- | / | + | |
A few notes about dc2 and quad2: | A few notes about dc2 and quad2: | ||
+ | * If both control pins for a motor are high, the H-bridge is in brake mode, the power up default. | ||
+ | * If both control pins for a motor are low, the H-bridge is in coast mode. | ||
+ | * The dc2 motor controller has a watchdog timer that shuts off the motors if there is not an update within some specified number of milliseconds. This defaults to off any you have to set the timer value to enable it. | ||
+ | * The quad2 data steam has the count and period for each of the two quadrature decoder. Divide the count by the period to get a fairly accurate estimate of the speed of the motor. This is especially useful when the you have wheel encoders and not motor encoders. | ||
- | - If both control pins for a motor are high, the H-bridge is in brake mode, the power up default. | + | ==== Python Program |
- | - If both control pins for a motor are low, the H-bridge is in coast mode. | + | I decided to put all above shell commands inside a python code. My original plan is to control all things with a single |
- | + | Below Python | |
- | - The dc2 motor controller has a watchdog timer that shuts off the motors if there is not an update within some specified number of milliseconds. This defaults to off any you have to set the timer value to enable it. | + | |
- | + | | |
- | - The quad2 data steam has the count and period for each of the two quadrature decoder. Divide the count by the period to get a fairly accurate estimate of the speed of the motor. This is especially useful when the you have wheel encoders and motor encoders. | + | |
- | + | ||
- | ==== Use Python Program to Control (with videos) ==== | + | |
- | + | ||
- | I decided to put all above shell commands inside a python code. My original plan is to control all things with a single | + | |
- | Below phython | + | |
- | | + | |
- | + | ||
- | | + | |
The links of videos are embedded inside the python code | The links of videos are embedded inside the python code | ||
- | + | | |
- | # one example to use python to control the moving of robot, do this, | + | # one example to use python to control the moving of robot, do this, |
- | # comment out the line " | + | # comment out the line " |
- | # robot will move forward 5 seconds, then reverse 5 seconds | + | # robot will move forward 5 seconds, then reverse 5 seconds |
- | # https:// | + | # https:// |
- | + | ||
- | # two examples to control the decorder with python, do this, | + | # two examples to control the decorder with python, do this, |
- | # keep the line " | + | # keep the line " |
- | # and set sample rate 50 (or 20) at the line os.system (" | + | # and set sample rate 50 (or 20) at the line os.system (" |
- | # https:// | + | # https:// |
- | # https:// | + | # https:// |
- | # you will see robot keeps ouputing counts and times | + | # you will see robot keeps ouputing counts and times |
- | + | ||
- | # to use python to control both robot and encorder | + | # to use python to control both robot and encorder |
- | # you need to do some coding | + | # you need to do some coding |
- | + | ||
- | + | ||
- | import os | + | import os |
- | import time | + | import time |
- | + | ||
- | os.system ("sudo chmod 666 / | + | os.system ("sudo chmod 666 / |
- | os.system ("stty -F / | + | os.system ("stty -F / |
- | os.system ("cat DPCore.bin > / | + | os.system ("cat DPCore.bin > / |
- | os.system (" | + | os.system (" |
- | + | os.system (" | |
- | os.system (" | + | os.system (" |
- | os.system (" | + | |
- | + | while(1): | |
- | while(1): | + | |
- | + | os.system (" | |
- | os.system (" | + | os.system (" |
- | os.system (" | + | os.system (" |
- | os.system (" | + | os.system (" |
- | os.system (" | + | os.system (" |
- | os.system (" | + | os.system (" |
- | os.system (" | + | os.system (" |
- | os.system (" | + | time.sleep(5) |
- | time.sleep(5) | + | os.system (" |
- | os.system (" | + | os.system (" |
- | os.system (" | + | os.system (" |
- | + | os.system (" | |
- | os.system (" | + | os.system (" |
- | os.system (" | + | os.system (" |
- | os.system (" | + | time.sleep(5) |
- | os.system (" | + | |
- | time.sleep(5) | + | |