Registered: 1444086789 Posts: 27
Reply with quote #1
Is it possible to use one button to change the power/sensitivity of multiple motors. Specifically, can pressing one digital button cause the wheel motors and an arm motor to all have more sensitivity. I apologize if I am using the wrong term. Also, does the maximum power decrease in this situation.
Thank you Danny
Registered: 1443021001 Posts: 184
Reply with quote #2
I'll walk through some of the steps; The Joystick Analog stick return an 8 bit value from -127 to +127. A joystick button returns a value of 0 or 1, and Simulink probably has a way to detect the press of a button, and the release of a button. Simulink also has a "gear shift" block that probably does what you want. Look for examples that use that. You can probably have different buttons for shift up and shift down for wheels, and two more buttons for shift up /shift down for arm motors. Regarding max power reduction: The motors take an 8 bit value from -127 to +127, which controls the motor output PWM (pulse width modulated) signal. The M29 Motor controller has a tiny cpu that receives the PWM, and drives the H-bridge controls that turn the motor on forward (+127) or backward (-127); The H-bridge output to the motor is also (a different format) PWM, with a period of 1ms, and a duty cycle of -100% to 0% to +100%; since the motor is mostly an inductor, it averages out the pulses to some voltage between - to + battery voltage. The motor port PWM is updated by the master Cortex CPU every 10ms or so. Your program running on the slave Cortex CPU motor speed commands are communicated over a SPI (Serial Port Interface) to the Master CPU. I think I figured out once that the slave CPU to actual motor change can take anywhere between 13-30ms. You can imagine a lookup table with 256 rows, each row has a motor value, and we use the input joystick value to pick which row. A straight linear lookup table has the motor value set to whatever the joystick value is -127 to +127, but it doesn't have to be linear, you can make it S shaped, or parabolic, or whatever. The gear shift function is like swapping to a different lookup table. The slow lookup table might map joystick -127 to +127 to motor values -64 to +64. A deadband function might map the joystick values from -10 to +10 to be motor value of 0, so that nearly center joystick is off; The fast lookup table might map every input > +/-10 to between 64 to 127, so there is no slow speed. Naturally, if you want max power to the motor, you have to set it to 100% PWM = +/-127 motor speed. If want to hold the Arm a one location, that usually requires an angle sensor on the arm, so you know where it is, and if it is moving.
Registered: 1426398216 Posts: 67
Reply with quote #3
Yes, this is very much possible. My understanding is that you want to use a single button to change the "sensitivity" for multiple motors and servos. One method is to just connect the button output to the divide logic for each motor or servo. When the button is pressed, the divider takes affect and reduces (divides) the joystick output going to each motor/servo by whatever amount to want for each one. So, the "sensitivity" can be uniquely programmed for each motor/servo.
You may consider using two buttons to control increase/decrease of sensitivity like jgraber mentioned, like what is done in the Simulink GearShift example model. If you use state flow as in the GearShift example, you can simply include the motor/servo divide logic (math) in the equation for each output of the stateflow diagram that will connect to each motor/servo.
Registered: 1426724490 Posts: 78
Reply with quote #4
As jgraber and gyoung mentioned, the gearshift example (under 'Example Models' from the VEX App) would be helpful, but a more relevant example for what you are asking is the '_halfspeed.slx' model file. This one lets you half the full speed of the motors for the full range of the joystick i.e. divide the motor speed by 2 overall. This way you can drive the motor with more precise control when the speed is halved.
Hope this helps. Sandeep firstname.lastname@example.org