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:49] bob |
beginhere [2020/10/03 21:36] (current) bob |
||
---|---|---|---|
Line 28: | Line 28: | ||
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:// | ||
- | + | {{ ::d7hb.jpg? | |
- | 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 115: | Line 116: | ||
{{ : | {{ : | ||
+ | {{ : | ||
==== Some photos of my Robot ==== | ==== Some photos of my Robot ==== | ||
Line 162: | Line 163: | ||
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) | + | |