LAB 4: Motors and Open Loop Control

This purpose of this lab is to equip the robot with time of flight sensors to enable it judge distances accurately in order to avoid running into obstacles and perform stunts.

PARTS REQUIRED

  • 1 x SparkFun RedBoard Artemis Nano
  • 2 x Dual motor drivers
  • 1 x USB C-to-C or A-to-C cable
  • 2 x 4m Time of Flight Sensors
  • 1 x QWIIC Breakout board
  • 2 x QWIIC connectors
  • 1 x Li-Ion 3.7V 850mAh battery

The Motor Drivers

image

Wiring diagram

As can be seen from the wiring diagram below, instead of driving both motors with the two inputs and outputs, we decided to parallel-couple the inputs and outputs on each motor driver and power them separately. By doing this, we are able to deliver twice the average current without running the risk of overheating the chip thus enabling our robot to run faster than it would have if powered on single channels instead. image

Per the wiring diagram, I soldered the appropriate inputs and outputs to achieve power-coupling before soldering the connections to the motors. I ran one motor driver with pins 6 and 7 on the Artemis board and another with pins 12, and 13. These pins were chosen because they support sending PWM signals via AnalogWrite commands from the Artemis to the motors.

Powering Motor Drivers - Battery considerations

As depicted in the wiring diagram above, we opted to power both motor drivers and motors using a 3.7V Li-Ion battery distinct from the one used to power the Artemis. This decision stemmed from several considerations, primarily aimed at ensuring the isolation of power systems.

The choice for separate power sources was driven by the potential for electrical or electromagnetic noise generated by the motors, which could lead to interference with the Artemis. Additionally, motors typically necessitate higher voltage and current requirements compared to the Artemis, and they may draw substantial currents, especially during start-up or under high load conditions. By isolating the power systems, we mitigated the risk of such fluctuations impacting the Artemis’s power needs and overall operation.

Motors

Testing

To activate each motor, I employed PWM signals to instruct them to start rotating. By designating one pin as high and the other as low, I controlled the direction of rotation. In the provided code snippet, I specifically set PIN_6 to a value of 130 (out of 255) and PIN_7 to 0 using the analogWrite command. This configuration initiated the motor’s rotation. By swapping the PWM values, I could alter the direction of the wheels, enabling both forward and backward motion.

Code snippet for running one set of wheels

...
if (motor_run){
  if (pwm_37_left_forward){
    Serial.println("6 and 7");
    analogWrite(PIN_6, 130);
    analogWrite(PIN_7, 0);
  }
  else if (pwm_37_left_backward){
      analogWrite(PIN_7, 130); 
      analogWrite(PIN_6, 0); 
  }
...

For one set of wheels, a signal value of 100 was enough to set it spinning really fast but for the other set, even a signal value of 200 made it spin only slightly so there was the need for some calibration.

Wheels spinning in both directions

Powering motors from battery

I powered the motors using a single 850mAh Li-Ion battery and it worked as it did with the power supply.

image

Power supply and oscilloscope setup

osc-power-supply-hookup

oscilloscope

Lower Limit PWM

In my investigation, I initiated a series of PWM tests, starting from a random low value of approximately 30, and incrementally increased the PWM signals by 5 to determine the minimum threshold required to set the wheels in motion. The outcomes of this analysis are summarized in the table provided below:
image
From the table above, the motors only began to spin in air at PWM values of 40 and 50 respectively. On the ground however, these PWM values were not enough to overcome the friction between the wheels and the ground to set the car in motion. Testing with higher values showed that the car only moved, albeit slowly, at PWM values of 73 and 80.

Calibration

After examining the results of my lower limit PWM experiment, it was clear that one motor operated faster than the other. To ensure the car moved in a straight line, I tested various PWM combinations. When I applied a PWM signal of around 100 to both motors simultaneously, the car spun in a near-perfect circle, confirming the speed difference between the motors.

Knowing this, I tried different PWM pairs. The car only moved straight with PWM value pairs like (70, 83), (90, 106), (100, 130), (110, 145), (120, 160), and (150, 215) where the lower value indicated the faster motor between the two. Using the pairs above, the line of best fit was computed as 1.72485929341561 * x - 45.43903844849798.

image

Car moving in a straight path

Car moving in straight line for 6ft

Components secured in car

image

image

Other labs