Close

Drive Motor Upgrade - Ampflow A28-400-F48 with VEX Victor BB Driver

A project log for WEEDINATOR 2019

The WEEDINATOR project continues .... The inevitability of robots working on farms draws ever nearer ....

capt-flatus-oflahertyCapt. Flatus O'Flaherty ☠ 08/04/2018 at 16:457 Comments

A while back, I made myself a promise that as soon as enough USD had accumulated in my PayPal account I would upgrade the drive motors. So, using the $2000 odd seed funding from the Hackaday prize and some advertising income from one of my other websites, I made the plunge and ordered those crazy expensive Ampflow motors shown in a previous log. The motors are used by large combat robots for TV shows and don't have optical encoders and positioning control, which, I think, will be an advantage as I have already proven that I can balance the torques on the left and right drive motors using current sensors. The motors themselves (A28-400-F48) are brushed, high torque, high current DC devices with expensive neodymium magnets and a staggering 9.1 Hp at 200 amps for help with manoeuvring over rough ground. They are fan cooled, but will they get hot? Will the VEX Victor BB controller box get hot? Will the motor mounting bolts shear? ….. It's all very risky, but we all got to take risks when the odds are ok and we can afford, both financially and emotionally, to lose.

Firstly, the motors need to have adapter plates made and adapter collars for the shafts to fit the drive gearboxes. These are currently being manufactured so will be shown in the next log.
Next, the motors and drivers boxes are set up on a bench and tested using the proprietary VEX software with a Prolific USB to serial cable. Once I'd got a genuine cable from a reputable supplier, the software ran very easily and I was able to make the motors run in no time. 
I was a bit concerned about how to control the motors using an MCU, but Alex at VEX's technical support soon put me on the right track. The signal that the Victor BB requires is not a straightforward PWM, but rather an 'asynchronous' PWM where the LOW part of the waveform must be 20ms long. The duration of the HIGH's gives the motor speed and a HIGH of duration 1.0 ms gives full speed forwards, 2.0 ms gives full speed backwards and 1.48 gives neutral ….. Simples!
The VEX Victor BB driver box is wired to an Arduino Uno for testing and the wiring is as below:

It would be possible to code the Arduino with two delay() functions:

digitalWrite(13,LOW);
delayMicroseconds(20000);
digitalWrite(13,HIGH);
delayMicroseconds(1400);

But that's no use in my TC275 code as delay cannot be used as it will screw up all the other motor timings. Instead, asynchronous motor timing is done with the micros() function. The code was run with an LED and serial print console at very low speed to check that the asynchronous ratios were correct. Serial must be removed, as shown, when running the code at high speed.

// Asynchronous timer
float speedTimerA = 0.001;
float speedTimerB = 0.001;
int LEDState = HIGH;
unsigned long previousMicrosTimerA = 0; 
unsigned long previousMicrosTimerB = 0; 
unsigned long intervalTimerA = 0;
unsigned long intervalTimerB = 0;
int count =0;

void setup() 
{
  Serial.begin(9600);
  pinMode(13, OUTPUT);   // LED
  pinMode(3, OUTPUT);    // motor
  delay(5000);
}
void loop()
{
  motor();
  //printOut();                     // Remove this when using at high speed
}
///////////////////////////////////////////////////
void motor()
{
  unsigned long currentMicros = micros();
/////////////////////////////////////////////////////
  speedTimerA = 650;                                     // Between 1000 and 500. Neutral is 675.
  intervalTimerA = 1000000/speedTimerA;
  speedTimerB = 50;                                      // B MUST be slower than A. Speed of 50 Hz == 20 ms.
  intervalTimerB = 1000000/speedTimerB; 
  intervalTimerB = intervalTimerB + intervalTimerA;

  count++;
  if ((currentMicros - previousMicrosTimerA) >= intervalTimerA)
  {
    previousMicrosTimerA = currentMicros;
    if(LEDState == HIGH)
    {
       count =0;             // Count was used to help prove the maths worked ok.
    }
    LEDState = LOW;
    if ((currentMicros - previousMicrosTimerB) >= intervalTimerB)
    {
      LEDState = HIGH;
      count =0;
      previousMicrosTimerB = currentMicros;
    }
    digitalWrite(13,LEDState);
    digitalWrite(3,LEDState);
  }
} // motor
void printOut()
{
 unsigned long currentMicros = micros();
 Serial.print("  Count: ");Serial.print(count); 
 Serial.print("  LEDState: ");Serial.print(LEDState); 
 Serial.print("  TimerA: "); Serial.print(currentMicros - previousMicrosTimerA);
 Serial.print("  TimerB: "); Serial.println(currentMicros - previousMicrosTimerB);
 delay(1000);
}

Discussions

Jan wrote 08/05/2018 at 08:44 point

"coding is not my speciality!" I second that sooo much. That's why my comment was more or less a hint, not a instruction :)
I am rewriting huge parts of my beelogger code atm so I can't really hop in on your project unfortunately. Projects man, I should switch my day to 8 hours for projects, not 8 hours earning money! Guess that's not how it works haha...

  Are you sure? yes | no

Capt. Flatus O'Flaherty ☠ wrote 08/05/2018 at 09:38 point

I saw your bee logger project - nice! I'm planning to use a Jetson TX2 Ai dev board on the Weedinator and, as a spin off project, build a Asian hornet sentry gun.

  Are you sure? yes | no

Jan wrote 08/05/2018 at 09:51 point

Nice idea! Are you gonna feed hornets from a reservoir into tubes and fire them stinger first at people with compressed air?

  Are you sure? yes | no

Capt. Flatus O'Flaherty ☠ wrote 08/05/2018 at 09:57 point

"Nice idea! Are you gonna feed hornets from a reservoir into tubes and fire them stinger first at people with compressed air?" ……. LOL! ……. No, I'd like to use a laser to shoot hornets down in mid flight. There's no Asian hornets here  …. yet. Have you got them at all?

  Are you sure? yes | no

Jan wrote 08/05/2018 at 10:20 point

Haven't seen one yet, but they're expected to invade most of Europe in the next few years/decades.
The European hornet is a super fascinating insect. It's super friendly as long as you don't come too close (under 1m/3 feet) to their nest or spray them with some shit. They're wasps no 1 enemy as well. In Germany they're protected and killing a nest of them you can be fined thousands of Euros!
Asian hornets are described to be much like the Hornets we have here...

  Are you sure? yes | no

Jan wrote 08/05/2018 at 07:28 point

That PWM signal really reminds me of how servos are controlled. Maybe you could try a servo library. You could as well look into the Atmega328 PWM section in the datasheet. Plenty of options to generate waveforms by direct timer manipulation (maybe for a later rev of your code). It's just a bit annoying reading through all the registers I must admit. That's why I like libraries for some things timer related :) 

  Are you sure? yes | no

Capt. Flatus O'Flaherty ☠ wrote 08/05/2018 at 08:02 point

Yes I admit that the code is a bit protracted - coding is not my speciality! I'd very much like to have it done better at some stage, but I'm constantly distracted by other parts of the project such as improving the camera functionality in strong sunlight. Please feel free to join the project and revamp the code if you can do it.

  Are you sure? yes | no