[acme-dev] SF.net SVN: acme-dev:[83] python/fox.py

  • From: claudyus@xxxxxxxxxxxxxxxxxxxxx
  • To: acme-dev@xxxxxxxxxxxxx
  • Date: Sat, 21 May 2011 08:40:41 +0000

Revision: 83
          http://acme-dev.svn.sourceforge.net/acme-dev/?rev=83&view=rev
Author:   claudyus
Date:     2011-05-21 08:40:41 +0000 (Sat, 21 May 2011)

Log Message:
-----------
fox.py: Define step_pwm class as frontend of stepper-drv

Modified Paths:
--------------
    python/fox.py

Modified: python/fox.py
===================================================================
--- python/fox.py       2011-05-21 08:40:26 UTC (rev 82)
+++ python/fox.py       2011-05-21 08:40:41 UTC (rev 83)
@@ -252,3 +252,56 @@
                if (self.have_lowpwr):
                        self.low_pwr.free()
 
+#In
+MOTOR_ENABLE  = 19210
+MOTOR_DIR     = 19211
+MOTOR_PWM_ON  = 19212
+MOTOR_PWN_OFF = 19213
+MOTOR_PWM_SET  = 19214
+MOTOR_RESET  = 19215
+MOTOR_STEPS  = 19216
+MOTOR_START  = 19217
+MOTOR_LOWPWR  = 19218
+
+#Out
+MOTOR_TO_END = 19230
+
+class step_pwm:
+       """ This class allow you to drive a stepper motor using pwm emulation 
driver.\n
+You should load the stepper driver appropriately. the class use the follow 
paramethers as costructor:\n
+     (device_name)\n
+       """
+
+       def __init__ (self,device_name):
+               self.dev_fd_pwm = open (device_name)
+
+       def dir(self, val):
+               fcntl.ioctl(self.dev_fd_pwm, MOTOR_DIR, val)
+
+       def pwm_on(self):
+               fcntl.ioctl(self.dev_fd_pwm, MOTOR_PWM_ON)
+
+       def pwm_off(self):
+               fcntl.ioctl(self.dev_fd_pwm, MOTOR_PWM_OFF)
+
+       def pwm_set(self,val_ns):
+               """set the pulse width, express in ns"""
+               fcntl.ioctl(self.dev_fd_pwm, MOTOR_PWM_SET, val_ns)
+
+       def step_reset (self):
+               fcntl.ioctl(self.dev_fd_pwm, MOTOR_RESET)
+
+       def step_set(self, val):
+               """ set the needed """
+               fcntl.ioctl(self.dev_fd_pwm, MOTOR_STEPS, val)
+
+       def start(self):
+               fcntl.ioctl(self.dev_fd_pwm, MOTOR_START)
+
+       def lowpwr(self):
+               fcntl.ioctl(self.dev_fd_pwm, MOTOR_LOWPWR)
+
+       #output
+       #def to_end(self)
+       #       fcntl.ioctl(self.dev_fd_pwm, MOTOR_TO_END, val)
+       #       return val


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

Other related posts:

  • » [acme-dev] SF.net SVN: acme-dev:[83] python/fox.py - claudyus