Saving the data on your computer using putty


To collect data, we need to find a way to move data from the Arduino to your computer. It turns out the Arduino's memory is too small to hold much data, so collecting the data and sending it after an experiment is over is not an option. The data has to be sent in real time, as it is generated. We use the USB connection to do this, which is simulating a serial link to your computer. So our programs just print out data, which sends it over the USB link. To do this we need to use a high baud rate (2000000). This is also the baud rate we set in all the Arduino programs with

  Serial.begin( 2000000 );
  
The Bluetooth link is too slow. We could use the WiFi link to move data wirelessly, but I haven't tried this. Unfortunately, the Arduino IDE does not provide a way to save what is printed out. We can run a terminal emulator that can capture (log) whatever is sent from the Arduino. I use Putty, as it is a popular terminal emulator that runs on Linux, Windows, and Macs. There are many other terminal emulators that run on Windows, so if you are already familiar with one that can log the Arduino output, use that.

  1. You first download the program you want to run to the Arduino using the Arduino IDE. Then you kill all running Arduino IDEs.
  2. If you don't already have Putty installed, you can install it from putty.org or, on Linux, install it from a package (sudo apt install putty)
  3. Run putty and set it up. Click on the "Serial" entry in the left hand side menu. Enter the serial port name next to "Serial line to connect to", which should be the same port the Arduino is using (for me /dev/ttyACM0, for Windows it should be a COM port). For Speed I put 2000000 (you will need to run the Arduino at 2000000 baud as well). Set "Parity" and "Flow control" to None. Click on "Logging" on the left hand side menu, and choose "Printable output" Click on "Session" on the left hand side menu. Click on "Serial" in that window, between "SSH" and "other". You should see your serial line and baud rate get listed in the boxes above. Type a name for your session in the box "Saved Sessions" (I picked "arduino"). Click on "Save" on the right hand side of that window. Now, every time you run Putty and click on your saved session name, "Load", and then "Open", you will be connected to the Arduino, and you will be saving its output in putty.log. Click on "Load", and "Open" now to see if it works. You should get a putty window. You may see some output from the Arduino, or you may just seen a blank screen. You can type g to make something happen for programs that are waiting for a g to do something.
  4. You can change whether putty asks you when you start up what you want to do with the old putty.log (Overwrite or Append).
  5. Here are what the various Putty menus look like after doing the above.



  6. When I tried to run putty, I got an error:
    PuTTY: unable to load font "server:fixed"
    With the arduino session "loaded", go to fonts and choose some other font. Then save the session. This should get rid of the error.

You can type commands to the Arduino by typing into the Putty window.

In a perfect world, whenever you started Putty, the Arduino would reboot and you would be capturing its output. You would be able to download new programs using the Arduino IDE. This did not work on my Linux boxes. I had to have no Putty running while downloading a program using the Arduino IDE, kill any running Arduino IDEs, and then start Putty to capture output. I had to then kill the Putty in order to download a new program, and then restart Putty. Sometimes I had to press the reset button on the Arduino Nano (white button near the USB connector on the Arduino itself (hard to reach), or the button near the back of the board near the rows of red, black, and yellow pins (easy to reach))

or power cycle the Arduino (remove USB cable from laptop and turn the battery off, and then re-plug in the USB cable and turn the battery back on) to get the Arduino to reboot and show a prompt when putty is started up again. You don't need to do this if you don't need to see what the Arduino initially prints out.


Let's collect some data using the steps or sinusoids program. First put the robot upside down, so the robot doesn't actually go anywhere, the wheels just spin in the air.

Make sure your battery is fully charged. Connect the USB cable between the Arduino Nano and your computer.


Preload steps or sinusoids using the Arduino IDE. Then kill the Arduino IDE.


Run putty and type a g into that window. Watch the pretty characters whiz by.


Press the reset button on the rear end of the controller board next to the rows of red, black, and yellow pins to reboot the Arduino and kill putty.


Notice the putty.log file in the directory you ran putty in.