Close
0%
0%

4 Channel Non Invasive Current Sensor for Robots

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

Similar projects worth following
This project uses the LEM HO 6-P-0000 Open Loop Current Sensor, -20 → 20A, 19 → 25mA output current, https://uk.rs-online.com/web/p/current-transducers/1383456/ The sensors are offset from one another so that cables can are travel side by side, unobstructed by neighbouring sensors.Sometimes, if two or motors are working together, it's useful to know the current and hence the torque on each motor for torque balancing. In the WEEDINATOR project (https://hackaday.io/project/53896-weedinator-2018) the main drive motors can sometimes work against each other, even if they are both moving in the same direction. This imbalance can occur if, for example, one wheel goes over a rock. Balancing the current can get the motors back in synch again.

So why four channels? ........ The device is specifically designed for agri - robots where there are normally 4 drive wheels - four wheel drive. If one of the wheels is providing more torque than the others, unless it 'slips', it will effectively be fighting against the others and wasting energy and reducing overall traction. The most advanced motors are servo motors with optical encoders and these give all the sophisticated control features that we could ever want! ...... But on the cheaper motors drives there may not be analogue signal output for torque or current so in this case we'd have to build our own. It's really not a problem as the board is dead easy to build and works really well. Slightly more difficult to code as reading AC signals requires sampling of the whole AC wave and, normally, integrating it. Here, I've just calculated the peak amps during the cycle and used them to give the relative torque of each motor ..... Simples!

* The current sensor is not breadboard friendly so it's better to go straight for PCB mounting for testing these devices. 

* All the SMD components are 1206 and are easy to hand solder so no stencil is required.

* Datasheet is here: https://docs-emea.rs-online.com/webdocs/15c5/0900766b815c552a.pdf

* The sensors are 5v friendly so perfect for Arduino Uno, Mega etc.

Current sensor 01.pcb

Opens with 'Design Spark'.

pcb - 142.50 kB - 05/01/2018 at 10:12

Download

Current sensor 01.zip

Gerber files

x-zip-compressed - 42.30 kB - 05/01/2018 at 10:12

Download

View all 7 components

  • In Actual use

    Capt. Flatus O'Flaherty ☠07/16/2018 at 15:57 0 comments

    Incredibly simple. Incredibly effective ……. This PCB is wired for 2 channels.

    Green wire = earth

    Red wire = 5V

    Yellow wire = signal to analogue read pin.

  • Testing the sensors on a robot

    Capt. Flatus O'Flaherty ☠05/09/2018 at 15:55 0 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:

  • Example Code

    Capt. Flatus O'Flaherty ☠05/07/2018 at 15:20 0 comments

    The code below gets readings from 2 sensors on AC 'live' wires. In the UK, our AC supply is 50 Hertz so to get the peak amps at any given time, the wave form needs to be sampled over 20 micro seconds. NB. The sensors have not been calibrated.

    int i=0;
    int sensorValueOne;
    int sensorValueTwo;
    float maxValueOne;
    float maxValueTwo;
    float runningMaxValueOne = 0;
    float runningMaxValueTwo = 0;
    unsigned long currentMillis = 0;
    unsigned long previousMillisOne = 0;
    unsigned long previousMillisTwo = 0;
    int intervalOne = 0;
    const int intervalTwo = 1000;
    int millisCalcOne =0;
    int millisCalcTwo =0;
    int ACFrequency = 50; // Hertz
    
    void setup() 
    {
      Serial.begin(115200);
      intervalOne = 1000 / ACFrequency; // Capture data over one complete AC cycle.
    }
    
    void loop() 
    {
      currentMillis = millis();
      millisCalcOne = currentMillis - previousMillisOne;
      millisCalcTwo = currentMillis - previousMillisTwo;  
      i++;
      //Serial.print("  i:  ");Serial.println(i);
      sensorValueOne = analogRead(A0);
      sensorValueTwo = analogRead(A1);
      if(sensorValueOne > maxValueOne)
      {
        maxValueOne = sensorValueOne;
      }
      if(sensorValueTwo > maxValueTwo)
      {
        maxValueTwo = sensorValueTwo;
      }
    //////////////////////////////////////////////////////////////////////////////
      if (millisCalcOne > intervalOne)
      {
        runningMaxValueOne = (maxValueOne - 523)/80;
        runningMaxValueTwo = (maxValueTwo - 523)/80;
        //Serial.print("  LHS amps max:  ");Serial.print(runningMaxValueOne,2);Serial.print("  RHS amps max:  ");Serial.println(runningMaxValueTwo,2);
        maxValueOne = 0;
        maxValueTwo = 0;
        i=0;
        previousMillisOne = currentMillis;
      }
      if (millisCalcTwo > intervalTwo)
      {
        //Serial.print("sensorValueOne:  ");Serial.print(sensorValueOne); 
        Serial.print("  LHS amps max:  ");Serial.print(runningMaxValueOne,2);Serial.print("  RHS amps max:  ");Serial.println(runningMaxValueTwo,2);
        previousMillisTwo = currentMillis;
      }
    }

  • Boards arrived and Populated

    Capt. Flatus O'Flaherty ☠05/06/2018 at 10:46 0 comments

    Quickly solder on the components and ready to test.

  • PCBs in the Post

    Capt. Flatus O'Flaherty ☠05/01/2018 at 10:17 0 comments

    Gerber files have been sent to JLCPLC.com , China. Now waiting for PCBs to arrive ..... I cant believe these PCBs cost 0.4 USD each ..... How do they do that? ..... And the quality is really good.

View all 5 project logs

Enjoy this project?

Share

Discussions

luka.persolja wrote 10/18/2018 at 05:26 point

This would be perfect, but I am limited with space, especially with height so is there a smaller sensor? I found the NP series, but was a bit confused about how it works, since it doesn’t have a hole for the wire. Do you hook up the current to a pin on the sensor?

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates