aboutsummaryrefslogtreecommitdiffstats
path: root/System_Python
diff options
context:
space:
mode:
authorRaspberry Pi <pi@umn.edu>2019-10-15 18:46:52 -0500
committerRaspberry Pi <pi@umn.edu>2019-10-15 18:46:52 -0500
commit632729e3396ce834d1201af342cccd7a0dd55c92 (patch)
tree5ee3db98578af0b91fb67f76c14cfbb982be20f3 /System_Python
parentUpdated encoder for proper zero setting and offset behavior. Tested system li... (diff)
downloadee4511w-632729e3396ce834d1201af342cccd7a0dd55c92.tar
ee4511w-632729e3396ce834d1201af342cccd7a0dd55c92.tar.gz
ee4511w-632729e3396ce834d1201af342cccd7a0dd55c92.tar.bz2
ee4511w-632729e3396ce834d1201af342cccd7a0dd55c92.tar.lz
ee4511w-632729e3396ce834d1201af342cccd7a0dd55c92.tar.xz
ee4511w-632729e3396ce834d1201af342cccd7a0dd55c92.tar.zst
ee4511w-632729e3396ce834d1201af342cccd7a0dd55c92.zip
Measured linear movement from physical system. Slightly modified test_Motor to test on physical system.
Diffstat (limited to 'System_Python')
-rw-r--r--System_Python/system.py10
-rw-r--r--System_Python/test_Motor.py10
2 files changed, 9 insertions, 11 deletions
diff --git a/System_Python/system.py b/System_Python/system.py
index 1e532fa..ff38628 100644
--- a/System_Python/system.py
+++ b/System_Python/system.py
@@ -44,8 +44,7 @@ class System:
angular_position = self.encoder_angular.read_position('Degrees')
if angular_position > 180:
angular_position = angular_position - 360
- #linear_position = self.encoder_linear.read_position()
- linear_position = 0
+ linear_position = self.encoder_linear.read_position()
return (angular_position, linear_position)
# END measure()
@@ -70,7 +69,7 @@ class System:
# This class is to help with using an absolute encoder for linear position sensing as assembled in the physical system.
# The function definitions here are the same as with the regular encoder (pseudo-interface).
class Linear_Encoder:
- DIAMETER = 4.0 # MEASURE THIS
+ PROPORTION = 14.5
def __init__(self, clk_pin, cs_pin, data_pin):
self.encoder = Encoder(clk_pin, cs_pin, data_pin)
@@ -95,8 +94,7 @@ class Linear_Encoder:
# We are moving to the left (negative) and have completed a new rotation
self.rotations = self.rotations - 1
# Save the last position for the next calculation
- self.last_position = position
-
+ self.last_position = position
# compute the position based on the system parameters
# linear position = (2pi*r)(n) + (2pi*r)(position/1024) = (2pi*r)(n + position/1024) = (pi*d)(n + position/1024)
- return (math.pi*DIAMETER)*(self.rotations + position/1024)
+ return (PROPORTION)*(self.rotations + position/1024)
diff --git a/System_Python/test_Motor.py b/System_Python/test_Motor.py
index 99db520..80cff1e 100644
--- a/System_Python/test_Motor.py
+++ b/System_Python/test_Motor.py
@@ -11,13 +11,13 @@ m = Motor(speed_pin, forward_pin, reverse_pin)
dir = 'ascending'
speed = 0.0
while 1:
- m.move(speed)
- if speed >= 100.0:
+ if speed >= 15.0:
dir = 'descending'
- elif speed <= -100.0:
+ elif speed <= -15.0:
dir = 'ascending'
if dir == 'ascending':
- speed = speed + 0.5
+ speed = speed + 2.0
else:
- speed = speed - 0.5
+ speed = speed - 2.0
+ m.move(speed)
time.sleep(0.1) \ No newline at end of file