Drawing Robot – Programming and Troubleshooting

So we built a robot, what can we do with it now?

(Tip: if you get stuck  on any of these steps, head down to the Troubleshooting section)

Step 1 – Connecting to the robot:

  1. Turn the robot on – connect the black and red wires from the battery pack.
  2. With a computer (preferred), phone or tablet – scan for available wifi networks.
  3. Connect to the robot-0 network. (0 is whatever number your robot is, written in marker ‘chip’)
  4. Visit http://192.168.4.1 that is the robot landing page.
  5. You should see:Screen Shot 2016-01-23 at 2.19.07 PM

Step 2 – Programming the robot:

  1. Now you can tell your robot what to draw.  The robot only knows how to do 6 things:
    1. forward
    2. backward
    3. left
    4. right
    5. pen up
    6. pen down
  2. The easiest way to explain how to instruct the robot is with an example, if you want to draw a square you would enter:
    1. pen down
    2. forward 30
    3. right 90
    4. forward 30
    5. right 90
    6. forward 30
    7. right 90
    8. forward 30
    9. pen up
  3. Let’s explain what these lines do:
    1. pen down – this tells the robot to put the pen down onto the paper
    2. forward 30 – this tells the robot to go forward 30mm
    3. right 90 – this tells the robot to turn right 90 degrees
    4. and then we repeat that a few times to make a square
  4. Hit preview and see if a red square appears.
  5. If you don’t get a red square check that you entered the program correctly, then try again.
  6. If you have a red square, then it’s time to have the robot draw.

Step 3 – The robot draws

  1. Grab the marker and the hat shaped collar.
  2. Attach the collar to the marker:
  3. Place the marker into the robot:
  4. Set the robot on some paper (make sure you have enough, and that you won’t marker on anything important if the robot goes off the paper).
  5. Press the ‘send’ button.  This sends the program to the robot.
  6. Press the ‘start’ button, this starts the robot drawing.  The robot takes several seconds before it begins moving, so don’t get worried if it doesn’t spring into action instantly.
  7. Watch and enjoy.

Step 4 – Calibration

  1. Now that your robot can draw, it is time to make it draw better.
  2. You can visit http://192.168.4.1/config.htm to get into the configuration page.

 

Troubleshooting

Step 1 – Connecting to the robot

  1. When you turn the robot on, the blue light should turn on, and the red lights should turn off.  Is your blue light on?
    1. Yes
    2. No – UNPLUG THE RED WIRE FROM THE BATTERY PACK – QUICKLY –
      1. Let’s double check the wiring, follow along with these photos to make sure you have the wires attached correctly:
        1. First, make sure your ‘brains’ are plugged in correctly
          IMG_6790
        2. Then, let’s make sure the batteries are in place.  Has the robot worked before?  Could the batteries be dead?
        3. Servo Motor
          IMG_6800
        4. Left stepper
          IMG_6804
        5. Right stepper
          IMG_6806
        6. Black wire from battery pack – to the left of the brains, where the board says GND
        7. Red wire from battery pack – to the right of the brains, where the board says VCC
      2. Does the blue light turn on now?
        1. Yes – Awesome – Keep going down the list
        2. No – email me chris@cu.rious.org, I’ve got extra pieces and you’ll probably need something replaced.
  2. Are your red lights off?
    1. Yes – Good, let’s keep going down the list then – head over to 3.
    2. No
      1. Let’s double check the wiring, follow along with these photos to make sure you have the wires attached correctly:
        1. First, make sure your ‘brains’ are plugged in correctly
          IMG_6790
        2. Then, let’s make sure the batteries are in place.  Has the robot worked before?  Could the batteries be dead?
        3. Servo Motor – This is the most likely cuplrit, make sure the brown wire faces the back of the robot.
          IMG_6800
        4. Left stepper
          IMG_6804
        5. Right stepper
          IMG_6807
        6. Black wire from battery pack- to the left of the brains, where the board says GND
        7. Red wire from battery pack- to the right of the brains, where the board says VCC
  3. With a computer or tablet/smart phone, scan for available wireless networks, you should see one that starts with robot-.
    1. Do you see any networks whose name starts with ‘robot’ ?
      1. Yes – Great, go on to the next step and see if you can connect to it.
      2. No – Have you previously connected it to your home WiFi network?
        1. Yes – Try to visit http://robotN.local/ where N is the number of your robot, like http://robot3.local/
        2. No – Email me at chris@cu.rious.org we might need to update the firmware on your robot.  It’s easy and I will help you get it done.
    2. Let’s attach to the robot network.  Try to connect to the robot network.  Did your computer or table succeed in connecting?
      1. Yes – Ok, next we’ll try visiting the program page.
      2. No – Email me at chris@cu.rious.org we might need to update the firmware on your robot.  It’s easy and I will help you get it done.
    3. Now that we’re attached to the robot, let’s pull up the program page.  With a web browser visit http://192.168.4.1, does your page look like this:
      Screen Shot 2016-01-23 at 2.19.07 PM

      1. Yes – Awesome, you’re connected and should be able to continue on to the next step.
      2. No –
        1. Do you see any page?
          1. Yes – If the page doesn’t look correctly, try using a different browser, like Chrome, if that doesn’t work email me chris@cu.rious.org because I haven’t seen this problem yet.
          2. No – Looks like you probably aren’t connected, email me chris@cu.rious.org we might need to make sure the chip is working correctly.

 

Robot Time in Holland, MI

[Update – 11-21-2015]

We’ve got the date and time and location locked down!

When: Jan 9 – 1pm-3pm

Where: First Reformed Church, Holland, MI

Cost: $20

Registration ends Dec 15.

Sign up here

wpid-wp-1447031530463.jpg

 

Alright, as promised, here are some more details about the robot build we’re going to have.  We don’t have the date exactly – but we are penciling it in for Jan 9, 2016.  The robot kits will cost $20 and will include everything you need to have your own drawing robot – including: electronics, batteries, wires, screws, nuts, wooden chassis, motors, and most importantly markers.

This project is really targeted at 1st – 5th graders.  They will assemble the robots and connect the wires, but no soldering is required.  Then they’ll learn how interact with the software we’ve loaded on to the robots to give the robot instructions on what to draw.

The robots will all have Wifi, and be able to be programmed and operated from a web browser on a phone, tablet, PC…  We will be walking everyone through the build including some explanation of why things are the way they are and we’ve got some great volunteers who will help.  Once the robots are built we’ll learn how to program them to draw whatever we fancy.  The programming is limited to forward, backward, left, right, pen up, and pen down.  The kids don’t need to be strong readers or technical wizards.  They just need to show up and have fun.

If you want to participate, please leave a comment here on my blog or leave me a message on Facebook, or send me an email chris <at> cu <dot> rious <dot> org.

Here is the promised video – the first robot in action:

 

Here are some of the technical details:

The general idea and many of the printable parts came from this instructable: http://www.instructables.com/id/Low-Cost-Arduino-Compatible-Drawing-Robot/.  The robot is driven by 2 stepper motors (24byj-48) held on with brackets based on the ones from Thingiverse.   The pen holder is also based on one from Thingiverse and is operated by a 9g micro servo.  The chassis is made from the cheapest underlayment I could find at Lowes and is the direct result of my recent bathroom remodel.  My 3d printer is not very large and with the volume of other parts I need to print, it was nice to get my CNC router some love.  The files I use will all be uploaded to Thingiverse as well as the GitHub https://github.com/csamuelson/esp8266-draw-bot.

To make programming easier for the kids I opted to go with an ESP8266 chip instead of something like an Arduino.  This way you only need a smart phone or tablet to interact with your robot.  I really believe that being able to quickly and easily iterate is one of the most important tools for hands on learning, so I’m putting a lot of effort into making the software as easy to use as possible.  I’m hoping to be able to do it all in Lua with the NodeMCU firmware.  But, if that doesn’t work I will just write it in C using the ESP8266 open SDK.

Resources:

GitHub Project: https://github.com/csamuelson/esp8266-draw-bot

Similar/Inspirational Instructable Project: http://www.instructables.com/id/Low-Cost-Arduino-Compatible-Drawing-Robot/

Robot build – Holland, MI

[UPDATE 11-8-2015] – New post with more details, check it out: http://cu.rious.org/make/robot-time-in-holland-mi/

[UPDATE 11-6-2015] – I am so pumped about the response we’re getting for robot build day!  We are doing everything we can to make sure we’ll be able to accommodate all the kids who want to build.  Here is a photo of a nearly assembled bot, I have to wait until tomorrow before I have all the parts.  I will post more details about signing up as well as some videos of the bot in action this weekend.  Stay tuned!

P.S.  If you have a 3d printer and would be willing to print some parts for the build, drop a comment below and don’t worry if you want to help out but don’t have a printer we’ve got plenty of work available.

robot1
robot_partsI’m getting ready for a local robot build day in Holland, MI in either December or January.  We’re going to help the kids build drawing robots.  If you’re interested in participating the cost per robot will be $20.  I’m going to assemble a working bot this weekend and I’ll post photos and videos so you can see what we’ll be doing.

Let me know in the comments section below if you’d like to participate and I will get you more details.

Here’s my tiny 3d printer churning out some of the wheel brackets:

I’m going to build the prototype this weekend.  I’ll upload more videos and source files after that.

tDCS – Rev 2 – With Ammeter

I built the IMG_20150424_165653second version of my tDCS.  This version uses the LM334 instead of the LM317, I actually have two LM334’s inside, one to drive the LED inside the power switch and the other to provide the constant current for tDCS.  You can see I have also added an ammeter panel, I picked this one up from Amazon.  It seems to work great.  Matches up very closely with multi-meter.

I also soldered all of the components together on some RadioShack perf board.  I still want to add over-current protection.  I’ve been reading about doing that with a JFET.  Once I have the safety features in place in Rev 3, I will post schematics.  For now, I’m enjoying the red glow of the power switch and the ammeter.

I also want to make a Rev 4 that is MCU controlled, so I can do things like ramp-up ramp-down, timer, double blind tests, etc…  My initial sketch of Rev 4 uses a digital pot in place of the physical pot.  I will probably stick w/ an AVR since I have plenty of them laying around and I’m familiar with programming them.  This project will also, most likely, be built on a real PCB.  That lets me use surface mount components.

tDCS – Second try

After reading this blog post about a tDCS montage, I decided that would be the second tDCS montage I would try.  So, I used my new measuring cap and got started.  I was mostly looking for the motivational and memory effects of this montage, not so much the anti-depression effects.  I tried it for 13 minutes without any ill effect.  I think I will try this one out for the next few days and report back on any changes I’ve noticed.

Standing Desk

Getting the most out of being human doesn’t stop at the brain. Having recognized that my body is s not in the best shape, so I’ve decided to do something about it. Starting with my desk.
There are countless articles on the web about the dangers of sitting all day. So I setup a standing desk.
wpid-wp-1429970111878.jpg

It was inexpensive and portable. So far it is working great. But, standing that much made my back hurt? What to do? One of my coworkers had been talking about a book called Becoming a Supple Leopard that helped him overcome some shoulder pain from CrossFit. So, I got the book and it blew my mind. Not only did it help me improve my posture so that my back didn’t hurt, it opened my mind to all the things I should be able to do with my body, but can’t.
If you haven’t already, go check out the site MobilityWOD.com or pick up the book Becoming a Supple Leopard
.

tDCS Measuring Cap

Measuring for the 10-20 system takes some work.  I’m trying to build a cap that will make it easier to for me to place electrodes.  Here’s what I’ve got so far, I’m using the cheapest fabric I could find at Hobby Lobby.  I just cut strips of the fabric and hot-glued them together, starting with a circle around my head from the bridge of my nose to the occipital point.  Basically following this guide.

IMG_20150424_233832

 

I want to turn this into a complete cap with all of the markers drawn on it, and maybe some velcro underneath to hold electrodes in place.  I don’t know much about sewing so this might take me a while.  Leave me a comment below if you have found a better way to make a tDCS cap.

tDCS – First Attempt

IMG_20150422_195439

Transcranial Direct Current Stimulation

Disclaimer – what I’m doing is insane, you should not do this.  I’m literally pumping electricity into my brain – this could kill me, or worse.  So, please, don’t do this.

Consider this a bit of a live blog.  Right now I am trying tDCS for the first time, while I write this post.  I built a very simple tDCS box today, using a constant current circuit built around an LM317 (which you can find at Radio Shack).  I’m powering it with 2 9v batteries in series and I have the power output set to 1.5mA.  I’m trying out the F10 spot (right temple) anode and left shoulder cathode.  This is supposed to help you reduce your mental noise.

I don’t have a good way to ramp up, so I hooked up the electrodes and hit the power button.  I could feel a tingle from both electrodes instantly, and I also had a little visual flash in my right eye.  I powered down and tried again and got the same effect.  I also noticed a metallic taste in my mouth that quickly went away.

I just hit the 5 minute mark – I’m not sure if I feel any different, and I don’t have any objective tests setup.  This session is really about safety and comfort.  So far, I’m comfortable, no pain or weird effects.

10 Minutes – My inner noise dialog does seem to have diminished.  A few minutes ago I was thinking that the effect would be more subtle, but this is pretty dramatic, it didn’t happen instantly but it did happen.  Like being in the ‘zone’ or just after good meditation.

13 Minutes – A lot of the research I’ve seen limits sessions to 13 minutes, so I’m going to as well.  Although I still don’t have any negative effects.  When I shut off the power, I also had a visual flash in my right eye.

Here are some more details about my setup:

I have better materials on order, but I wanted to try this out today, so I built a super quick and dirty tDCS box.  The only thing I went out and purchased was the aluminum enclosure from Radio Shack for $3.50.  What a deal, I hope to use the enclosure for my next revision.  It has enough room for me to mount the digital mA meter I ordered from Amazon on the front.

The circuit isn’t a great design – it’s built around things I already had:

  • 10K Linear Taper Pot
  • Power button
  • LM317
  • Resistor
  • Solderless breadboard

When I build my tDCS Rev 2, I will post schematics etc.

IMG_20150422_195439

tDCS – Rev 1 – with electrodes

Inside of tDCS - Rev 1
Inside of tDCS – Rev 1
IMG_20150422_234116
Inside of the electrode.

I made the conductive part of the electrode from some scrap PCB I had laying around.  I want to pick up some copper sheet to use instead.

I got the idea for this electrode from this reddit post, but instead of hot glueing the pieces together, I sewed them together.  Obviously, I’m no expert, but I really liked the electrode.

Also, the redditor mention they had used Mr. Clean sponge cloth, but my local Walmart only carried Dawn sponge cloth.  Appears to be nearly identical.

Sponge
Sponge

 

Nootropics – Aniracetam

By Jü (Own work) [Public domain], via Wikimedia CommonsI chose to enter the world of nootropics by trying aniracetam and choline bitartrate.  My exploration began as a single dose, just to see what kind of effects it might have.  I was so pleased with the mood lifting properties that I have continued to use  between 1 and 1.5 grams per day for the last 3 weeks.  I feel as though I stay sharper (less foggy) later into the evening and that I am more centered and generally in a better mood.  To be fair though, this is not a legitimate test – my results are subjective.

Aniracetam seems to be an excellent choice if you need extra clarity as well as improved mood.  It seems like it would be a great fit for any job where you interact with people – sales, management, customer support.  It helps you stay mentally sharp and emotionally positive.

Some things to note about aniracetam:

  • each dose (I am currently taking ~ 500 mg at a time) seems to have the greatest effect for about 3 hours.
  • aniracetam is fat-soluble, this means you should take aniracetam with food or a fat source such as fish oil
  • aniracetam is a nootropic as well as an ampakine (it enhances attention span and alertness)

If you are interested in trying any of the nootropics check out the nootropic sampler pack offered by PowderCity – you can use this link to get 10% off anything they sell: http://powdercity.refr.cc/RHBPTT9 .

HC-05 Bluetooth with Arduino

Some time ago, I bought a couple of HC-05 Bluetooth modules.  They use the CSR Bluecore 04-External single chip Bluetooth system.  ITead Studio has a great little datasheet for the HC-05.

I wanted to be able to configure the device from the Arduino programatically, but according to the documentation you need to power cycle the chip to get it into AT mode (the mode necessary to send AT commands to the module).  Instead, I have found that you can achieve the same result by simple pulling the RESETB pin low for more than 5ms.  In my code below, I have a function enterATMode() that raises PIO11 HIGH, then resets the module so that it will accept AT commands.  Once I have finished setting the device up correctly with AT commands, I pull PIO11 LOW and then reset the device again, using the function enterComMode.

I list the pin connections in the DEFINES at the beginning of each code block.

HC-05 Slave Mode with Arduino:

[code]

/*
Copyright Chris Samuelson 2012
*/

#include <SoftwareSerial.h> //Software Serial Port
#define RxD 6
#define TxD 7
#define Reset 5
#define PIO11 8
#define Led 13
#define RTS 4

SoftwareSerial blueToothSerial(RxD,TxD);

void setup()
{
Serial.begin(9600);
pinMode(RxD, INPUT);
pinMode(TxD, OUTPUT);
pinMode(Led, OUTPUT);
pinMode(PIO11, OUTPUT);
digitalWrite(PIO11, HIGH);
pinMode(Reset, OUTPUT);
digitalWrite(Reset, LOW);
pinMode(RTS, INPUT);
setupBlueToothConnection();
}

void loop()
{
char recvChar;
boolean rtsStatus = true;
while(1){
if(blueToothSerial.available()){//check if there’s any data sent from the remote bluetooth shield
recvChar = blueToothSerial.read();
if(recvChar == ‘a’){
digitalWrite(Led, HIGH);
}
if(recvChar == ‘b’){
digitalWrite(Led, LOW);
}
Serial.print(recvChar);
}
if(Serial.available()){//check if there’s any data sent from the local serial terminal, you can add the other applications here
recvChar = Serial.read();
blueToothSerial.print(recvChar);
}
}
}

void setupBlueToothConnection()
{
enterATMode();
sendATCommand();
sendATCommand("UART=57600,0,0");
sendATCommand("ROLE=0");
sendATCommand("PSWD=4567");
sendATCommand("CMODE=1");
}

void resetBT()
{
digitalWrite(Reset, LOW);
delay(2000);
digitalWrite(Reset, HIGH);
}

void enterComMode()
{
blueToothSerial.flush();
delay(500);
digitalWrite(PIO11, LOW);
resetBT();
delay(500);
blueToothSerial.begin(57600);
}

void enterATMode()
{
blueToothSerial.flush();
delay(500);
digitalWrite(PIO11, HIGH);
resetBT();
delay(500);
blueToothSerial.begin(38400);

}

void sendATCommand(char *command)
{
blueToothSerial.print("AT");
if(strlen(command) > 1){
blueToothSerial.print("+");
blueToothSerial.print(command);
delay(100);
}
blueToothSerial.print("rn");
}

void sendATCommand()
{
blueToothSerial.print("ATrn");
delay(100);
}

[/code]

HC-05 Master Mode

[code]
/*
Copyright Chris Samuelson 2012</pre>
*/

#include <SoftwareSerial.h> //Software Serial Port
#define RxD 6
#define TxD 7
#define Reset 5
#define PIO11 8
#define Led 13
#define RTS 4

SoftwareSerial blueToothSerial(RxD,TxD);

void setup()
{
Serial.begin(9600);
pinMode(RxD, INPUT);
pinMode(TxD, OUTPUT);
pinMode(Led, OUTPUT);
pinMode(PIO11, OUTPUT);
digitalWrite(PIO11, HIGH);
pinMode(Reset, OUTPUT);
digitalWrite(Reset, LOW);
pinMode(RTS, INPUT);
setupBlueToothConnection();
}

void loop()
{
char recvChar;
boolean rtsStatus = true;
while(1){
blueToothSerial.print("a");
delay(500);
blueToothSerial.print("b");
delay(500);
if(blueToothSerial.available()){//check if there’s any data sent from the remote bluetooth shield
recvChar = blueToothSerial.read();
if(recvChar == ‘a’){
digitalWrite(Led, HIGH);
}
if(recvChar == ‘b’){
digitalWrite(Led, LOW);
}
Serial.print(recvChar);
}
if(Serial.available()){//check if there’s any data sent from the local serial terminal, you can add the other applications here
recvChar = Serial.read();
blueToothSerial.print(recvChar);
}
if(digitalRead(RTS)){
if(!rtsStatus){
rtsStatus = true;
Serial.print("rts changed true");
}
}else{
if(rtsStatus){
rtsStatus = false;
Serial.print("rts changed false");
}
}
}
}

void setupBlueToothConnection()
{
enterATMode();
sendATCommand();
sentATCommand("UART=57600,0,0");
sendATCommand("ROLE=1");
sendATCommand("PSWD=0000");
sendATCommand("PAIR=0018,e4,0c680a");
sendATCommand("BIND=0018,e4,0c680a");
sendATCommand("CMODE=0");
enterComMode();
}

void resetBT()
{
digitalWrite(Reset, LOW);
delay(2000);
digitalWrite(Reset, HIGH);
}

void enterComMode()
{
blueToothSerial.flush();
delay(500);
digitalWrite(PIO11, LOW);
resetBT();
delay(500);
blueToothSerial.begin(57600);
}

void enterATMode()
{
blueToothSerial.flush();
delay(500);
digitalWrite(PIO11, HIGH);
resetBT();
delay(500);
blueToothSerial.begin(38400);

}

void sendATCommand(char *command)
{
blueToothSerial.print("AT");
if(strlen(command) > 1){
blueToothSerial.print("+");
blueToothSerial.print(command);
delay(100);
}
blueToothSerial.print("rn");
}

void sendATCommand()
{
blueToothSerial.print("ATrn");
delay(100);
}
<pre>[/code]