A C A D E M Y 2016
ASSIGNMENT

 

GENERAL OBJETIVE:

13

 

Output Devices

 

    Add an output device to a microcontroller board you've designed and program it to do something

 

 

    For the assignment of this week will be held hello.RGB.45 card as proof of an output device. For this file (PNG)

Downloaded from here

 

Once downloaded using FabModules the PCB was machined on a copper plate

 

Once you finished machining the following result is achieved:

 

Assignment13_1

 

After some sanding to remove burrs from the plate and facilitate the welding process is obtained:

Assignment13_2

 

Once the plate is free from burrs, it is easier to solder the components and once all have been welded components results in:

Assignment13_4

 

Once you have the plate welded components and connectors list programming can be done, for this we will use the following code in C language

//

//

// hello.RGB.45.c

//

// RGB LED software PWM hello-world

//

// Neil Gershenfeld

// 11/10/10

//

// (c) Massachusetts Institute of Technology 2010

// 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>

 

#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 pin_test(pins,pin) (pins & pin) // test for port pin

#define bit_test(byte,bit) (byte & (1 << bit)) // test for bit set

#define PWM_delay() _delay_us(100) // PWM delay

 

#define led_port PORTB

#define led_direction DDRB

#define red (1 << PB1)

#define green (1 << PB0)

#define blue (1 << PB2)

 

int main(void) {

 //

 // main

 //

 unsigned char count, pwm;

 //

 // set clock divider to /1

 //

 CLKPR = (1 << CLKPCE);

 CLKPR = (0 << CLKPS3) | (0 << CLKPS2) | (0 << CLKPS1) | (0 << CLKPS0);

 //

 // initialize LED pins

 //

 set(led_port, red);

 output(led_direction, red);

 set(led_port, green);

 output(led_direction, green);

 set(led_port, blue);

 output(led_direction, blue);

 //

 // main loop

 //

 while (1) {

  //

  // off -> red

  //

  for (count = 0; count < 255; ++count) {

   clear(led_port,red);

   for (pwm = count; pwm < 255; ++pwm)

   PWM_delay();

   set(led_port,red);

   for (pwm = 0; pwm < count; ++pwm)

   PWM_delay();

  }

  //

  // red -> green

  //

  for (count = 0; count < 255; ++count) {

   set(led_port,red);

   clear(led_port,green);

   for (pwm = count; pwm < 255; ++pwm)

   PWM_delay();

   clear(led_port,red);

   set(led_port,green);

   for (pwm = 0; pwm < count; ++pwm)

   PWM_delay();

  }

  //

  // green -> blue

  //

  for (count = 0; count < 255; ++count) {

   set(led_port,green);

   clear(led_port,blue);

   for (pwm = count; pwm < 255; ++pwm)

   PWM_delay();

   clear(led_port,green);

   set(led_port,blue);

   for (pwm = 0; pwm < count; ++pwm)

   PWM_delay();

  }

  //

  // blue -> on

  //

  for (count = 0; count < 255; ++count) {

   set(led_port,blue);

   clear(led_port,green);

   clear(led_port,red);

   for (pwm = count; pwm < 255; ++pwm)

   PWM_delay();

   set(led_port,blue);

   set(led_port,green);

   set(led_port,red);

   for (pwm = 0; pwm < count; ++pwm)

   PWM_delay();

  }

 

  //

  // on -> off

  //

  for (count = 0; count < 255; ++count) {

   set(led_port,blue);

   set(led_port,green);

   set(led_port,red);

   for (pwm = count; pwm < 255; ++pwm)

   PWM_delay();

   clear(led_port,blue);

   clear(led_port,green);

   clear(led_port,red);

   for (pwm = 0; pwm < count; ++pwm)

   PWM_delay();

  }

 }

}

 

This code can modify the time at which the color changes are made very simply by changing the delay parameter (25), which currently has a delay of 25 ms. Performing color variations and video; however, if the parameter is changed color changes are faster or slower. You can also change the color settings to select which one is led to light and thus generate different colors by combining red, green and blue.

 

As a complement to this assignment and to use in the final draft, it will make a opto-coupling circuit to control the temperature of the resistance function will heat the material.

 

For this assignment which must make a card external outputs, for this you will work with an opto electronic coupling in this way will work with alternating and direct current without any problems of noise signals introduced by the alternating signal line, this in order to activate and deactivate the heat generating electrical resistance of the final project, analyzing the possibility of introducing a PWM signal controlled by a P controller to keep the temperature constant only

 

 

Assignment13_5
Assignment13_6