Search
Close this search box.

STELLA-Q – Programming Instructions

Step 1: Programming STELLA-Q microcontroller

If using a Windows computer:

1.Put the CircuitPython operating system onto the microcontroller.

The microcontroller is an Adafruit Industries Feather STM32F405. We’re following the instructions on this webpage: https://learn.adafruit.com/adafruit-stm32f405-feather-express/dfu-bootloader-details

With the microcontroller disconnected from the computer, use a piece of wire to temporarily connect the B0 via to the 3.3V via. When plugged in, the microcontroller powers up into bootloader mode.

STELLA-Q programming microcontroller

2.Once it’s powered up, check that the bootloader appears in the device listing:
Open the Control Panel, Hardware and Sound, Devices and Printers, and STM32 BOOTLOADER should show up in the Unspecified devices list.

3.Get the STM32CubeProgrammer from ST.com

https://www.st.com/en/development-tools/stm32cubeprog.html

4.
Click “Get Software”, and choose the operating system version you have, most likely for Win64. Click “Get Latest”

5.At this point you have to register for an ST account. No way around that.

Submit your registration, and check your email to confirm. In your email, make very sure it’s from ST.com, and click “Download Now”.

The download will be a  218MB .zip file. Open it and click “Extract All”.

You’ll need administrator privileges to install the software.

The guide for operating the STMCubeProgrammer is here:

https://learn.adafruit.com/adafruit-stm32f405-feather-express/dfu-bootloader-details#step-3045684

6. Following the STMCubeProgrammer instructions, remove the wire between B0 and 3.3V, and unplug the microcontroller. Plug it back in, and you should see a CIRCUITPY drive on the hierarchy on the left in Windows.

7. Go to the webpage codewith.mu and download the Mu Editor.

8. Install and run the Mu Editor

9. Click on the Serial button in Mu, to look at the output of the STELLA instrument. If you click in the serial dialogue panel, ctrl-c will cancel the program, stopping it from running, and ctrl-d will decancel, restarting the program. You’ll see error messages in this panel that we will need for debugging.

10. If it’s all working correctly, that’s super! The clock still needs to be set, just once for as long as the clock battery lasts. It should be set to UTC, universal coordinated time, which you can get here: https://time.is/UTC

In the repository, in the folder titled test_codes, there is a folder titled real_time_clock. From that folder, copy code.py to the CIRCUITPY drive. It will run the real time clock read and set program. In the Mu editor, click the Load button to load the program.

The first if False: statement contains a place to set the clock. Set it to True, change the date, time, and day in the t = time.struct…. line, and then run the program to set the clock. Change it back to False, and re-run the program to confirm the time is set properly.

11. Then copy the instrument code to the instrument again, exactly as you did in Step 5.

At this point, it will either be working, or there will be some trouble in the wiring or the components. Look around in test_codes.

If using an Apple computer:

1.Put the CircuitPython operating system onto the microcontroller.

The microcontroller is an Adafruit Industries Feather STM32F405. We’re following the instructions on this webpage: https://learn.adafruit.com/adafruit-stm32f405-feather-express/dfu-bootloader-details

With the microcontroller disconnected from the computer, use a piece of wire to temporarily connect the B0 via to the 3.3V via. When plugged in, the microcontroller powers up into bootloader mode.

STELLA-Q programming microcontroller
2.
Click on the Apple icon on the upper left of the screen.

Choose: About this Mac

Choose: System Report

Confirm that the STM32 BOOTLOADER shows in the USB device tree.

STELLA-Q microcontroller programming Mac

3.Check that you have HomeBrew installed. If not, install it:
Applications, Utilities, Terminal

% brew -v

if you have brew, the response will be something similar to this:

Homebrew 3.6.14
Homebrew/homebrew-core (git revision a4894735611; last commit 2022-12-11)
if you don’t, the response will be that no brew is found.

To install Homebrew, we will use the command:

% /bin/bash -c “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/
install.sh)”
which we find a the Homebrew source webpage: https://brew.sh
The system will ask for your password, since you need Super User access to install Brew.
(“sudo”)
==> This script will install:
/opt/homebrew/bin/brew
/opt/homebrew/share/doc/homebrew
/opt/homebrew/share/man/man1/brew.1
/opt/homebrew/share/zsh/site-functions/_brew
/opt/homebrew/etc/bash_completion.d/brew
/opt/homebrew
Press enter to accept this installation.


4.
Get the CircuitPython file from this webpage: https://circuitpython.org/board/feather_stm32f405_express/

Download the latest BIN file.

Move that file from Downloads into the directory you are running terminal in.

Run this command in terminal, replacing the “firmware.bin” with the full filename of the CircuitPython file you just downloaded.

% dfu-util -a 0 −−dfuse-address 0x08000000 -D firmware.bin

In my case, the command looks like this.

% dfu-util -a 0 −−dfuse-address 0x08000000 -D adafruit-circuitpythonfeather_stm32f405_express-en_US-8.0.0-beta.6.bin

You’ll see this:

Downloading element to address = 0x08000000, size = 550496

Erase [=========================] 100% 550496 bytes

Erase done.

Download [=========================] 100% 550496 bytes
Download done.
File downloaded successfully

* if dfu-util is not found after installing Home-brew type

% brew install dfu-util

6. remove the wire from between B0 and 3.3V, and unplug the microcontroller from the computer, and then plug it in again.

The microcontroller will flash a yellow light, and the CIRCUITPY drive for this device will appear in your Finder tree, under Locations. If you don’t see it, click on the flippy triangle for Locations, to expand that list, and CIRCUITPY should show up.

Step 2: Setting the Time

1. Open Mu Editor.

2. Turn on the STELLA, and plug it in to your computer.

3. Click on the Serial button at the top of the Mu window.

4. In the Serial Dialogue panel that opens at the bottom of the Mu window, you should see a line of text that loads every second:
“Memory B: Used xxxxxx /Free xxxxxx recording…”
That tells you that Mu is communicating properly with the STELLA.

5. Open the Finder (on a Mac) (File Explorer in Windows). Find the CIRCUITPY drive in the file list. Click on it to load it into the window. You should see three items: boot_out.txt, code.py, and a folder called lib.

6. In another Finder/Explorer window your computer, in the code files that you downloaded for programming the STELLA, open the folder called test_codes. In there you should find a folder called real_time_clock, and in that folder you should find a file named code.py

7. Copy that code.py file, and paste it onto the CIRCUITPY drive. (Drag and drop should also work)

The system will ask you if you want to replace the existing code.py file, and you should choose to Replace.

8. Now go back to the Mu window. In the Serial panel it should be printing out the date and time, once a second. That shows that you have the real time clock test code running on the STELLA. The STELLA screen itself should be either blank, or showing the same printout as you are seeing in the Serial dialogue.

9. Now click on the Load button at the top of the Mu editor. You should see the contents of the CIRCUITPY drive. If you see some other contents, change the choices so that you are looking at the CIRCUITPY drive. (If you save a file somewhere else on the computer, it will not run on the STELLA, but Mu doesn’t warn you about that, or offer a Save As button to correct that)

10. In the Load window, select the code.py file on the CIRCUITPY drive, and the real time clock test code should load in the Mu window.

11. There is a line of code that reads “if False”. Change that line to “if True”. It’s important to get the capitalization correct (lower case if, upper case T in True).

12. Open a web browser window, and navigate to time.is/UTC to get a readout of the current global universal time.

13. A few lines below the “if True” line is a line “t = time.struct_time((…))” That line is a bit out of date by now. Change the line as follows: I’m setting my STELLA as I am writing this, so the line now should read:

t = time.struct_time(( 2022, 09, 30, 19, 38, 00, 5, -1, -1))

I’ve set the seconds to 00. 5 designates the day as Friday, and the -1, -1 tells the clock not to set the day of the year or ‘is daylight savings’ fields.

14. Wait for the web UTC clock to get within two seconds of the time you’ve put in the time.struct line, and then click the Save button at the top of the Mu editor. That sets the real time clock module on the STELLA. The printout in the Serial panel should show the correct time now.

15. To make sure we don’t save again and reset the time incorrectly, change the “if True” line to “if False”. Then save the code again. The Serial printout should continue to show the correct time.

16. Now go back to the Finder/ Explorer, and locate the STELLA-Q-code-and-libraries folder. . Copy the code.py from there to the CIRCUITPY drive, choose to Replace the existing file, and the STELLA should run the full instrumentation, now with the correct time.

Step 3: Programming STELLA-Q

Now that you have CircuitPython installed on the microcontroller, you are ready to program your STELLA-Q.

1. Download the .ZIP file that contains the latest software.

2. In the folder labelled “code and libraries”, copy the folder named “lib”, and paste it onto the CIRCUITPY drive. (You can also drag and drop it to the CIRCUITPY drive.) You may get a message that the folder already exists; choose to replace the existing folder.

3. From the same “code and libraries” folder, select the file named “code.py” and copy/paste or drag/drop it onto the CIRCUITPY drive. The code should start up (it takes 12 seconds to boot) and you will have a working STELLA spectrometer. We’ve written the code so that it is tolerant of missing devices, so even if you haven’t got all the parts it should still work.

4. In the “test codes” folder, there is a subfolder called “real time clock”. Inside that folder is a file named “code.py” Copy and paste that file to the CIRCUITPY drive to set the real time clock. Follow the detailed instructions here to set the clock.

5. Once the clock is set, repeat Step 3 to install the STELLA instrument software.

6. The operator’s manual for the STELLA-Q is here.

* Any use of trade, firm, or product names is for descriptive purposes only and does not imply endorsement by the U.S. Government.