SCROLL
finalProject 0000 0001 CAD 0010 cutting 0011 programmer 0100 3Dprinting 0101 elecDesign 0110 makeBig 0111 embedProg 1000 moldCast 1001 inputs 1010 outputs 1011 networks 1100 machine 1101 interface 1110 wildcard 1111 notesIndividual Assignment:
Group Assignment:
Probe an input device's analog levels and digital signals
Analog:
One of the sensor options for my final project is a circle of sonar proximity sensors. I am going to try to get the basic hello.HC-SR04 board working. This board is simpler than the hello.world board I worked on a few weeks ago.
Parts (eagleFab library):
ATTINY45
AVRISPSMD
10K OHM RESISTOR
1uF CAPACITOR
HC-SR04 SONAR SENSOR
Here are the parts laid out in my eagle schematic. I could not find the sonar sensor part in libraries, so I will just draw the pads in manually.
Connected up (minus the sonar sensor). Note, even though the sonar part is not present in the schematic, it is important to net and name the pins it will be connected to (PB3, PB4). If you do not, you will not be able to draw traces from those pins to the rectangles you add in to act as pads for the sensor.
Also, where connecting wires to your self drawn rectangles, Eagle may stop you from drawing a wire right onto a pad. Instead draw the wire as close to the pad as allowed and then use the move tool to drag the trace longer and onto the pad. Alternatively you can drag the pad onto the wire.
Images for mods:
Traces
Outline
I milled, soldered and programmed the board as per past weeks. The programming took a few extra steps than last time.
Just need to add the FTDI connector and the sonar sensor.
The pins on the sensor are too long and at an awkward angle for securely soldering onto the board.
I'm going to bend out then snip the legs so that they can be securely soldered to the board.
Complete:
Ran make -f hello.HC-SR04.make
Tried the make-fuses
command but kept getting an error saying no "target".
I read through this handy guide I noticed that I do not have these lines:
xxxxxxxxxx
program-usbtiny-fuses: $(PROJECT).hex
avrdude -p t44 -P usb -c usbtiny -U lfuse:w:0x5E:m
in my make file... maybe I don't need to run the sudo make -f hello.HC-SR04.make program-usbtiny-fuses
command at all.
Going to skip it and run
sudo make -f hello.HC-SR04.make program-usbtiny
Loading the program onto my board seems to have been successful
Now trying to run it with CoolTerm following the steps from electronics design week. (Selecting port and baud rate of 115200 (this turned out to be wrong, should be 9600))
Strange output (incorrect baud rate selected):
I want to get the cool GUI visualization that Neil showed in class. Time to do some digging.
Downloading the hello.HC-SR04.py
file from here
Running python hello.HC-SR04.py
Some errors I corrected one by one - most seem to be coming from the fact that I'm running python 3.7.1 rather than 2.7 which has some syntactical differences.
Added parentheses around print "command line: hello.HC-SR04.py serial_port"
print ("command line: hello.HC-SR04.py serial_port")
Changed first line to:
from tkinter import *
I don't have serial
package download so will do that now
First downloading pip
package manager for python using curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
and then python get-pip.py
in terminal.
Then python -m pip install pyserial
Now retrying python hello.HC-SR04.py
but I need to add the serial port as a command line argument. Only problem is I do not know what exactly the port is nor how to find out.
I remembered that in coolTerm options there was a port field in which I selected usbserial-FT9PFE7K
Trying full command: python hello.HC-SR04.py usbserial-FT9PFE7K
Returned an error saying "No such file or directory: 'usbserial-FT9PFE7K"
Clearly I need to find the actual name of the serial port... to Google I turn
Found this, suggesting I first use ls /dev/tty.*
to find the serial port.
/dev/tty.usbserial-FT9PFE7K
as one of the ports, this must be the format the python program was looking forThen use screen /dev/tty/.[yourSerialPortName] [yourBaudRate]
to read the port
So the command I'm going to try is: screen /dev/tty.usbserial-FT9PFE7K 9600
9600
is written in the .c
file as the baud rate to be used (which explains why CoolTerm didn't exactly work. I selected 115200)Which gives me this wacky output as I move my hand closer to and away from the sonar sensor:
Screen Recordings:
Going to re-try in CoolTerm now with the proper baud rate selected
Now trying with the original python command except python hello.HC-SR04.py /dev/tty.usbserial-FT9PFE7K
YESSSSSS!!!
Moving my hand closer to then away from the sensor causes the display to read:
I found the sensor to be accurate within 1cm up to ~135cm. However I was bouncing the sound waves off of a concrete floor. I imagine it would be much less accurate on softer materials and materials not perpendicular to the direction the waves coming out of the sensor are traveling.
If and only if using python 3 (check using python --version
in terminal):
Add parentheses around print "command line: hello.HC-SR04.py serial_port"
so that it reads:
print ("command line: hello.HC-SR04.py serial_port")
Chang first line to:
from tkinter import *
rather than from Tkinter import *
If you don't have serial
package downloaded
First downloading pip
package manager for python using curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
and then python get-pip.py
Then python -m pip install pyserial
If you don't have serial
package downloaded:
pip
package manager for python using curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
and then python get-pip.py
python -m pip install pyserial
Run ls /dev/tty.*
and copy the /dev/tty.usbserial-FT9PFE7K (or what ever alphanumeric sequence you get)
Run python hello.HC-SR04.py /dev/tty.usbserial-FT9PFE7K
(where /dev/etc... is the port name you copied)
Voila