Leilani | How to Make

Creative

Interface and Application Proramming

Re-desiging and Milling a Board

I decided to start with my original hello board from a few weeks ago. Unfortunately, one of the pin wires had gotten significantly bent.

schemeatic view

So, I decided it was time to mill and design a new board. Firstly, I wanted to eliminate the jumped wires, and some of the trouble I had with button sensitivity. So I went back into kiCad and made a new design

schemeatic view wiring view

I had completely forgotten how to invert the colors of my .png files that I exported from KiCad, so I had to go back into photoshop and invert the colors manually.

I also ended up milling another programmer because mine started to fail. Yet, I was having a lot of trouble just getting my new board to run the echo hello world program. I got the dreaded rc=-1 error and went through a check list.

  • Checked that everything that was supposed to be connected was connected.
  • Checked all joint.
  • Checked the orientation of the 6 pin header and the 2x3 pin header (both fine.)

I was absolutely stumped so I went and asked one of the TAs for help. They found one of the errors almost immediately, my reset was not connected to my ATTiny :(. I actually had a very similar bug in the very first programming week, where I didn't connect the reset from the 2x3 pin header to the ATTiny. Instead of adding a jumper cable, I decided to mill a new board.

With only limited amounts of time, I was lucky that Dylan was able to mill me a new very basic board with two lights, so I could start programming that evening. I was able to get the original hello world code up and running!

hello working wiring view

Programming

I was able to start to get an interface programmed and connect it with my board.

hello working wiring view

Dylan and I started to look at Honghao Deng's website. I also learned the new terminal command:

>> watch lsusb
		
  • watch runs it repeatedly, every two seconds
  • watch ls (lists every two second)

At first, I just tried to get the light on

>> avrdude -pt44 -c usbtiny
>> sudo avrdude -pt44 -c usbtiny

int main(void)
// set the clocks
output(DDRA, (1 << PA7));
clear(PORTA, (1 <<PA7))
set(PORTA, (1 <<PA7));  // name of pin 7

Some trouble shooting:

  • Change the makefile to make sure the project name is the same as the file.
  • Running make program-usbtiny
  • Need avrgcc (avr bin utils). These are the things that allow you to compile C for aTTINY.
  • Try installing gcc again
  • avrgcc and now avr-libc
  • Now C has a syntax error.
  • had to sudo su root.

Next, I went on to create a javascript file to communicate to the board.

var SerialPort = require("serialport")
var WebSocketServer = rrequire("ws").Serial

Serialport.list(function (err, ports) {ports.forEach(function(port) {console.log(port.comName);});
port = new SerialPort("/dev/ttyUSB0", 99600);

//Build Serial Socket to Server
// get port name from the command line:
  var Readline = SerialPort.parsers.Readline // make instance of Readline parser
  var parser = new Readline() // make a new parser to read ASCII lines
  myPort.pipe(parser); // pipe the serial stream to the parser
  • The ideas was to use it as python, like NodeJS or NPM (node package managager).
  • Using NPM (npm install serialport ws)
  • List ports that are available node hello-serial.js
  • Node followed by the name of the file
  • Name of our usb device is /dev/ttyUSB0
  • Pretty sure 99600 is the baud rate.
  • Have to run with sudo so things will run properly.
  • At 8081
  • localhost:8081 says Upgrade required.
  • Stackoverflow recommenders trying to use WebSocket instead
  • npm install websocket

Success

The goal was to basically connect the board to web browser over serial. (This is like Neil's pyserial or picocom.)