week 13

Input Devices

ASSIGNMENTS:

  • Measure something: add a sensor to a microcontroller board that you have designed and read it

home

about me

Ultrasonic distance sensor

weekly work

For the Input Device I have decided to make a ultrasonic distance sensor. As the Final project requires one Input device in it I thought about designing the distance sensor to avoid collision of the robot .

 

Now, the robot has been controlled from, Grasshopper. So the board has to be read and compatible with Grasshopper-Firefly. I have taken the base of the Danielle Ingrassia's Satshakit and designed over it with the bare minimum pins.

 

My contribution to this specific board are as follows:

  1.  Power Pins are at different location to cater my need without rerouting the power from elsewhere.
  2. Separate header set for TX, RX and RST of FTDI as in the original Satshakit its a bit hard to find and needs counting always.
  3. Separate RSTP in a header set and Arduino 11,12 and 13 pin in a header. Easy to understand programmable pins.
  4. Provision of Ultrasonic distance sensor in this particular board taking Arduino Pin 2 . So that particular Pin can be read from Firefly inside Grasshopper to measure distance.

 

Designing in eagle

For the designing part I have used eagle and started with Daniel Ingrassia's Schematic. First thing as to reduce the amount of pins like ADC and unused Digital pins. After a small sketching decided to keep pin 11,12,13, TX, RX as is as they will be needed to program the board. Along with Pin 2 and 4 depending on the type of US distance sensor. It might be using the Old ping library or the new Ping library.

Next was to introduce the different header pins for th Programming, FTDI (TX-RX-RST), Sonar and Reset Pin.

Grasshoper Firmata uses the new ping library but I have the sensor with Separate trig and Echo Pin. So i had to connect the 2 pin and send the combined out put to Pin 2 of Arduino. For normal use the Pin 4 could have been used.

This is how the new schematic looks. Reduced and simplified for the specific usage.

 

Now we shift to board workspace. majorly all the routing has been done manually with moving the components over the board..

Next was to relocate the power pins (VCC and GND) to the right of the board to power the distance sensor easily. I have also used the same configuration for the Krab board to keep the common ground between the VCC from FTDI and 5 Volt from the external power supply.

The FTDI and Reset Headers were placed in the top left replacing the original pin headers

To the right of these headers Sonar was placed.

LED at Pin 13 was retained the place changing the orientation to complete the ground circuit.

The full board is like the next image where I have added an insignia of myself.

The board was checked again fab.dru and no major errors were found.

Next was to export the board as a monochrome PNG and used Photoshop to generate the separate trace and cutout images.

After milling in Roland Modela MDX 20 and few minutes of soldering the board was ready to take program and burned bootloader.

FTDI connectors

sensor connector

power

progammer

Arduino as ISP was used to burn the bootloader onto the chip.

Wiring guide is given in the Arduino as ISP code as well as Satshakit Github Page.

programming with fab isp

As this board is based on Satshakit, I will be using Daniele Ingrassia's FabISP programming guide as found in the Satshakit Github Page. The hookup diagram looks like the following:

I have used a separate programming header set. So from there I have used the connections.

13- SCK

12-MISO

11-MOSI

RST-RST

VCC and GND same from the FabISP. (That is one exception I have made.)

According to the hookup, I made the physical connections and the power LED lights up. So it denotes that power is successfully going from FabISP to my Input device.

From the last programing setup, I just had to change to the Programmer as "USBTiny". I used Arduino as ISP last time.

Now, I have pressed Burn Bootloader from Tools> Burn Bootloader. And to my luck it has been successfully burnt.

FabISP needed a bit of work to be programming ready. That process I have described in my week 10 _ Output Devices.

putting firmata

I needed to read the board through Grasshopper, as i have already mentioned . for that it need to perform a serial communication throughout. So it needed a firmata. Firefly firmata was added to perform the ultrasonic calculation. The lines are in the screenshot. Code is added at the end of the page. That code was uploaded to the board using FTDI connection.

Next stage was to create the grasshopper code to read the sensor data stepwise. Following are the steps to get the sensor data into grasshopper:

  1. Run Grasshopper and make sure Firefly is installed in the system with Arduino.
  2. Bring the 'COM Ports Available ' component from Arduino & I/O boards tab. It will give the available ports to which a compatible device is attached.
  3. Now Get the 'Open Port ' component to access that particular port.
  4. Get Uno Read Component. Connect the boolean toggle, port and a timer to read data from the component.

 

The grasshopper tutorial follows.

 

Get Port

Open port Component.

Uno Read Component

2 Boolean Toggle component and a timer.

Few panel components to see the output data ad messages.

1 Concatenate component to format the output text

Now we need to make all the connections to make the code running.

Port to Open Port and Port of Uno Read.

Toggle to Open of Open Port and Start of Uno Read.

Also, the timer to Uno Read.

Attach panels to read any errors/ message:

Panel to Msg

Panel to DPin2 to read the value of the Sensor.

Attach DPin 2 panel to A of concatenate and another panel with string "  cm" to B of the same to get the data in a formatted in centimeter.

 

The output can be seen the following GIFs.

In my case my Input device board was connected to the computer at COM5 with the UltraSonic connected. Dear friend Harleen played with the set up while took the screen capture and photos. It gave output in CM. The data looks like this.

This week's file can be accessed here.

 go to WEEK 14 >>

Avishek Das   |   2017   |   FabLab CEPT