bascom avr tft lcd made in china

In recent time, China domestic companies like BOE have overtaken LCD manufacturers from Korea and Japan. For the first three quarters of 2020, China LCD companies shipped 97.01 million square meters TFT LCD. And China"s LCD display manufacturers expect to grab 70% global LCD panel shipments very soon.

BOE started LCD manufacturing in 1994, and has grown into the largest LCD manufacturers in the world. Who has the 1st generation 10.5 TFT LCD production line. BOE"s LCD products are widely used in areas like TV, monitor, mobile phone, laptop computer etc.

TianMa Microelectronics is a professional LCD and LCM manufacturer. The company owns generation 4.5 TFT LCD production lines, mainly focuses on making medium to small size LCD product. TianMa works on consult, design and manufacturing of LCD display. Its LCDs are used in medical, instrument, telecommunication and auto industries.

TCL CSOT (TCL China Star Optoelectronics Technology Co., Ltd), established in November, 2009. TCL has six LCD panel production lines commissioned, providing panels and modules for TV and mobile products. The products range from large, small & medium display panel and touch modules.

Established in 1996, Topway is a high-tech enterprise specializing in the design and manufacturing of industrial LCD module. Topway"s TFT LCD displays are known worldwide for their flexible use, reliable quality and reliable support. More than 20 years expertise coupled with longevity of LCD modules make Topway a trustworthy partner for decades. CMRC (market research institution belonged to Statistics China before) named Topway one of the top 10 LCD manufactures in China.

Founded in 2006, K&D Technology makes TFT-LCM, touch screen, finger print recognition and backlight. Its products are used in smart phone, tablet computer, laptop computer and so on.

The Company engages in the R&D, manufacturing, and sale of LCD panels. It offers LCD panels for notebook computers, desktop computer monitors, LCD TV sets, vehicle-mounted IPC, consumer electronics products, mobile devices, tablet PCs, desktop PCs, and industrial displays.

bascom avr tft lcd made in china

A touchscreen is a display that also serves as an input device. Some touchscreens require a proprietary pen for input, though most modern touchscreens detect human touch. Since touchscreen devices accept input directly through the screen, they do not require external input devices, such as mice and keyboards. This makes touchscreens ideal for computer kiosks, as well as portable devices, such as tablets and smartphones. www.stoneitech.com/about/news/sharing/what-is-lcd-capacitive-touch-screen.html

bascom avr tft lcd made in china

It can be used in any embedded systems which require display high quality colorful image. The LCD has a SD slot, SPI flash footprint. We specialized in providing TFT LCD modules embedded systems for fun and creativity.

I tried using standart arduino shield connection for itead 3.2 TFT in the link. It is mega shield but i only use D0-D15 connection directly DUE board without shield -> Page Not Found

bascom avr tft lcd made in china

STONE Technologies is a proud manufacturer of superior quality TFT LCD modules and LCD screens. The company also provides intelligent HMI solutions that perfectly fit in with its excellent hardware offerings.

STONE TFT LCD modules come with a microcontroller unit that has a 1GHz Cortex-A8 CPU. Such a module can easily be transformed into an HMI screen. Simple hexadecimal instructions can be used to control the module through the UART port. Furthermore, you can seamlessly develop STONE TFT LCD color user interface modules and add touch control, features to them.

The famous china LCD display manufacturers. It is the world’s leading semiconductor display technology, products, and services provider. Products are widely used in mobile phones, tablets, laptops, monitors, televisions, cars, digital information displays, and other display fields.

Focus on the development and production of china HMI (Intelligent TFT LCD Module) LCD display manufacturers, production, and sales of LCD display modules for 16 years. The company master TFT LCD technology and software system. The main products are industrial electronic series, advanced series, and civil and commercial series. Application scenarios include automation systems, medical beauty equipment, vending machines, smart lockers, energy, and power equipment (refueling machines, charging piles), elevators, smart homes, and offices, measuring instruments, public transportation, etc.

Mainly committed to the r&d, production, and sales of TFT-LCD/stn-LCD /OLED display modules, it is a modern high-tech enterprise that provides a full range of product LCD module technology and manufacturing support services for TCL group member enterprises and international electronic enterprises.

Set an LCD display module (LCM), capacitive touch screen (CTP), fully integrated touch display module (TDM), LCD thin technology development, production, and service in one national high-tech company.

Domestic size of the top four small and medium-sized flat panel display manufacturers. The products cover medium and small-size TFT-LCD display modules and high-precision miniature cameras, which have been widely used in the fields of smartphones, medical treatment, and industrial display.

The LCD business division is specialized in the r&d, production, and sales of the LCD display (LCD) and LCD module (LCM) series of products. It has ten semi-automatic COG production lines, 1.5KK of monthly COG products, covering COG, TAB, COB, and other LCD module products, TFT, CSTN, and other color LCD display products, and OLED display products. touch screen manufacturers.

Byd IT products and business mainly include the establishment of rechargeable batteries, plastic parts, metal parts, hardware, and electronic products, mobile phone keys, microelectronics, LCD display module, optoelectronic products, flexible circuit board, chargers, connectors, uninterruptible power supply, dc power supply, solar energy products, mobile phone decoration, mobile phones ODM, mobile phone test, assembly operations, laptop, ODM, manufacturing, testing and assembly operations, etc.

Star source products cover backlight, LCD, optical diaphragm, etc., widely used in LCD modules, photo frames, tablets, portable, instruments, and meters.

The company has long invested in the research and development of the TFT-lcm LCD module, focusing on consumer products and industrial control products. Currently, 3.5-11.6 inch modules are available, among which 4.0, 4.3, 5, 6, and 10.1-inch products have reached the leading level in the industry. Products are mainly used in vehicles, mobile TV, PMP, DVD, EPC, security, and industrial control products.

Professional development, design, production, and sales of LCD display module (LCM), products cover COB, TAB, COG, and other LCD module products, TFT, CSTN, and other color LCD display products, as well as OLED display products. Products are widely used in mobile phones, communications, digital products, household appliances, industrial control, instrumentation, vehicle display, color screen display, and other fields.

Mainly engaged in research and development, manufacturing, and sales of the LCD display and LCD display module. Products are widely used in all kinds of electronic products and equipment HMI interface, such as medical equipment, instruments and meters, audio, household appliances, telephone and clocks, game machines, and other different types and use.

Focusing on the LCD module industry, is a collection of research and development, manufacturing, sales as one of the high-tech enterprises. TFT module size from 1.44 to 7 inches, product specifications cover QVGA, WVGA, qHD, HD, etc., the market prospects are broad.

The display manufacturers company mainly researches and develops the LCD display, charger, battery, and other products of mobile communication mobile phone, telephone, MP3, and other high-tech products.

The company integrates research and development, design, production, sales, and service into one, and provides comprehensive touch and display integrated solutions for the complete machine touch screen manufacturer of smartphones, specializing in the development and manufacture of Sensor sensors, capacitive touch screens (GFF/OGS/GG), small and medium-sized LCD (TN/HTN/STN/CSTN/TFT) and corresponding modules and glass cover plate products. The company’s products are widely used in communication terminals (smartphone, tablet computer, etc.), household appliances, car electronics, digital products, and other industries, exported to Europe and America, Japan and South Korea, Singapore, and other countries.

Mainly produces medium and small-size LCD display module (LCM), multi-point capacitive touch screen (CTP), and other high-tech products. At present, more than 1000 models of 1.2-12.1 inch products have been developed. Products are widely used in mobile phones, GPS, mobile TV, tablet computers, digital photo frames, e-books, and other consumer electronics.

It is a professional development and production of small and medium-sized flat panel display upstream materials manufacturers. The company’s main products include LCD display panels, color filter, ITO conductive glass (CF), TFT LCD panel, and capacitive touch screen with multi-touch control functions (sensor and the final module), can provide complete medium and small size flat-panel display device using the solution of raw materials, product specifications varieties complete, widely used in 10.4 inches below the smartphone, tablet, PMP, digital camera, digital camera, GPS and other products of the display panel.

Now it is divided into mobile phone business division: the main products are (2.8-6) inch and the LCD screen and capacitive screen all fit together.MID tablet computer and ultrabook computer division: the main production product size is (7-15) inch capacitive touch screen.

Committed to 3.5~4.3 inches, 5 inches, 5.88 inches, 6.2 inches, 7.0 inches, 8.0 inches, 9.7 inches, 10.1 inches, 12.1 inches medium size FOG, backlight process production, products should be widely used in high-end communication phones, tablets, notebook computers, car TV, navigator, and other display products. automotive LCD display touch screen manufacturers.

The company has an injection molding business division, SMT business division, FPC business division, backlight business division, irrigation crystal business division, TFT module business division, SIN module business division, products involving touch screen, LCD display module, backlight, black and white screen, flexible circuit board.

Engaged in the laptop, tablet, smartphone, computer high-performance board card, LCD module, and other electronic products research and development, production, and sales of high-tech private enterprises.

Is a professional engaged in LCD display module, electronic components, production, design, research and development, sales as one of the high-tech enterprises. Products are widely used in mobile phones, game consoles, PDA, portable DVDs, video phones, intercom doorbells, car video, industrial control medical, and other fields.

STONE provides a full range of 3.5 inches to 15.1 inches of small and medium-size standard quasi TFT LCD module, LCD display, TFT display module, display industry, industrial LCD screen, under the sunlight visually highlight TFT LCD display, industrial custom TFT screen, TFT LCD screen-wide temperature, industrial TFT LCD screen, touch screen industry. The TFT LCD module is very suitable for industrial control equipment, medical instruments, POS system, electronic consumer products, vehicles, and other products.

bascom avr tft lcd made in china

On eBay I recently purchased a set of cute small USB AVR programmers which I intend to use in the course 1TE663 Microcontroller Programming at Uppsala University.

This is the point where I usually ask Google. So I did and I found some threads discussing the same issue and pointing out, that these programmers needed a different software and were not at all compatible with avrdude. BAD!

But of course, one should be able to reprogram the programmer using another programmer. At my home this is not a henn and egg problem, since I have accumulated several AVR programmers.

bascom avr tft lcd made in china

What is a computer? ................................................................................................................... 95 What does a computer system do? ............................................................................................. 95 What exactly is a microcontroller? ............................................................................................... 96 What does a microcontroller system do?..................................................................................... 97 What you do when learning to program ....................................................................................... 98 AVR microcontroller hardware .................................................................................................... 99 Power supplies............................................................................................................................ 99 BASCOM and AVR assignment ................................................................................................ 100 Programming words you need to be able to use correctly ......................................................... 102

11 Getting started with AVR Programming ........................................................................ 103 11.1 11.2 11.3 11.4 11.5 11.6 11.7 11.8

Breadboard ............................................................................................................................... 103 Breadboard+Prototyping board circuit ....................................................................................... 104 Alternative ATTiny461 breadboard circuit.................................................................................. 106 Alternative ATMega48 breadboard circuit ................................................................................. 107 Alternative ATMega breadboard circuit ..................................................................................... 108 AVR circuit description .............................................................................................................. 109 Output Circuit - LED .................................................................................................................. 110 AVR programming cable ........................................................................................................... 110

12 Getting started with Bascom & AVR .............................................................................. 111 12.1 12.2 12.3 12.4 12.5 12.6 12.7

The compiler ............................................................................................................................. 111 The programmer ....................................................................................................................... 111 An introduction to flowcharts ..................................................................................................... 112 Bascom output commands ........................................................................................................ 113 Introducing ‘bugs’ to see what happens .................................................................................... 114 Getting started code for the ATMega48 .................................................................................... 115 Getting started code for the ATMega8535................................................................................. 116

Variables - numbers inside the AVR.......................................................................................... 134 Pedestrian crossing lights controller .......................................................................................... 135 Pedestrian Crossing Lights schematic ...................................................................................... 136 Pedestrian Crossing Lights PCB Layout.................................................................................... 137 Algorithm planning example – pedestrian crossing lights .......................................................... 138 Flowchart planning example – pedestrian crossing lights .......................................................... 139 Program example - pedestrian crossing lights ........................................................................... 140 Modification exercise for the pedestrian crossing ...................................................................... 141 Changing a variable – simple stepping/counting ....................................................................... 142 For-next tricks with flashing LEDs ......................................................................................... 144 For-Next ................................................................................................................................ 145 Using variables for data......................................................................................................... 147 Types of memory .................................................................................................................. 147 Binary and Hexadecimal numbers ......................................................................................... 148 Learning to count in binary .................................................................................................... 149 Learning some Hexadecimal (HEX) ...................................................................................... 150 Rules about variables ............................................................................................................ 153 a few examples of variables in use ........................................................................................ 153 Random Numbers ................................................................................................................. 154 The Bascom-AVR simulator .................................................................................................. 155 Variables research assignment ............................................................................................. 157 Byte variable limitations......................................................................................................... 158 Electronic dice project ........................................................................................................... 159 Programming using variables – dice...................................................................................... 159 Dice layout stage 1................................................................................................................ 160 Dice layout stage 2................................................................................................................ 161 Dice Layout final.................................................................................................................... 162 First Dice Program flowchart ................................................................................................. 163 A note about the Bascom Rnd command .............................................................................. 164 Modified dice ......................................................................................................................... 165 Multiple LEDs - 7 segment displays....................................................................................... 167 Programming using variables - sound ................................................................................... 173 Make a simple siren .............................................................................................................. 175 Quiz Game Controller............................................................................................................ 177 Quiz game controller system context diagram ....................................................................... 177 Quiz game controller block diagram ...................................................................................... 178 Quiz game controller Algorithm ............................................................................................. 179 Quiz game schematic ............................................................................................................ 180 Quiz game board veroboard layout ....................................................................................... 181 Quiz Controller flowchart ....................................................................................................... 186 "Quiz Controller program code ............................................................................................... 187

31 LCDs (liquid crystal displays) ......................................................................................... 264 31.1 Alphanumeric LCDs .................................................................................................................. 265 ATTINY26 Development PCB with LCD ............................................................................................... 266 31.2 Completing the wiring for the LCD............................................................................................. 268 31.3 LCD Contrast Control ................................................................................................................ 269 31.4 Learning to use the LCD ........................................................................................................... 270 31.5 Adding more interfaces to the ATTiny26 Development board.................................................... 271 31.6 Ohms law in action – a multicoloured LED ................................................................................ 273 31.7 Repetition again - the ‘For-Next’ and the LCD ........................................................................... 275 31.8 Defining your own LCD characters ............................................................................................ 276 31.9 LCD custom character program ................................................................................................ 276 31.10 To CLS or not to CLS that is the question ............................................................................. 278 31.11 A simple digital clock ............................................................................................................. 279

Strings assignment ................................................................................................................... 296 ASCII Assignment ..................................................................................................................... 298 Time in a string ......................................................................................................................... 301 Scrolling message assignment .................................................................................................. 303 Some LCD programming exercises........................................................................................... 304

Microcontroller power limitations ............................................................................................... 305 Power ....................................................................................................................................... 307 Power dissipation in resistors .................................................................................................... 307 Diode characteristics ................................................................................................................. 308 Using Zener diodes ................................................................................................................... 309 How diodes work....................................................................................................................... 310 How does a LED give off light? ................................................................................................. 311 LCD Backlight Data ................................................................................................................... 312 Transistors as power switches .................................................................................................. 313 High power loads .................................................................................................................. 314 AVR Power matters............................................................................................................... 314 Darlington transistors - high power ........................................................................................ 316 ULN2803 Octal Darlington Driver .......................................................................................... 318 Connecting a FET backlight control to your microcontroller ................................................... 320 FET backlight control ............................................................................................................ 321

ADC - Analog to Digital conversion ........................................................................................... 344 Light level sensing .................................................................................................................... 344 Voltage dividers review ............................................................................................................. 345 AVR ADC connections .............................................................................................................. 345 Select-Case .............................................................................................................................. 346 Reading an LDR’s values .......................................................................................................... 348 Marcus’ Nightlight project .......................................................................................................... 350 Temperature measurement using the LM35 .............................................................................. 353 A simple temperature display .................................................................................................... 354 LM35 temperature display ..................................................................................................... 357 Voltage measurement using a voltage divider ....................................................................... 360 Variable power supply voltmeter program ............................................................................. 362 Force Sensitive Resistors ...................................................................................................... 364 Piezo sensor ......................................................................................................................... 364 Multiple switches and ADC .................................................................................................... 365

H-Bridge.................................................................................................................................... 373 H-Bridge Braking....................................................................................................................... 375 L293D H-Bridge IC .................................................................................................................... 376 L298 H-Bridge IC .................................................................................................................... 378 LMD18200 H-Bridge IC ............................................................................................................. 379 LMD18200 program .................................................................................................................. 382 Darlington H-Bridge .................................................................................................................. 383 Stepper motors ......................................................................................................................... 386 PWM - pulse width modulation .................................................................................................. 393 PWM outputs ........................................................................................................................ 394 Uses for PWM ....................................................................................................................... 395 ATMEL AVRs PWM pins ....................................................................................................... 396 PWM on any port .................................................................................................................. 397 PWM internals ....................................................................................................................... 398

40 AVR pull-up resistors ...................................................................................................... 400 41 Keypad interfacing........................................................................................................... 401 41.1 41.2 41.3 41.4 41.5 41.6

Analogue seconds display on an LCD ....................................................................................... 426 LCD big digits ........................................................................................................................... 429

Simplex and duplex ................................................................................................................... 499 Synchronous and asynchronous ............................................................................................... 499 Serial communications, Bascom and the AVR .......................................................................... 500 RS232 serial communications ................................................................................................... 501 Build your own RS232 buffer..................................................................................................... 503 Talking to an AVR from Windows XP ........................................................................................ 504 Talking to an AVR from Win7 .................................................................................................... 506 First Bascom RS-232 program .................................................................................................. 508 Receiving text from a PC .......................................................................................................... 509 BASCOM serial commands ................................................................................................... 510 Serial IO using Inkey() ........................................................................................................... 511 Creating your own software to communicate with the AVR ................................................... 514 Microsoft Visual Basic 2008 Express Edition ......................................................................... 515 Stage 1 – GUI creation .......................................................................................................... 516 Stage 2 – Coding and understanding event programming ..................................................... 525 Microsoft Visual C# commport application ............................................................................. 530 Microcontroller with serial IO. ................................................................................................ 535 PC software (C#) to communicate with the AVR ................................................................... 540 Using excel to capture serial data ......................................................................................... 544 PLX-DAQ .............................................................................................................................. 546 StampPlot ............................................................................................................................. 547 Serial to parallel .................................................................................................................... 549 Keyboard interfacing – synchronous serial data ........................................................................ 554 Keyboard as asynchronous data ............................................................................................... 561

56 Amplifier ........................................................................................................................... 608 57 Bike audio amplifier project ............................................................................................ 608 58 Graphics LCDs ................................................................................................................. 614 58.1 58.2 58.3

The T6963 controller ................................................................................................................. 614 Graphics LCD (128x64) – KS0108 ............................................................................................ 619 Generating a negative supply for a graphics LCD ..................................................................... 624

59 GLCD Temperature Tracking Project ............................................................................. 626 59.1 59.2 59.3 59.4 59.5 59.6 59.7

Low level languages:................................................................................................................. 638 AVR Internals – how the microcontroller works ......................................................................... 639 1. The 8bit data bus .................................................................................................................. 640 2. Memory ................................................................................................................................. 640 3. Special Function registers ..................................................................................................... 641 A simple program to demonstrate the AVR in operation ............................................................ 641

Keypad- polling versus interrupt driven ..................................................................................... 645 Improving the HT12 radio system by using interrupts ................................................................ 650 Magnetic Card Reader .............................................................................................................. 652 Card reader data structure ........................................................................................................ 652 Card reader data timing ............................................................................................................ 653 Card reader data formats .......................................................................................................... 654 Understanding interrupts in Bascom- trialling ............................................................................ 654 Planning the program ................................................................................................................ 657

69 SSD1928 based colour graphics LCD ............................................................................ 759 69.1 69.2 69.3 69.4 69.5 69.6 69.7 69.8 69.9 69.10 69.11 69.12 69.13 69.14 69.15 69.16 69.17 69.18 69.19 69.20 69.21 69.22

System block diagram ............................................................................................................... 759 TFT LCDs ................................................................................................................................. 760 System memory requirements .................................................................................................. 761 System speed ........................................................................................................................... 761 SSD and HX ICs ....................................................................................................................... 761 Colour capability ....................................................................................................................... 761 SSD1928 and HX8238 control requirements ............................................................................. 762 SSD1928 Software ................................................................................................................... 763 SSD1928 microcontroller hardware interface ............................................................................ 767 Accessing SSD control registers ........................................................................................... 768 SSD1928_Register_routines.bas .......................................................................................... 771 Accessing the HX8238. ......................................................................................................... 775 SSD1928_GPIO_routines.bas............................................................................................... 775 LCD timing signals ................................................................................................................ 777 HX setups ............................................................................................................................. 778 SSD setups ........................................................................................................................... 779 SSD line / HSync timing ........................................................................................................ 780 SSD row / VSync/ frame timing ............................................................................................. 781 HX and SSD setup routine .................................................................................................... 783 "SSD1928_HardwareSetup_Routines.bas ............................................................................. 783 SSD1928_Window_Control_Routines.bas ............................................................................ 787 Colour data in the SSD memory ............................................................................................ 790

Traffic Light help and solution ....................................................................................... 800 USB programmer - USBASP ........................................................................................... 806 USBTinyISP programmer ................................................................................................ 808 Various AVR development board schematics and layouts .......................................... 812 AVR Development Board 2 ....................................................................................................... 815 Dev board version 2 circuit diagram .......................................................................................... 816 Dev board pcb layout version 2 ................................................................................................. 817 ATMEGA V4b development board circuit – 12TCE 2011 .......................................................... 818 V4b devboard layout 12TCE 2011 ............................................................................................ 819 ATMega Dev PCB V5DSchematic (2012) ................................................................................. 820 ATMega Dev PCB V5DLayout (2012) ....................................................................................... 821 ATMega Dev PCB V5D Copper (2012) ..................................................................................... 822

128x64 GLCD Schematic – VerC -data on portB ...................................................................... 827 128x64 GLCD Layout – VerC –data on portB ........................................................................... 828 128x64 GLCD Schematic – VerD -data on portB ...................................................................... 829 128x64 GLCD Layout –VerD -data on portB ............................................................................. 830

1. Develop an understanding of what a computer is and build a correct mental model for one a. Input and output conversion at the voltage level b. Conversion of input and output voltages into data c. Processing and manipulating data which is stored in variables 2. Get to know about the hardware you are using a. Get a copy of the datasheet b. Learn about the power supply required c. Learn how to configure pins as either input or output d. Learn how to interface common I/O circuits: LED’s, Switches, Piezo, LDR… e. Find out about the different types of memory and amount of each f. Find out about the speed of processing 3. Get to know the language and the IDE you are using a. Learn to access the helpfile (e.g. highlight a word and press F1) b. The language has syntax (specific grammar/word rules) you must use correctly c. The IDE (Integrated Development Environment) has special commands and built in functions you must know and use: F7, F4, $crystal, $regfile, config, alias, const, port, pin d. Learn common I/O functions: set, reset, locate, LCD, GetADC e. Understand the limitations of and use variables: byte, word, long, single, double f. Use constants instead of numbers in the code (e.g. waitms timedelay) g. Get to know the control functions: Do-Loop (Until), For-Next, While-Wend, If-Then (Else) h. Get to know about text and math functions (read help file, write a few simple programs using the simulator) 4. Develop Algorithms (written plans for the process the program must carry out) a. Have a goal in mind for the program – use specifications and write a simple brief b. Plan your I/O by drawing a system block diagram c. Determine variables and constants required in the program d. Determine the state of all the I/O when the program begins e. Write the algorithm – Identify, order and describe the major processes the micro must do. 5. Draw Flowcharts or Statecharts (visual diagram for the process the program must carry out) a. Identify the blocks/states that will be used b. Use arrows to link the blocks and visualise control processes and program flow 6. Develop code from the flowcharts a. The outer looping line is replaced with a do-loop b. Backwards loops are replaced with do-loop do-loop-until, for-next, while-wend c. Forward loops are generally replaced with If-Then-EndIf d. Replace the blocks with actual commands e. Layout the code with correct indentations(tabs) to improve readability f. Learn to comment code so that it explains what is happening (not just describes) g. Use subroutines to organise complex code so that logic code is separate from I/O code h. Trial different ways of solving the problem and keep records of you experiments This is not a step by step process; as when you get to know about one area you get to know about others at the same time. The key to gaining depth in your knowledge and understanding comes from LOTS OF EXPERIMENTATION! That means making mistakes and above all having fun, you need to know that good decisions come from experience and experience comes from bad decisions!!! So experimenting is ok. In your electronics courses at school the aim is not to make you an expert in all the above (expertise comes after about 10 years working in an area), the aim is to introduce you to microcontroller electronics and programming, and to understand some of what is happening in the world around you and to feel able to see that you can control it and not have it control you. 98

A microcontroller is a general purpose electronic circuit; it is a full computer inside a single integrated circuit (IC or chip). Often ICs have fixed functions e.g. the TDA2822M amplifier or LM358 opamp, they only do one job and their input and output pins have fixed roles, so you have limited control over what they do, and therefore limited control over how to connect them. With a microcontroller however you are in control, you decide:  what the function of the IC is  what most of the pins are used for (inputs or outputs)  and what external input/output devices these pins are connected to. If you want an egg timer, a car alarm, an infrared remote control or whatever, it can all be done with a microcontroller. A commercial range of microcontrollers called ‘AVR’ is available from ATMEL (www.atmel.com). You could start with the ATTiny461, it has 4kbytes of Flash for program storage, 128 bytes of Ram and 128 bytes of EEPROM for long term data storage. Or you could start with the ATMega48, it has 4kbytes of Flash, 512 bytes of RAM and 256 bytes of EEPROM. ATTiny461

The AVR is a microcontroller from which manufacturer________________ The URL for their website is: ________________________ Download the specific datasheet for our microcontroller (the summary version not the full version) and print the first 2 pages and put them in your journal. The Programmable Memory size is ______ The SRAM size is _______The EEPROM size is _______ The number of I/O lines is __________ and they are arranged in _______ports

BASCOM-AVR is a compiler from _____________________ The URL for their website is: ________________________ Download the latest version of the BASCOM AVR demo and install it on your PC. There are a number of application notes on the website for the AVR Describe what AN128 is about __________________________________________________________________________ __________________________________________________________________________ __________________________________________________________________________

There are a number of other great resource websites for the AVR and BASCOM Find 3 websites on the internet that have useful resource information on BASCOM List the websites URL and what you found there __________________________________________________________________________ __________________________________________________________________________ __________________________________________________________________________ __________________________________________________________________________ __________________________________________________________________________ __________________________________________________________________________ __________________________________________________________________________

11 Getting started with AVR Programming Microcontrollers, such as the ATMEL AVR, are controlled by software and they can do nothing until they have a program inside them. The AVR programs are written on a PC using BASCOM-AVR. This software is a type of computer program called a compiler, it comes from www.mcselec.com. It comes in a freeware version so students may download it and use it at home. The AVR is connected to the PC with a 5 wire cable.

The 5 pin header (connector) is for programming the AVR from a PC. The 0.1uF capacitor between 0V and VCC is to reduce any variations in power supply voltage. The 10k is a pull-up resistor for the reset pin, a low (connection to ground) on this pin will halt the microcontroller and when it is released(pulled high by the resistor) the program will run from the beginning again. The 1N4148 is a protection diode that will stop high voltages possibly damaging the microcontroller (it is only required on the reset pin because all the other microcontroller pins have built in protection diodes). The 0.1uF capacitor and 100R resistor are the power supply for the ADC circuit

A five wire cable is needed to connect the AVR circuit to a PC. It connects the PC’s parallel port to the AVR circuit. One end has a DB25M connector on it (as in this picture)

12 Getting started with Bascom & AVR BASCOM-AVR is four programs in one package, it is known as an IDE (integrated development environment); it includes the Program Editor, the Compiler, the Programmer and the Simulator all together.

When you have successfully compiled a program pressing F4 or the green IC picture in the toolbar starts the programmer. If no microcontroller is connected an error will pop up. If the IC s connected then the BASCOM completes the programming process and automatically resets your microcontroller to start execution of your program.

Flash1LEDv1.bas Type the code below into BASCOM, save it, then F7 to compile and then F4 to program ‘ Flash1LEDv1.bas "-----------------------------------------------" Compiler Setup (this tell Bascom things about our micro) $regfile = "attiny461.dat" "bascom must know the micro $crystal = 1000000 "bascom must know its speed "-----------------------------------------------" Hardware Setups " (these tell bascom how to setup our micro) Config Porta = Output "LEDs on port "-----------------------------------------------" Declare Constants " (these tell bascom names we will use for numbers " in our program, this makes it easy "to change things quickly later) Const Flashdelay = 150 ‘ preset how long a wait will be "-----------------------------------------------Do ‘start of a loop Porta = &B10000000 ‘ LED 7 on Waitms Flashdelay ‘wait a preset time Porta = &B00000000 ‘all LEDs off Waitms Flashdelay ‘wait a preset time Loop ‘return to do and start again End YOU NEED TO INDENT CODE BETWEEN ALL CONTROL STRUCTURES SUCH AS WITH THIS DO-LOOP, it really helps make your code more readable and easier to debug! Use the TAB key in Bascom to do it.

This is a typical first program to test your hardware Every line of the code is important. $regfile=”attiny461.dat”, Bascom needs to know which micro is being used as each micro has different features; this is the name of a file in the Bascom program folder with every detail about the ATTiny461. $crystal=1000000, This line tells Bascom the speed at which our microcontroller is executing operations 1 million per second)so that Bascom can calculate delays such as waitms properly Config porta=output, each I/O must be configured to be either an input or output; (it cannot be both at once) Const Flashdelay=150, ‘constants’ are used in a program, it is easier to remember names and it is useful to keep them all together in one place in the program (this is a code of practice). DO - LOOP statements enclose code which is to repeat forever; when programming it is important to indent (tab) code within loops; this makes your code easier to follow (this is a code of practice). Waitms flashdelay wait a bit, a microcontroller carries out operations sequentially, so if there is no pause between turning an LED on and turning it off the led will not be seen flashing Output Code Porta = &B10000000 make porta.7 high (which will turn on the LED connected to that port) and make all the other 7 output pins on that port low Porta = 0 make all 8 pins on porta low (which will turn off any LEDs connected to that port)

In the code throughout this book different AVR microcontrollers are referred to in different places. So take special note of the $regfile and $crystal commands used and make sure they match the micro you are using. Note that the ATTiny461 and ATMega48 both run by default at 1,000,000MHz while the ATMega8535 runs at 8,000,000 MHz. You will also have to make changes to the ports used in the program: the ATTiny461 has ports A & B, the ATMega48 has B, C & D, the Amega8535 ahd ports A, B, C & D.

Note the change to $regfile and $crystal (If the timing of the flashing is wrong then try $crystal=1000000 (as AVRs often come setup at 1MHz not 8 MHz)

"this program shows how to write code which controls the whole port at "once using the commands portA=&B0000000, rather than individual set and ‘reset commands which are very wasteful of code space when multiple LEDs ‘have to "be contolled (excellence comment) "-----------------------------------------------------------------" Compiler Setup (these tell Bascom things about our micro) $regfile = "attiny461.dat" "bascom needs to know the micro $crystal = 1000000 "bascom needs to know its speed "-----------------------------------------------------------------" Hardware Setups (these tell bascom how to setup our micro) " setup direction of all ports Config Porta = Output "LEDs on portA Config Portb = Input "switches on portB " Hardware Aliases (these tell bascom names we will use for I/O devices " attached to the Micro, names are easier to remember that ports) Config Porta = Output Config Portb = Output "-----------------------------------------------------------------" Declare Constants (these tell bascom names we will use for numbers in " " our program, this makes it easy to change things quickly later) " times have been made shorter for testing purposes Const Delaytime = 25 Do Porta = &B10000000 "1 =A.7 Waitms Delaytime Porta = &B01000000 "2 =A.6 119

Bascom’s sound command can be used to directly make a tone. Piezo alias portA.3 Sound piezo, 500, 300 ‘that’s all that’s required The Bascom sound command has three parameters (values) attached ot it.  The port or pin of the microcontroller used  The duration of the sound (number of pulses)  The time the pin is high and low for. This command is not easy to use to get accurate tones from your AVR, but they do make useful sounds. Experiment with the sound command and make a series of tones suitable for an alarm. "-----------------------------------------------------------------" Compiler Setup (these tell Bascom things about our micro) $regfile = "attiny461.dat" "bascom needs to know the micro $crystal = 1000000 "bascom needs to know its speed "-----------------------------------------------------------------" Hardware Setups (these tell bascom how to setup our micro) " setup direction of all ports Config Porta = Output "LEDs on portA Config Portb = Output "switches on portB " Hardware Aliases (these tell bascom names we will use for I/O devices " attached to the Micro, names are easier to remember that ports) Leda4 Alias Porta.4 Piezo Alias Portb.3

"-----------------------------------------------------------------" Declare Constants (these tell bascom names we will use for numbers in " " our program, this makes it easy to change things quickly later) " times have been made shorter for testing purposes Const Flashdelay = 150

In this first program we would like the LED to change from off to on every time the switch is pressed. “When the switch is pressed change the LED” "-----------------------------------------" Compiler Setup (these tell Bascom things about our micro) $regfile = "attiny461.dat" "bascom needs to know the micro $crystal = 1000000 "bascom needs to know its speed "----------------------------------------" Hardware Setups (these tell bascom how to setup our micro) " setup direction of all ports Config Porta = Output "LEDs on portA Config Portb.5 = Input "switches on portB " Hardware Aliases (these tell bascom names we will use for I/O devices " attached to the Micro, names are easier to remember that ports) RedSw Alias Pinb.6 " hardware alias "---------------------------------------" Program starts here Do If Redsw = 0 Then "only do if switch pressed Toggle LED End If Loop End

We alter the program to wait a bit after the switch is pressed, which will give us time to release ithe switch “When the switch is pressed change the LED” "-----------------------------------------" Compiler Setup (these tell Bascom things about our micro) $regfile = "attiny461.dat" "bascom needs to know the micro $crystal = 1000000 "bascom needs to know its speed "----------------------------------------" Hardware Setups (these tell bascom how to setup our micro) " setup direction of all ports Config Porta = Output "LEDs on portA Config Portb.5 = Input "switches on portB " Hardware Aliases (these tell bascom names we will use for I/O devices " attached to the Micro, names are easier to remember that ports) RedSw Alias Pinb.6 " hardware alias "---------------------------------------" Program starts here Do If Redsw = 0Then " wait until switch press Toggle LED Waitms waitdelay End If Loop End

“If the switch is pressed, debounce the switch then toggle LED” "---------------------------------------" Compiler Setup (these tell Bascom things about our micro) $regfile = "attiny461.dat" "bascom needs to know the micro $crystal = 1000000 "bascom needs to know its speed "----------------------------------------" Hardware Setups (these tell bascom how to setup our micro) " setup direction of all ports Config Porta = Output "LEDs on portA Config Portb.5 = Input "switches on portB " Hardware Aliases (these tell bascom names we will use for I/O devices " attached to the Micro, names are easier to remember that ports) RedSw Alias Pinb.6 " hardware alias "---------------------------------------" Program starts here Do If Sw = 0 Then Waitms debouncetime Do Loop until Sw = 1 Waitms debouncetime Toggle Led End If Loop End

"-----------------------------------------------------------------" Title Block " Author: B.Collis " Date: 1 Aug 2008 " File Name: PedestrianCrossingLightsVer3.bas "-----------------------------------------------------------------" Program Description: " reads switch to check if pedestrian wants to cross " and changes the lights "-----------------------------------------------------------------" Compiler Setup (these tell Bascom things about our micro) $regfile = "attiny461.dat" "bascom needs to know the micro $crystal = 1000000 "bascom needs to know its speed "-----------------------------------------------------------------" Hardware Setups (these tell bascom how to setup our micro) " setup direction of all ports Config Porta = Output "LEDs on portA Config Portb = Input "switches on portB " Hardware Aliases (these tell bascom names we will use for I/O devices " attached to the Micro, names are easier to remember that ports) Greenlight Alias Porta.7 Orangelight Alias Porta.6 Redlight Alias Porta.5 Crossbutton Alias Pinb.6 Crossnowlight Alias Porta.3 Dontcrosslight Alias Porta.4 "-----------------------------------------------------------------" DIMENSION VARIABLES (a variable can be changed during the program, so we might have different delays at different times of the day (maybe before and after school we could change the orange and cross delay)

"----------------------------------------------" Compiler Setup $regfile = "attiny461.dat" $crystal = 1000000 "bascom needs to know its speed "-----------------------------------------------" Hardware Setups " setup direction of all ports Config Porta = Output "LEDs on portA Config Portb = Input "switches on portB " Hardware Aliases Green Alias Porta.1 Red Alias Porta.0 "-----------------------------------------------" Declare Constants Const Orangedelay = 7 Const Crossdelay = 20 Const Dontcrossdelay = 5 "----------------------------------------------" Program starts here "Declare Constants Const Lightontime = 500 Const Lightofftime = 2500 "---------------------------------------------"Declare Variables Dim Count As Byte "----------------------------------------------Program starts here Do For Count = 1 to 20 Set Red Waitms Lightontime Reset Red Waitms Lightofftime Incr Count Next For Count = 1 to 20 Set Green Waitms Lightontime Reset Green Waitms Lightofftime Incr Count Next Loop End

1.Type in the program COMPLETE THE MISSING PARTS, save it, Compile (F7) and Simulate it (F2). In the simulator window Step A: Choose the menu button with LCD, to open Hardware Simulation Step B: Select the switch inputs PinB.0 through PinB.4 as high (this simulates pullup resistors) Step C: Select the upper most blank yellow box in the variable area. Then double click it to get a drop down box. Then choose cars Do this for the 3 other variables

Variabes must start with a letter not a digit e.g. Dim Red_cars As Byte not Dim 1cars As Byte Variabes must not be Bascom reserved(special) words e.g. Dim band As Byte not Dim And As Byte Variables must contain no spaces e.g. Dim Red_cars As Byte not Dim Red cars As Byte Variable names should relate to what the variable is used for e.g. Dim Red_cars As Byte, not Dim hgashg As Byte Variable names cannot be used for other things such as constants or subroutines e.g. Dim Red_cars As Byte, means yu cannot have Const Red_cars = 12 as well

The simulator is an ideal tool for testing small parts of a program to see if you achieved what you wanted to. We will use it to explore the numerical range of different types of variables Here is some code to show off a few BASIC commands. Copy this program into BASCOM and compile it and see if you can understand what is happening and why. " ShowComandsV1.bas . $sim $crystal = 1000000 $regfile = "attiny26.dat" Config Porta = Output Config Portb = Output Config Pinb.6 = Input "dimension variables Dim Byte1 As Byte Dim Byte2 As Byte Dim Word1 As Word Dim Int1 As Integer Dim Single1 As Single Dim Single2 As Single

Every microcontroller has different amount of RAM available for storing variables Carry out research on these different AVR microcontrollers RAM size (bytes)

First lets review what a tone is. It is a repeated turning on and off of our piezo. The frequency of the tone is 1/period. The duration of the tone is the number of complete cycles. A piezo will not make a sound when you turn it on; it only makes a sound when you turn it on and off rapidly. So to make a tone we must turn the piezo on then wait a bit, then turn it off and we repeat this for the duration of the tone. In this program the tone period will be 1mS so the piezo must be on for 500uS (1/2 mS) and off for the same. Bascom has a waitus command (it is not particularly accurate but its good enough for this exercise). We want the tone to last long enough to hear it so we need to repeat it 150 times. 150 times 1mS will give us a tone duration of 150mS (0.15S). To count the number of cycles we will dimension a variable called cyclecount, and we will increase it inside a do-loop. It will count upto the max number of cycles and then we will have a 2 second break. Then it will repeat. Remember to reset cycle count to 0 or it will overflow. This program works similalrly to the Bascom SOUND command.

"-----------------------------------------------------------------" Title Block " Author: B.Collis " Date: 22 Feb 08 " File Name: SirenV1.bas "-----------------------------------------------------------------" Program Description: " This program makes a simple tone using a piezo " Program Features: " makes use of Bascom waitus (microseconds) command " introduces first use of a variable " the variable cyclecount increases from 0 until it reaches the preset (constant) " value maxcyclecount at which point there is a quiet time " the led is on when the the tone is occuring " Hardware Features " a pezo can be directly connected to the micro port " the led has a 1k resistor in series to limit the current "-----------------------------------------------------------------" Compiler Directives (these tell Bascom things about our hardware) $regfile = "attiny26.dat" "the micro we are using $crystal = 1000000 "rate of executing code "-----------------------------------------------------------------" Hardware Setups Config Portb = Output " Hardware Aliases Piezo Alias Portb.3 "us