💬 Long Range Vehicle Controller





  • @openhardware.io Can you explain more of what this would be used for? I am guessing that it wouldn't be for the directional motor control as I don't see any kind of H bridge drivers. H-bridge drivers would give it differential steering, though you do say "Includes tilt-compensated compass for fully automated hold-heading and/or course correction." I also don't see any programming header.


  • Hardware Contributor

    It can be used to engage up to 3 thrusters, solenoids, or other unidirectional actuators . Speed is controlled by pulse width modulation. Directional control is achieved by varying the speeds of two identical motors rather than reversing motor direction. There is no programming header. The Atmega chip is in a socket, and can be easily removed for programming on a breadboard or Arduino socket.

    I am trying to keep the price and number of parts as low as possible because I will be using this with robotic ocean craft that may have a high rate of loss due to extreme weather.



  • @CORTEX-Systems My reason for the question was for an old project I am resurecting. I just started a forum post about it. https://forum.mysensors.org/topic/7852/mowbot-resurecting-a-15-year-old-project/

    I am basically looking to redo all of the electronics and one of the things I have to think of is navigation. You mention "fully automated hold-heading and/or course correction". Do you do this using the LSM303? I would be curious to see some code.


  • Hardware Contributor

    The mowbot looks pretty interesting -- I like the variety of sensors you incorporated.

    Here is some basic code you can use to test the course correcting ability of the LSM303. The code will print to screen "turn right" or "turn left." After a set amount of time, the code will print "reverse" and set you on a new heading.

    #include <Wire.h>
    #include <LSM303.h>
    
    int target = 350;
    int target2 = 180;
    unsigned long timer = 60000;
    boolean reverse = false;
    
    LSM303 compass;
    
    void setup() {
      Serial.begin(9600);
      Wire.begin();
      compass.init();
      compass.enableDefault();
      
      /*
      Calibration values; the default values of +/-32767 for each axis
      lead to an assumed magnetometer bias of 0. Use the Calibrate example
      program to determine appropriate values for your particular unit.
      */
      compass.m_min = (LSM303::vector<int16_t>){-485, -508, -291};
      compass.m_max = (LSM303::vector<int16_t>){+476, +456, +588};
    }
    
    void loop() {
      compass.read();
      
      /*
      When given no arguments, the heading() function returns the angular
      difference in the horizontal plane between a default vector and
      north, in degrees.
      
      The default vector is chosen by the library to point along the
      surface of the PCB, in the direction of the top of the text on the
      silkscreen. This is the +X axis on the Pololu LSM303D carrier and
      the -Y axis on the Pololu LSM303DLHC, LSM303DLM, and LSM303DLH
      carriers.
      
      To use a different vector as a reference, use the version of heading()
      that takes a vector argument; for example, use
      
        compass.heading((LSM303::vector<int>){0, 0, 1});
      
      to use the +Z axis as a reference.
      */
      int heading = compass.heading();
      float deviation = abs(target - heading);
    if (deviation > 1){
      if (deviation >= 180){
        if (heading < target){
          Serial.println("turn left");}
          else{
            Serial.println("turn right");}
            }
      else {
        if (heading < target){
          Serial.println("turn right");}
          else{Serial.println("turn left");}
      }}
      else{Serial.println("On Course");}
      
      Serial.println(heading);
      if (reverse == false) {
        if (millis() >= timer){
        target = target2;
        reverse = true;
        Serial.println("Reverse");}} 
      
      delay(100);
    }
    

    You can change the variables target, target2 and timer, the delay interval and also deviation in the line of code:

    if (deviation > 1){
    

    You can further modify the code so that instead of (or in addition to) to printing commands, the commands are sent to the motors. For smoother operation, you can average the deviation over several loops before course-correcting.



  • Nice, Thanks



Suggested Topics

1
Online

11.4k
Users

11.1k
Topics

112.6k
Posts