Wicked Device Motor Shield
Software Library for Wicked Device Motor Shield
WickedMotorShield.cpp
Go to the documentation of this file.
1 /**
2  * @mainpage
3  * This is the code for the motor shield by Wicked Device.
4  *
5  * The following are my questions about the code.
6  * - It is assumed that this code applies to both the MOTO4 (4 DC motors)
7  * and MOTO6 (6 DC motors). Is this correct, or are any modifications
8  * required?
9  * - What are hard brake and soft brake? Does hard brake refer to
10  * dynamic braking where the leads of the DC motor are wired together?
11  * Does the setting of the pulse width modulation (PWM pin) affect the
12  * percentage of the time that the leads are connected? Does soft
13  * brake mean that the leads to the DC motor are isolated from grounds
14  * and voltage sources.
15  * - In Wicked_DCMotor#setBrake(), the value of the previous value of
16  * the direction bit should be copied to WickedMotorShield#old_dir only
17  * if the brake bit was previously clear (indicating BRAKE_OFF) and the BRAKE_HARD or
18  * BRAKE_SOFT condition is the new brake condition. It appears that the
19  * WickedMotorShield#old_dir value is currently updated if going from
20  * BRAKE_SOFT to BRAKE_HARD or from BRAKE_HARD to BRAKE_SOFT.
21  * - It appears that either the brake status should be set to #BRAKE_OFF
22  * when the direction is set or no action should be taken if the brake status
23  * is not #BRAKE_OFF.
24  * - Are the alternate pins for use with the Arduino Mega? If the alternate
25  * pins are to be used, how is this represented in the position of the
26  * the jumpers? Is some other method used to indicate the use of
27  * alternate pin locations?
28  * - Can I use the two RC in pins to provide for two way communication using I2C
29  * with another device such as a Bluetooth serial card? Should the configuration
30  * of the pins be removed from the constructor since the motor shield library does
31  * not use them. The pins would then be configured by the software that
32  * communicates with the outside world.
33  * @file
34  */
35 /* Copyright (C) 2014 by Victor Aprea <victor.aprea@wickeddevice.com>
36 
37 Permission is hereby granted, free of charge, to any person obtaining
38 a copy of this software and associated documentation files (the
39 "Software"), to deal in the Software without restriction, including
40 without limitation the rights to use, copy, modify, merge, publish,
41 distribute, sublicense, and/or sell copies of the Software, and to
42 permit persons to whom the Software is furnished to do so, subject to
43 the following conditions:
44 
45 The above copyright notice and this permission notice shall be
46 included in all copies or substantial portions of the Software.
47 
48 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
49 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
50 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
51 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
52 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
53 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
54 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
55 
56 #include "WickedMotorShield.h"
57 /**
58  * Clock pin used for loading shift registers.
59  */
60 #define SERIAL_CLOCK_PIN (2)
61 /**
62  * Latch pin used for loading shift registers.
63  */
64 #define SERIAL_LATCH_PIN (7)
65 
66 #define OPERATION_CLEAR (0)
67 #define OPERATION_SET (1)
68 #define OPERATION_NONE (2)
69 /**
70  * Contains direction and brake status for motors
71  * #M1, #M2, #M3, and #M4.
72  */
74 /**
75  * Contains direction and brake status for motors
76  * #M5 and #M6.
77  */
79 /**
80  * Digital Arduino pin used to send data to motor shield.
81  *
82  * Pin 12 for standard pins, pin 0 for alternate pins.
83  */
85 /**
86  * Digital pin used for Radio Control Input Pin 1.
87  *
88  * Pin 4 used for standard pins, pin 3 for alternate pins.
89  */
91 /**
92  * Digital pin used for Radio Control Input Pin 2.
93  *
94  * Pin 8 used for standard pins, pin 11 for alternate pins.
95  */
97 /**
98  * Digital pin for M1 PWM (pulse width modulation).
99  *
100  * Pin 11 for standard pins, use pin 8 for alternate pins.
101  */
102 uint8_t WickedMotorShield::M1_PWM_PIN = 11;
103 /**
104  * Digital pin for M6 PWM (pulse width modulation).
105  *
106  * Pin 3 for standard pins, pin 4 for alternate pins.
107  */
109 /**
110  * Contains the old value of the direction bit if the
111  * value of the brake bit is changed from 0 to 1.
112  *
113  * When the brake bit is changed from 0 to 1, the
114  * direction bit indicates whether it is BRAKE_SOFT or
115  * BRAKE_HARD. If the direction bit wasn't copied to
116  * this array, the value would be lost.
117  */
118 uint8_t WickedMotorShield::old_dir[6] = {0,0,0,0,0,0};
119 
120 /**
121  * Constructor for WickedMotorShield, which has Wicked_DCMotor and
122  * Wicked_Stepper as subclasses.
123  *
124  * @param use_alternate_pins if the value is equal to #USE_ALTERNATE_PINS,
125  * the values used for WickedMotorShield#SERIAL_DATA_PIN,
126  * WickedMotorShield#RCIN1_PIN, WickedMotorShield#RCIN2_PIN,
127  * WickedMotorShield#M1_PWM_PIN, and WickedMotorShield#M6_PWM_PIN
128  * changed to an alternate set.
129  *
130  * <table>
131  * <tr><td>Symbol</td><td>Standard</td><td>Alternate</td></tr>
132  * <tr><td>WickedMotorShield#SERIAL_DATA_PIN</td><td>12</td><td>0</td></tr>
133  * <tr><td>WickedMotorShield#RCIN1_PIN</td><td>4</td><td>3</td></tr>
134  * <tr><td>WickedMotorShield#RCIN2_PIN</td><td>8</td><td>11</td></tr>
135  * <tr><td>WickedMotorShield#M1_PWM_PIN</td><td>11</td><td>8</td></tr>
136  * <tr><td>#M2_PWM_PIN</td><td>9</td><td>9</td></tr>
137  * <tr><td>#M3_PWM_PIN</td><td>5</td><td>5</td></tr>
138  * <tr><td>#M4_PWM_PIN</td><td>10</td><td>10</td></tr>
139  * <tr><td>#M5_PWM_PIN</td><td>6</td><td>6</td></tr>
140  * <tr><td>WickedMotorShield#M6_PWM_PIN</td><td>3</td><td>4</td></tr>
141  * </table>
142  *
143  * <p>Pins 4 and 8 do not support PWM on Arduino Uno R3 microcontroller board.
144  * However, all of these pins support PWM on the
145  * <a href="https://www.electroschematics.com/arduino-mega-2560-pinout/" target="_blank">
146  * Arduino Mega</a></p>
147  */
148 WickedMotorShield::WickedMotorShield(uint8_t use_alternate_pins){
149 
150  if( use_alternate_pins == USE_ALTERNATE_PINS){
156  }
157 
158  // intialize pins
159  pinMode(SERIAL_CLOCK_PIN, OUTPUT);
160  pinMode(SERIAL_LATCH_PIN, OUTPUT);
161  pinMode(SERIAL_DATA_PIN, OUTPUT);
162 
163  pinMode(RCIN1_PIN, INPUT);
164  pinMode(RCIN2_PIN, INPUT);
165 
166  for(uint8_t ii = 0; ii < 6; ii++){
167  old_dir[ii] = DIR_CW; // initial direction coming out of brake is clockwise
168  }
169 
170  // load the initial values so the motors are set to a brake state initially
172 }
173 /**
174  * Load the contents of second_shift_register and first_shift_register to the
175  * motor shield using SERIAL_LATCH_PIN, SERIAL_DATA_PIN, and SERIAL_CLOCK_PIN
176  * pins.
177  *
178  * Data is only moved from the memory values on the Arduino board to the
179  * motor shield. No data is moved in the other direction.
180  */
182  digitalWrite(SERIAL_LATCH_PIN, LOW);
185  digitalWrite(SERIAL_LATCH_PIN, HIGH);
186 }
187 /**
188  * Get the shift register information for a specific motor.
189  * @param motor_number Number of motor for which information is desired.
190  *
191  * The information for motors M1 to M4 are contained in the first shift
192  * register. The information for motors M5 and M6 is contained in the
193  * second shift register.
194  */
195 uint8_t WickedMotorShield::get_shift_register_value(uint8_t motor_number){
196  uint8_t temp = first_shift_register;
197  if(motor_number == M5 || motor_number == M6){
198  temp = second_shift_register;
199  }
200 
201  return temp;
202 }
203 /**
204  * Copy the shift register data for the specified motor into the correct data structure.
205  *
206  * @param motor_number number of motor for which data has been modified.
207  * @param value information to be moved to shift register.
208  */
209 void WickedMotorShield::set_shift_register_value(uint8_t motor_number, uint8_t value){
210  if(motor_number == M5 || motor_number == M6){
211  second_shift_register = value;
212  }
213  else{
214  first_shift_register = value;
215  }
216 }
217 
218 /**
219  * Carry out bitwise or/and operation .
220  * @param shift_register_value Address of shift register to be altered.
221  * This will be the address of either WickedDeviceShield#first_shift_register
222  * or WickedDeviceShield#second_shift_register. Only the bit whose location is
223  * given by the mask parameter will be altered.
224  * @param mask with bit set in position to be changed.
225  * @param operation flag indicating whether bit to be set (#OPERATION_SET)
226  * or cleared (#OPERATION_CLEAR). A value of #OPERATION_NONE indicates
227  * that no action is to be taken.
228  *
229  * If operation clear do a bitwise and operation on the shift register byte
230  * and the mask with all bits inverted. In the inverted mask, the bit to be cleared
231  * is 0 and the other bits are 1.
232  *
233  * If operation set do a bitwise or operation on the shift register byte and the
234  * mask. The mask has a one in the bit of the shift register to be set to be set.
235  */
236 void WickedMotorShield::apply_mask(uint8_t * shift_register_value, uint8_t mask, uint8_t operation){
237  switch(operation){
238  case OPERATION_CLEAR:
239  *shift_register_value &= ~mask;
240  break;
241  case OPERATION_SET:
242  *shift_register_value |= mask;
243  break;
244  case OPERATION_NONE:
245  // do nothing
246  break;
247  }
248 }
249 /**
250  * Apply a mask to an eight bit integer using bitwise and.
251  * @param shift_register_value byte to which mask is to be applied
252  * @param mask byte containing mask to be applied
253  * @return 0 if bit indicated by mask is 0, otherwise return 1
254  */
255 uint8_t WickedMotorShield::filter_mask(uint8_t shift_register_value, uint8_t mask){
256  if((shift_register_value & mask) == 0){
257  return 0;
258  }
259 
260  // else
261  return 1;
262 }
263 
264 uint32_t WickedMotorShield::getRCIN(uint8_t rc_input_number, uint32_t timeout){
265 
266  uint8_t rc_input_pin = get_rc_input_pin(rc_input_number);
267  if(rc_input_pin == 0xff){
268  return 0xffffffff; //invalid RCIN number
269  }
270 
271  if(timeout == 0){
272  return pulseIn(rc_input_pin, HIGH);
273  }
274 
275  //else
276  return pulseIn(rc_input_pin, HIGH, timeout);
277 }
278 
279 uint8_t WickedMotorShield::get_rc_input_pin(uint8_t rc_input_number){
280  if(rc_input_number == RCIN1){
281  return RCIN1_PIN;
282  }
283  else if(rc_input_number == RCIN2){
284  return RCIN2_PIN;
285  }
286 
287  //else
288  return 0xff;
289 }
290 
291 // for pwm value use a value between 0 and 255
292 void WickedMotorShield::setSpeedM(uint8_t motor_number, uint8_t pwm_val){
293  switch(motor_number){
294  case M1:
295  analogWrite(M1_PWM_PIN, pwm_val);
296  break;
297  case M2:
298  analogWrite(M2_PWM_PIN, pwm_val);
299  break;
300  case M3:
301  analogWrite(M3_PWM_PIN, pwm_val);
302  break;
303  case M4:
304  analogWrite(M4_PWM_PIN, pwm_val);
305  break;
306  case M5:
307  analogWrite(M5_PWM_PIN, pwm_val);
308  break;
309  case M6:
310  analogWrite(M6_PWM_PIN, pwm_val);
311  break;
312  }
313 }
314 /**
315  * Set the value for the direction in Mx_DIR_MASK bit and the element of the
316  * old_dir directory.
317  * @param motor_number number of motor for which direction is to be set
318  * @param direction value to be set for direction (#DIR_CW or #DIR_CCW). The
319  * value of DIR_CW is 1 while the value for DIR_CCW is set to 0.
320  *
321  * Change Jan, 2020 - No action to be taken if brake bit is set.
322  *
323  * This needs to be reviewed. Either the brake status should be set to #BRAKE_OFF
324  * when the direction is set or no action should be taken if the brake status
325  * is not #BRAKE_OFF. Should the brake status always be changed to BRAKE_OFF
326  * if this method is called.
327  */
328 void WickedMotorShield::setDirectionData(uint8_t motor_number, uint8_t direction){
329  uint8_t shift_register_value = get_shift_register_value(motor_number);
330  uint8_t * p_shift_register_value = &shift_register_value;
331  uint8_t dir_operation = OPERATION_NONE;
332  uint8_t brake_status = getMotorBrakeM(motor_number);
333 
334 
335  if(motor_number >= 6){
336  return; // invalid motor_number, go no further
337  }
338  if (brake_status > 0) { return; }
339  //TODO: is this the "correct" sense of DIR_CW / DIR_CCW
340  // this explicitly becomes the old direction value
341  if(direction == DIR_CW){
342  dir_operation = OPERATION_SET;
343  old_dir[motor_number] = 1;
344  }
345  else if(direction == DIR_CCW){
346  dir_operation = OPERATION_CLEAR;
347  old_dir[motor_number] = 0;
348  }
349 
350  switch(motor_number){
351  case M1:
352  apply_mask(p_shift_register_value, M1_DIR_MASK, dir_operation);
353  break;
354  case M2:
355  apply_mask(p_shift_register_value, M2_DIR_MASK, dir_operation);
356  break;
357  case M3:
358  apply_mask(p_shift_register_value, M3_DIR_MASK, dir_operation);
359  break;
360  case M4:
361  apply_mask(p_shift_register_value, M4_DIR_MASK, dir_operation);
362  break;
363  case M5:
364  apply_mask(p_shift_register_value, M5_DIR_MASK, dir_operation);
365  break;
366  case M6:
367  apply_mask(p_shift_register_value, M6_DIR_MASK, dir_operation);
368  break;
369  }
370 
371  set_shift_register_value(motor_number, shift_register_value);
372 }
373 /**
374  * Set the contents of the shift_registers to indicate the desired brake condition.
375  * @param motor_number number of motor for which data is to be set
376  * @param brake_type value is #BRAKE_OFF, BRAKE_HARD, or #BRAKE_SOFT. Value is
377  * the new brake condition.
378  *
379  * Change Jan, 2020 : The value of #WickedMotorShield#old_dir is only changed if brake status is
380  * changed from #BRAKE_OFF to (#BRAKE_HARD or #BRAKE_SOFT) or from
381  * (#BRAKE_HARD or #BRAKE_SOFT) to #BRAKE_OFF.
382  */
383 void WickedMotorShield::setBrakeData(uint8_t motor_number, uint8_t brake_type){
384  uint8_t shift_register_value = get_shift_register_value(motor_number);
385  uint8_t * p_shift_register_value = &shift_register_value;
386  uint8_t brake_operation = OPERATION_NONE;
387  uint8_t dir_operation = OPERATION_NONE;
388 
389  if(motor_number >= 6){
390  return; // invalid motor_number, go no further
391  }
392 
393  // calculate the affect on the relevant shift register bits
394  // TODO: Merging this if/else with next if/else would make code more readable
395  if(brake_type == BRAKE_OFF){
396  brake_operation = OPERATION_CLEAR;
397  dir_operation = OPERATION_NONE;
398  }
399  else if(brake_type == BRAKE_SOFT){
400  brake_operation = OPERATION_SET;
401  dir_operation = OPERATION_CLEAR;
402 
403  }
404  else if(brake_type == BRAKE_HARD){
405  brake_operation = OPERATION_SET;
406  dir_operation = OPERATION_SET;
407  }
408  uint8_t brake_status = getMotorBrakeM(motor_number);
409 
410  // save / restore directionality
411  // we already know motor_number is a safe index into old_dir because we checked earlier
412  if(brake_type == BRAKE_OFF && brake_status > 0){
413  // when clearing the brake, restore the old_dir value
414  if(old_dir[motor_number] == 1){
415  dir_operation = OPERATION_SET;
416  }
417  else{
418  dir_operation = OPERATION_CLEAR;
419  }
420  }
421  else if(brake_status == 0 && ((brake_type == BRAKE_SOFT) || (brake_type == BRAKE_HARD))){
422  // when applying the brake, save the old_dir value
423  old_dir[motor_number] = get_motor_directionM(motor_number);
424  }
425 
426  switch(motor_number){
427  case M1:
428  apply_mask(p_shift_register_value, M1_BRAKE_MASK, brake_operation);
429  apply_mask(p_shift_register_value, M1_DIR_MASK, dir_operation);
430  break;
431  case M2:
432  apply_mask(p_shift_register_value, M2_BRAKE_MASK, brake_operation);
433  apply_mask(p_shift_register_value, M2_DIR_MASK, dir_operation);
434  break;
435  case M3:
436  apply_mask(p_shift_register_value, M3_BRAKE_MASK, brake_operation);
437  apply_mask(p_shift_register_value, M3_DIR_MASK, dir_operation);
438  break;
439  case M4:
440  apply_mask(p_shift_register_value, M4_BRAKE_MASK, brake_operation);
441  apply_mask(p_shift_register_value, M4_DIR_MASK, dir_operation);
442  break;
443  case M5:
444  apply_mask(p_shift_register_value, M5_BRAKE_MASK, brake_operation);
445  apply_mask(p_shift_register_value, M5_DIR_MASK, dir_operation);
446  break;
447  case M6:
448  apply_mask(p_shift_register_value, M6_BRAKE_MASK, brake_operation);
449  apply_mask(p_shift_register_value, M6_DIR_MASK, dir_operation);
450  break;
451  }
452 
453  set_shift_register_value(motor_number, shift_register_value);
454 }
455 /**
456  * Return motor direction for a specific motor.
457  * @param motor_number integer representing motor
458  * @return shift register value for motor having done a bitwise
459  * and operation with the direction mask for the motor. Value will
460  * zero if direction bit is set (counter clockwise).
461  * Otherwise it will be greater than zero
462  * if direction bit is not set (clockwise).
463  */
464 uint8_t WickedMotorShield::get_motor_directionM(uint8_t motor_number){
465  uint8_t shift_register_value = get_shift_register_value(motor_number);
466 
467  switch(motor_number){
468  case M1:
469  return filter_mask(shift_register_value, M1_DIR_MASK);
470  case M2:
471  return filter_mask(shift_register_value, M2_DIR_MASK);
472  case M3:
473  return filter_mask(shift_register_value, M3_DIR_MASK);
474  case M4:
475  return filter_mask(shift_register_value, M4_DIR_MASK);
476  case M5:
477  return filter_mask(shift_register_value, M5_DIR_MASK);
478  case M6:
479  return filter_mask(shift_register_value, M6_DIR_MASK);
480  }
481 
482  return 0xff; // indicate error - bad motor_number argument
483 
484 }
485 /**
486  * Return motor brake status for a specific motor.
487  * @param motor_number integer representing motor
488  * @return shift register value for motor having done a bitwise
489  * and operation with the brake mask for the motor. This
490  * will be zero if the brake bit is not set and greater
491  * than zero if the brake bit is set.
492  */
493 uint8_t WickedMotorShield::get_motor_brakeM(uint8_t motor_number){
494  uint8_t shift_register_value = get_shift_register_value(motor_number);
495 
496  switch(motor_number){
497  case M1:
498  return filter_mask(shift_register_value, M1_BRAKE_MASK);
499  case M2:
500  return filter_mask(shift_register_value, M2_BRAKE_MASK);
501  case M3:
502  return filter_mask(shift_register_value, M3_BRAKE_MASK);
503  case M4:
504  return filter_mask(shift_register_value, M4_BRAKE_MASK);
505  case M5:
506  return filter_mask(shift_register_value, M5_BRAKE_MASK);
507  case M6:
508  return filter_mask(shift_register_value, M6_BRAKE_MASK);
509  }
510 
511  return 0xff; // indicate error - bad motor_number argument
512 
513 }
514 
515 /**
516  * Version number is hard-coded to a value of 1.
517  */
519  return 1;
520 }
521 
522 
523 
524 Wicked_Stepper::Wicked_Stepper(uint16_t number_of_steps, uint8_t m1, uint8_t m2, uint8_t use_alternate_pins)
525  :WickedMotorShield(use_alternate_pins){
526 
527  this->step_number = 0; // which step the motor is on
528  this->speed = 0; // the motor speed, in revolutions per minute
529  this->direction = 0; // motor direction
530  this->last_step_time = 0; // time stamp in ms of the last step taken
531  this->number_of_steps = number_of_steps; // total number of steps for this motor
532 
533  this->m1 = m1;
534  this->m2 = m2;
535 
536  setSpeedM(m1, 255);
537  setSpeedM(m2, 255);
543 }
544 
545 void Wicked_Stepper::setSpeed(uint32_t speed){
546  this->step_delay = 60L * 1000L / this->number_of_steps / speed;
547 }
548 
549 void Wicked_Stepper::step(int16_t number_of_steps){
550  int steps_left = abs(number_of_steps); // how many steps to take
551 
552  // determine direction based on whether steps_to_mode is + or -:
553  if (number_of_steps > 0) {this->direction = 1;}
554  if (number_of_steps < 0) {this->direction = 0;}
555 
556 
557  // decrement the number of steps, moving one step each time:
558  while(steps_left > 0) {
559  // move only if the appropriate delay has passed:
560  if (millis() - this->last_step_time >= this->step_delay) {
561  // get the timeStamp of when you stepped:
562  this->last_step_time = millis();
563  // increment or decrement the step number,
564  // depending on direction:
565  if (this->direction == 1) {
566  this->step_number++;
567  if (this->step_number == this->number_of_steps) {
568  this->step_number = 0;
569  }
570  }
571  else {
572  if (this->step_number == 0) {
573  this->step_number = this->number_of_steps;
574  }
575  this->step_number--;
576  }
577  // decrement the steps left:
578  steps_left--;
579  // step the motor to step number 0, 1, 2, or 3:
580  stepMotor(this->step_number % 4);
581  }
582  }
583 }
584 
585 //TODO: convert the code below into analogous shift register loads
586 void Wicked_Stepper::stepMotor(int this_step){
587  switch (this_step) {
588  case 0: // 1010
591  break;
592  case 1: // 0110
595  break;
596  case 2: // 0101
599  break;
600  case 3: // 1001
603  break;
604  }
605 
607 }
608 
609 
610 Wicked_DCMotor::Wicked_DCMotor(uint8_t motor_number, uint8_t use_alternate_pins)
611  :WickedMotorShield(use_alternate_pins){
612 
613  this->motor_number = motor_number;
614 }
615 
616 // for direction use one of the symbols: DIR_CW, DIR_CC
617 void Wicked_DCMotor:: setDirection(uint8_t direction){
618  setDirectionData(motor_number, direction);
620 }
621 
622 // for brake_type use one of the symbols: HARD, SOFT, OFF
623 void Wicked_DCMotor::setBrake(uint8_t brake_type){
624  setBrakeData(motor_number, brake_type);
626 }
627 
630 }
631 
633  switch(motor_number){
634  case M1:
635  return analogRead(A0);
636  case M2:
637  return analogRead(A2);
638  case M3:
639  return analogRead(A1);
640  case M4:
641  return analogRead(A3);
642  case M5:
643  return analogRead(A4);
644  case M6:
645  return analogRead(A5);
646  }
647 
648  return 0xffff; // indicate error - bad motor_number argument
649 }
650 
651 void Wicked_DCMotor::setSpeed(uint8_t pwm_val){
652  setSpeedM(motor_number, pwm_val);
653 }
M1
#define M1
Definition: WickedMotorShield.h:51
Wicked_Stepper::Wicked_Stepper
Wicked_Stepper(uint16_t number_of_steps, uint8_t m1, uint8_t m2, uint8_t use_alternate_pins=0)
Definition: WickedMotorShield.cpp:524
M4
#define M4
Definition: WickedMotorShield.h:63
M5_PWM_PIN
#define M5_PWM_PIN
Definition: WickedMotorShield.h:183
BRAKE_HARD
#define BRAKE_HARD
Definition: WickedMotorShield.h:43
BRAKE_OFF
#define BRAKE_OFF
Definition: WickedMotorShield.h:39
WickedMotorShield::load_shift_register
void load_shift_register(void)
Definition: WickedMotorShield.cpp:181
WickedMotorShield::second_shift_register
static uint8_t second_shift_register
Definition: WickedMotorShield.h:200
Wicked_Stepper::setSpeed
void setSpeed(uint32_t speed)
Definition: WickedMotorShield.cpp:545
WickedMotorShield::get_motor_brakeM
uint8_t get_motor_brakeM(uint8_t motor_number)
Definition: WickedMotorShield.cpp:493
WickedMotorShield::SERIAL_DATA_PIN
static uint8_t SERIAL_DATA_PIN
Definition: WickedMotorShield.h:201
WickedMotorShield::RCIN1_PIN
static uint8_t RCIN1_PIN
Definition: WickedMotorShield.h:202
M2_BRAKE_MASK
#define M2_BRAKE_MASK
Definition: WickedMotorShield.h:122
WickedMotorShield::RCIN2_PIN
static uint8_t RCIN2_PIN
Definition: WickedMotorShield.h:203
M2
#define M2
Definition: WickedMotorShield.h:55
DIR_CCW
#define DIR_CCW
Definition: WickedMotorShield.h:35
BRAKE_SOFT
#define BRAKE_SOFT
Definition: WickedMotorShield.h:47
Wicked_DCMotor::motor_number
uint8_t motor_number
Definition: WickedMotorShield.h:257
WickedMotorShield::apply_mask
void apply_mask(uint8_t *shift_register_value, uint8_t mask, uint8_t operation)
Definition: WickedMotorShield.cpp:236
Wicked_DCMotor::currentSense
uint16_t currentSense(void)
Definition: WickedMotorShield.cpp:632
WickedMotorShield
Definition: WickedMotorShield.h:197
M5_DIR_MASK
#define M5_DIR_MASK
Definition: WickedMotorShield.h:159
M2_DIR_MASK
#define M2_DIR_MASK
Definition: WickedMotorShield.h:115
USE_ALTERNATE_PINS
#define USE_ALTERNATE_PINS
Definition: WickedMotorShield.h:195
M6_DIR_MASK
#define M6_DIR_MASK
Definition: WickedMotorShield.h:145
SERIAL_CLOCK_PIN
#define SERIAL_CLOCK_PIN
Definition: WickedMotorShield.cpp:60
WickedMotorShield::setDirectionData
void setDirectionData(uint8_t motor_number, uint8_t direction)
Definition: WickedMotorShield.cpp:328
WickedMotorShield::version
static uint8_t version(void)
Definition: WickedMotorShield.cpp:518
OPERATION_SET
#define OPERATION_SET
Definition: WickedMotorShield.cpp:67
Wicked_Stepper::speed
uint16_t speed
Definition: WickedMotorShield.h:239
WickedMotorShield::get_shift_register_value
uint8_t get_shift_register_value(uint8_t motor_number)
Definition: WickedMotorShield.cpp:195
DIR_CW
#define DIR_CW
Definition: WickedMotorShield.h:37
M3_BRAKE_MASK
#define M3_BRAKE_MASK
Definition: WickedMotorShield.h:136
WickedMotorShield::M1_PWM_PIN
static uint8_t M1_PWM_PIN
Definition: WickedMotorShield.h:210
RCIN1
#define RCIN1
Definition: WickedMotorShield.h:185
WickedMotorShield.h
WickedMotorShield::setSpeedM
void setSpeedM(uint8_t motor_number, uint8_t pwm_val)
Definition: WickedMotorShield.cpp:292
M5_BRAKE_MASK
#define M5_BRAKE_MASK
Definition: WickedMotorShield.h:166
WickedMotorShield::getRCIN
static uint32_t getRCIN(uint8_t rc_input_number, uint32_t timeout=0)
Definition: WickedMotorShield.cpp:264
M4_DIR_MASK
#define M4_DIR_MASK
Definition: WickedMotorShield.h:80
RCIN2
#define RCIN2
Definition: WickedMotorShield.h:186
WickedMotorShield::set_shift_register_value
void set_shift_register_value(uint8_t motor_number, uint8_t value)
Definition: WickedMotorShield.cpp:209
Wicked_Stepper::stepMotor
void stepMotor(int this_step)
Definition: WickedMotorShield.cpp:586
WickedMotorShield::filter_mask
uint8_t filter_mask(uint8_t shift_register_value, uint8_t mask)
Definition: WickedMotorShield.cpp:255
Wicked_Stepper::step_number
uint16_t step_number
Definition: WickedMotorShield.h:242
OPERATION_NONE
#define OPERATION_NONE
Definition: WickedMotorShield.cpp:68
M3_DIR_MASK
#define M3_DIR_MASK
Definition: WickedMotorShield.h:129
M4_PWM_PIN
#define M4_PWM_PIN
Definition: WickedMotorShield.h:179
M1_DIR_MASK
#define M1_DIR_MASK
Definition: WickedMotorShield.h:94
Wicked_DCMotor::get_motor_direction
uint8_t get_motor_direction(void)
Definition: WickedMotorShield.cpp:628
WickedMotorShield::old_dir
static uint8_t old_dir[6]
Definition: WickedMotorShield.h:216
Wicked_DCMotor::setDirection
void setDirection(uint8_t direction)
Definition: WickedMotorShield.cpp:617
Wicked_Stepper::step
void step(int16_t number_of_steps)
Definition: WickedMotorShield.cpp:549
M4_BRAKE_MASK
#define M4_BRAKE_MASK
Definition: WickedMotorShield.h:87
M2_PWM_PIN
#define M2_PWM_PIN
Definition: WickedMotorShield.h:171
OPERATION_CLEAR
#define OPERATION_CLEAR
Definition: WickedMotorShield.cpp:66
M3_PWM_PIN
#define M3_PWM_PIN
Definition: WickedMotorShield.h:175
Wicked_Stepper::last_step_time
uint32_t last_step_time
Definition: WickedMotorShield.h:243
Wicked_DCMotor::Wicked_DCMotor
Wicked_DCMotor(uint8_t motor_number, uint8_t use_alternate_pins=0)
Definition: WickedMotorShield.cpp:610
WickedMotorShield::M6_PWM_PIN
static uint8_t M6_PWM_PIN
Definition: WickedMotorShield.h:215
WickedMotorShield::WickedMotorShield
WickedMotorShield(uint8_t use_alternate_pins=0)
Definition: WickedMotorShield.cpp:148
Wicked_Stepper::m1
uint8_t m1
Definition: WickedMotorShield.h:244
WickedMotorShield::get_rc_input_pin
static uint8_t get_rc_input_pin(uint8_t rc_input_number)
Definition: WickedMotorShield.cpp:279
M1_BRAKE_MASK
#define M1_BRAKE_MASK
Definition: WickedMotorShield.h:108
M6_BRAKE_MASK
#define M6_BRAKE_MASK
Definition: WickedMotorShield.h:152
Wicked_Stepper::direction
uint8_t direction
Definition: WickedMotorShield.h:238
M5
#define M5
Definition: WickedMotorShield.h:67
M6
#define M6
Definition: WickedMotorShield.h:71
Wicked_Stepper::number_of_steps
uint16_t number_of_steps
Definition: WickedMotorShield.h:241
Wicked_Stepper::m2
uint8_t m2
Definition: WickedMotorShield.h:245
WickedMotorShield::first_shift_register
static uint8_t first_shift_register
Definition: WickedMotorShield.h:199
M3
#define M3
Definition: WickedMotorShield.h:59
Wicked_DCMotor::setBrake
void setBrake(uint8_t brake_type)
Definition: WickedMotorShield.cpp:623
WickedMotorShield::setBrakeData
void setBrakeData(uint8_t motor_number, uint8_t brake_type)
Definition: WickedMotorShield.cpp:383
WickedMotorShield::get_motor_directionM
uint8_t get_motor_directionM(uint8_t motor_number)
Definition: WickedMotorShield.cpp:464
SERIAL_LATCH_PIN
#define SERIAL_LATCH_PIN
Definition: WickedMotorShield.cpp:64
Wicked_Stepper::step_delay
uint32_t step_delay
Definition: WickedMotorShield.h:240
Wicked_DCMotor::setSpeed
void setSpeed(uint8_t pwm_val)
Definition: WickedMotorShield.cpp:651