This document provides information on interfacing circuits and components for use with PICAXE microcontrollers. It begins with an overview of standard interfacing circuits that can be used with most output devices, such as transistor circuits, Darlington driver ICs, relay circuits, and power MOSFET circuits. The document then describes how to interface various output devices like LEDs, lamps, buzzers, motors, stepper motors, servos, displays and more using these standard circuits. It also covers interfacing common input devices like switches, potentiometers, light sensors and temperature sensors. The document concludes with examples of interfacing more advanced components such as LCD displays and serial communication. Code samples and circuit diagrams are provided throughout to illustrate
This document introduces microcontrollers and compares them to microprocessors. It focuses on AVR microcontrollers, describing their components, architectures like ATmega16, and how to program them using an ISP. Microcontrollers integrate CPU, memory and peripherals onto a single chip while microprocessors require external components. AVRs are faster and use less power than other microcontrollers. The document provides an overview of AVR features and tutorials for further learning.
this is a complete summer training report on embedded sys_AVR. It aslo includes a project and its coding and other topics which are learnt in training.
Training Report on embedded Systems and RoboticsNIT Raipur
Deepak Kumar completed a training report on embedded systems and robotics at I3indya Technologies in Delhi for his vocational project in the 2012-2013 academic year. He studied topics including an overview of embedded systems, microcontrollers like the Atmega16, analog to digital conversion, timers, interfacing various components like 7-segment displays, LCDs, DC motors, sensors, and more. The 3-page report was submitted to his college, the National Institute of Technology Raipur, to fulfill requirements for his Bachelor of Technology degree.
The STM32L4 MCU series provides several key advantages for ultra-low-power applications with performance:
1) It offers 1 Mbyte of Flash memory and 128 Kbytes of SRAM with safety and security features, smart and numerous peripherals, and advanced low-power analog circuits in small packages.
2) ST has built a new architecture to achieve best-in-class ultra-low-power figures through high flexibility as well as deliver 100 DMIPS at 80 MHz based on its Cortex-M4 core with FPU.
3) It addresses a large market range through innovations like smart peripherals and embeds benefits from the STM32 ecosystem and pin compatibility.
This document provides an introduction to microcontrollers and embedded systems. It discusses C/C++ programming basics for microcontrollers, including variable types, memory, numbering systems, and loops. It also covers electrical components and circuits for interfacing sensors and actuators with microcontrollers, such as resistors, capacitors, analog-to-digital conversion, and pulse-width modulation. The document is intended to cover the fundamentals needed for robotics applications using embedded microcontroller systems.
This document provides an overview of digital input/output drivers and related topics for an ATMEGA 32 microcontroller. It discusses ATMEGA 32 ports and registers for controlling I/O, pull-up/pull-down resistors, switch types and debouncing, LEDs, seven segment displays, and LED matrices. Practical examples are given for interfacing these components through software and external driver chips.
This document introduces microcontrollers and compares them to microprocessors. It focuses on AVR microcontrollers, describing their components, architectures like ATmega16, and how to program them using an ISP. Microcontrollers integrate CPU, memory and peripherals onto a single chip while microprocessors require external components. AVRs are faster and use less power than other microcontrollers. The document provides an overview of AVR features and tutorials for further learning.
this is a complete summer training report on embedded sys_AVR. It aslo includes a project and its coding and other topics which are learnt in training.
Training Report on embedded Systems and RoboticsNIT Raipur
Deepak Kumar completed a training report on embedded systems and robotics at I3indya Technologies in Delhi for his vocational project in the 2012-2013 academic year. He studied topics including an overview of embedded systems, microcontrollers like the Atmega16, analog to digital conversion, timers, interfacing various components like 7-segment displays, LCDs, DC motors, sensors, and more. The 3-page report was submitted to his college, the National Institute of Technology Raipur, to fulfill requirements for his Bachelor of Technology degree.
The STM32L4 MCU series provides several key advantages for ultra-low-power applications with performance:
1) It offers 1 Mbyte of Flash memory and 128 Kbytes of SRAM with safety and security features, smart and numerous peripherals, and advanced low-power analog circuits in small packages.
2) ST has built a new architecture to achieve best-in-class ultra-low-power figures through high flexibility as well as deliver 100 DMIPS at 80 MHz based on its Cortex-M4 core with FPU.
3) It addresses a large market range through innovations like smart peripherals and embeds benefits from the STM32 ecosystem and pin compatibility.
This document provides an introduction to microcontrollers and embedded systems. It discusses C/C++ programming basics for microcontrollers, including variable types, memory, numbering systems, and loops. It also covers electrical components and circuits for interfacing sensors and actuators with microcontrollers, such as resistors, capacitors, analog-to-digital conversion, and pulse-width modulation. The document is intended to cover the fundamentals needed for robotics applications using embedded microcontroller systems.
This document provides an overview of digital input/output drivers and related topics for an ATMEGA 32 microcontroller. It discusses ATMEGA 32 ports and registers for controlling I/O, pull-up/pull-down resistors, switch types and debouncing, LEDs, seven segment displays, and LED matrices. Practical examples are given for interfacing these components through software and external driver chips.
This document provides information about integrating a keyboard and LCD display with a microcontroller and creating a CID calculator project. It includes:
1) Block diagrams and classifications of microprocessors and microcontrollers.
2) Instructions on connecting a 4x4 keyboard to a microcontroller port and reading button presses.
3) Details on initializing and writing text and numbers to a 16x2 LCD display connected to a microcontroller.
4) An overview of the steps needed to program a microcontroller and create a CID calculator, including required components and sample code.
The document provides an overview of embedded systems and their components. It discusses embedded hardware such as microcontrollers and microprocessors. Specific microcontrollers like the 8051 and PIC are examined in terms of their features, pin diagrams, and basic components. The hardware design of embedded systems including power supply, signal generation, and peripheral integration is also covered. Programming embedded systems in C and example programs are outlined.
The document provides information about interfacing an RF transmitter module with an Arduino board. It includes the technical specifications of the RF transmitter and receiver modules. The circuit diagram shows how to connect the RF transmitter module to an Arduino board. It also includes the Arduino code for the RF transmitter to send digital signals and the RF receiver code to receive the signals and control an LED accordingly.
The document discusses several embedded application development platforms including Arduino, Raspberry Pi, Tiva C Series, and MSP430. It provides overview information on each platform, including key components, features, programming languages supported, and examples of applications. For Arduino, it describes the Arduino Uno board in detail. For Raspberry Pi, it outlines the basic specifications and components. For Tiva C Series and MSP430, it summarizes the development boards and features of the microcontrollers.
The document discusses the AVR microcontroller architecture. It describes how AVR was developed in 1996 and derives its name from its creators. There are three families of AVR microcontrollers: TinyAVR for simpler applications, MegaAVR for moderate to complex applications, and XmegaAVR for high speed complex applications. The document then focuses on describing the features of the ATmega16 microcontroller, including its I/O ports, ADC, timers, memory, and communication interfaces.
What is Microcontroller, Microcontroller vs Microprocessor, Development/Classication of microcontrollers, Harvard vs. Princeton Architecture, RISC AND CISC CONTROLLERS
Features of RISC, Microcontroller for Embedded Systems
10 x86 PC Embedded Applications, Choosing a Microcontroller
Criteria for Choosing a Microcontroller, Mechatronics, and Microcontrollers, A brief history of the PIC microcontroller, PIC Microcontrollers, Feature: PIC16F877, Simplied Features.
Summer training embedded system and its scopeArshit Rai
CETPA INFOTECH PVT LTD is one of the IT education and training service provider brands of India that is preferably working in 3 most important domains. It includes IT Training services, software and embedded product development and consulting services.
Summer training project report on embedded system at BSNL ALTTC Ghaziabad. Submitted by RAM AVTAR (ECE Department of IMSEC) of 2016 Batch. Submitted in IMS Engineering College, Gaziabad
Introduction on STM32 Platform and Presentation of a Water-Level & Temperatur...Julio César Carrasquel
The following slides were used as an introductory support for the hands-on workshop on the STM32 Platform that was held on the Pervasive Systems course (La Sapienza University of Rome, May 2017).
This document provides an overview of an introduction to STM32 course. The course covers the ARM Cortex processor, STM32 system on chip, STM32 building blocks, low power operation, safety features, the flash module, and development tools. The goal of the course is to help students understand what the ARM Cortex processor and STM32 SoC are, and identify the main components of the STM32 microcontroller.
Embedded system hardware architecture iiGrace Abraham
This document discusses several topics related to embedded system hardware and software design including electrostatic discharge effects, fault tolerance techniques, hardware development tools, software development tools, thermal analysis and design considerations for battery-powered systems. It also covers processor performance metrics like instructions per second, operations per second, and benchmarks.
embedded systems and robotics on avr platformNeha Sharma
This document discusses embedded systems and robotics using an AVR microcontroller platform. It begins with an overview of embedded systems and types. Real-time and non-real-time embedded systems are described. Examples of embedded system applications include cell phones, printers, and environmental monitoring. The ATmega16 microcontroller is then explained, including its pin diagram and features. Programming the microcontroller using Code Vision AVR is covered as well as I/O functions. The document concludes with sections on robotics laws, how an autonomous robot moves using motors and sensors, and a conclusion that electronics, mechanics, and software combine to create a robot.
This document provides an overview of microcontrollers and embedded systems. It discusses characteristics of embedded systems and integrated circuits used in processors. It also describes challenges in embedded system design and common microcontrollers like the 8051. Examples are given of interfacing components like seven segment displays, keypads, and LCDs to microcontrollers. Finally, an example project is outlined for an electronic code lock using a microcontroller and password input from a keypad.
This document provides an overview of embedded systems and interfacing with the ATmega8 microcontroller. It discusses the characteristics of embedded systems and gives examples such as appliances, medical devices, vehicles, and more. It also covers the 8051 and AVR microcontrollers, focusing on the ATmega8's architecture, programming, and interfacing with various components like LEDs, LCDs, seven segment displays, motors, and sensors. The goal is to provide knowledge about embedded systems and practical experience interfacing the ATmega8 microcontroller.
This document introduces the STM32 microcontroller. It will cover the ARM Cortex processor, the STM32 system-on-chip, and its basic building blocks. The course outline includes introductions to the Cortex architecture, CMSIS standard, STM32 system architecture, peripherals, low power operation, safety features, flash memory, and development tools.
This presentation provides an overview of embedded systems and describes a collision avoidance robot project. It discusses embedded systems concepts like microcontrollers and examples. It then describes the key components of the collision avoidance robot project including infrared sensors to detect obstacles, an 8051 microcontroller as the control unit, a DC motor as the actuator, and coding in assembly language to control the robot's movement and avoid collisions. The robot is able to move forward and backward, as well as turn, based on signals from its front and rear sensors to navigate around detected obstacles.
This curriculum vitae summarizes the education and work experience of Alexander R. Mait. He received a Bachelor's degree in Physics and Mathematics from Washington and Lee University and a Master's degree in Mechanical and Aerospace Engineering from the University of Virginia. His research focuses on injury biomechanics and prevention, specifically syndesmotic ankle sprains. He has managed several cadaveric research projects studying ankle mechanics and ligament behavior. Mait has authored and co-authored several journal publications and conference papers on his biomechanics research.
This document provides information about integrating a keyboard and LCD display with a microcontroller and creating a CID calculator project. It includes:
1) Block diagrams and classifications of microprocessors and microcontrollers.
2) Instructions on connecting a 4x4 keyboard to a microcontroller port and reading button presses.
3) Details on initializing and writing text and numbers to a 16x2 LCD display connected to a microcontroller.
4) An overview of the steps needed to program a microcontroller and create a CID calculator, including required components and sample code.
The document provides an overview of embedded systems and their components. It discusses embedded hardware such as microcontrollers and microprocessors. Specific microcontrollers like the 8051 and PIC are examined in terms of their features, pin diagrams, and basic components. The hardware design of embedded systems including power supply, signal generation, and peripheral integration is also covered. Programming embedded systems in C and example programs are outlined.
The document provides information about interfacing an RF transmitter module with an Arduino board. It includes the technical specifications of the RF transmitter and receiver modules. The circuit diagram shows how to connect the RF transmitter module to an Arduino board. It also includes the Arduino code for the RF transmitter to send digital signals and the RF receiver code to receive the signals and control an LED accordingly.
The document discusses several embedded application development platforms including Arduino, Raspberry Pi, Tiva C Series, and MSP430. It provides overview information on each platform, including key components, features, programming languages supported, and examples of applications. For Arduino, it describes the Arduino Uno board in detail. For Raspberry Pi, it outlines the basic specifications and components. For Tiva C Series and MSP430, it summarizes the development boards and features of the microcontrollers.
The document discusses the AVR microcontroller architecture. It describes how AVR was developed in 1996 and derives its name from its creators. There are three families of AVR microcontrollers: TinyAVR for simpler applications, MegaAVR for moderate to complex applications, and XmegaAVR for high speed complex applications. The document then focuses on describing the features of the ATmega16 microcontroller, including its I/O ports, ADC, timers, memory, and communication interfaces.
What is Microcontroller, Microcontroller vs Microprocessor, Development/Classication of microcontrollers, Harvard vs. Princeton Architecture, RISC AND CISC CONTROLLERS
Features of RISC, Microcontroller for Embedded Systems
10 x86 PC Embedded Applications, Choosing a Microcontroller
Criteria for Choosing a Microcontroller, Mechatronics, and Microcontrollers, A brief history of the PIC microcontroller, PIC Microcontrollers, Feature: PIC16F877, Simplied Features.
Summer training embedded system and its scopeArshit Rai
CETPA INFOTECH PVT LTD is one of the IT education and training service provider brands of India that is preferably working in 3 most important domains. It includes IT Training services, software and embedded product development and consulting services.
Summer training project report on embedded system at BSNL ALTTC Ghaziabad. Submitted by RAM AVTAR (ECE Department of IMSEC) of 2016 Batch. Submitted in IMS Engineering College, Gaziabad
Introduction on STM32 Platform and Presentation of a Water-Level & Temperatur...Julio César Carrasquel
The following slides were used as an introductory support for the hands-on workshop on the STM32 Platform that was held on the Pervasive Systems course (La Sapienza University of Rome, May 2017).
This document provides an overview of an introduction to STM32 course. The course covers the ARM Cortex processor, STM32 system on chip, STM32 building blocks, low power operation, safety features, the flash module, and development tools. The goal of the course is to help students understand what the ARM Cortex processor and STM32 SoC are, and identify the main components of the STM32 microcontroller.
Embedded system hardware architecture iiGrace Abraham
This document discusses several topics related to embedded system hardware and software design including electrostatic discharge effects, fault tolerance techniques, hardware development tools, software development tools, thermal analysis and design considerations for battery-powered systems. It also covers processor performance metrics like instructions per second, operations per second, and benchmarks.
embedded systems and robotics on avr platformNeha Sharma
This document discusses embedded systems and robotics using an AVR microcontroller platform. It begins with an overview of embedded systems and types. Real-time and non-real-time embedded systems are described. Examples of embedded system applications include cell phones, printers, and environmental monitoring. The ATmega16 microcontroller is then explained, including its pin diagram and features. Programming the microcontroller using Code Vision AVR is covered as well as I/O functions. The document concludes with sections on robotics laws, how an autonomous robot moves using motors and sensors, and a conclusion that electronics, mechanics, and software combine to create a robot.
This document provides an overview of microcontrollers and embedded systems. It discusses characteristics of embedded systems and integrated circuits used in processors. It also describes challenges in embedded system design and common microcontrollers like the 8051. Examples are given of interfacing components like seven segment displays, keypads, and LCDs to microcontrollers. Finally, an example project is outlined for an electronic code lock using a microcontroller and password input from a keypad.
This document provides an overview of embedded systems and interfacing with the ATmega8 microcontroller. It discusses the characteristics of embedded systems and gives examples such as appliances, medical devices, vehicles, and more. It also covers the 8051 and AVR microcontrollers, focusing on the ATmega8's architecture, programming, and interfacing with various components like LEDs, LCDs, seven segment displays, motors, and sensors. The goal is to provide knowledge about embedded systems and practical experience interfacing the ATmega8 microcontroller.
This document introduces the STM32 microcontroller. It will cover the ARM Cortex processor, the STM32 system-on-chip, and its basic building blocks. The course outline includes introductions to the Cortex architecture, CMSIS standard, STM32 system architecture, peripherals, low power operation, safety features, flash memory, and development tools.
This presentation provides an overview of embedded systems and describes a collision avoidance robot project. It discusses embedded systems concepts like microcontrollers and examples. It then describes the key components of the collision avoidance robot project including infrared sensors to detect obstacles, an 8051 microcontroller as the control unit, a DC motor as the actuator, and coding in assembly language to control the robot's movement and avoid collisions. The robot is able to move forward and backward, as well as turn, based on signals from its front and rear sensors to navigate around detected obstacles.
This curriculum vitae summarizes the education and work experience of Alexander R. Mait. He received a Bachelor's degree in Physics and Mathematics from Washington and Lee University and a Master's degree in Mechanical and Aerospace Engineering from the University of Virginia. His research focuses on injury biomechanics and prevention, specifically syndesmotic ankle sprains. He has managed several cadaveric research projects studying ankle mechanics and ligament behavior. Mait has authored and co-authored several journal publications and conference papers on his biomechanics research.
The document lists locations and events related to summer learning opportunities in 2008. It mentions a summer learning fair in Nashville, TN and Portland, OR as well as a Summer Learning Institute that took place that year.
El documento describe tres situaciones positivas o corregidas en un pueblo. Primero, se colocaron vallas frente a un colegio para evitar que los alumnos salgan a la calzada y que los vehículos suban a la acera. Segundo, se quitarán los postes de cableado que quedan en la fachada del colegio. Tercero, la acera frente a una biblioteca que había desaparecido debido a una obra ahora es transitable nuevamente para los peatones.
I am wearing is a drawing project from 2006/07 for 2nd year students in groups A and B. The document appears to be about an art assignment where students drew what they were wearing. In 3 sentences or less, it summarizes the title, date, and subject of the artwork created for the project.
O documento apresenta uma avaliação econômico-financeira da concessão do Aeroporto Internacional de Salvador. Ele inclui premissas de volumes de passageiros e receita, custos operacionais, investimentos, fluxo de caixa, análise de viabilidade financeira e geração de dividendos para os acionistas ao longo do período da concessão.
El documento describe las funciones de varias comisiones para un seminario, incluyendo una comisión de redacción para redactar documentos con buena ortografía y sinónimos, una comisión de revisión para revisar el material antes de la impresión, y una comisión de disciplina para asegurar que se cumplan las tareas y normas.
Flexibele arbeid is binnen tien jaar de norm, verwacht Raymond Wijnands, managing director van de Poel Nederland. Dat levert niet alleen een paar stevige uitdagingen op, maar ook grote kansen.
In deze workshop krijgt u concrete handvatten om gestructureerd aan de slag te gaan met strategische personeelsplanning. Vanuit de ondernemingsstrategie, via de organisatie van arbeid naar een gap-analyse van benodigde en beschikbare competenties. Met wellicht de belangrijkste vraag: wat wordt de rol van flexibele arbeid binnen uw strategische personeelsplanning? En hoe haalt u maximaal rendement uit die flexibele schil?
Raymond Wijnands verzorgde deze presentatie tijdens P&O strategisch jaarcongres op 17 april in de Jaarbeurs, Utrecht.
Este documento descreve o programa de uma festa religiosa de Nossa Senhora das Grotas que ocorrerá entre 30 de agosto e 8 de setembro de 2016, incluindo um novenário, datas comemorativas, transmissões ao vivo, participação de várias comunidades católicas, início do pastoreio do novo bispo, procissão e missas solenes.
Para recuperar un archivo borrado, hay que iniciar el ordenador en modo seguro pulsando F8 durante el encendido, luego conectar un USB y copiar el archivo de la carpeta COMO_LO_HAGO al USB para recuperarlo. El modo seguro ofrece opciones como modo seguro normal, con funciones de red o con símbolo del sistema para facilitar la búsqueda y copia del archivo borrado en un dispositivo externo USB.
Consolidated Analytic Report - Second ShowIZE Creative
Consolidated Analytic Report of the Social Media Presence (Mainly Facebook) of the movie Second Show, handled by us. Started on an Online Advertising Budget of "Zero", all audience growth was completely organic, a feat which we are still very proud of!
With a couple of firsts like holding the First Celebrity Wall Chat in Malayalam Film Industry, the movie made a huge presence in the Social Media circles and eventually went on to become the first SuperHit of 2012!
Os alunos devem produzir 4 fotos em duplas explorando a perspectiva forçada até 30/11 ou 03/12, usando um celular ou câmera e aplicando a Regra dos Terços, enviando para o professor de Arte por e-mail.
La tabla periódica tiene sus orígenes en los antiguos filósofos griegos como Empédocles y Aristóteles, quienes propusieron los primeros modelos de elementos. Más tarde, los alquimistas descubrieron nuevos elementos a través de la transformación de sustancias. En el siglo XIX, científicos como Dalton establecieron las bases teóricas de los átomos y la composición química. Döbereiner identificó patrones en grupos de tres elementos, mientras que Newlands y Mendeleiev crearon las primeras t
The document lists various locations and people followed by the word "toilets" in Spanish, including:
1) Cities like Del Mundo, Florence, Germany 2006, England, France, New York, Las Vegas, Japan, and Florida.
2) Groups like athletes, musicians, and bankers.
3) Individuals like Rosie O'D, people with stomach problems, mothers with large families, mothers-in-law, Bush, and Clinton.
4) Generic references to public toilets and toilets for women.
The main idea of Octagram approach is based on the execution of all tasks by one platform - controller with necessary substitutable software. Thus, the platform A1 can be used for any facility with any size and complexity.
In our technology, there is no need to search and match equipment, one can determine necessary functions, and the compatible software can be directly ordered from the catalog; and as a rule, only the selected functions should be paid.
This document is a report on a wireless based control project submitted for a Bachelor of Technology degree. It describes a wireless secured lock system using an AT89S52 microcontroller that allows only authorized persons to access appliances via entering a code on a keypad. The system uses RF transmission at 433MHz between a transmitter with an encoder, and a receiver with a decoder connected to the microcontroller. If the entered code matches the stored code, the microcontroller activates a relay to power the appliance. The report includes block diagrams of the system components, descriptions of the microcontroller and other ICs, the circuit diagram, and the software flowchart.
The PIC16C505 is an 8-bit microcontroller with 1024 bytes of program memory and 72 bytes of data memory. It uses a Harvard architecture with separate program and data buses. The PIC16C505 has a RISC-style architecture with 33 single-cycle instructions. It includes features like an 8-bit ALU, 8-bit working register, STATUS register, and Timer0 module. The device comes in 14-pin packages and supports features like in-circuit serial programming and various oscillator options.
This document provides an overview and instructions for using various ControlNet communication modules with Logix5000 control systems. It describes the different module options and how to connect a computer to the ControlNet network. The document also explains how to configure ControlNet modules using RSLogix 5000 and RSNetWorx software, including adding local and remote modules, downloading projects, and scheduling the ControlNet network. Instructions are provided for controlling I/O, messaging, and communicating with HMIs over ControlNet.
Rodrigo Almeida - Microkernel development from project to implementationFelipe Prado
This document discusses developing a microkernel from project to implementation. It covers topics like kernel components, designing a kernel project, concepts for developing a microkernel like function pointers and structs, building a device driver controller, and using callbacks. Code examples are provided for initializing hardware and communicating with an LCD. The goal is for participants to have a better understanding of kernels, their advantages, and restrictions.
This document provides an overview of the TCP/IP protocol suite. It begins with an introduction to the OSI reference model and describes how the TCP/IP model compares. The key layers of the TCP/IP model are then discussed in more detail, including the application layer, transport layer, internet layer, and network access layer. Specific protocols associated with each layer like TCP, UDP, IP, Ethernet, and PPP are also introduced.
This document provides an overview of the TCP/IP protocol suite. It begins with an introduction to the OSI reference model and compares it to the TCP/IP model. The tutorial then describes each layer of the TCP/IP model in detail, including the application layer, transport layer, internet layer, and network access layer. It provides examples of common protocols that operate at each layer, such as TCP and IP at the transport and internet layers respectively, and Ethernet at the network access layer.
Density based traffic light controlling (2)hardik1240
The document discusses the aims and scope of a project to build a traffic control system based on density. It uses IR sensor pairs placed at intervals to automatically detect traffic density and give priority to heavier traffic. The system aims to solve the problem of wasted time at intersections when traffic density is uneven between sides. It will control traffic lights based on real-time density calculations from the sensor data.
CodeWarrior, Linux; OrCad and Hyperlynx; QMS Toolsdjerrybellott
This document describes the configuration of a Freescale 8313RDB board with a PowerQuicII 8313 processor running Linux. It includes the configuration file contents which set memory window addresses and DDR controller registers to interface external memory. It also describes using U-Boot to load Linux and the Codewarrior IDE to compile and download programs to the board.
SoMachine is an OEM software solution that allows users to program, configure, and commission entire machines from a single environment. It supports programming and commissioning of logic, motor control, HMI, and network automation functions using Schneider Electric controllers and devices. SoMachine aims to optimize machine development and help users achieve machine transparency.
Tech Book: WAN Optimization Controller Technologies EMC
The document discusses network and deployment topologies for WAN Optimization Controller (WOC) appliances. It describes various network topologies and implementations that WOCs use to optimize TCP performance over WAN links with high latency and packet loss. It also discusses different deployment topologies for WOCs, including in-path/in-line and out-of-path/routed configurations. Additionally, it provides a brief overview of how WOCs can optimize data at various layers of the OSI model through techniques like TCP acceleration, data deduplication, and compression.
The document is a report submitted by Priya Hada to Ms. Pushpa Gotwal on PLC and SCADA. It includes a certificate signed by Mr. Sudhir Kumar Mishra confirming Priya completed the work. The report contains an introduction to automation, PLCs, and SCADA. It discusses the history and features of PLCs, and provides examples of ladder logic programming. It also covers the architecture, communications, interfacing and applications of SCADA systems.
This document summarizes a paper on practical attacks against HomePlugAV powerline communication devices. It begins by providing background on powerline communication technology and discussing the HomePlugAV specification. It then describes analyzing HomePlugAV networks using various tools to understand the protocols and encryption. The document outlines several practical attacks demonstrated, including intercepting network keys, bruteforcing passwords, and gaining remote memory access on devices once on the network. It concludes by discussing future work areas like firmware analysis and authentication message fuzzing.
This document provides specifications for an LB Remote I/O System, including:
1. System components include backplanes, I/O modules, communication units, and power supplies that plug into slots on the backplanes.
2. Backplanes come in various sizes to accommodate different numbers of I/O modules. Extension backplanes can be used to expand the system.
3. The system supports several fieldbus protocols through different communication unit options and is designed for use in hazardous and non-hazardous areas.
Design and implementation of real time security guard robot using GSM/CDMA ne...Claude Ndayisenga
This is my "Design and implementation of real time security guard robot using GSM/CDMA networking " final year project.NDAYISENGA JEAN CLAUDE at PERIYAR UNIVERSITY .
The document provides information about the Stratix 8000 and Stratix 8300 Ethernet Managed Switches, including:
- An introduction to the switches and their hardware features.
- Instructions for initializing a switch using Express Setup and accessing the switches' management interfaces.
- An overview of the switches' software features, such as VLANs, Smartports, IGMP Snooping, Spanning Tree Protocol, Storm Control, and Port Security.
- Details on how these features isolate and optimize traffic, users, and ports.
This document provides important safety and operational information for the PowerFlex 525 Embedded EtherNet/IP Adapter user manual. It contains warnings about the differences between solid-state and electromechanical equipment. The document also has legal disclaimers noting that Rockwell Automation is not responsible for issues resulting from the use of this equipment and cannot guarantee the accuracy of examples provided. Revision details are provided listing changes to parameters, diagrams and examples between manual versions.
This document provides important user information and safety guidelines for using a PowerFlex 525 Embedded EtherNet/IP Adapter user manual. It outlines revisions that have been made to the manual and provides a table of contents for the manual's chapters which cover topics like setting up the adapter, configuring the adapter and I/O, using implicit and explicit I/O messaging, and using the adapter in multi-drive mode. The document contains instructions and programming examples for integrating the PowerFlex 525 drive with Rockwell Automation controllers over EtherNet/IP networks.
The document discusses programmable logic controllers (PLCs) and supervisory control and data acquisition (SCADA) systems. It provides an overview of PLC components, operation, and ladder logic programming. It also describes key SCADA features such as dynamic process graphics, alarms, recipes, security, and connectivity. The document outlines two projects - one using a PLC to control LEDs and another using SCADA software to simulate a sewage water treatment system.
The Indian government has been working over the past few years to include elements of ITS in the transport sector. This standard ensures the optimal operation of the current transport infrastructure. It also increases the efficiency, safety, comfort, and quality of the system. That is why the government created the AIS-140 standard. Compliance with this standard means all vehicles used for public transit must have panic buttons and vehicle tracking modules installed. Nevertheless, in future in the standard protocol of AIS-140 you can expect fare collection and CCTV capabilities.
Get more information here: https://blog.watsoo.com/2023/12/27/all-about-prithvi-ais-140-gps-vehicle-tracker/
Google Calendar is a versatile tool that allows users to manage their schedules and events effectively. With Google Calendar, you can create and organize calendars, set reminders for important events, and share your calendars with others. It also provides features like creating events, inviting attendees, and accessing your calendar from mobile devices. Additionally, Google Calendar allows you to embed calendars in websites or platforms like SlideShare, making it easier for others to view and interact with your schedules.
1. 1 Section 3
MICROCONTROLLER INTERFACING CIRCUITS
revolution Revolution Education Ltd. Web: www.picaxe.co.uk
Version 4.4 12/2010
1
www.picaxe.co.uk
Contents
About this manual .......................................................................................... 2
Microcontroller Interfacing Circuits ................................................................... 3
What is a PIC Microcontroller? .......................................................................... 3
What is a PICAXE microcontroller?..................................................................... 3
Interfacing to the PICAXE Microcontroller .......................................................... 4
Note on the BASIC Code Samples ...................................................................... 5
Note on Component Selection .......................................................................... 5
Standard Interfacing Circuits ............................................................................ 6
Standard Circuits 1 - The Transistor Interfacing Circuit ........................................ 6
Standard Circuits 2 - Using a Darlington Driver IC ............................................... 7
Standard Circuits 3 - The Relay Interfacing Circuit .............................................. 8
Standard Circuits 4 - The Power MOSFET Interfacing Circuit ................................. 8
Output Device Interfacing ................................................................................ 9
Output Device 1 - Light Emitting Diode (LED) .................................................... 9
Output Device 2 - Signal Lamp ....................................................................... 10
Output Device 3 - Buzzer ................................................................................ 10
Output Devices 4 - Piezo Sounder & Speaker .................................................... 11
Output Devices 5 - Solar & DC “Toy” Motors ...................................................... 12
Output Device 6 - Unipolar stepper motor ....................................................... 15
Output Device 7 - Bipolar Stepper motor ......................................................... 17
Output Device 8 - Radio Control Servo ............................................................ 19
Output Device 9 - Counter module .................................................................. 20
Output Device 10 - Seven Segment Display ...................................................... 21
Output Device 11 - Solenoid & Solenoid Valves ............................................... 24
Output Device 12 - Smart Wire & Smart Springs ................................................ 25
Input Device Interfacing ................................................................................ 26
Input Device 1 - Switches .............................................................................. 26
Switch Bounce .............................................................................................. 27
Input Device 2 - Potentiometer ...................................................................... 28
Input Device 3 - Light Dependant Resistor (LDR) ............................................. 29
Input Device 4 - Thermistor ........................................................................... 30
Advanced Component Interfacing ................................................................... 31
Advanced Interfacing 1 - LCD Display .............................................................. 31
LCD Characters ............................................................................................... 31
A Simple LCD Program .................................................................................... 37
More Advanced LCD Program........................................................................... 38
Standard LCD Sub-Procedures (Direct Connection)............................................ 39
Advanced Interfacing 2 - Serial Interfacing to a Computer. ............................... 43
Computer Communication Software ................................................................. 43
2. 2 Section 3
MICROCONTROLLER INTERFACING CIRCUITS
revolution Revolution Education Ltd. Web: www.picaxe.co.uk
Version 4.4 12/2010
2
www.picaxe.co.uk
About this manual
Please note an update version of this manual is under preparation. See
www.picaxe.co.uk for latest version
The PICAXE manual is divided into three separate sections:
Section 1 - Getting Started (picaxe_manual1.pdf)
Section 2 - BASIC Commands (picaxe_manual2.pdf)
Section 3 - Microcontroller interfacing circuits (picaxe_manual3.pdf)
This third section provides general microcontroller interfacing circuits, and
example programs, for most common input/output transducers used within
microcontroller circuits.
For general information on getting started with the PICAXE system please see
section 1 of the manual. No prior understanding of microcontrollers is
required. A series of tutorials introduces the main features of the system.
For more specific information, syntax and examples of each BASIC Command
please see section 2 ‘BASIC Commands’.
The software used for programming the PICAXE is called the ‘Programming
Editor’. This software is free to download from www.picaxe.co.uk. This manual
was prepared using Version 5.2.0 of the Programming Editor software. Please
ensure you are using this version (or later) of the software, as earlier versions
may not support all the commands and features described.
The latest version of this document is available on the PICAXE website at
www.picaxe.co.uk
If you have a question about any command please post a question on the very
active support forum at this website.
3. 3 Section 3
MICROCONTROLLER INTERFACING CIRCUITS
revolution Revolution Education Ltd. Web: www.picaxe.co.uk
Version 4.4 12/2010
3
www.picaxe.co.uk
Microcontroller Interfacing Circuits
What is a PIC Microcontroller?
A PIC microcontroller is a single integrated circuit small enough to fit in the palm of a
hand. ‘Traditional’ microprocessor circuits contain four or five separate integrated
circuits - the microprocessor (CPU) itself, an EPROM program memory chip, some
RAM memory and an input/output interface. With PIC microcontrollers all these
functions are included within one single package, making them cost effective and easy
to use.
PIC microcontrollers can be used as the ‘brain’ to control a large variety of products. In
order to control devices, it is necessary to interface (or ‘connect’) them to the PIC
microcontroller. This section will help to enable those with limited electronics
experience to successfully complete these interfacing tasks.
What is a PICAXE microcontroller?
A PICAXE microcontroller is a standard Microchip PICmicro™ microcontroller that has
been pre-programmed with the PICAXE bootstrap code. The bootstrap code enables
the PICAXE microcontroller to be re-programmed directly via a simple serial
connection. This eliminates the need for an (expensive) conventional programmer,
making the whole download system a very low-cost simple serial cable!
The pre-programmed bootstrap code also contains common routines (such as how to
generate a pause delay or a sound output), so that each download does not have to
waste time downloading this commonly required data. This makes the download time
much quicker.
As the blank microcontrollers purchased to ‘make’ PICAXE microcontrollers are
purchased in large volumes, it is possible for the manufacturer to program the
bootstrap code and still sell the PICAXE microcontroller at prices close to standard
catalogue process for single un-programmed PIC microcontrollers. This means the cost
of the PICAXE microcontroller to the end user is very economical.
4. 4 Section 3
MICROCONTROLLER INTERFACING CIRCUITS
revolution Revolution Education Ltd. Web: www.picaxe.co.uk
Version 4.4 12/2010
4
www.picaxe.co.uk
Interfacing to the PICAXE Microcontroller
This section explains how to interface many different input and output devices to the
PICAXE microcontroller. Explanations of BASIC commands are provided in the
Commands section (available separately). The interfacing circuits can also be used
with any other PIC microcontrollers such as the PIC16F84A, although these
microcontrollers may require programming in assembler code.
This section is split into four subsections:
• Introduction to ‘standard’ interfacing circuits
• Output Device Interfacing
• Input Device Interfacing
• Advanced Component Interfacing
5. 5 Section 3
MICROCONTROLLER INTERFACING CIRCUITS
revolution Revolution Education Ltd. Web: www.picaxe.co.uk
Version 4.4 12/2010
5
www.picaxe.co.uk
Note on the BASIC Code Samples
Simple BASIC code examples are provided within each subsection. The samples are
not ‘complete’ programs but sections of code that can be included within a main
program when using that particular component. When using these code samples it
must be remembered that:
1. Each pin should be set up as an input or output before using the code (stamp
users only).
2. If the hardware pins are changed from those given in the circuit diagrams it will
be necessary to modify the pin numbers in the code.
3. Any ‘let dirs =’ or ‘let pins =’ commands will adjust all 8 pins, in the port.
4. Try to keep variables independant of each other. If a sub-procedure uses a
variable, do not use the same variable anywhere else in the code. If the same
variable must be used again, make sure there is no way it can clash with any
other part of the code. This is the most common way of adding ‘hard-to-find’
bugs into software code.
Note on Component Selection
For convenience and ease of understanding, a single device has been adopted when
using standard interfacing components such as transistors and MOSFETS. For instance,
the ‘standard’ transistor selected is the darlington device BCX38C. This does not mean
that this device is the only transistor that can be used in all the transistor circuits, as it
is not, but it is chosen because it is suitable for the majority of project work
applications. All components listed are common devices that can be purchased from
most electronics distributors.
6. 6 Section 3
MICROCONTROLLER INTERFACING CIRCUITS
revolution Revolution Education Ltd. Web: www.picaxe.co.uk
Version 4.4 12/2010
6
www.picaxe.co.uk
Standard Interfacing Circuits
Standard Circuits 1 - The Transistor Interfacing Circuit
Many output devices will require a transistor switching circuit. In most cases a
darlington pair formed from two transistors is ideal.
However this circuit requires that two separate transistors are used. It is possible to
buy a device that contains the two transistors in a single package. This transistor is
called the BCX38C, and can switch currents up to 800mA. This is the transistor used in
all the circuits through this book.
Note that it is usual to connect a back emf suppression diode across the output device.
This is essential with devices such as relays, solenoids and motors which create a back
emf when power is switched off. The diode type 1N4001 is the device recommended.
0V
Pin
1k
Output
device
BC639
Back EMF
suppression
diode
1N4001
V+
BC548B
0V
Pin
1k
Output
device
BCX38C
V+
7. 7 Section 3
MICROCONTROLLER INTERFACING CIRCUITS
revolution Revolution Education Ltd. Web: www.picaxe.co.uk
Version 4.4 12/2010
7
www.picaxe.co.uk
0V
V+
0V
M
M
Pin 1
Pin 2
ULN2003
In 1
In 2
In 3
In 4
In 5
In 6
In 7
Gnd
Out 1
Out 2
Out 3
Out 4
Out 5
Out 6
Out 7
V+
1
8
16
9
0V
V+
0V
M
M
Pin 1
Pin 2
ULN2803
In 1
In 2
In 3
In 4
In 5
In 6
In 7
In 8
Gnd
Out 1
Out 2
Out 3
Out 4
Out 5
Out 6
Out 7
Out 8
V+
1
9
18
10
Standard Circuits 2 - Using a Darlington Driver IC
If a number of output devices are being controlled it may be necessary to use a
number of output transistors. In this case it will often be more convenient to use a
ULN2003 Darlington driver IC. This is simply a 16 pin ‘chip’ that contains 7
darlington transistors similar in value to the BCX38C. The ‘chip’ also contains internal
back emf suppression diodes and so no external 1N4001 diodes are required.
A device called the ULN2803 Darlington Driver IC is also available. This is identical to
the ULN2003 except that it is an 18 pin device and contains 8 darlington pairs instead
of 7. If it is necessary to pass relatively high currents through a device it can be useful
to ‘pair up’ drivers as shown with this circuit.
A ULN2803 darlington driver is supplied prefitted to the PICAXE project boards.
8. 8 Section 3
MICROCONTROLLER INTERFACING CIRCUITS
revolution Revolution Education Ltd. Web: www.picaxe.co.uk
Version 4.4 12/2010
8
www.picaxe.co.uk
Standard Circuits 3 - The Relay Interfacing Circuit
A relay can be used to switch higher power devices such as motors and solenoids. If
desired, the relay can be powered by a separate power supply, so, for instance, 12V
solenoids can be controlled by the microcontroller. Note the use of a back emf
suppression diode across the relay contacts. This is to prevent damage to the transistor
when the relay switches off. Diode type 1N4001 is suitable for this diode.
0V
Pin
1k
BCX38C
1N4001 RL1
5V
Standard Circuits 4 - The Power MOSFET Interfacing Circuit
Power MOSFETs can be used instead of darlington transistor pairs to switch medium
power devices. The standard MOSFET circuit is shown below. The device IRL520 is a
suitable logic level MOSFET to use in this circuit.
Note that it is usual to connect a back emf suppression diode across the output device.
This is essential with devices such as relays, solenoids and motors which create a back
emf when power is switched off. The diode type 1N4001 is the device recommended.
When a PICAXE chip resets the output pin is momentarily not directly driven.
Therefore on sensitive circuits it may be necessary to include a 10k pulldown resistor
on the MOSFET gate. This holds the gate off until the PICAXE actively drives the
output.
0V
Pin
+5V
IRL520
M1N4001
10k
9. 9 Section 3
MICROCONTROLLER INTERFACING CIRCUITS
revolution Revolution Education Ltd. Web: www.picaxe.co.uk
Version 4.4 12/2010
9
www.picaxe.co.uk
Output Device Interfacing
Output Device 1 - Light Emitting Diode (LED)
The PICAXE microcontroller can sink (“absorb”) or source (“give
out”) a small amount of current, which means that an LED can be
connected directly to the output pin. A series resistor
(value 330R) is also required to limit the current.
LED connected to Ground Rail.
To switch on LED - high 1
To switch off LED - low 1
LED connected to Power Rail.
To switch on LED - low 1
To switch off LED - high 1
Bi-colour LEDs often contain both green and red LEDs connected in ‘inverse parallel’.
This means if current flows one way through the device the LED lights green, and if
current flows the other way the LED lights red. Therefore by using the sink/source
capabilities of the PICAXE microcontroller it is possible to light the LED in both
colours.
To switch on LED in red - high 0
low 1
To switch on LED in green - low 0
high 1
To switch off LED - low 0
low 1
or, high 0
high 1
0V
Pin 1
330R
Pin 1
5V
330R
Pin 0
330R
Red Green
Bi-colour LED
Pin 1
10. 10 Section 3
MICROCONTROLLER INTERFACING CIRCUITS
revolution Revolution Education Ltd. Web: www.picaxe.co.uk
Version 4.4 12/2010
10
www.picaxe.co.uk
Output Device 2 - Signal Lamp
To interface a signal lamp the standard transistor interfacing circuit is used. Note that if
a different power supply is used for the signal lamp, the 0V rails of each power supply
must be connected to provide a common reference.
If a battery is used as the power supply, it is worth remembering that LEDs draw much
less current than lamps. Therefore, if a simple ‘indicator’ is required, a LED will be a
better solution than a lamp as the batteries will last far longer.
To switch on Lamp - high 1
To switch off Lamp - low 1
signal lamp
buzzer
Output Device 3 - Buzzer
To interface a buzzer the standard transistor interfacing circuit is used. Note that if a
different power supply is used for the buzzer, the 0V rails of each power supply must
be connected to provide a common reference.
If a battery is used as the power supply, it is worth remembering that piezo sounders
draw much less current than buzzers. Buzzers also just have one ‘tone’, whereas a
piezo sounder is able to create sounds of many different tones.
To switch on buzzer - high 1
To switch off buzzer - low 1
0V
Pin
1k
Buzzer
BCX38C
5V
0V
Pin 1
1k
Signal
lamp
5V
BCX38C
11. 11 Section 3
MICROCONTROLLER INTERFACING CIRCUITS
revolution Revolution Education Ltd. Web: www.picaxe.co.uk
Version 4.4 12/2010
11
www.picaxe.co.uk
Output Devices 4 - Piezo Sounder & Speaker
A piezo sounder or speaker can be used to produce many different sounds, whereas a
buzzer can only produce a single tone. Buzzers produce a noise when power is
applied, but a piezo or speaker requires a pulsed signal to generate the noise.
Fortunately this is very easy to generate from the microcontroller by using the BASIC
‘sound’ command.
To produce a note of pitch 100, length 50 on pin 1 -
sound 1, (100,50)
To produce a varying noise using variable b1 -
for b1 = 1 to 100
sound 1, (b1,25)
next b1
Pin 1
0V
Pin 1
0V
+
40R
10uF
12. 12 Section 3
MICROCONTROLLER INTERFACING CIRCUITS
revolution Revolution Education Ltd. Web: www.picaxe.co.uk
Version 4.4 12/2010
12
www.picaxe.co.uk
Output Devices 5 - Solar & DC “Toy” Motors
Many projects require the use of a cheap dc motor to create rotational movement.
There are a number of ways motors can be interfaced to the microcontroller.
This circuit uses a darlington transistor to switch the motor on and off. This circuit will
work with ‘solar’ motors, but may not function correctly with cheap dc ‘toy’ motors.
This is because this type of motor introduces a lot of electrical ‘noise’ on to the power
rails. This noise can affect the microcontroller, and in some cases can completely stop
the control program functioning.
0V
Pin 1
1k
Solar
motor
6V
0V
BCX38C
M1N4001
solar motor
Electrical noise can be reduced by
soldering suppression capacitors
across the motor contacts, as
shown. Use a 220nF polyester
(non polarised) capacitor.
In order to switch medium power motors, a power MOSFET is used instead of a
darlington transistor. The MOSFET circuit is shown below. The device IRL520 is a
suitable power MOSFET to use in this circuit.
0V
Pin
+5V
IRL520
M1N4001
10k
13. 13 Section 3
MICROCONTROLLER INTERFACING CIRCUITS
revolution Revolution Education Ltd. Web: www.picaxe.co.uk
Version 4.4 12/2010
13
www.picaxe.co.uk
On many occasions it may be necessary to control two motors. A convenient and
cheap approach would be to use a motor driver IC such as the L293D. This IC will
allow control of two dc motors, using four data lines from the microcontroller.
Naturally, if only one motor is to be controlled then only two output lines are used.
Both inputs low - motor halt
First output high, second output low - motor forward
First output low, second output high - motor reverse
Both inputs high - motor halt
Changing the states of the input pins has the effect of altering the direction of current
flow through the motor, as shown below.
0V 0V
M
Pin 4
L293D
5V
In 1
Out 1
0V
0V
Out 2
In 2
V+
5V
In 3
Out 3
0V
0V
Out 4
In 4
5V
1
8
16
9
Pin 5
To V2+
V2+
Motor A M
Pin 6
Pin 7
Motor B
Note that the L293D will become warm with continuous use. A heatsink bonded onto
the top of the chip will help keep it cool.
Current flow
14. 14 Section 3
MICROCONTROLLER INTERFACING CIRCUITS
revolution Revolution Education Ltd. Web: www.picaxe.co.uk
Version 4.4 12/2010
14
www.picaxe.co.uk
0V
Pin 0
1k
BCX38B
1N4001 RL1
M
5V
V+
Pin 1
1k
RL2
1/2
2/1
1/1
GND
Contacts 2/2 not used
relay
0V
Pin 1
1k
BCX38C
1N4001 RL1
M
5V
6V
battery
One way to prevent electrical noise affecting the microcontroller is to use separate
power supplies for the ‘control’ electronics and the motor. For example, a PP3 battery
may be chosen to power the microcontroller and 4xAA cells to power the motors.
Naturally it will be necessary to ‘link’ the two circuits so that the motor can be
controlled. A relay is an ideal component to do this.
The above circuit will only switch the motor on and off. If the motor is required to run
in both directions (forwards and reverse), two relays can be used as shown.
15. 15 Section 3
MICROCONTROLLER INTERFACING CIRCUITS
revolution Revolution Education Ltd. Web: www.picaxe.co.uk
Version 4.4 12/2010
15
www.picaxe.co.uk
Output Device 6 - Unipolar stepper motor
Stepper motors are very accurate motors that are commonly used in computer disk
drives, printers and clocks. Unlike dc motors, which spin round freely when power is
applied, stepper motors require that their power supply be continuously pulsed in
specific patterns. For each pulse, the stepper motor moves around one ‘step’, often 7.5
degrees (giving 48 steps in a full revolution).
There are two main types of stepper motors - Unipolar and Bipolar. Unipolar motors
usually have four coils which are switched on and off in a particular sequence. Bipolar
motors have two coils in which the current flow is reversed in a similar sequence. Use
of bipolar motors is covered in the next section.
Each of the four coils in a unipolar stepper motor must be switched on and off in a
certain order to make the motor turn. Many microprocessor systems use four output
lines to control the stepper motor, each output line controlling the power to one of the
coils.
As the stepper motor operates at 12V, the standard transistor circuit is required to
switch each coil. As the coils create a back emf when switched off, a suppression diode
on each coil is also required. The table below show the four different steps required to
make the motor turn.
Step Coil 1 Coil 2 Coil 3 Coil 4
1 1 0 1 0
2 1 0 0 1
3 0 1 0 1
4 0 1 1 0
1 1 0 1 0
Look carefully at the table, and notice that a pattern is visible. Coil 2 is always the
opposite (or logical NOT) of coil 1. The same applies for coils 3 and 4. It is therefore
possible to cut down the number of microcontroller pins required to just two by the
use of two additional NOT gates.
stepper motor
+12V
16. 16 Section 3
MICROCONTROLLER INTERFACING CIRCUITS
revolution Revolution Education Ltd. Web: www.picaxe.co.uk
Version 4.4 12/2010
16
www.picaxe.co.uk
Fortunately the darlington driver IC ULN2003 can be used to provide both the NOT
and darlington driver circuits. It also contains the back emf suppression diodes so no
external diodes are required. The complete circuit is shown below.
Before programming, there is another pattern to notice in the stepping sequence. Look
at this table, which just shows coil 1 and coil 3.
Step Coil 1 Coil 3 Change
1 1 1
coil 3
2 1 0
coil 1
3 0 0
coil 3
4 0 1
coil 1
1 1 1
Notice the change from step 1 to step 2, just coil 3 changes. Then look at the next
change - just coil 1 changes. In fact the two coils take it ‘in turns’ to change from high
to low and back again. This high-low-high changing can be described as ‘toggling’
state. This makes the programming very simple by using the BASIC toggle
command.
steps: toggle 1 ‘ Toggle pin 1
pause 200 ‘ Wait 200 ms
toggle 2 ‘ Toggle pin 2
pause 200 ‘ Wait 200ms
goto steps ‘ Loop
Note: If stepper motor ‘wobbles’, try adjusting wire polarity.
0V
To 11
Pin 2
ULN2003
In 1
In 2
In 3
In 4
In 5
In 6
In 7
Gnd
Out 1
Out 2
Out 3
Out 4
Out 5
Out 6
Out 7
Diode
1
8
16
9
To 10
NC
Pin 1
1k
1k
+12V
NC
To 1
To 4
1k
1k
+5V
BRN
BLK
ORG
YEL
+12V
(power supply)
RED
Stepper motor
N.B. colours of stepper
motor leads may vary
17. 17 Section 3
MICROCONTROLLER INTERFACING CIRCUITS
revolution Revolution Education Ltd. Web: www.picaxe.co.uk
Version 4.4 12/2010
17
www.picaxe.co.uk
Output Device 7 - Bipolar Stepper motor
Stepper motors are very accurate motors that are commonly used in computer disk
drives, printers and clocks. Unlike dc motors, which spin round freely when power is
applied, stepper motors require that their power supply be continuously pulsed in
specific patterns. For each pulse, the stepper motor moves around one ‘step’, often 7.5
degrees (giving 48 steps in a full revolution).
There are two main types of stepper motors - Unipolar and Bipolar. Unipolar motors
usually have four coils which are switched on and off in a particular sequence. Bipolar
motors have two coils in which the current flow is reversed in a similar sequence. Use
of unipolar motors is covered in the previous pages.
The bipolar stepper motor has two coils that must be controlled so that the current
flows in different directions through the coils in a certain order. The changing magnetic
fields that these coils create cause the rotor of the motor to move around in steps.
The circuit that is normally used to control one of the coils is shown below. Notice
how there are four ‘control’ transistors, that are switched on in ‘pairs’. Therefore with
two coils there are four control transistor pairs (Q1-Q4) which must be switched on
and off in a certain sequence.
motor coil
Q1A
Q2B
Q2A
Q1B
12V
0V
Current flow
18. 18 Section 3
MICROCONTROLLER INTERFACING CIRCUITS
revolution Revolution Education Ltd. Web: www.picaxe.co.uk
Version 4.4 12/2010
18
www.picaxe.co.uk
Notice that as the coils create a back emf when switched off 8 suppression diodes (4
on each coil) are also required.
The table below show the four different steps required to make the motor turn
Step Q1 Q2 Q3 Q4
1 1 0 1 0
2 1 0 0 1
3 0 1 0 1
4 0 1 1 0
1 1 0 1 0
Fortunately the motor driver L293D has been specifically designed to provide this
transistor switching circuit. The L293D contains all 8 transistors and diodes within one
16 pin package.
Four pins from the microcontroller are connected to the four transistor ‘pairs’ via IC
pins 2, 7, 10 and 15.
0V 0V
M
Pin 4
L293D
5V
In 1
Out 1
0V
0V
Out 2
In 2
V+
5V
In 3
Out 3
0V
0V
Out 4
In 4
5V
1
8
16
9
Pin 5
To V2+
V2+
Motor A M
Pin 6
Pin 7
Motor B
This sample procedure makes the motor spin 100 steps to the left and then 100 steps
to the right by using two sub-procedures. lstep causes the motor to move one step to
the left, rstep causes the motor to move one step to the right. Variable b1 is used to
store the step position and so should not be used elsewhere in the program.
main: for b3 = 0 to 99 ‘ start a for...next loop
gosub lstep ‘ call left step sub-procedure
next b3 ‘ next loop
for b3 = 0 to 99 ‘ start a for...next loop
gosub rstep ‘ call left step sub-procedure
next b3 ‘ next loop
lstep: let b1 = b1 + 1 ‘ add 1 to variable b1
goto step2 ‘ goto the lookup table
rstep: let b1 = b1 - 1 ‘ subtract 1 from variable b1
step2: let b1 = b1 & %00000011 ‘ mask lower two bits of b1
lookup b1,(%1010,%1001,%0101,%0110),b2 ‘ lookup code into b2
let pins = b2 ‘ output b2 onto control lines
return
19. 19 Section 3
MICROCONTROLLER INTERFACING CIRCUITS
revolution Revolution Education Ltd. Web: www.picaxe.co.uk
Version 4.4 12/2010
19
www.picaxe.co.uk
Output Device 8 - Radio Control Servo
Servos are used in most radio controlled
cars and planes to control the steering
mechanism. They are accurate devices that
always rotate the same amount for a given
signal, and so are ideal for use in many
automated machines.
Servos can be driven directly via the ‘servo’
command, or via pulsout commands.
A typical servo has just three connection wires, normally red, black and white (or
yellow). The red wire is the 5V supply, the black wire is the 0V supply, and the white
(or yellow) wire is for the positioning signal.
The positioning signal is a pulse between 0.75 and 2.25 milliseconds (ms) long,
repeated about every 18ms (so there are roughly 50 pulses per second). With a 0.75ms
pulse the servo moves to one end of its range, and with a 2.25ms pulse the servo
moves to the other. Therefore, with a 1.5ms pulse, the servo will move to the central
position. If the pulses are stopped the servo will move freely to any position.
Unfortunately servos require a large current (up to 1A) and also introduce a large
amount of noise on to the power rail. Therefore in most cases the servo should be
powered from a separate power supply, as shown below. Remember that when using
two power supplies the two 0V rails must be joined to provide a common reference
point.
init: servo 4,75 ‘ start servo on 4
main: servopos 4,75 ‘ move servo to one end
pause 2000 ‘ wait 2 seconds
servopos 4,150 ‘ move servo to centre
pause 2000 ‘ wait 2 seconds
servopos 4,225 ‘ move servo to other end
pause 2000 ‘ wait 2 seconds
goto main ‘ loop back to start
Pin
330R
W or Y
R
B
SERVO
6V SUPPLY
V2+
6V 0V
0V
100n
20. 20 Section 3
MICROCONTROLLER INTERFACING CIRCUITS
revolution Revolution Education Ltd. Web: www.picaxe.co.uk
Version 4.4 12/2010
20
www.picaxe.co.uk
Output Device 9 - Counter module
The Counter Module is a numeric LCD display module that can be used to show a
‘counter’ value. To increment the counter a pulse (between 1 and 1.5V) must be
applied to the counter pad 3. As the PICAXE microcontroller operates at 5V a potential
divider formed from resistors must be used to reduce the PICAXE microcontroller
output signal to 1.5V. As the counter uses it’s own, internal, 1.5V battery, the two 0V
rails must also be connected.
3k3
Pin 1
1k
0V
Counter
1 3
reset
2
0V count
To increment counter: pulsout 1,100
To reset the counter, a second potential divider is added and connected to pin 2.
21. 21 Section 3
MICROCONTROLLER INTERFACING CIRCUITS
revolution Revolution Education Ltd. Web: www.picaxe.co.uk
Version 4.4 12/2010
21
www.picaxe.co.uk
Output Device 10 - Seven Segment Display
Pin 2
Pin 1
16
15
14
13
12
11
10
9
1
2
3
4
5
6
7
8
Pin 0
+5V
0V
Pin 3
f
g
a
b
c
d
e
B
C
LT
BK
ST
D
A
Gnd
+5V
f
g
a
b
c
d
e
a
g
d
e
f b
c
4511B
This code example counts through the digits 0 to 9
main: for b1 = 0 to 9 ‘ Set up a for...next loop using variable b1
let pins=b1 ‘ Output b1 onto the four data lines
pause 1000 ‘ Pause 1 second
next b1 ‘ Next
goto main ‘ Loop back to start
A seven segment display contains seven LED
‘bars’ that can be lit up in different
combinations to show the ten digits 0 to 9. In
theory each ‘bar’ could be connected to one
microcontroller output pin, but this would
use up 7 of the 8 available pins!
A better solution is to use a dedicated integrated circuit, such as the CMOS 4511B to
control the seven segment display. This IC controls the seven segment display
according to the binary ‘code’ on the four data lines. This system uses four pins rather
than 7.
IMPORTANT NOTE - Seven segment displays are available in two types, called ‘common
cathode’ and ‘common anode’. The following circuits will only work with a ‘common
cathode’ type display. Use the manufacturer’s datasheet to determine the pinout
arrangement of the LED bars.
22. 22 Section 3
MICROCONTROLLER INTERFACING CIRCUITS
revolution Revolution Education Ltd. Web: www.picaxe.co.uk
Version 4.4 12/2010
22
www.picaxe.co.uk
Another possible solution is to use the CMOS 4026B to control the seven segment
display. This system uses just two pins to control the display. The reset pin is used to
reset the display to 0, the clock pin is then used to increment the digit up from 0. This
means to display the digit ‘4’ it is necessary to reset and then pulse the clock line 4
times. In reality this means that the display shows the digits 0-1-2-3-4, but, as they are
clocked extremely rapidly, the human eye cannot see the changes, and so the number
‘4’ seems to appear immediately!
This code example uses sub-procedure ‘clock’ to display the digit ‘4’, which is stored in
the variable b1.
‘This is the sub-procedure
clock: pulsout 1,10 ‘ reset display to 0
if b1 = 0 then endclk ‘ if b1 = 0 then return
for b3 = 1 to b1 ‘ start a for...next loop
pulsout 0,10 ‘ pulse clock line
next b3 ‘ next loop
endclk: return ‘ return from sub-procedure
This is the main code
main: let b1 = 4 ‘ give variable b1 the value 4
gosub clock ‘ call sub-procedure
pause 1000 ‘ wait 1 second
goto main ‘ loop
Pin 0
16
15
14
13
12
11
10
9
1
2
3
4
5
6
7
8
+5V
0V
c
b
e
a
d
Clock
Out
f
g
Gnd
+5V
Reset
c
b
e
a
d
a
g
d
e
f b
c
4026
f
g
Pin 1
To
7 segment
display
23. 23 Section 3
MICROCONTROLLER INTERFACING CIRCUITS
revolution Revolution Education Ltd. Web: www.picaxe.co.uk
Version 4.4 12/2010
23
www.picaxe.co.uk
This system can be expanded to two digits by adding a second 4026B IC and a second
seven segment display, as shown in the diagram below. No changes to the code are
required, just give the variable b1 a value between 0 and 99 and the number will be
displayed on the two displays when sub-procedure ‘clock’ is called.
Pin 1
Pin 0
16
15
14
13
12
11
10
9
1
2
3
4
5
6
7
8
+5V
0V
Clock
Out
f
g
Gnd
+5V
Reset
c
b
e
a
d
4026B
16
15
14
13
12
11
10
9
1
2
3
4
5
6
7
8
Clock
Out
f
g
Gnd
+5V
Reset
c
b
e
a
d
4026B
24. 24 Section 3
MICROCONTROLLER INTERFACING CIRCUITS
revolution Revolution Education Ltd. Web: www.picaxe.co.uk
Version 4.4 12/2010
24
www.picaxe.co.uk
Output Device 11 - Solenoid & Solenoid Valves
A solenoid consists of a steel plunger inside an electric coil which is wrapped around a
tube. When the coil is energised a magnetic field is created, and this draws the plunger
into the tube. When the coil is de-energised a spring pushes the plunger back out of
the tube.
To control a solenoid the standard MOSFET circuit is used.
The isonic solenoid valve can be used to control air flow through a pneumatic system.
Isonic valves are ideal for battery operated products as operate at a low voltage and
draw much less current than traditional solenoid valves. The standard transistor
switching circuit can be used to drive the isonic valve.
To switch the solenoid on - high 1
To switch the solenoid off - low 1
0V
Pin 1
1k
1N4001 Solenoid
valve
5V
solenoid
0V
Pin 1
+5V
IRL520
1N4001
10k
25. 25 Section 3
MICROCONTROLLER INTERFACING CIRCUITS
revolution Revolution Education Ltd. Web: www.picaxe.co.uk
Version 4.4 12/2010
25
www.picaxe.co.uk
smart
wire
Output Device 12 - Smart Wire & Smart Springs
Shape Memory Alloy wire or springs are ‘smart’ materials that can be used to create
mechanical actuation (movement). When an electric current is passed through the wire
it heats up and so contracts with a large pulling force. When the current is removed the
wire cools and so expands again (a ‘traditional’ steel spring is sometimes used to pull
the smart wire/spring taut as it cools).
Smart wire or springs draw a relatively large current, and so the standard FET
interfacing circuit should be used to interface to the microcontroller.
To make the wire / spring contract - high 1
To allow the wire / spring to expand again - low 1
0V
Pin 1
+5V
IRL520
1N4001 smart
wire
10k
26. 26 Section 3
MICROCONTROLLER INTERFACING CIRCUITS
revolution Revolution Education Ltd. Web: www.picaxe.co.uk
Version 4.4 12/2010
26
www.picaxe.co.uk
Input Device Interfacing
Input Device 1 - Switches
There are a large variety of switches available, but the majority all have two ‘contacts’
which are either ‘open’ (off) or ‘closed’ (on). The two circuits shown below can be used
with almost all switches.
With this circuit the input pin is low when the switch is open and high when the
switch is closed.
Goto ‘jump’ when switch is open: if pin0 = 0 then jump
Goto ‘jump’ when switch is closed: if pin0 = 1 then jump
5V
0V
10k
1k
Pin 0
5V
0V
10k
1k
Pin 0
With this circuit the input pin is high when the switch is open and low when the
switch is closed.
Goto ‘jump’ when switch is open: if pin0 = 1 then jump
Goto ‘jump’ when switch is closed: if pin0 = 0 then jump
27. 27 Section 3
MICROCONTROLLER INTERFACING CIRCUITS
revolution Revolution Education Ltd. Web: www.picaxe.co.uk
Version 4.4 12/2010
27
www.picaxe.co.uk
5V
0V
10k
Pin 0
330R
Pin 1
Switch Bounce
All mechanical switches ‘bounce’ when the switch opens or closes. This means that the
switch contacts ‘bounce’ against each other before settling. As the PICAXE
microcontroller operates so quickly it is possible that in some programs the
microcontroller may register 2 or 3 of these ‘bounces’ instead of just registering one
‘push’.
The simplest way to debounce a circuit
is to simply add a time delay (pause
100) after the if... command. If the
section of code after the push is quite
long this time delay will occur
naturally (as the other code
commands are carried out) and so is
unnecessary. However if the code does
not have a long delay, as in the
following example, a pause command
can be used instead.
The following two programs show the effect of switch bouncing. The program should
light the LED on pin1 when the switch connected to pin0 has been pressed more than
5 times. However, the first listing may not work correctly, because the microcontroller
may count ‘bounces’ rather than actual pushes, and so the LED may light prematurely.
init: let b0 = 0
main: if pin 1 = 1 then add
goto main
add: let b0 = b0 + 1
if b0 < 5 then main
high 1
goto main
init: let b0 = 0
main: if pin 1 = 1 then add
goto main
add: pause 100 ‘short delay
let b0 = b0 + 1
if b0 < 5 then main
high 1
goto main
28. 28 Section 3
MICROCONTROLLER INTERFACING CIRCUITS
revolution Revolution Education Ltd. Web: www.picaxe.co.uk
Version 4.4 12/2010
28
www.picaxe.co.uk
Input Device 2 - Potentiometer
A potentiometer (or ‘variable resistor’)
has a spindle that can be moved to change
the resistance value of the potentiometer.
This can be used to measure rotational or
linear movement.
The readADC command is used to measure the value of the resistance by carrying out
an Analogue to Digital Conversion. The value of the resistance is given a ‘value’
between 0 and 255 which is then stored in a variable. After storing the reading in the
variable, the if...then command can be used to perform different functions.
The program below lights three different LEDs (connected to pins 1, 2 and 3),
depending on the analogue sensor reading.
main: readadc 0,b1 ‘ read value on pin0 into variable b1
if b1<75 then light1 ‘ if b1 is less than 75 then light 1
if b1<175 then light2 ‘ if b1 is less than 175 then light 2
goto light3 ‘ if b1 is greater than 175 then light 3
light1: high 1 ‘ switch on LED 1
low 2 ‘ switch off LED 2
low 3 ‘ switch off LED 3
goto main ‘ loop
light2: low 1 ‘ switch off LED 1
high 2 ‘ switch on LED 2
low 3 ‘ switch off LED 3
goto main ‘ loop
light3: low 1 ‘ switch off LED 1
low 2 ‘ switch off LED 2
high 3 ‘ switch on LED 3
goto main ‘ loop
0V
3 x 330R
Pin 3
Pin 2
Pin 1
+5V
Analogue pin 0
29. 29 Section 3
MICROCONTROLLER INTERFACING CIRCUITS
revolution Revolution Education Ltd. Web: www.picaxe.co.uk
Version 4.4 12/2010
29
www.picaxe.co.uk
Input Device 3 - Light Dependant Resistor (LDR)
A Light Dependant Resistor (LDR) is a resistor that changes in value according to the
light falling on it. A commonly used device, the ORP-12, has a high resistance in the
dark, and a low resistance in the light. Connecting the LDR to the microcontroller is
very straight forward, but some software ‘calibrating’ is required.
It should be remembered that the LDR response is not linear, and so the readings will
not change in exactly the same way as with a potentiometer. In general there is a larger
resistance change at brighter light levels. This can be compensated for in the software
by using a smaller range at darker light levels. Experiment to find the most
appropriate settings for the circuit.
main: readadc 0,b1 ‘ read the value
if b1<50 then light1 ‘ range 0-50 = 50
if b1<100 then light2 ‘ range 50-100 = 50
if b1<145 then light3 ‘ range 100-145 = 45
if b1<175 then light4 ‘ range 145-175 = 30
goto main
0V
LDR
analogue pin
10k
5V
30. 30 Section 3
MICROCONTROLLER INTERFACING CIRCUITS
revolution Revolution Education Ltd. Web: www.picaxe.co.uk
Version 4.4 12/2010
30
www.picaxe.co.uk
Input Device 4 - Thermistor
A thermistor is a resistor that changes in value according to it’s heat. In actual fact all
resistors change in value as they heat up or cool down, but thermistors are
manufactured to show a large resistance change. Connecting the thermistor to the
microcontroller is very straight forward, but some software ‘calibrating’ is required.
It should be remembered that the thermistor response is not linear, and so the
readings will not change in exactly the same way as with a potentiometer. In general
there is a larger resistance change at lower temperatures. This can be compensated for
in the software by using a smaller range at higher temperatures. Experiment to find the
most appropriate settings for the circuit.
main: readadc 0,b1 ‘ read the value
if b1<50 then light1 ‘ range 0-50 = 50
if b1<100 then light2 ‘ range 50-100 = 50
if b1<145 then light3 ‘ range 100-145 = 45
if b1<175 then light4 ‘ range 145-175 = 30
goto main
0V
analogue pin 0
10k
5V
-t°
thermistor
31. 31 Section 3
MICROCONTROLLER INTERFACING CIRCUITS
revolution Revolution Education Ltd. Web: www.picaxe.co.uk
Version 4.4 12/2010
31
www.picaxe.co.uk
Advanced Component Interfacing
Advanced Interfacing 1 - LCD Display
A Liquid Crystal Display is an electronic device that can be
used to show numbers or text. There are two main types
of LCD display, numeric displays (used in watches,
calculators etc) and alphanumeric text displays
(often used in devices such as photocopiers
and mobile telephones).
The display is made up of a number of shaped ‘crystals’. In numeric displays these
crystals are shaped into ‘bars’, and in alphanumeric displays the crystals are simply
arranged into patterns of ‘dots’. Each crystal has an individual electrical connection so
that each crystal can be controlled independently. When the crystal is ‘off’ (i.e. when
no current is passed through the crystal) the crystal reflect the same amount of light as
the background material, and so the crystals cannot be seen. However when the crystal
has an electric current passed through it, it changes shape and so absorbs more light.
This makes the crystal appear darker to the human eye - and so the shape of the dot or
bar can be seen against the background.
It is important to realise the difference between a LCD display and an LED display. An
LED display (often used in clock radios) is made up of a number of LEDs which
actually give off light (and so can be seen in the dark). An LCD display only reflects
light, and so cannot be seen in the dark.
LCD Characters
The table on the next page shows the characters available from a typical LCD display.
The character ‘code’ is obtained by adding the number at the top of the column with
the number at the side of the row.
Note that characters 32 to 127 are always the same for all LCDs, but characters 16 to 31
& 128 to 255 can vary with different LCD manufacturers. Therefore some LCDs will
display different characters from those shown in the table.
Characters 0 to 15 are described as ‘user-defined’ characters and so must be defined
before use, or they will contain ‘randomly shaped’ characters. For details on how to
use these characters see the LCD manufacturers data sheets.
33. 33 Section 3
MICROCONTROLLER INTERFACING CIRCUITS
revolution Revolution Education Ltd. Web: www.picaxe.co.uk
Version 4.4 12/2010
33
www.picaxe.co.uk
Start with a piece of paper, on which one letter is written. Place the card over the paper,
and the letter will be visible because it shows through the ‘display window’. Remove
the card, write another letter, replace the card and they will both be visible. In fact all
of the first sixteen letters will be visible, but the seventeenth will not, as the ‘display
window’ is only wide enough for 16 letters.
Blank ‘paper’
First letter can be seen
a
Next letter can be seen
a b
17th letter cannot be seen as it is ‘outside’ the display window
a b c d e f g h i j k l m n o p q r s t
The operation of the display is quite complex as the display can actually store more
characters than can be displayed at once. A simple model makes this easier to
understand. Imagine a piece of paper with a row of letters written across it. If a piece of
card is taken, which has a ‘window’ cut in it, and the card is placed over the paper, only
some of the letters will be visible. The other letters are still there, it’s just that they
cannot be seen. This is how a LCD display works - it stores a lot of characters, but only
shows a few, through the ‘display window’, at once
20 letters stored in display memory
a b c d e f g h i j k l m n o p q r s t
Only 16 letters can be seen at one time
a b c d e f g h i j k l m n o p
b c d e f g h i j k l m n o p q
34. 34 Section 3
MICROCONTROLLER INTERFACING CIRCUITS
revolution Revolution Education Ltd. Web: www.picaxe.co.uk
Version 4.4 12/2010
34
www.picaxe.co.uk
To be able to see the seventeenth letter it is necessary to move (or ‘scroll’) the display
window one place to the right, but this will also mean that the first letter can no
longer be seen. Advantage can be taken of this ‘moving’ window method to make long
messages appear to scroll across the LCD screen. To do this a long message is written
into the LCD memory, and then the display window is repeatedly scrolled across the
message. This is equivalent to ‘pulling’ the paper under the window to show the long
message. The LCD window does not ‘physically’ move - so to anyone watching the
LCD the letters ‘appear’ to be moving to the right.
a b c d e f g h i j k l m n o p q r s t
a b c d e f g h i j k l m n o p q r s t
a b c d e f g h i j k l m n o p q r s t
a b c d e f g h i j k l m n o p q r s t
On most LCD displays there is memory for 40 characters on each line. Each space in
the RAM memory can be thought of as a ‘box’ which is ready to hold a single
character. Each RAM ‘box’ has a numbered address to describe it. The first line RAM
‘boxes’ are at addresses 128 to 191, the second line RAM ‘boxes’ are from 192 to 255.
16x2 displays have a window that is two lines deep. That means that 16 letters can be
seen on each line. If a character is to be printed on the second line, it is necessary to
move the cursor to the start of line 2. Moving the cursor is very simple; simply send
the RAM address (of the ‘box’ to be moved) as an instruction. Therefore to move the
cursor to the start of the second line, simply send the instruction ‘192’ to the LCD
module. To move the cursor to the fifth position on the second line send the
instruction ‘197’ (=192+5).
35. 35 Section 3
MICROCONTROLLER INTERFACING CIRCUITS
revolution Revolution Education Ltd. Web: www.picaxe.co.uk
Version 4.4 12/2010
35
www.picaxe.co.uk
Note about 16x1 displays...
Most 16x1 LCDs are in actual fact 8x2 LCDs, but with the ‘second’ line positioned
directly after the first (instead of underneath it). This makes 16x1 displays confusing
to use, as, after 8 characters have been printed, the cursor seems to disappear in the
middle of the display! If this type of display is needed, remember that the ‘ninth’
character is actually the first character of the second line.
There are three main ways of interfacing LCDs to microcontrollers.
1) Serial LCD firmware chip
2) Serial LCD Module with onboard firmware chip
3) Direct Connection
Connecting The LCD using a serial firmware chip(OPTION 1)
The serial LCD firmware is used to allow serial control of an alphanumeric LCD. This
allows microcontrollers (and microcontroller based systems such as the PICAXE or
Basic Stamp) to visually output user instructions or readings onto a text screen without
the need for a host computer. This is especially useful when working, for example,
with analogue sensors, as the analogue reading can easily be displayed on the LCD
module. All LCD commands are transmitted serially via a single microcontroller pin.
A sample instruction, using the serout command is as follows:
to print the text ‘Hello’ the instruction is simply
serout 7,T2400,(“Hello”)
LCD
serial
LCD
firmware
PICAXE
single
pin
5V
0V
5V
0V0V
5V
1
2
3
4
5
6
7
8
9
18
17
16
15
14
13
12
11
10
+5V
0V
serial
input
4 MHz
4k7
reset
LCDFIRMWARE
D7
D6
D5
D4
RS
E
14
13
12
11
4
6
Pin 9
Pin 8
Pin 7
Pin 6
Pin 1
Pin 2
10k
0V
Vdd V0 Vss R/W D0 D1 D2 D3
2 3 1 5 7 8 9 10
Pin 5
Pin 18
Pin 17
680R
0V
connectionstoLCDfirmware
For more information, see the Serial LCD Firmware datasheet:
www.rev-ed.co.uk/docs/frm010.pdf
36. 36 Section 3
MICROCONTROLLER INTERFACING CIRCUITS
revolution Revolution Education Ltd. Web: www.picaxe.co.uk
Version 4.4 12/2010
36
www.picaxe.co.uk
Using a Serial LCD Module (OPTION 2)
The serial LCD module, part AXE033, contains a LCD module fitted to a custom printed
circuit board fitted with a LCD firmware chip. This enables the user to rapidly build an LCD
circuit that uses the single wire connection as with option 1. See the AXE033 Serial LCD/
Clock Module datasheet for more details:
www.rev-ed.co.uk/docs/axe033.pdf
Connnecting The LCD (OPTION 3)
The LCD has 6 lines that can be connected directly to the PICAXE microcontroller pins.
However it is a good design practice to add a low value resistor (e.g. 330R) on the
lines to protect against static discharges. The 10k potentiometer connected to pin 3 is
used to adjust the contrast of the display. All unused lines should be tied to ground as
shown.
DB7
DB6
DB5
DB4
E
RS
14
13
12
11
6
4
6 x 330R
Pin 7
Pin 6
Pin 5
Pin 4
Pin 3
Pin 2
+5V
10k
0V
Vdd V0 Vss R/W DB0 DB1 DB2 DB3
2 3 1 5 7 8 9 10
37. 37 Section 3
MICROCONTROLLER INTERFACING CIRCUITS
revolution Revolution Education Ltd. Web: www.picaxe.co.uk
Version 4.4 12/2010
37
www.picaxe.co.uk
A Simple LCD Program
The following program will print out the phrase ‘Hello there!’ on two lines of the LCD
display. It uses three sub-procedures called init, wrins and wrchr. These three sub-
procedures carry out all the ‘difficult’ software tasks, and are ‘standard’ sub-procedures
that will not have to be changed. In fact they can be used without understanding how
they work, but it is necessary to know what they do:
init ‘initialises’ the LCD so that it is ready to accept instructions
wrins sends an instruction stored in variable b1 to the LCD module
wrchr sends a character stored in variable b1 to be ‘printed’ on the LCD screen
The three sub-procedures are explained further in the following sections.
EEPROM 0,(“Hellothere!”) ‘ store the text in the EEPROM memory
gosub init ‘ initialise LCD
main: let b1 = 1 ‘ set b1 to ‘clear display’ instruction
gosub wrins ‘ send instruction to LCD
for b3 = 0 to 4 ‘ setup for...next loop (“Hello” - positions 0 to 4)
read b3, b1 ‘ read letter from EEPROM into variable b1
gosub wrchr ‘ send character to LCD
next b3 ‘ next loop
let b1 = 192 ‘ set b1 to ‘start of second line’ position
gosub wrins ‘ send instruction to LCD
for b3 = 5 to 11 ‘ setup for...next loop (“there!”-positions 5 to 11)
read b3, b1 ‘ read letter from EEPROM memory into variable b1
gosub wrchr ‘ send character to LCD
next b3 ‘ next loop
38. 38 Section 3
MICROCONTROLLER INTERFACING CIRCUITS
revolution Revolution Education Ltd. Web: www.picaxe.co.uk
Version 4.4 12/2010
38
www.picaxe.co.uk
More Advanced LCD Program
The following program scrolls the message ‘Hello there everybody!’ across the screen.
As the text is longer than 16 letters, the message is first stored in the LCD memory, and
then the display window is repeatedly scrolled to show all the message.
EEPROM 0,(“Hello there everybody!”) ‘ store the text in the EEPROM memory
gosub init ‘ initialise LCD
start: let b1 = 1 ‘ set b1 to ‘clear display’ instruction
gosub wrins ‘ send instruction to LCD
for b3 = 0 to 22 ‘ setup a for...next loop
read b3, b1 ‘ read letter from EEPROM into variable b1
gosub wrchr ‘ send character to LCD
next b3 ‘ next loop
let b1 = 12 ‘ set b1 to ‘hide cursor’ instruction
gosub wrins ‘ send instruction to LCD
main: let b1 = 24 ‘ set b1 to ‘scroll display left’ instruction
gosub wrins ‘ send instruction to LCD
pause 250 ‘ pause for 0.25s
goto main ‘ loop
39. 39 Section 3
MICROCONTROLLER INTERFACING CIRCUITS
revolution Revolution Education Ltd. Web: www.picaxe.co.uk
Version 4.4 12/2010
39
www.picaxe.co.uk
Standard LCD Sub-Procedures (Direct Connection)
Before the sub-procedures are studied, it is important to understand how the LCD
module operates. It has two modes of operation, which are called ‘character’ mode and
‘instruction’ mode. The RS pin (pin 2) controls the mode - when high the LCD is in
character mode, when low the LCD is in instruction mode.
The character or instruction is sent as a 4 bit binary number down the data lines (pins
7-4). Every time the Enable pin (pin 3) is ‘pulsed’ the LCD reads the data lines and
prints the character (or carries out the instruction) which is given by the number on
the data lines.
This is not quite the whole story, as each character or instruction is actually made up of
an 8 bit number, which contains a table of all the character and instruction codes. As
there are only four data lines, this 8 bit number is split into two ‘halves’ which are sent
one after the other. The two halves are called the ‘high nibble’ and the ‘low nibble’.
This means that two nibbles are transmitted down the data lines for each character.
1011 0101 = 10110101
high nibble + low nibble = byte
The three ‘standard’ sub-procedures described below perform all of the ‘complicated’
software tasks when using the LCD display. Each sub-procedure is called from the
main program to perform a certain task. These tasks are:
init initialise the display and sets the module to two line operation
wrchr ‘prints’ one ‘character’ onto the LCD screen
wrins writes one ‘command’ to the LCD module.
(This is actually just the wrchr sub-procedure with the addition of one line
that sets the RS line into ‘instruction’ mode at the start of the sub-
procedure).
DB7
DB6
DB5
DB4
E
RS
14
13
12
11
6
4
6 x 330R
Pin 7
Pin 6
Pin 5
Pin 4
Pin 3
Pin 2
+5V
10k
0V
Vdd V0 Vss R/W DB0 DB1 DB2 DB3
2 3 1 5 7 8 9 10
40. 40 Section 3
MICROCONTROLLER INTERFACING CIRCUITS
revolution Revolution Education Ltd. Web: www.picaxe.co.uk
Version 4.4 12/2010
40
www.picaxe.co.uk
init: let pins = 0 ‘ Clear all output lines
let b4 = 0 ‘ Reset variable b3
let dirs = 252 ‘ Set pins 2-7 as output lines (Stamp only).
pause 200 ‘ Wait 200 ms for LCD to reset.
let pins = 48 ‘ Set to 8-bit operation.
pulsout 3,1 ‘ Send data by pulsing ‘enable’
pause 10 ‘ Wait 10 ms
pulsout 3,1 ‘ Send data again
pulsout 3,1 ‘ Send data again
let pins = 32 ‘ Set to 4-bit operation.
pulsout 3,1 ‘ Send data.
pulsout 3,1 ‘ Send data again.
let pins = 128 ‘ Set to two line operation
pulsout 3,1 ‘ Send data.
let b1 = 14 ‘ Screen on, cursor on instruction
gosub wrins ‘ Write instruction to LCD
return
wrchr: let pins = b1 & 240 ‘ Mask the high nibble of b1 into b2.
high 2 ‘ Make sure RS is high
pulsout 3,1 ‘ Pulse the enable pin to send data.
let b2 = b1 * 16 ‘ Put low nibble of b1 into b2.
let pins = b2 & 240 ‘ Mask the high nibble of b2
high 2 ‘ Make sure RS is high
pulsout 3,1 ‘ Pulse enable pin to send data.
return
wrins: let pins = b1 & 240 ‘ Mask the high nibble of b1 into b2.
pulsout 3,1 ‘ Pulse the enable pin to send data.
let b2 = b1 * 16 ‘ Put low nibble of b1 into b2.
let pins = b2 & 240 ‘ Mask the high nibble of b2
pulsout 3,1 ‘ Pulse enable pin to send data.
high 2 ‘ Back to character mode
return
Note that init uses a let dirs = commands that will affect all 8 pins, not just the 6 used by the
LCD display. The let pins = commands used by wrins/wrchr will not alter the state of unused pins
0 and 1. Do not use variable b1 or b2 (or w0 or w1 ) for any other function within a program.
NB. The | character is ‘SHIFT + ’ (next to Z on a UK layout keyboard).
41. 41 Section 3
MICROCONTROLLER INTERFACING CIRCUITS
revolution Revolution Education Ltd. Web: www.picaxe.co.uk
Version 4.4 12/2010
41
www.picaxe.co.uk
Using the LCD Instruction set
The codes for the LCD instructions are given below. Each code can be sent to the LCD
module by using the wrins sub-procedure. These instructions can be used to make the
LCD messages more interesting - for instance by flashing the screen or creating
‘moving’ messages which scroll across the screen.
Code Instruction
1 Clear display and move to the start of the first line
2 Move the cursor and display ‘window’ to the start of the first line
4 Set ‘right to left printing’ mode
5 Set ‘scroll printing to the left’ mode
6 Set ‘left to right printing’ mode
7 Set ‘scroll printing to the right’ mode
10 Turn visual LCD screen off
12 Hide cursor
13 Make cursor flash
14 Turn visual LCD screen (and cursor) on
16 Move cursor left one position
20 Move cursor right one position
24 Scroll display ‘window’ left one position
28 Scroll display ‘window’ right one position
128 Move cursor to the start of the first line
192 Move cursor to the start of the second line
42. 42 Section 3
MICROCONTROLLER INTERFACING CIRCUITS
revolution Revolution Education Ltd. Web: www.picaxe.co.uk
Version 4.4 12/2010
42
www.picaxe.co.uk
Examples:
Clear the display
clear: let b1 = 1 ‘ Set b1 to clear instruction
call wrins ‘ Send it to LCD
Move cursor to the second line
clear: let b1 = 192 ‘ Set b1 to start of second line
call wrins ‘ Send it to LCD
Flash a message 10 times
flash: for b3 = 1 to 10 ‘ Start a for...next loop using
‘ variable b3 Don’t use b1!!
let b1 = 10 ‘ Set b1 to ‘turn visual display
‘ off’ instruction
gosub wrins ‘ Send instruction to LCD
pause 200 ‘ Pause for 0.2 second
let b1 = 14 ‘ Set b1 to ‘turn visual display
‘ back on’ instruction
gosub wrins ‘ Send instruction to LCD
pause 200 ‘ Pause for 0.2 second
next b3 ‘ End of for...next loop
Scroll a long message (30 characters long)
scroll: for b3 = 1 to 30 ‘ Start a for...next loop using
‘ variable b3 Don’t use b1!!
let b1 = 28 ‘ Set b1 to ‘scroll display
‘ window right’ instruction
gosub wrins ‘ Send instruction to LCD
pause 200 ‘ Pause for 0.2 second
next b3 ‘ End of for...next loop
let b1 = 1 ‘ Set b1 to ‘move scroll window
‘ back to start’ instruction
gosub wrins ‘ Send instruction to LCD
pause 200 ‘ Pause for 0.2 second
goto scroll ‘ Loop
43. 43 Section 3
MICROCONTROLLER INTERFACING CIRCUITS
revolution Revolution Education Ltd. Web: www.picaxe.co.uk
Version 4.4 12/2010
43
www.picaxe.co.uk
Advanced Interfacing 2 - Serial Interfacing to a Computer.
Most computers can ‘talk’ to other devices by serial communication. Serial
communication uses a common ‘protocol’ (or code) where characters are converted
into numbers and then transmitted via cables. A computer mouse normally
‘communicates’ serially with a computer, and computer modems work by turning
these numbers into sounds to travel down telephone lines.
As all computers use the same ASCII code for transmitting and receiving characters it is
relatively easy to program the PICAXE microcontroller to ‘talk’ to any type of
computer. All that is needed is a suitable cable and some very simple electronic
circuits.
Connecting to the Computer
The system we will use requires just three wires between the computer and the
microcontroller. The ground wire provides a common reference, the RX wire sends
signals from the computer to the PICAXE microcontroller, and the TX wire sends
signals from the PICAXE microcontroller to the computer.
The best way to make a serial cable is to buy a serial ‘extension’ cable and cut it in
half. This will give two cables with a suitable connector at each end. The diagrams
below show the various wiring connections required.
Computer Communication Software
To use this system a communication software package is required for the PC. The
examples below use the Terminal option within the Programming Editor software, but
any communications package can be used.
There are various different protocols that can be used for serial communication, and it
is important that both the computer and the microcontroller use the same setting. The
2400,N,8,1 protocol is used here, which means baud speed 2400, no parity, 8 data bits
and one stop bit. This baud speed is quite slow by modern standards, but is quite
sufficient for the majority of project work tasks. All ‘handshaking’ (hardware or
software) must also be disabled.
PC/RISC PC PC (25 way) Mac
5 3 2 7 3 2 5 4 3
RX = 3
TX = 2
GND = 5
RX = 3
TX = 2
GND = 7
RX = 3
TX = 5
GND = 4
44. 44 Section 3
MICROCONTROLLER INTERFACING CIRCUITS
revolution Revolution Education Ltd. Web: www.picaxe.co.uk
Version 4.4 12/2010
44
www.picaxe.co.uk
PICAXE Microcontroller Interfacing Circuit
The system described here requires just three wires between the computer and the
PICAXE microcontroller. Strictly speaking RS232 serial voltages should be at ±15V, but
the standard 5V from the on-board 5V regulator will be used here. This is not the
industry standard, but works perfectly OK with the majority of computers. This is the
circuit that will be used use for serial communication.
To provide true RS232 voltages another integrated circuit is required. The most
common IC used is the MAX232, which has on-board voltage boosters to create the
required voltage swing. If this setting is used it is necessary to change the N2400
(negative) in all the serial software commands to T2400 (true positive).
ONLY USE ONE OF THESE TWO CIRCUIT OPTIONS!
0V
10k
22k
Pin 0
180R
Pin 1
0V
RX
TX
To
computer
To
PICAXE
MAX232
1
2
3
4
5
6
7
8
16
15
14
13
12
11
10
9
+
+
+
+
10uF
10uF
10uF
10uF
5V
0V
TX
RX
Pin 0
Pin 1
NC
NC
NC
NC
0V
Computer
PICAXE
NB. Note polarity - capacitors connected to
pins 2 and 6 are connected ‘upside down’.
45. 45 Section 3
MICROCONTROLLER INTERFACING CIRCUITS
revolution Revolution Education Ltd. Web: www.picaxe.co.uk
Version 4.4 12/2010
45
www.picaxe.co.uk
Transmitting Characters to the Computer Screen
The following program will transmit the word ‘Hello’ to the computer screen over and
over again. If the cable is connected and the communication software is operating
correctly, the word will appear every second.
main: serout 1,N2400,(“Hello”) ‘ Send the word ‘Hello’
serout 1,N2400,(10,13) ‘ Send the ‘new line’ instructions.
pause 1000 ‘ Wait one second
goto main ‘ Loop back to the start
Notice that “text” must be enclosed within speech marks. This tells the microcontroller
to convert the text into a string of ASCII codes. Individual ASCII codes can be
transmitted by just giving their numbers. Therefore the two commands below achieve
the same task:
serout 1,N2400,(“Hello”)
serout 1,N2400,(72,101,108,108,111)
Receiving Keyboard Input from the Computer
It can be useful to be able to use a keyboard for people to ‘answer’ questions. This is
achieved by using the serin command as shown below.
main: serout 1,N2400,(10,13) ‘ Start a new line
serout 1,N2400,(“Press a key- “) ‘ Send a message
serin 0,N2400,b1 ‘ Receive a character into variable b1
serout 1,N2400,(b1) ‘ Transmit character back to the screen
if b1=”a” then hot ‘ Is character ‘a’? If yes goto hot
goto main ‘ No, so loop back to start
hot: serout 1,N2400, (10,13,”A is the Hot Key!”)
‘ Send message
goto main ‘ Loop back to start
If this program is run and then a key is pressed on the keyboard, the character will appear on the screen. This
is the microcontroller (not the computer) working. The keyboard press has been
received from the keyboard and then transmitted back to the screen!
46. 46 Section 3
MICROCONTROLLER INTERFACING CIRCUITS
revolution Revolution Education Ltd. Web: www.picaxe.co.uk
Version 4.4 12/2010
46
www.picaxe.co.uk
Characters or numbers?
Consider this command: serout 1,N2400,(65)
This will send the ASCII character ‘A’ to the screen.
Now consider this command: serout 1,N2400,(b1)
This will send the character stored in variable b1 to the screen, and so if b1=65, the
character ‘A’ will be sent to the screen.
However, variables are often used to store the answers to mathematical sums, and so it
may be necessary to send the number ‘65’ to the screen rather than the letter ‘A’. To do
this, the microcontroller must be told that a number is to be sent rather than a
character. This is achieved by adding a hash (#): serout 1,N2400,(#b1)
This will send the number ‘65’ (actually the two characters ‘6’ and ‘5’) to the screen
rather than the character ‘A’.
This is a summary of the serial commands used. Remember that the pin number may
have to be changed, and also to the N2400 section to T2400 if the MAX232 interfacing
circuit is used.
serout 1,N2400,(“Hello”)- Sends a message to the screen.
serout 1,N2400,(10) - Sends a direct ASCII instruction to the screen.
serout 1,N2400,(b1) - Sends an ASCII character stored in variable to the screen.
serout 1,N2400,(#b1) - Sends a number stored in a variable to the screen.
serin 0,N2400,b1 - Receives an ASCII character from a keypress on the
keyboard and stores it as the ASCII value in a variable (b1)
serin 0,N2400,#b1 - Receives a real number from the number keys on the
keyboard and stores it in a variable (b1)