Microcontrollers
There are a number of microcontroller components that must be taken into consideration when viewing different units. These necessary types and values for each part will vary from one controller to another, but the general information remains constant throughout. The ‘generic’ microcontroller information that needs to be researched before purchase is as follows:
- General input/output pins available
- Type of communication between components
- Development environments available
- Onboard memory available
- Power needed for operation
- Cost of controller and development kits
The number of input and output pins is an essential aspect of the microcontroller. These pins are what allow the controller unit to communicate with other devices that may be connected. Thus, there must be an adequate number of pins that will be reserved for various functions. If there are an insufficient number of pins then the system would not have proper communication between devices and would never properly function. One would also want to avoid purchasing a controller with too many in/out pins. The reason is that more pins generally mean a larger controller and a slight increase of price. To ensure that the proper amount of in/out pins are selected for the controller, it would be advised to tally up how many pins are required for each device to be interfaced with the controller. Microcontrollers come equipped with a wide range of general input/output pins available. There are models with as few as four and far exceeding forty pins. This makes the controllers able to handle a wide range of applications.
The type of communication the microcontroller uses over the input and output pins is also an important issue to be dealt with. The communication between components must be synchronized in some way to make sure that the data is properly passed. If the components are not coordinated with each other, data may be lost due to false highs and lows in the voltages, or the signal may not be stable for the proper amount prior to the clock change to properly read the data. There are a few methods easily incorporated to make sure the components are in step with one another. One method is using a general clock line that would stem from the microcontroller and connect to the various components. This would ensure that all components are running in harmony with each other. The use of this method would cause an extra bus line on the developed circuit board. Another method is called asynchronous communication and would be accomplished by the use of a serial communication line. Communication done in this fashion requires no clock line for synchronization. This would mean that when the components want to talk to one another there would be a “handshake” between them. This handshake allows the different components to send the data between them at the same speeds, and in step with one another. The downside to this is the increased overhead in the information passed between components. To do this the microcontroller and the connected device would need to have input/output pins that supported a serial communication. Controllers currently available can support one or both of the communication types mentioned above making them suited for the connection of many different devices.
The environments available for one to program the microcontroller is another aspect one would look into when purchasing a suitable unit. Depending on the brand and model there are different programming languages that one could use. Most controllers allow a person to design the code an assembly language that is native to the brand to program the unit. Some will allow a user to use a high level language such as C or C++ to develop their chip. While coding in C and other high level languages is generally machine independent assembly languages can differ from chip to chip. For different brands there are different registers available and different ways to write and store data. When considering which environment to choose one should consider what languages they are more comfortable with. Also if choosing an assembly environment one should review the structure of the language before programming. Choosing a more familiar language will reduce development time and reduce the amount of programming errors that may occur.
Onboard memory is another key factor when selecting a microcontroller. This memory is used to store not only any data that will be sent to and retrieved from the controller, but also the programming that allows your controller to work properly. There are many different values of memory available on controllers that make it easy to select a proper amount. Depending on the complexity and number of functions to be incorporated within the unit the more memory one would need available. In many cases the memory available for the main programming and input/output data is separated. This allows the programmer to make sure when data is being written to the controller no part of the controllers programming is being deleted or overwritten. Different types of memory available on chips such as random access memory (RAM), read only memory (ROM), and FLASH memory. The different types would serve different purposes. RAM is volatile memory so if there is power disruption all data stored would be lost. This is not a memory that one would use for programming but rather use for temporary data that is sent and received from the controller. The FLASH and ROM is a non-volatile memory and would be ideal for placing the controller’s main programming on. This is because even if there is no power the information stored will remain keeping the unit functional. If the main software running the controller was lost the unit would be rendered completely inoperative. Of course selecting the exact amount of memory needed would be ideal the amount is not easily calculated. If unsure of the amount needed it would be better to use a non-conservative estimate.
The voltage levels required by the microcontroller to operate are very important for many projects. In nearly every project power consumption is a factor to consider. If the power consumption of the chip is large it will cost more to operate, or drain battery power often. In order to keep cost of electricity down and extend the life of batteries a microcontroller that consumes very little power would be ideal in nearly all cases. The operating voltage of a chip can be as low as 1.8 volts (for ultra-low power devices) to approximately 8 volts. Other power saving features included on many controller units is use of standby and hibernate modes. Standby modes allow the chip to suspend most operations and run at very low power levels. The unit uses an interrupt to return to its active mode, which is initiated by some type of input caused from by an end user or connected device. Hibernate mode allows the chip to store all data currently being used and completely turn the chip off. Thus when the controller is put into hibernate mode all temporary data is stored on non-volatile memory and the chip is turned off to stop the usage of power. The next time the unit is powered on all of the saved information is reloaded into its proper location of RAM and the controller is returned into the operational mode. Nearly all controllers available support many levels of standby modes and a hibernate mode. This allows developers to decrease the amount of power consumption as much as possible.
To keep the final design cost of a project down the price per microcontroller and for the development kits need to be researched. Many controllers are available at a fairly low cost ranging from approximately three to fifteen dollars. The development kits however can run substantially higher in price. There are a few factors that influence the price of development kits, the brand, family, and features. These packages can cost a person or business as little as twenty dollars and can exceed two hundred dollars. Some of the features that may be included in a development kit include support for high level programming, USB or serial port interfacing, simulation tools for the controller, simulation tools for interfacing controller with other devices, and development boards. Often the more tools that one could purchase in the kit the easier it is to program the microcontroller. This is due the added support and testing methods.
Remote Control Microcontroller
Input/Output Programming Controls
The main module that will be managing the remote control unit is the microcontroller. This unit will be responsible for controlling a variety of devices as follows:
- RF Transceiver
- LCD with LED Backlight
- End User Input Commands
When choosing the proper controller for this part of the design project the following controller specifications where considered:
- General Input/Output Pins
- Supported Communication
- Development Kits
- Features and Environments
- Onboard Memory
- Power Consumption
The microcontroller will be responsible for setting the RF transceiver into send/receive mode, switching the unit on and off, and communicating packet data between them. Most of the RF transceivers viewed have two general in/out pins, but if the transceivers are bought in units of a receiver, and transmitter there will be four pins required on the controller unit. These pins will be used to transport information to and from the controller and transceiver. The microcontroller will use the design teams developed software to organize and read the data included into the packets that are being transmitted wirelessly. When not in use the microcontroller will be switching the RF unit on/off or into sleep modes to preserve power.
To display text an LCD with a LED backlight will be incorporated. These units will be in part controlled by the microcontroller. Many of the displays use ten control pins that will be connected to the controller. Two of the pins will set the modes the LCD is currently in. The microcontroller will then send a high or low signal over the other eight pins that correspond to specific ASCII symbols to be displayed. This will be controlled by the controller’s software, and will be done by loading each bit of the ACCII character onto the proper output pin. The controller will also have to set the LCD into a standby/hibernate mode when not in use. This will help prolong battery life by lowering power consumption.
The user inputs from the remote unit will also have to be run through the microcontroller. These inputs will be translated by the microcontroller to provide a variety of functions that must be programmed into the controller. A few examples of the routines would be to toggle a light between on and off, check the status of the lights and set a particular switch to a button. The number of pins required to accomplish this greatly depends on how many rooms the system will be allowed to handle, and how many lights are available per room. If the system is to be robust enough to handle nearly all clients there will need to be approximately eight rooms with four lights per room. This would allow the system to compensate for thirty two different light switches. For the controller to accept this amount of rooms and lights there would need to be eleven input/output pins. For the user to check the status of the lights and to set the switches to buttons there would be an additional two pins used. Thus there would be a preliminary total of thirteen user input pins. This value may vary depending on the specs of the final product.
The remote control unit needs a microcontroller that would be able to support approximately twenty seven general input/output pins. The communication over these pins may need to be serial or clocked depending on the connected devices. The specifications noted are easily achieved with available products.
Using a development kit that enables extensive virtual testing would allow for an easier implementation of the remote control. It would also benefit the design team to select a kit that allows for high level programming, and supports USB interface.
The amount of memory that will be needed for the remote control is not yet known. This is a hard value to quantize of the information already known. What is known are the types of memory that should be available and approximate complexity of the controller’s software. The remote unit should include both ROM or FLASH and RAM. The ROM or FLASH will be used for the main software and other information such as a table of addresses for each light. The RAM will be used to send data to the other components such as the LCD and transceiver. There should also be substantially more ROM or FLASH when compared to the amount of RAM.
The amount of power needed to run the microcontroller of the remote control is a very important aspect to consider for this project. This is because the remote unit will be battery powered. Thus a low power unit is necessary to prolong battery life. The models of controllers that operate at 1.8 volts would be a first choice in controllers. An ideal controller for this project would also allow for both standby and a hibernate modes.
For the project at hand the ideal specifications for the microcontroller would be:
- At least 27 general input/output pins
- Supporting Asynchronous communication (Serial)
- Available Clock Line
- Familiar Development Environment such as the C programming language
- Virtual development and testing
- Combination of Memory types
- FLASH or ROM for program
- RAM for temporary data
- Low power consumption
- 1.8 volts to power
- Low cost for chip and development tools
A basic diagram of the microcontroller and component interface is as follows:
Wall Unit Microcontroller
Input/Output Programming Controls
The main module that will be controlling the wall switch unit is the microcontroller. This unit will be responsible for controlling the following devices:
- RF Transceiver
- Power Switch
- Dimmer
- End User Inputs
When choosing the proper controller for this part of the design project the following controller specifications where considered:
- General Input/Output Pins
- Supported Communication
- Development Kits
- Features and Environments
- Onboard Memory
- Power Consumption
The RF communication for the wall switch will work in much the same way the remote control will manage the device. The packet information will be organized and analyzed in the same fashion. The main difference is that the use of the hibernate function will not be employed. The wall switch may receive wireless data without any prior warning so the RF transceiver will need to stay in either the operational or standby modes.
Two turn the light on and off a switch will need to be incorporated onto the AC line. Many of the wireless light controls on the market require the wall switch to be on for the remote control to work. To circumvent the problem the microcontroller will control the light from the switch and the allowing independent toggling of the light between the wall switch and remote control unit. There are different ways to do this, one method is to have a physical switch that will break and connect the AC power line when the light status is to be switched. In order to turn on or off the light the physical switch would receive a signal from the microcontroller to change its status. The positive side to this is that there will be no power loss when the light is not on. The downsides include the possible malfunction of the mechanical switch. Another possible method is to use a power metal oxide field effect transistor (MOSFET) to control the switch. This method would also be controlled by the microcontroller. When the MOSFET is to be on an output voltage from the controller would be sent to the transistor. By eliminating this voltage the MOSFET would not allow the AC power to flow through to the light. This allows the switch to be digitally controlled and lowers the possibility for mechanical failure. On the other hand there is some power loss when the transistor is off. For this project the power MOSFET seems to be the best choice. This device requires only one control line from the microcontroller and is smaller in size than a physical switch.
A dimmer for the lights would also be controlled by the microcontroller. This would require approximately one input/output pin. When a dimming level is selected by the end user the microcontroller would have to compute the proper level and set a triode for alternating current (TRAIC) to fire at the appropriate level. If the dimming is set to half power the controller needs to set the TRIAC to fire when the AC voltage is at half power. This is possible because the voltage and frequency is known so the controller will have to have a preset function to find the proper levels.