Week 15: Tool Chains, Automation, and Open Hardware

Summary

Synthetic biology requires great hardware. Every synthetic biology experiment utilizes a variety of hardware, from liquid handling systems to centrifuges to culture machines and microscopes. During this week, we have to create our own open hardware!

Hardware Assignment:
DIY Low-Freq Capacitance Measurements

Fabrication of the electronics

Fig.2: Circuit board designed in EAGLE software.
Fig.3: Circuit board designed in EAGLE software.
Fig.4: Milled with a Modela MDX-20.
Fig.5: Board with all components soldered.

Embedded Programming

    //
    // main.c
    //
    // Bioware v1.0
    //
    // Thrasyvoulos Karydis
    // 12/7/15
    //
    // (c) Massachusetts Institute of Technology 2015
    // This work may be reproduced, modified, distributed,
    // performed, and displayed for any purpose. Copyright is
    // retained and must be preserved. The work is provided
    // as is; no warranty is provided, and users accept all
    // liability.
    //



    #include <avr/io.h>
    #include <util/delay.h>
    #include <stdio.h>

    #define F_CPU 32000000UL

    #define output(directions,pin) (directions |= pin)      // set port direction for output
    #define set(port,pin) (port |= pin)                     // set port pin
    #define clear(port,pin) (port &= (~pin))                // clear port pin

    #define VPORTA VPORT0       // pre-mapped virtual port A
    #define VPORTC VPORT1       // pre-mapped virtual port C
    #define VPORTD VPORT2       // pre-mapped virtual port D
    #define VPORTR VPORT3       // pre-mapped virtual port R

    #define ADCPORT VPORTA      // ADC Port
    #define OUTPORT VPORTC      // Output port

    #define SM_DELAY 100        // small delay
    #define LG_DELAY 1000       // Large delay
    #define OUT_REF PIN2_bm
    #define OUT_SAMP PIN3_bm
    #define ADC_IN PIN2_bm

    #define led_port VPORTD.OUT
    #define led_direction VPORTD.DIR
    #define led_pin PIN6_bm

    static int uart_putchar(char c, FILE *stream);

    void setup_clock(void){
    //
    // set up clock
    //
    OSC.CTRL = OSC_RC32MEN_bm;                  // enable 32MHz clock
    while (!(OSC.STATUS & OSC_RC32MRDY_bm));    // wait for clock to be ready
    CCP = CCP_IOREG_gc;                         // enable protected register change
    CLK.CTRL = CLK_SCLKSEL_RC32M_gc;            // switch to 32MHz clock
    }

    void setup_serial(void)
    {
    // Setting up serial on port D, pins 2/3
    VPORTD.DIR  |= PIN3_bm;
    //VPORTD.OUT |= PIN3_bm

    //VPORTD.IN  |= PIN2_bm

    // Baud rate selection
    // BSEL = (32000000 / (2^0 * 16*115200) -1 = 16.333 -> BSCALE = 0
    // FBAUD = ( (32000000)/(2^0*16(16+1)) = 9615.384 -> it's alright

    USARTD0_BAUDCTRLB = 0;          //Just to be sure that BSCALE is 0
    USARTD0_BAUDCTRLA = 0x10;       // 207

    //Disable interrupts, just for safety
    USARTD0_CTRLA = 0;

    //Enable receive and transmit
    USARTD0_CTRLB = USART_TXEN_bm | USART_RXEN_bm;

    //8 data bits, no parity and 1 stop bit
    USARTD0_CTRLC = USART_CHSIZE_8BIT_gc;

    }

    static int uart_putchar (char c, FILE *stream)
    {
    if (c == '\n')
    uart_putchar('\r', stream);

    // Wait for the transmit buffer to be empty
    while (  !(USARTD0_STATUS & USART_DREIF_bm) );

    // Put our character into the transmit buffer
    USARTD0_DATA = c;

    return 0;
    }

    int uart_getchar(FILE *stream)
    {
    while( !(USARTD0_STATUS & USART_RXCIF_bm) );
    char data = USARTD0_DATA;
    if(data == '\r')
    data = '\n';
    uart_putchar(data, stream);
    return data;
    }



    int main(void) {

    setup_clock();
    setup_serial();

    //Overwrite standard stdout;
    FILE * uart_str;
    uart_str = fdevopen(uart_putchar, uart_getchar); //send , receive functions
    stdout = stdin = uart_str;


    //
    // set up port directions
    //
    output(led_direction, led_pin);
    OUTPORT.DIR = OUT_REF | OUT_SAMP;

    printf("Bioware v0.1");
    set(led_port, led_pin);

    while (1) {
    clear(led_port,led_pin);
    _delay_ms(500);
    printf("%c", 'h');
    set(led_port,led_pin);
    _delay_ms(500);
    }
    }

Experimental Measurements

Fig.6: Experimental Setup.
Fig.7: Measurements plotted in Matlab.