User Tools

Site Tools


beginhere

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
beginhere [2020/10/02 21:55]
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://demandperipherals.com/peripherals/dc2.html]]. I used the Demand Peripherals dual 7-amp H-bridge card since it interfaces easily to their FPGA card. Other H-bridge cards will work too. The schematics and more information about the D7HB can be found here: [[https://demandperipherals.com/cards/d7hb.html]]. The Linux API and FPGA parts of the motor controllers are described here: [[https://demandperipherals.com/peripherals/dc2.html]]. I used the Demand Peripherals dual 7-amp H-bridge card since it interfaces easily to their FPGA card. Other H-bridge cards will work too. The schematics and more information about the D7HB can be found here: [[https://demandperipherals.com/cards/d7hb.html]].
- +{{ ::d7hb.jpg?direct&200 |}}
-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. 
-{{:motorwheel.png?direct&200|}}{{:gearheadmotor.png?direct&200|}}+ 
 +{{:motorwheel.png?direct&200|}} 
 +{{:gearheadmotor.png?direct&200|}}
  
 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:
    
 {{ :layout2.png?direct&400 |}} {{ :layout2.png?direct&400 |}}
 +{{ :layout2.jpg?direct&400 |}}
  
 ====     Some photos of my Robot ==== ====     Some photos of my Robot ====
Line 165: Line 166:
   * If both control pins for a motor are low, the H-bridge is in coast mode.   * 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 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.+  * 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.
  
-====     Use Python Program to Control (with videos) ====+==== Python Program for Robot Control ====
  
-I decided to put all above shell commands inside a python code. My original plan is to control all things with a single python code, including the maneuvering of robot to move, the collection of encordering readings of two motors, and the output of the encoder readings to two LCD screens. +I decided to put all above shell commands inside a python code. My original plan is to control all things with a single Python code, including the maneuvering of robot to move, the collection of encodering readings of two motors, and the output of the encoder readings to two LCD screens. 
 Below Python code is still ongoing and it is not yet completed. As for now, the code output two dummy data to two LCD screens, and repeat the forward and reverse each for 5 seconds. I still have following pending works to be finished. Below Python code is still ongoing and it is not yet completed. As for now, the code output two dummy data to two LCD screens, and repeat the forward and reverse each for 5 seconds. I still have following pending works to be finished.
-    a. Solve the issue of “dpcat quad 2 counts”. When I execute this line of command, the shell command keep outputting the “counts” and “timing” of two encorders to terminal screens. I need to figure out a way to output the data to variables inside a python, so I can process the variables inside the python. If I am able to do so, I will be able to control the moving of robot precisely.  +    Solve the issue of “dpcat quad 2 counts”. When I execute this line of command, the shell command keep outputting the “counts” and “timing” of two encoders to terminal screens. I need to figure out a way to output the data to variables inside a python, so I can process the variables inside the python. If I am able to do so, I will be able to control the moving of robot precisely.  
- +    Output the encorder readings to LCD screen. This one is to be done after I solve the issue above
-    b. Output the encorder readings to LCD screen. This one is to be done after I solve the issue of (a)+
 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 "os.system ("dpcat quad2 counts") "  +  # comment out the line "os.system ("dpcat quad2 counts") "  
-# robot will move forward 5 seconds, then reverse 5 seconds +  # robot will move forward 5 seconds, then reverse 5 seconds 
-# https://www.youtube.com/watch?v=7hZcdAOTbUg +  # https://www.youtube.com/watch?v=7hZcdAOTbUg 
- +   
-# two examples to control the decorder with python, do this, +  # two examples to control the decorder with python, do this, 
-# keep the line "os.system ("dpcat quad2 counts") "  +  # keep the line "os.system ("dpcat quad2 counts") "  
-# and set sample rate 50 (or 20) at the line os.system ("dpset 5 update_period 50") +  # and set sample rate 50 (or 20) at the line os.system ("dpset 5 update_period 50") 
-# https://www.youtube.com/watch?v=teaGGiQSkis +  # https://www.youtube.com/watch?v=teaGGiQSkis 
-# https://www.youtube.com/watch?v=pTqB3A1N5hY +  # https://www.youtube.com/watch?v=pTqB3A1N5hY 
-# 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 /dev/ttyUSB0") # ttyUSB0 is where the FPGA connect +  os.system ("sudo chmod 666 /dev/ttyUSB0") # ttyUSB0 is where the FPGA connect 
-os.system ("stty -F /dev/ttyUSB0 raw") # no CR-to-CRLF translation +  os.system ("stty -F /dev/ttyUSB0 raw") # no CR-to-CRLF translation 
-os.system ("cat DPCore.bin > /dev/ttyUSB0") # green LED turns on +  os.system ("cat DPCore.bin > /dev/ttyUSB0") # green LED turns on 
-os.system ("dpdaemon -ef &") # -ef so we see error messages +  os.system ("dpdaemon -ef &") # -ef so we see error messages 
- +  os.system ("dpset 4 pwm_frequency 20000") # set the motor pwm frequency 
-os.system ("dpset 4 pwm_frequency 20000") # set the motor pwm frequency +  os.system ("dpset 5 update_period 50") # set the quadrature decorder sampling rate 
-os.system ("dpset 5 update_period 50") # set the quadrature decorder sampling rate +   
- +  while(1): 
-while(1): +   
- +    os.system ("dpset 2 display 2.22222"
-os.system ("dpset 2 display 2.22222"+    os.system ("dpset 3 display 3.33333"
-os.system ("dpset 3 display 3.33333"+    os.system ("dpset 4 mode0 f") 
-os.system ("dpset 4 mode0 f") +    os.system ("dpset 4 mode1 f") 
-os.system ("dpset 4 mode1 f") +    os.system ("dpset 4 power0 50") 
-os.system ("dpset 4 power0 50") +    os.system ("dpset 4 power1 50") 
-os.system ("dpset 4 power1 50") +    os.system ("dpcat quad2 counts") ###  
-os.system ("dpcat quad2 counts") ###  +    time.sleep(5) 
-time.sleep(5) +    os.system ("dpset 4 mode0 b") 
-os.system ("dpset 4 mode0 b") +    os.system ("dpset 4 mode1 b") 
-os.system ("dpset 4 mode1 b") +    os.system ("dpset 4 mode0 r") 
- +    os.system ("dpset 4 mode1 r") 
-os.system ("dpset 4 mode0 r") +    os.system ("dpset 4 power0 50") 
-os.system ("dpset 4 mode1 r") +    os.system ("dpset 4 power1 50") 
-os.system ("dpset 4 power0 50") +    time.sleep(5) 
-os.system ("dpset 4 power1 50") +
-time.sleep(5) +
  
  
  
  
beginhere.1601675705.txt.gz · Last modified: 2020/10/02 21:55 by bob