@@ -119,13 +119,6 @@ def __runInitSequence__(self, **kwargs):
119119
120120 self .DAC = MCP4728 (self .H , 3.3 , 0 )
121121
122- def get_resistance (self ):
123- V = self .get_average_voltage ('RES' )
124- if V > 3.295 : return np .Inf
125- I = (3.3 - V ) / 5.1e3
126- res = V / I
127- return res * self .resistanceScaling
128-
129122 def __print__ (self , * args ):
130123 if self .verbose :
131124 for a in args :
@@ -649,86 +642,6 @@ def __write_data_address__(self, address, value):
649642 self .H .__sendInt__ (value )
650643 self .H .__get_ack__ ()
651644
652- # -------------------------------------------------------------------------------------------------------------------#
653-
654- # |==============================================MOTOR SIGNALLING====================================================|
655- # |Set servo motor angles via SQ1-4. Control one stepper motor using SQ1-4 |
656- # -------------------------------------------------------------------------------------------------------------------#
657-
658- def __stepperMotor__ (self , steps , delay , direction ):
659- self .H .__sendByte__ (CP .NONSTANDARD_IO )
660- self .H .__sendByte__ (CP .STEPPER_MOTOR )
661- self .H .__sendInt__ ((steps << 1 ) | direction )
662- self .H .__sendInt__ (delay )
663-
664- time .sleep (steps * delay * 1e-3 ) # convert mS to S
665-
666- def stepForward (self , steps , delay ):
667- """
668- Control stepper motors using SQR1-4
669-
670- take a fixed number of steps in the forward direction with a certain delay( in milliseconds ) between each step.
671-
672- """
673- self .__stepperMotor__ (steps , delay , 1 )
674-
675- def stepBackward (self , steps , delay ):
676- """
677- Control stepper motors using SQR1-4
678-
679- take a fixed number of steps in the backward direction with a certain delay( in milliseconds ) between each step.
680-
681- """
682- self .__stepperMotor__ (steps , delay , 0 )
683-
684- def servo (self , angle , chan = 'SQ1' ):
685- '''
686- Output A PWM waveform on SQR1/SQR2 corresponding to the angle specified in the arguments.
687- This is used to operate servo motors. Tested with 9G SG-90 Servo motor.
688-
689- .. tabularcolumns:: |p{3cm}|p{11cm}|
690-
691- ============== ============================================================================================
692- **Arguments**
693- ============== ============================================================================================
694- angle 0-180. Angle corresponding to which the PWM waveform is generated.
695- chan 'SQ1' or 'SQ2'. Whether to use SQ1 or SQ2 to output the PWM waveform used by the servo
696- ============== ============================================================================================
697- '''
698- self .pwm_generator .generate (chan , frequency = 100 , duty_cycles = 7.5 + 19 * angle / 180 )
699-
700- def servo4 (self , a1 , a2 , a3 , a4 ):
701- """
702- Operate Four servo motors independently using SQR1, SQR2, SQR3, SQR4.
703- tested with SG-90 9G servos.
704- For high current servos, please use a different power source, and a level convertor for the PWm output signals(if needed)
705-
706- .. tabularcolumns:: |p{3cm}|p{11cm}|
707-
708- ============== ============================================================================================
709- **Arguments**
710- ============== ============================================================================================
711- a1 Angle to set on Servo which uses SQR1 as PWM input. [0-180]
712- a2 Angle to set on Servo which uses SQR2 as PWM input. [0-180]
713- a3 Angle to set on Servo which uses SQR3 as PWM input. [0-180]
714- a4 Angle to set on Servo which uses SQR4 as PWM input. [0-180]
715- ============== ============================================================================================
716-
717- """
718- params = (1 << 5 ) | 2 # continuous waveform. prescaler 2( 1:64)
719- self .H .__sendByte__ (CP .WAVEGEN )
720- self .H .__sendByte__ (CP .SQR4 )
721- self .H .__sendInt__ (10000 ) # 10mS wavelength
722- self .H .__sendInt__ (750 + int (a1 * 1900 / 180 ))
723- self .H .__sendInt__ (0 )
724- self .H .__sendInt__ (750 + int (a2 * 1900 / 180 ))
725- self .H .__sendInt__ (0 )
726- self .H .__sendInt__ (750 + int (a3 * 1900 / 180 ))
727- self .H .__sendInt__ (0 )
728- self .H .__sendInt__ (750 + int (a4 * 1900 / 180 ))
729- self .H .__sendByte__ (params )
730- self .H .__get_ack__ ()
731-
732645 def enableUartPassthrough (self , baudrate , persist = False ):
733646 '''
734647 All data received by the device is relayed to an external port(SCL[TX],SDA[RX]) after this function is called
0 commit comments