Interface and Application Programming

This week, I planned to make a temperature sensor for my final project, and use interface programming to display the temperature.

Making the board

I ran into a few issues with the SRM-20 while trying to mill the board. The 1/64 end mill seemed to work fine. When I switched to the 1/32 end mill, the machine would life up and run the path in the air. I tried restarting the machine and rebooting the computer. But none of that helped. I then switched the numbers for the 1/64 end mill, and tricked the computer to run the 1/32 numbers with the 1/64 program, and it worked.

The next day, Justin told me that this happens if the z-coordinate tries to go below 0. When the end mill touches the surface, we have to make sure that z is not below 3, so when the program runs, z is still above zero.

The next issue I had was that the temperature sensor board turned out too big with the dpi setting I was using. So, I had to mill the board again with a higher dpi.

And, then I finally soldered all the components on the board.

Programming the board

With the rest of the issues fixed, I finally got to programming the board last evening. I uploaded the make file and it seemed to work okay. I then tried to run the python file and ran into some errors. Unfortunately, I was out of time without enough time to troubleshoot. I will work on this later today.

I went through the class webpage, and made a note of all the tools I want to try for this week: Arduino, Python/Pyserial, Processing I first wanted to use pyserial to display the temperature measurements from the temperature sensor board. I started by installing Pyserial. And, hooked up the temperature sensor board I had made for this week.

However, I did not have Tkinter installed. Tkinter is Python’s de facto standard GUI (Graphical User Interface) package. In order to run Neil’s code, and visualize the temperature changes, I needed to install Tkinter. I wasn’t able to install Tkinter on Python 2. So, I had to install python 3 in order to get tkinter, with the command: brew install python3 on Xcode on my Macbook. This process took a while, because it turns out that I already had python 3 on my computer. I had to uninstall python 3 and then reinstall it using: brew install python3 --with-tcl-tk

Then, I ran the python code using: python3 hello.temp.45.py /dev/cu.usbserial-A10744PR And, got this error message: SyntaxError: Missing parentheses in call to 'print'. Did you mean print(nt "command line: hello.temp.45.py serial_port")?

After going back and forth between python 2 and python 3 a few times, and using Google to troubleshoot, I found out that the Missing parenthesis error is specific to Python 3!!! It’s just a change that needed to be incorporate in the code when switching from version 2 to 3. Great! Fixed that! Then, the next problem was: No Tkinter! Turns out it just needed to be tkinter in the code, instead of Tkinter.. Fixed that, and tried again!!

Next error: No numpy. I installed numpy and tried again. Now it worked! I was able to get the temperature window to pop up on the screen. So, the python code was successfully running. I tried using touching the sensor with something cold from my fridge to see how quickly the temperature changes, and it was almost instantaneous!

Success!

Here are the lines I changed to alter the characteristics like color, font and style of the display window.

The line that does the conversion from resistance to temperature in Celsius is highlighted. We can alter this to show the temperature in F, if we prefer that unit. I prefer reading temperature measurements in Celsius. So, I won’t change that.

The second tool I wanted to try for the week was Processing: I was able to write a few different types of codes to display the temperature in different formats. One was a graphical display, and another was a digital display.

When I compiled and uplaoded the code, it seemed to show a display window but really the correct temperature. So I had to go back and edit the temperature calibration part of my code to get it to display the right temperature. div class="container">

The third tool was Arduino: I have been programming in C all these weeks, and never used Arduino. So, my first goal was to run Arduino and use the FTDI to usb serial communication to display temperature from my temperature sensor board I built few weeks ago.

First I had problems with finding Attiny. I then downloaded the library and added it to the Arduino folder. Then, I tried running my program again.

I had a memory issue.. I resolved that as well. Then, it said: 'Serial' was not declared in this scope Changed it to mySerial and it worked.

But there was a different error:

avrdude: initialization failed, rc=-1 Double check connections and try again, or use -F to override this check. I was able to fix this and get the temperature to display for my final project. Refer to my final project here!