Quick Start

Setting Up Your Computer and M0/M4!

Please Read!

This guide should apply to everyone on a modern operating system (Windows, MacOS, most modern Linux distros).

Also, if I refer to a script, I am most likely referring to a Python program that will run on your computer/laptop. If I refer to a sketch, I am most likely referring to an Arduino program that will run on your MCU.

Tip

Since I primarily use Linux, I will refer to Terminal, cmd, PowerShell, and whatever other analogous app as "terminal". For Windows users, if you see a command run as sudo in the guide below, you will have to run that same command (without including sudo) in an elevated/administrator cmd or PowerShell window.

General Requirements

Arduino IDE

The bare IDE will not recognize our microcontrollers (MCUs) without some set up.

  1. Open Arduino IDE.
  2. Go to File->Preferences
  3. At the bottom, there will be an empty text box titled "Additional boards manager URLS". Paste in the following:
https://adafruit.github.io/arduino-board-index/package_adafruit_index.json
  1. ...and click OK.
  2. Next, in the left sidebar, open the Boards Manager.
  3. Search for and install Adafruit SAMD Boards.
    • This will install the proper dependencies for our MCUs.

Validating Your Setup!

Now we'll run a test program on your MCU to make sure the basics are set up properly. Make sure your MCU is plugged into your computer before proceeding.

  1. In Arduino IDE, go to File->Examples->Basics->Blink. This should look something like this:
    • Pasted image 20241125142949.png|350
    • This will open a new window with the Blink example sketch.
  2. In Arduino IDE, you should see a dropdown menu in the top left that looks something like this:
    • Pasted image 20241125142646.png|300
    • Windows users will see ports such as COM6 or COM4
    • Mac users will see ports such as /dev/cu.usbmodem1101
      • You may see a pop up to install xcrun. Allow the install to finish before proceeding.
    • Linux users will see ports such as /dev/ttyACM0
  3. If your setup is correct, you should see an entry in there for every connected MCU. Select the one you'd like to test.
  4. Click the -> button in the top left to compile and upload the example sketch onto your MCU!
    • Pasted image 20241125144350.png|150
  5. Once the upload is complete, you should see a small LED on your MCU start blinking near the USB port. If everything so far has worked, then you should be good to go!

Using the All-In-One Serial Importer Script!

Dependencies

Acknowledging VENVs

I know this isn't quite the cleanest way of handling our dependencies. Once I've cleaned up the current GitHub repository more, I will work on updating all relevant scripts to work with Python's virtual environments.

The Code

Please make sure you are looking at the serial_log_binary branch found here!

Python

Arduino

MCU Setup

  1. Open serial_log.ino using Arduino IDE, or open Arduino IDE first and go to File->Open... to open serial_log.ino.
    • You may see a new IDE window open with the sketch opened.
  2. Use the dropdown menu to select your MCU:
    • Pasted image 20241125142646.png|300
    • Make note of the listed port!
      • In this case, my MCU is connected to serial port /dev/ttyACM0
  3. Click the -> button in the top left to compile and upload the sketch. Wait for it to complete.
    • Pasted image 20241125144350.png|150
  4. The MCU should now be ready for use in conjunction with the script.

Running the Script!

  1. Open a terminal window in the script's directory, or cd into it as needed.
  2. Run python ./serial_importer_all_in_one.py to see the general help message. Please read this to get a better understanding of the functionality provided.
    • The help message may tell you to use ./import_serial_binary.py instead of ./serial_importer_all_in_one.py. Don't listen to it :)
    • Note that the -l flag may not work properly on Linux devices. Refer back to Step 2 of the MCU Setup section above to find the proper port.
  3. Once you're ready, try running python serial_importer_all_in_one.py --plot port=<port for M0> baud=9600 hz=50 sec=10 to see the live plotter. Type out the same port you used in the Arduino IDE.
    • 50 points per second
    • 10 second time window

General Script Info

Voltage in the live plot graph is presented as a value in the range [0,4095] as our ADC takes 12-bit readings. To convert to the real voltage:

live plot reading3.34096=3.3V reading

Voltages from the live printer are presented as a value in the range [0,65520] as this is the sum of 16 12-bit readings. To convert to the real voltage:

printer reading3.3409616=3.3V reading

Live Plotter

Saving Data