collapse

Welcome!



Welcome to Robot Rebels, an online robot maker community.

Register today to post your projects, ask questions, share knowledge and meet like-minded people from around the world.


The RobotRebel.org Community

Author Topic: ESP32 - Stepper - LIDAR - Platform  (Read 106 times)

Gareth

  • Member
  • ****
  • Posts: 37
ESP32 - Stepper - LIDAR - Platform
« on: July 13, 2018, 04:28:46 AM »
Thought it may be of interest to document a rover platform using Stepper Motors as drive linked to an ESP32 sporting a Web gui to control movement and display Sensor data.
It will map with LIDAR, the LIDAR will be a home brew system ....still on order....

Its still early stages, however at least the mechanics and Gui are functional.
Basic Platform :-
rover.png
*rover.png (1186.93 kB . 1032x581 - viewed 26 times)
This consists of a 3D printed chassis (back-end still in blender) holding two stepper motors , you might notice the training wheels (springy 3D coils to keep it upright and allow platform to function in temporary mode).
Its controlled with an ESP32 with A4988 Stepper motor drivers.


#include <WiFi.h>

const char* ssid     = "Robot";
const char* password = "Rebels";
int num=4;
int stepper=15;
int sliderint=0;
int gridx=0; int gridy=0;
int nemaA,nemaB;

WiFiServer server(80);

void setup()
{
    Serial.begin(115200);
 pinMode(16, OUTPUT);      pinMode(17, OUTPUT);      pinMode(18, OUTPUT);    pinMode(19, OUTPUT);   

    // We start by connecting to a WiFi network

    Serial.println();    Serial.print("Connecting to ");    Serial.println(ssid);    WiFi.begin(ssid, password);

    while (WiFi.status() != WL_CONNECTED) {  delay(100);   Serial.print("."); }

    Serial.println("");    Serial.println("WiFi connected");    Serial.println("IP address: ");    Serial.println(WiFi.localIP());   
    server.begin();
}

void loop(){
  String currentLine = "";   
  String slidera = "blahblahblah";  sliderint=250;  // random string content probably not needed...

 WiFiClient client = server.available();   // listen for incoming clients
 
  if (client) {                             // if you get a client
   // Serial.println("new client");           // print a message out the serial port
               // make a String to hold incoming data from the client
    while (client.connected()) {            // loop while the client's connected
      if (client.available()) {             // if there's bytes to read from the client,
        digitalWrite(13, HIGH);
        char c = client.read();             // read a byte, then
       // Serial.write(c);                    // print it out the serial monitor
        if (c == '\n') {                    // if the byte is a newline character
          if (currentLine.length() == 0) {
         
            client.println("<!DOCTYPE html>");
            client.print("<html><head><style>div { width: 250px; height: 250px; border: 1px solid black;}</style></head>");         
            client.print("<body><div onmousedown='showCoords(event)' ></div><p id='demo'></p>");
            client.print("<script>function showCoords(event) {");
            client.print("var x = event.clientX;");
            client.print("var y = event.clientY*250;");
            client.print("var coor =  x +  y;");   
client.print("document.getElementById('demo').innerHTML = location.href= coor+'end';}</script> ");
            client.print("</body></html>");
            client.println();
            // break out of the while loop:
            break;
          } else {  currentLine = "";   }
        } else if (c != '\r') { currentLine += c;  }

        }

         if (currentLine.startsWith("GET") && currentLine.endsWith("end")) { slidera[0]=currentLine[5];slidera[1]=currentLine[6];slidera[2]=currentLine[7];slidera[3]=currentLine[8];slidera[4]=currentLine[9];slidera[5]=0;sliderint=slidera.toInt();Serial.print(currentLine );Serial.print(">");Serial.print(sliderint);gridy=sliderint/250;gridx=sliderint-(gridy*250);Serial.print(" x>");Serial.print(gridx);Serial.print(" y>");Serial.println(gridy);
;}
         
    }
 
    }
    // close the connection:
    client.stop();
   
   if (millis()-nemaA >=(250-gridx)/10)    { MOTOR_A()    ; nemaA=millis();     }
   if (millis()-nemaB >=(250-gridy)/10)    { MOTOR_B()    ; nemaB=millis();      }
  }
 
void MOTOR_A()
{  if (gridx>150) {digitalWrite(16, LOW) ;  digitalWrite(19, HIGH); delayMicroseconds(1000);digitalWrite(19,LOW ); delayMicroseconds(1000);  } 
   if (gridx<150) {digitalWrite(16, HIGH);  digitalWrite(19, HIGH); delayMicroseconds(1000);digitalWrite(19,LOW ); delayMicroseconds(1000);  } 
  }
void MOTOR_B()
{  if (gridy>150) {digitalWrite(16, LOW) ;  digitalWrite(18, HIGH); delayMicroseconds(1000);digitalWrite(18,LOW ); delayMicroseconds(1000);  } 
   if (gridy<150) {digitalWrite(16, HIGH);  digitalWrite(18, HIGH); delayMicroseconds(1000);digitalWrite(18,LOW ); delayMicroseconds(1000);  } 
}



The highlighted regions in above code enables the placing and extraction of variables between Web Gui and ESP32 (its the key part to the project, which is the reason for sharing this info to make it simple/easier for other).

The ESP32 spits out a local IP Address .... (in my case 192.168.178.45)
All you need to do then is use a browser window pointed to this address and the Rover can be controlled by clicking the mouse pointer in the box.
The xy coords give direction and speed. works great.
Gui.png
*Gui.png (9.22 kB . 306x452 - viewed 27 times)
The end idea is to display a graphic in the box with more intuitive GUI and use a second box to display the LIDAR data.
« Last Edit: July 13, 2018, 09:50:40 AM by Gareth »

jinx

  • calling from free Europe
  • Sr. Member
  • *****
  • Posts: 440
Re: ESP32 - Stepper - LIDAR - Platform
« Reply #1 on: July 13, 2018, 01:33:15 PM »
keep it coming Gareth. you got a link to the esp32 ( time to dust off the wallet)
I build bots

Gareth

  • Member
  • ****
  • Posts: 37
Re: ESP32 - Stepper - LIDAR - Platform
« Reply #2 on: July 13, 2018, 04:19:01 PM »
Here is a a neat video giving in/outs of the latest modules. It really depends on what extra features might be needed.
I normally go for bare-bone systems - though many of my projects use Oled displays which would be a good addition, instead of digging out spec sheets for connection each time.

1 what

  • Member
  • *
  • Posts: 43
Re: ESP32 - Stepper - LIDAR - Platform
« Reply #3 on: July 13, 2018, 10:03:12 PM »
Really nice to somebody building something that is not a 3D printer  :) (not that I have anything against 3D printers).

jinx

  • calling from free Europe
  • Sr. Member
  • *****
  • Posts: 440
Re: ESP32 - Stepper - LIDAR - Platform
« Reply #4 on: July 14, 2018, 02:49:04 AM »
Quote
Really nice to somebody building something that is not a 3D printer  :) (not that I have anything against 3D printers).
Am midly offended with that statement >:D..... but I know what you mean, I look forward to seein your next bot. happy building
« Last Edit: July 14, 2018, 03:02:49 AM by jinx »
I build bots

1 what

  • Member
  • *
  • Posts: 43
Re: ESP32 - Stepper - LIDAR - Platform
« Reply #5 on: July 14, 2018, 07:02:46 AM »
Hi Jinx,
Please do not be offended.
There is no doubt that changes in technology drive development and that coding and bots that were once the domain of Nerds and Professionals are now primary school projects and (hopefully) we'll all be better off in the future for this. I have to declare that my original training was in valve technology (yes I'm that old) so I've lived through one or two paradigm changes.
The capacity for 3D printing to realise innovative design realisation by everyday "makers" and for it to facilitate as yet unimagined electro-mechanical creativity is (IMHO) a very exciting unfolding frontier.
As far as my ongoing "building" is concerned.... It's all "on hold" pending change of residence to an apartment. The plan is to join a "Maker" group when we shift in about 6 months and once again I'll have access to a lab and might have enough grey mater left to dream up some devices to amuse myself with the help of even more powerful magnifying glasses.
Happy building.

jinx

  • calling from free Europe
  • Sr. Member
  • *****
  • Posts: 440
Re: ESP32 - Stepper - LIDAR - Platform
« Reply #6 on: July 15, 2018, 04:58:51 AM »
Quote
Please do not be offended.
not at all bud, am just teasing. I do see there seems to be focus on 3DP with RR which is exacerbated  by the 3D junkies amongst us  :-X .  I personally think it about the best machine a hobbyist robot builder can have around, they aint overly noisy, not really messy either and far better than bashing balsa  :o, there still bashing and filing with 3DP... still its a prototyping production machine/tool which seems to get lost in the hype. best of all though, there becoming ever more affordable.

hope the move goes smoothly,  there aint a maker group close by start one! communities/world needs more of them.   
I build bots

 

* Search


* Recent Topics

Sloooow progress on the I3 clone by KingBeetle
[Today at 04:20:59 AM]


ESP32 - Stepper - LIDAR - Platform by jinx
[July 15, 2018, 04:58:51 AM]


MKS Gen L 1.0 by jinx
[July 15, 2018, 03:55:57 AM]


Motor rewinding machine by 1 what
[July 10, 2018, 06:03:46 PM]


All the stories in the forum are most important. by ZeroMax
[July 01, 2018, 09:44:53 PM]


Parallax CR Servo with Built-In Encoder by 1 what
[June 28, 2018, 12:13:32 PM]


He's Back...BoB V3.0 by k120189
[June 21, 2018, 07:03:17 PM]


Funding by MEgg
[June 21, 2018, 04:34:36 PM]


Robot Hive by jinx
[June 12, 2018, 03:58:03 AM]


Hi, Mushroom glue here. by Andrewsz
[June 11, 2018, 12:23:20 AM]


CZ-1 2.0: problems, calibration and printing, part2 by MEgg
[June 10, 2018, 06:10:53 AM]


Greetings! by Protowrxs
[June 05, 2018, 04:45:02 PM]


Raspberry Pi / Python eBook - free for the next 11 hours! by MEgg
[June 04, 2018, 05:21:07 PM]


All metal Titan Extruder by jinx
[May 27, 2018, 04:24:23 AM]


UConduit H-Bot printer design by KingBeetle
[May 26, 2018, 02:10:38 PM]

* Recent Posts

Re: Sloooow progress on the I3 clone by KingBeetle
[Today at 04:20:59 AM]


Re: Sloooow progress on the I3 clone by MEgg
[July 15, 2018, 08:44:53 AM]


Re: ESP32 - Stepper - LIDAR - Platform by jinx
[July 15, 2018, 04:58:51 AM]


Re: MKS Gen L 1.0 by jinx
[July 15, 2018, 03:55:57 AM]


Re: Sloooow progress on the I3 clone by jinx
[July 15, 2018, 03:46:18 AM]


Re: MKS Gen L 1.0 by KingBeetle
[July 14, 2018, 04:05:49 PM]


Re: Sloooow progress on the I3 clone by KingBeetle
[July 14, 2018, 11:13:35 AM]


Re: ESP32 - Stepper - LIDAR - Platform by 1 what
[July 14, 2018, 07:02:46 AM]


Re: Sloooow progress on the I3 clone by MEgg
[July 14, 2018, 05:38:34 AM]


Re: Sloooow progress on the I3 clone by KingBeetle
[July 14, 2018, 03:45:21 AM]


Re: ESP32 - Stepper - LIDAR - Platform by jinx
[July 14, 2018, 02:49:04 AM]


Re: ESP32 - Stepper - LIDAR - Platform by 1 what
[July 13, 2018, 10:03:12 PM]


Re: ESP32 - Stepper - LIDAR - Platform by Gareth
[July 13, 2018, 04:19:01 PM]


Re: ESP32 - Stepper - LIDAR - Platform by jinx
[July 13, 2018, 01:33:15 PM]


ESP32 - Stepper - LIDAR - Platform by Gareth
[July 13, 2018, 04:28:46 AM]