Input Devices

Sense the world.


Make an input board that will be useful in the Final project.

A quick design.

In this week i decided make a board than could be a experiment, and useful to the final project.

As you can see in my final project proposal i want to make a device than can know the height of the garbage in the trash can’s.

For than i will use IR led’s and IR phototransistor’s.

Why? Because they are cheaper easy to encapsulate.

At first i think in design using an attiy44, but if it was an experiment, it well be in all sense. So i chose attiny45.

first i go to the internet try to find an eagle example already made.

Why?! because i master eagle so i think i can skip some stages.

So i find it here.

Thank’s Anton Sky. :)

I change the ambient light sensor in order to full fill my intent’s

because i want to measure distances how much further as possible i will try to use differential gain amplitude in ADC module, as you can read in ADC section of attiny datasheet.

In fact in attiny45 we have 4 single input adc or one 1 diferential adc.

I will only need one adc so i chose that.

And because i have adc3 as already an adc input, i keep it. and adc2 will be ground… Howw wait a minute…

ERROR

I make an error in the design i know it now.

ADC0 or ADC2 can be used as deferential positive pin. And all ADC pin’s can be the negative one’s.

So i must change adc3 to adc2 and vice-versa.

Ok let’s begin. That’s my first experiment.

The second experiment is this. I will need an output to the led. But what i pin i should use? My left over pin’s was MISO and MOSI in programmer header. so i chose to use booth and the experiment if with 2 led’s in that pin’s i can program the board.

eagle sch eagle brd

So i design what left in the board.

After that i export the board traces and outline to png 500dpi. But i make another add on, the Penela logo to the board ;)

penela brd

I was ready to mill.

Milling Time.

It’s always challenging, but with fabmodule’s i consider it heavenly easy.

This time, i use fabmodules all way down. Because Luis Carvão make a server in the connect pc.

It’s very easy and integrated. as you can see in the photo’s.

pcb in fabmodules pcb mill

a new way stencil.

Since my first board stencil is a blessing that i carried into the fablab EDP. Maria Boavida my colleague in fabacademy love’s it every time.

But we struggle in something, we can’t in a easy way extract the only pad’s from eagle. We need to always go to the gimp or inkscape to kill the traces.

But can’t be…

I search and we found, people use eagle to make board’s and we have tcream layer that is exactly what we want, so we use it.

In order to use it we need to chose another solid color to them, but that’s it.
:)
eagle pads stencil tcream

After that is the habitual procedure:

  • vinil cutter.
  • vinil on the board
  • solder paste on the vinil
  • peal the vinil
  • place the component’s
  • apply hot air 320ºC

And voila a ready tho program board, nice cleaner wonderful.

pcb peal

pcb peal

Programming time

So after all this adventure it’s time to test it.

board with no power

Up’s it’s look’s that board have no Power.. i’m on debugging… see you



The board have a short in here as you can see also in milling file up at this page. pcb peal So i remove it by hand and make a wire insted. pcb peal So let's program.

make -f hello.mag.45.make program-usbtiny

and test it with

python hello.mag.45.py /dev/tty.usbserial-FTH0ZXW5

and here is the result

pcb peal The only diference for magnetic field code of Neil is that i change the ADC.

ADMUX = (0 << REFS2) | (0 << REFS1) | (0 << REFS0) // Vcc ref

| (0 << ADLAR) // right adjust

| (0 << MUX3) | (0 << MUX2) | (1 << MUX1) | (1 << MUX0); // ADC3

ADC3 insted of ADC2

Nodejs

For the nodejs

npm install ws and serialport

I need to install Xcode for instal ws

I need to change Neil on serial port.

var serial_port = "/dev/tty.usbserial-FTH0ZXW5"

and because the serial port sometimes the data comes at block i need to make a funtion to resolve that.
function coloca_dados(data){
   len = data.length;
   for (var i = 0; i < len; i++) {
      byte1 = byte2
         byte2 = byte3
         byte3 = byte4
         byte4 = byte5
         byte5 = byte6
         byte6 = byte7
         byte7 = data[i]
   };
}

sp.open(function(error) {
   if (error) {
      console.log('can not open '+serial_port)
      }
   else {
      console.log('opened '+serial_port)
      sp.on('data',function(data) {

         coloca_dados(data)
         // byte1 = byte2
         // byte2 = byte3
         // byte3 = byte4
         // byte4 = byte5
         // byte5 = byte6
         // byte6 = byte7
         // byte7 = data[0]
         //console.log(data.length)
         if ((byte1 == 1) & (byte2 == 2) & (byte3 == 3) & (byte4 == 4)) {
         //console.log(" byte1 " + byte1 + " byte2 " + byte2 + " byte3 " + byte3 + " byte4 " + byte4 + " byte5 " +byte5 + " byte6 " + byte6 + " byte7 " + byte7)
            value = (byte5 + 256*byte6 + 256*256*byte7)/samples //256*256
            }
         })
      }
   })
                        
another thing is.

run node in terminal
                            node hello.mag.45.js
                        

AND VERY IMPORTANT

open this file hello.mag.45.html in your browser.

node is serving websocket's but not the page it self.

And the great result is pcb peal

I remember that this board is only mesuring the IR light in the air.

Special thanks to mikesamuel who provides the code prettify :)


Here is the link to this week files. :)