Close

Testing the sensors on a robot

A project log for 4 Channel Non Invasive Current Sensor for Robots

If your motor drivers do not output current / torque data then current sensors may be needed.

capt-flatus-oflahertyCapt. Flatus O'Flaherty ☠ 05/09/2018 at 15:550 Comments

Firstly, the code that worked on the Arduino uno did not work on the 3 core TC275, probably because of a speed issue, but I never found out exactly why!

The new code, for CORE 1 is:

  ic = 0;
  while (ic < intervalFive)   // AC 50 hertz is equivalent to 20 ms per AC cycle
  {
    ic++;
    delay(1);                 // Capture data over one complete AC cycle.
    currentSensorValueFive = analogRead(A3);
    currentSensorValueSix = analogRead(A2);
    if(currentSensorValueFive > maxCurrentValueFive)
    {
      maxCurrentValueFive = currentSensorValueFive;
    }
    if(currentSensorValueSix > maxCurrentValueSix)
    {
      maxCurrentValueSix = currentSensorValueSix;
    }
  }
//////////////////////////////////////////////////////////////////////////////
    runningmaxCurrentValueFive = (maxCurrentValueFive - 523)/80;
    runningmaxCurrentValueSix = (maxCurrentValueSix - 523)/80;
    maxCurrentValueFive = 0;
    maxCurrentValueSix = 0;

.... And CORE 0:

void torqueDifferential()
{
  // Make RH wheel turn slightly faster if current in LH wheel too high. Three and five is LH and Four and six is RH.
  // Weighting is 6:4.
  intervalFour = ((0.60*intervalFour) + (0.40*(intervalFour * (runningmaxCurrentValueSix / runningmaxCurrentValueFive))));
}

 Core 0 runs without any 'delays' and controls the motors with 'step' and 'direction'.

The whole point of the current sensor gadget was to override positional errors created by situations where one of the drive wheels goes over a rock, which causes it to travel further in terms of rotational distance. The Agri - robot, the WEEDINATOR, needs at least one wheel with positional control to get quick and accurate translation between one grid of plants to the next without having to rely so much on GPS / accelerometers etc.

A ramp was used to create a positional error on one of the wheels and then the test was repeated with torqueDifferential() as above:

Discussions