Home

Załącznik nr 6 do ZW 15/2007

image

Contents

1. Place your code here PORTA counter bitwise negation of the I O port delay ms 100 100 ms delay counter counter incrementation 1 Before compiling this code we should connect 8 LED diodes to the output pins of the microcontroller according to the following circuit diagram shown in Fig 1 13 Please note that the bitwise negation operator of the counter variable is performed in order to obtain the lighting up of the LED diodes signaling the 1 high state Without that modification only the positions connected to ports lines in 0 Low state would light up the relevant LED diode After the modification the logic level 1 high states present on the PORT A output pins are displayed by lighted LED diodes Please also note that only decimal numbers from the range 0 255 00000000 11111111 in binary format can be displayed that way after reaching the maximal value the counter variable is reset back to zero As a general rule the n bit variable may contain values from 0 to 2 1 decimal where n is an integer positive number 18 ATMEGA16_DIP40 Figure 1 13 The wiring diagram for connecting LED diodes to the PORT A of an Atmegal6 microcontroller The operator in C language should be understood as incrementation In other words the following two lines of code will perform identical actions Counter Counter counter 1 Similarly operator will mean decrementati
2. u gt 2 z Q O r a z a COP WATCHDOG AND ILLEGAL ADDRESS DETECT CPU CLOCK osc INTERNAL DIVIDE 0 CZ OSCILLATOR BY TWO INTERNAL CLOCK Figure 1 4 The internal diagram of MC68HCOS5J1A microcontroller Motorola Freescale Another example of such a unit is an Atmel ATmegal6 device The ATmegal6 is a low power CMOS 8 bit microcontroller based on the AVR enhanced RISC Reduced Instruction Set Computer architecture microcontroller featuring proprietary instruction set designed by the Atmel Company Most of the instructions are executed in a single clock cycle thus the ATmegal6 MCU achieves throughputs approaching 1 MIPS per MHz The block diagram of ATmegal6 microcontroller is shown in Fig 1 5 PAD PAT PCO PC7 vec I PORTC DIGITAL INTERFACE I PORTA DIGITAL INTERFACE P60 P57 PDO PD7 Figure 1 5 Atmel Atmegal6 microcontroller block diagram Atmel The ATmegal6 provides among others the following features 16 Kbytes of In System Programmable Flash Program memory with Read While Write capabilities 512 bytes EEPROM 1 Kbyte static RAM SRAM memory 32 general purpose I O lines 32 general purpose working registers a JTAG interface for Boundary scan on chip Debugging support and programming three 8 Timer Counters with compare mod
3. PORTA 0X00 LED on delay ms 100 delay 100 milliseconds PORTA 0XFF LED off delay ms 100 delay 100 milliseconds Please note that the statements located after double slash sign are treated as comments by the compiler The program is to send a 5Hz square wave on the Port A of the microcontroller In order to obtain a low frequency of the wave we will use a delay function that has prototype in delay h library header file In order to properly declare that function we must add a following statement in the next line after the statement include lt megal16 h gt include lt delay h gt Then we must try to check if the program is correct Then please execute Project gt compile menu command or just press F9 key As a result you should obtain a window like below 16 i Information Compiler Chip Tmegal6L Clock frequency 8 000000 MHz Program type Application Memory model Small Optimize for Size sprintf features int width s scanf features int width Promote char to int Yes char is unsigned Yes global const stored in FLASH No 8 bit enums Yes Enhanced core instructions Yes Automatic register allocation Yes Smart register allocation Yes Build 3 O line s compiled No errors No warnings Bit variables size 0 byte s Data Stack area 60h to 15Fh Data Stack size 256 byte s Estimated Data Stack usage 0 byte s RAM Global variables size byte s Hardware Stack area
4. UNIA EUROPEJSKA KAPITA LUDZKI m EUROPEJSKI NARODOWA STRATEGIA SP JNO CI Politechnika Wroc awska FUNDUSZ SPO ECZNY ROZW J POTENCJA U I OFERTY DYDAKTYCZNEJ POLITECHNIKI WROC AWSKIEJ Wroc aw University of Technology Refrigeration and Cryogenics Artur J drusyna Krzysztof Tomczuk MECHATRONICS AND CONTROL SYSTEMS LABORATORY HANDBOOK Wroc aw 2011 Projekt wsp finansowany ze rodk w Unii Europejskiej w ramach Europejskiego Funduszu Spo ecznego Wroctaw University of Technology Refrigeration and Cryogenics Artur Jedrusyna Krzysztof Tomczuk MECHATRONICS AND CONTROL SYSTEMS LABORATORY HANDBOOK Wroctaw 2011 Copyright by Wroclaw University of Technology Wroclaw 2011 Reviewer Tadeusz Mikulczy ski ISBN 978 83 62098 58 3 Published by PRINTPAP d www printpap pl Contents Introduction The prerequisites 1 Microcontrollers 1 1 Introduction 1 2 Projects 1 2 1 The First Project 1 2 2 The Second Project 1 2 3 The Third Project 1 2 4 The Fourth Project 1 2 5 The Fifth Project Literature 2 Process automation using PLCs 2 1 Introduction 2 2 Simatic S7 200 PLC 2 3 Didactic Multi Production System MPS based on Festo equipment 2 4 Laboratory tasks 2 4 1 Preliminary tasks 2 4 2 Detailed tasks Literature Introduction This book is intended as the basic textbook for students attending Mechatronics and Control System Lab held at the Faculty of Mechanical a
5. 160h to 45Fh Hardware Stack size 768 byte s Heap size 0 byte s EEPROM usage 0 byte s 0 0 of EEPROM Figure 1 12 The result of program compilation As a next step you should execute Project gt Configure command In the window bookmark marked after build please check option After Build gt Program the Chip After compilation you may use an oscilloscope in order to monitor the signal present on PAO pin Please check the frequency of the signal and its PWM factor Please use delay_ms function in order to generate i 1 Hz square wave ii 1 kHz square wave Please note the changes in the intensity of LED light after running each version of the program 17 1 2 2 The Second Project A paced loop This project will help us to understand the practical applications of the binary and hexadecimal numerical systems In this example we will try to define an 8 bit software counter using a single byte char type variable and transfer its contents to I O port Please close the previous project next generate a new one the detailed procedure was described above Please use CodeWizardAVR and select the name of project test02 or any other name of your choice The following code will commence this task for sake of brevity only the crucial parts of the program were listed include lt delay h gt delay functions library declaration unsigned char counter an 8 bit variable called counter while 1
6. A letter on the display we should move the cursor back to the initial position This task could be accomplished with 1cd_gotoxy x y command using the following coordinates 0 0 15 0 0 1 15 1 As you can see the X coordinate values between 0 and 15 is related to the horizontal axis and the Y coordinate values 0 or 1 for two line display the vertical axis The reference point coordinates 0 0 is located in the left upper corner of the LCD display Next please modify your program in the following way while 1 Place your code here lcd_putchar A display a single character on LCD lcd_gotoxy 0 0 move cursor back to the reference point 0 0 After the compilation and running of the program we should see the following result The lcd_putchar command used in the last example can be used only for displaying a single character on an LCD screen In case a longer text string is needed Lcd putsf command should be utilized 23 while 1 Place your code here lcd _gotoxy 0 0 lcd _putsf Mechatronics lcd _gotoxy 0 1 lcd _putsf Lab After compilation and execution of the last example the display should look like this Mechatronics Lab Led_pusf function displays at the current position a string stored in flash memory Flash memory is used here in order to save valuable locations in RAM memory an amount of built in Flash memory is lower than RAM memory T
7. LDR editor Others required descriptions and programming details are available in reference 6 7 8 36 2 3 Didactic Multi Production System MPS based on Festo equipment 9 Station A the rollers distribution process The rollers distribution station showed in figure 2 4 is equipped with the vertical storage 1 and two pneumatic actuators 2 and 3 controlled using electrically actuated 3 2 and 5 2 pneumatic valves 4 The rollers workpieces inserted into the vertical storage 1 are consecutively pushed out by the horizontal actuator 2 and detected by a mechanical end position sensor 5 Next the rotary pneumatic actuator 3 picks up the workpieces with the aid of a pneumatic suction gripper 6 The rotary actuator can be set to various angles between 90 and 270 Its end positions are sensed by means of micro switches 7 The gripper is equipped with a pneumatic sensor 8 which indicates the carrying state of the roller When the roller is picked up to the destination X position optical sensor 9 generates its information The Station A is additionally equipped with S7 200 Programmable Logic Controller 10 CPU222 for process automation pressure regulator valve with gauge 11 electric pushbuttons and indicators 12 text display panel TD200 showed on the Figure 2 5 optionally 24V DC power supply 9 500 kPa 5 bar pressure connection PPI Multi Master programming cable and PC with Step7 Micro Win software Fig 2 4 The
8. connection with a Point to Point Interface PPI Multi Master cable or a Communications Processor CP card with an Multi Point Interface MPI cable The PPI Multi Master programming cable is the most common method of connecting PC to the S7 200 CPU This cable connects the communications port of the S7 200 CPU RS485 to the serial communications of PC RS232 The PPI Multi Master programming cable can also be used to connect other communications devices to the S7 200 CPU The STEP 7 Micro WIN programming software Fig 2 3 allows developing editing and monitoring the algorithms for the application control using three types of program editors Statement List STL Ladder Diagram LDR and Function Block Diagram FBD Fi STEP 7 Micro WIN 32 Project SIMATIC LAD aX E Fle Edt View PLC Debug Took Windows Help a asad an B o b 8 gt m aoan fag ho S AAAA Bw E Project CPU ZA REL o T Te KNNIRNOK WIORNIKEKY 3 a or ie ere oe on oe Z F EN ProsamBlock Em Va Toe Date Type Gone C MANN 081 TEN 422 SBR_O GBRO EW GENT OINTO TEMP ji j A PROGRAM COMMENTS ej Network 1 Neviok Tile Eo Deer A 100 Naz JL JE 22 1 Notwork 2 I MO EA m TON ver Network 3 I RA 005 i 1 M02 5 1 lt D Aman K BRO KINTI E a El Fig 2 3 An example of Step7 Micro Win window with
9. drilling process The rollers drilling station shown in figure 2 6 is equipped with the rotary table 1 with four sockets 2 electric drilling machine 3 mounted on the vertical pneumatic actuator lift 4 the vertical pneumatic actuator 5 horizontal pneumatic actuator 6 and the optical presence sensor 7 All pneumatic actuators are equipped with end position sensors and are controlled using electrically 38 actuated 3 2 or 5 2 pneumatic valves 8 Under the table there are four metal markers and inductive sensor 9 invisible in fig 2 6 that allow the user to determine the proper positions of the sockets for workpieces processing Rotary table 1 turns until inductive sensor 9 determines its correct position Then the table stops and the first socket is tested by optical sensor 7 In case of the presence of a roller it is punched using vertical pneumatic actuator 5 After that the table moves on and the socket appears on the next position under the drilling machine where the main process drilling runs During this operation the roller is blocked by means of horizontal pneumatic actuator 6 Station C is additionally equipped with S7 200 Programmable Logic Controller 10 CPU222 for process automation pressure regulator valve with gauge invisible on the fig 2 6 electric pushbuttons and indicators 11 text display panel TD200 optionally 24V DC power supply 500 kPa 5 bar pressure connection PPI Multi Master programming cable
10. is available as either commercial or code size limited trial version available for download at www hpinfotech ro The main window of the program was shown in Figure 1 7 12 CodeVisionAVR file Edit Search View Project Tools Settings Help Dz PWAOGG MJ ioe kRERERZE S FF X h 0 0 48 Pi B AAA AMBER ROK OSES F S N P S HASGe i Ke FE Code Navigator EG R Code Information FE Code Templates 3 EJ R Clipboard History 4 EJ m GM CodevisionaVA i Al No Project Other Files Sf Function Call Tree E F Messages Errors B Warnings Figure 1 7 CodeVisionA VR IDE main window In a next chapter a few projects using CodeVisionAVR and Gotronik AVR board will be discussed 13 1 2 Projects 1 2 1 The First Project In this example we will try to perform some simple input output I O operations for instance square wave generation on the microcontroller port After running the compiler the main window is opened Please select from menu File gt New gt Project The compiler will then ask you about the use of CodeWizard code generator Confirm 9 You are about to create a new project SS Do you want to use the CodeWizardAYR Figure 1 8 CodeWizard dialog window After answering Yes we should select the proper microcontroller type and its clock speed Please select ATmegal6L and 8MHz respectively These setting
11. of the most important parameters is the number of bits used Another important parameter is the reference voltage defined as the maximum value that the ADC can convert For instance an 8 bit ADC can convert values from Ov to the reference voltage This voltage range is divided into 256 values or steps CONVERSION CODE Digital Output RANGE OF DIGITAL Code Ideal Straight Line ANALOG OUTPUT INPUT CODE VALUES 0 101 4 5 5 5 0 101 3 5 4 5 0 100 0 100 Step m ee ee ee amas m tan 1 5 2 5 0 010 0 010 0 5 1 5 0 001 0 001 5 0 0 5 0 000 Step Width 1 LSB Analog Input 0 000 apes 0 1 2 4 5 gt Midstep Value of 0 011 Quantization Error TI Figure 1 16 Transfer Diagram of Analog to Digital converter Source Texas Instruments 5 26 LSB Analog Input Value mi Quantization Error 1 2 LSB Elements of Transfer Diagram for an Ideal Linear ADC The size of the step for n bit converter is given by a simple formula 1 step Vref 2 1 The voltage value equivalent to 1 step is also called Least Significant Bit LSB For n 10 and Vref 5V we obtain 1 LSB 5V 2 1 5V 1023 approx 5mV The analog to digital converter ADC found on the atMega MCU is a 10 bit successive approximation device There are a few important items that must be remembered when dealing with the converter a The inputs of the ADC share the common
12. pins with I O pins of PORTA b The ADC must be configured before using c When reading we must remember that the A D conversion time exceeds a few microseconds this may be vital during measurement of fast signals Before using ADC we should start a new project and open CodeWizardA VR Then we should open ADC bookmark and check ADC Enabled option Please also select Auto Trigger Source Free Running After program generation we should include the following code inside the main while 1 loop 27 3 CodeWizardAVR untitled cwp File Edit Help BENA GR RC iwe Zwiel c LCD BitBanged Project Information Ports ExtemalIRQ Timers Analog Comparator ADC SPI Program Preview ADC Enabled _ Use 8 bits Interrupt Volt Ref AREF pin v Clock 1000 000 kHz Auto Trigger Source Figure 17 CodeWizardA VR window ADC configuration dialog Include lt stdio h gt Include lt delay h gt Unsigned int result Char buffer 6 while 1 lcd_gotoxy 0 0 result read adc 0 read voltage present at ADCO input sprintf buffer u result convert the result to an integer value lcd_clear lcd_puts buffer delay _ms 200 28 After compilation and running the program we should see the dynamically changing contents of the LCD display XXXX Instead the xxxx a numerical value from th
13. resistors selected for each bit The Port C output buffers have symmetrical drive characteristics with both high sink and source capability As inputs Port C pins that are externally pulled low will source current if the pull up resistors are activated The Port C pins are tri stated when a reset condition becomes active even if the clock is not running If the JTAG interface is enabled the pull up resistors on pins PC5 TDI PC3 TMS and PC2 TCK will be activated even if a reset occurs Port C also serves the functions of the JTAG interface and other special features of the ATmegal6 processor Port D PD7 PD0 Port D is an 8 bit bi directional I O port with internal pull up resistors selected for each bit The Port D output buffers have symmetrical drive characteristics with both high sink and source capability As inputs Port D pins that are externally pulled low will source current if the pull up resistors are activated The Port D pins are tri stated when a reset condition becomes active even if the clock is not running RESET Reset Input A low level on this pin for longer than the minimum pulse length will generate a reset even if the clock is not running XTALI Input to the inverting Oscillator amplifier and input to the internal clock operating circuit XTAL2 Output from the inverting Oscillator amplifier AVCC AVCC is the supply voltage pin for Port A and the A D Converter It should be externally connected to VCC even if
14. the PLC Station D the rollers handling process 42 Load a red or silver roller to one of two enabled places for workpieces on the station Develop a LDR diagram to solve the following procedure The roller is automatically picked up to the second position in case of a blank place Consider different algorithms of the rollers rearranged when all four optical presence sensors are enabled The TD200 panel shows current messages describing the state of process ready to start process handling the roller status of the places for the rollers blank engaged amount of distributed rollers full cycle time etc When the process is stopped the TD 200 panel shows the current status of the station or displays demo connected with performing operations The task should be started and stopped alternatively by pushing the button mounted on the station or using the chosen function key F1 F8 on the text panel TD200 Literature 1 J Swider P Michalski G Wszolek Laboratory support for the didactic process of engineering processes automation at the Faculty of Mechanical Engineering Journal of Achievements in Materials and Manufacturing Engineering VOLUME 15 ISSUE 1 2 March April 2006 2 http en wikipedia org 3 http www automation siemens com 4 http www allmar pl S7 200 Programmable Controller System Manual 5 http www automation siemens solutionsandproducts AS_1 htm 6 http www allmar send pl up
15. working computer the designer has to use many separate integrated circuits However in microcontrollers all the peripheral devices are located inside the same integrated circuit this is the reason for the other name for a microcontroller a single board computer We should note that a microcontroller also described as MCU Microcontroller Unit usually performs repeatedly the following consecutive actions Command fetching Command decoding Scanning input ports Execution of the command Storing the results Updating output ports Fetching of the next command An abovementioned sequence of actions is called a machine cycle A more detailed description of microcontroller operation is beyond the scope of this textbook however the reader may easily find more information in numerous excellent books on the subject see e g 1 2 3 An example of a single microcontroller Motorola Freescale 68HC05J1A is shown in Figure 1 4 Please note all the parts mentioned before data and program memory CPU and I O ports USER ROM 1240 BYTES USER RAM 64 BYTES ka lt PAT PAG PAS PA4 PA3 PA2 pai Pao DATA DIRECTION REGISTER A 8 mA sink capability External interrupt capability ARITHMETIC LOGIC CPU CONTROL UNIT ACCUMULATOR IRQ M68HC05 RESET MGB INDEX REGISTER STACK POINTE oj0 0 0 1 1 PROGRAM COUNTER 0 a
16. RUCHOMENIOWY AVR s TI e PORT C PORT A 220 jeeeeeoes 4229979 007145999 rdf 76 5 4 3210 Figure 1 6 The layout of the ATmega development board by Gotronik Ltd 10 Explanations 1 LCD display 2 lines x16 characters 2 ISP programming socket 10 pin 3 Reset switch 4 8 LED diodes 5 4 potentiometers 6 four 8 segment LED displays 7 Matrix keyboard 4x4 with membrane microswitches 8 Power transistor buffer ULN2803 9 I2C PCF8574 expander 10 I2C memory 24xx family 11 Voltage supply connector 12VDC 12 LM358 operational amplifier 13 RS 232C transceiver The module contains also a built in 7805 voltage regulator and built in ISP In System Programming programmer compatible with STK200 300 model by Kanda System The only additional equipment necessary for using the Gotronik board are e DB25M DB25F connection cable used for connecting the board to the LPT port of PC computer e 9V 0 5A DC or AC power supply for powering the board e Some experiments will also require DB9M DB9M 9 pin serial cable for connecting the Gotronik board to the COM port of the PC computer Before programming the board should be connected to the LPT parallel port of the PC computer The power supply should of the board be connected only after making all the connections WARNING Connection or disconnection of the PC cables with the power switched on is absolutely forbidden as it may lead t
17. S7 200 from Siemens This device is intended for many applications among others in the chemical industry chemical and plant engineering diagnostics drug development the food industry electronics energy industry healthcare the textile industry environmental technologies waste management and recycling and paints coatings and inks Of course it can be use in refrigeration and cryogenics processes too The S7 200 PLC is designed as consistently modular system and can be used as either a stand alone micro PLC solution or in conjunction with other controllers its hardware configuration can be modified in accordance to varying circumstances D CPU Fault Power Central Processing Unit Digital Output Module Analog I O Module Communication Module Fig 2 1 An example of S7 200 hardware configuration The modular system provides a range of specific expansions for example for temperature measurement weighting technology positioning and communications 3 The S7 200 Central Processing Unit CPU combines a microprocessor an integrated 24V power supply input and output circuits all in a compact housing 4 5 On the front panel the S7 200 34 contains the logic indicators required to monitor and control the input and output devices in specified application fig 2 2 Terminal connector Status LEDs System Fault RUN STOP Acces door mode selector analog potentiometer ex
18. and PC with Step7 Micro Win software 10 8 4 3 5 6 2 7 9 1 11 Fig 2 6 The didactic station for rollers drilling process Station D the rollers handling process The rollers handling station shown in figure 2 7 is equipped with pneumatic two axis actuator manipulator 1 with a pneumatic suction gripper 2 mounted on vertical pneumatic actuator 3 controlled using electrically actuated 5 3 and 3 2 pneumatic valves 4 There are also two or four optionally optical sensors 5 pneumatic suction measuring device 6 and connection units with pushbuttons 7 39 The roller inserted into the marked place is detected by an optical sensor The handling device picks up the roller from there with the aid of a pneumatic gripper The workpieces can be moved to three available places according to defined criterion or can also be transferred to a downstream station if enabled Station D is additionally equipped with a portable set of S7 200 Programmable Logic Controller 8 CPU222 for process automation pressure regulator valve with gauge invisible on fig 2 7 text display panel TD200 optionally 24V DC power supply 9 500 kPa 5 bar pressure connection PPI Multi Master programming cable and PC with Step7 Micro Win software 8 4 1 2 6 3 Fig 2 7 The didactic station for rollers handling process 2 4 Laboratory tasks 2 4 1 Preliminary tasks Task 1 Create a pneumatic and electric diagram of your MPS and next pre
19. anies is placed on competitiveness 1 The main problem to solve is how to reduce manufacturing costs while simultaneously improving the quality reliability aesthetics modernity and durability of products To reach these goals appropriate methods of production management and optimization are required which is impossible without the implementation of control systems and robotics of the process technologies Due to the wide range of tasks for modern control systems applied devices should characterize such features as universality flexibility reliability and accordance to obtains standards These requirements fit so called Programmable Logic Controllers A Programmable Logic Controller PLC is a digital computer used for the automation of miscellaneous processes such as the control of machinery on factory assembly lines amusement rides or lighting fixtures PLCs are used in many industries and machines Unlike general purpose computers the PLC is designed for multiple inputs and output arrangements extended temperature ranges immunity to electrical noise and resistance to vibration and impact Programs to control machine operation are typically stored in battery backed or non volatile memory A PLC is an example of a real time system since output results must be produced in response to input conditions within a bounded time otherwise unintended operations will result 2 2 2 Simatic 7 200 PLC A popular example of PLC is Simatic
20. boards For debugging embedded systems which employ serial communication the IDE has a built in Terminal Besides the standard C libraries the CodeVisionAVR C compiler has dedicated libraries for Alphanumeric LCD modules Philips I2C bus National Semiconductor LM75 Temperature Sensor Philips PCF8563 PCF8583 Dallas Semiconductor DS1302 and DS1307 Real lime Clocks Dallas Semiconductor 1 Wire protocol Dallas Semiconductor DS1820IDS18S20 Temperature Sensors Dallas Semiconductor DS1621 Thermometer Thermostat Dallas Semiconductor DS2430 and DS2433 EEPROMs SPI Power management Delays Gray code conversion CodeVisionAVR also contains the CodeWizardAVR Automatic Program Generator that allows the user to write in a matter of minutes all the code needed for implementing the following functions External memory access setup Chip reset source identification Input Output Port initialization External Interrupts initialization Timers Counters initialization Watchdog Timer initialization UART initialization and interrupt driven buffered serial communication Analog Comparator initialization ADC initialization SPI Interface initialization 12C Bus LM75 Temperature Sensor DS1621 Thermometer Thermostat and PCF8563 PCF8583 DS1302 DS1307 Real Time Clocks initialization 1 Wire Bus and DS1820 DS18S20 Temperature Sensors initialization LCD module initialization CodeVision compiler
21. didactic station for rollers distribution process Station B the rollers recognition and selection process 37 The rollers recognition and selection station shown in figure 2 5 is equipped with an identification socket surrounded by three different sensors 1 two pneumatic actuators with end position sensors 2 and 3 controlled using electrically actuated 3 2 and 5 2 pneumatic valves 4 and the electric conveyor 5 The rollers inserted into the socket 1 are discerning by the sensors differentiation between black or non black workpieces metal or other stuff and can exit the socket with the aid of horizontal pneumatic actuator 2 or can be moved up using vertical pneumatic actuator 3 lift On this position the measurements of roller height using position sensor 6 and its accordance of color by means of camera 7 are available Next the roller can be pushed out with the aid of a horizontal pneumatic actuator 2 to onto conveyor 5 which can pick up its for example to next station The Station B is additionally equipped with S7 200 Programmable Logic Controller 8 CPU224 for process automation pressure regulator valve with gauge 9 electric pushbuttons and indicators 10 text display panel 11 TD200 24V DC power supply 12 500 kPa 5 bar pressure connection PPI Multi Master programming cable and PC with Step7 Micro Win software Fig 2 5 The didactic station for rollers recognition and selection process Station C the rollers
22. display string Count on the LCD sprintf buffer Su counter convert the binary value of counter variable to text form and store the result of the conversion in string variable buffer lcd puts buffer current value of the counter displayed in text form on LCD counter increment the value of the counter delay ms 10 10 ms delay before the next iteration lcd_clear clear the contents of the LCD display 1 After compiling and running the program we should see the dynamically changing contents of the LCD display Count xxxxx In place of the xxxxx the current value is displayed in a decimal format Please note that after reaching the value of 65535 the maximal value for two byte int type variable the counter is reset to zero The contents of the counter are updated approximately every 10 milliseconds Please as before try to replace operator with then try to analyze the result 25 1 2 4 The Fourth Project A D converter routines sensor signal conditioning The most obvious method of bringing analog inputs into a microprocessor is to use an analog to digital converter ADC An ADC accepts an analog input a voltage or a current and converts it to a digital word that can be read by a microprocessor Figure 16 shows an exemplary transfer diagram of ADC This part has one input and one output a digital word that represents in digital form the input value One
23. display to Atmegal6 microcontroller suggestions given by CodeWizardAVR tool As we can see the compiler automatically generates information about the recommended wiring of the LCD display Please connect the pins of the LCD and the pins of the microcontroller according to these suggestions The following circuit diagram should be a result 21 1 VSS kj 3 o 77 VLC e 5 JE UL PBO T 9 ADC PAO a 7 DBO PBI TI ADC PAL Gg 9 ES PB2 AINO ADC PA2 gt 0 e PB3 AIN1 ADC3 PA3 se II R PB4 SS ADC4 PA4 35 WW PBS MOSI ADCS PAS qq 3 PB MISO ADCO PAG 5 14 PB7 SCK ADC7 PA7 15 TR P 1 VED PDO RXD PO 33 a PDI TXD PCI 24 PD2 INT PQ 5 PD3 INTI PG HD4 PD4 OCIB PO4 ED oe ee 28 LCD DISPLAY 7 Z ea z 16 CHARACTERS X2 LINES RESET AREF z AGND 5 XI AVC 2 w O ATMEGAI6_DIP40 GND Figure 1 15 The wiring diagram for connecting LCD 16x2 display to atmega1l6 microcontroller Please note that CodeVision compiler uses slightly different names for LCD pins RD instead of RW E instead of EN Next please generate the program code Generate Save and Exit option from CodeWizardAVR window The compiler will prompt you for the name of your file please enter prog03 or any name of your choice then repeat the name two more times Then a template file should be generated and ope
24. e range 0000 1023 is displayed in a decimal format Please note that the readout is expressed in bits for 10 bit converter the range is from 0 to 2 1 In practical applications the more useful format of the measured signal value would be voltage In order to re scale the bit expressed values to volts we would need the following modifications float voltage_fp floating point variable declaration while 1 lcd _gotoxy 0 0 result read adc 0 read voltage present at ADCO input voltage _fp result 5 00 1023 convert the result to volts sprintf buffer 5 3f voltage fp convert the voltage value into a floating point number and store it in buffer lcd_clear lcd puts buffer delay ms 200 The last example should produce the following result X XXX Where x xxx is the measured voltage value expressed in volts as a fixed decimal point number Please note that the line voltage fp result 5 00 1023 Converts voltage variable int type into a floating point And the next line of code sprintf buffer 5 3f voltage_ fp converts floating point voltage_fp value into a text string format containing 5 digits stored in format x xxx 3 digits after the decimal point The text string will be stored in buf fer variable The A D converter can be used for measurement of any analog signal for instance for sensor signal acquisition 29 The detailed explanation of an A D converter operation is definitel
25. easurement using ADC and send the measured data over the serial interface In order to do so please create a new project Activate ADC and USART using CodeVisionAVR Then please insert the following code into the final while 1 loop include lt stdio h gt unsigned int result char buffer 6 while 1 32 Place your code here result read_adc 0 sprintf buffer Su result printf Su r result 1 Next please compile and execute the program then please activate the Terminal tool In the Terminal window we should see the consecutive results of the voltage measurement Please note that the transmitted data could be easily collected and stored in a disc file for future analysis Literature 1 Atmel atMegal6 MCU datasheet and application notes www atmel com 2 CodeVisionA VR User s Manual http www hpinfotech ro 3 Barnett Richard H Cox Sarah A O Cull Larry D Embedded C Programming and the Atmel AVR Second Edition Delmar Cengage Learning 2006 ISBN 1418039594 4 Kernighan Dennis M Ritchie The C Programming Language 2nd ed Englewood Cliffs NJ Prentice Hall ISBN 0 13 110362 8 http cm bell labs com cm cs cbook please note the book was later replaced by The ANSI C Programming Language 5 Understanding Data Converters TI Application Report SLAA013 www ti com 33 2 Process automation using PLCs 2 1 Introduction One of the more important demands for comp
26. es Internal and External Interrupts a universal programmable serial mode transmitter receiver USART an 8 channel 10 bit analog to digital converter ADC and a programmable Watchdog Timer a dedicated timer circuit protecting against program hang up and erratic operation Atmegal6 MCU Pin Descriptions VCC Digital supply voltage GND Ground Port A PA7 PA0 Port A serves as the analog input to the A D Converter Port A also serves as an 8 bit bi directional I O port if the A D Converter is not used Port pins can provide internal pull up resistors selected for each bit The Port A output buffers have symmetrical drive characteristics with both high sink and source capability When pins PAO to PA7 are used as inputs and are externally pulled low they will source current if the internal pull up resistors are activated The Port A pins are tri stated when a reset condition becomes active even if the clock is not running Port B PB7 PB0 Port B is an 8 bit bi directional I O port with internal pull up resistors selected for each bit The Port B output buffers have symmetrical drive characteristics with both high sink and source capability As inputs Port B pins that are externally pulled low will source current if the pull up resistors are activated The Port B pins are tri stated when a reset condition becomes active even if the clock is not running Port C PC7 PC0 Port C is an 8 bit bi directional I O port with internal pull up
27. he main limitation of lcd putsf function is that it is only capable of displaying a constant text string i e led_putsf function cannot be used for sending a result of measurement of computation or any other dynamic data to the LCD display To accomplish such a task a slightly more complex procedure should be used To illustrate this we will write a code that will be incrementing the integer variable starting from 0 in the loop during each iteration of the loop the current value of the variable will be displayed on the LCD In order to commence the task we should declare two variables The first variable of two byte type called int will be called counter the counted values will be stored there in binary format The next variable will be a 6 byte buffer in RAM memory for storing the counted values after conversion to the text string form type char The declaration should be located just after the comment Declare your global variables here Declare your global variables here unsigned int counter char buffer 6 Please also add the declaration of the standard input output library include lt stdio h gt The declarations of the system libraries should be placed before the declarations of the variables The contents of the main while loop are presented below with comments starting from signs 24 while 1 Place your code here lcd_gotoxy 0 0 cursor at initial position led_putsf Count
28. klight voltage is around 4 2V at 25 C using a VDD 5V capable model Character LCDs can operate in 4 bit or 8 bit mode In 4 bit mode pins 7 through 10 are unused and the entire byte is sent to the screen using pins 11 through 14 by sending 4 bits nibble at a time The Gotronik AVR board includes a HD4470 compatible LCD display 2 lines 16 characters per line Please start CodeVision AVR C compiler After the start up the compiler should open the window containing the last project We should close it with File gt Close All command Then we should create a new project from a scratch using File gt New command then please check project radio button The compiler will ask about the usage of CodeWizardA VR please answer Yes Then the window of CodeWizardA VR should open 20 Next please go to the LCD option select LCD Port PORT A The following screen will appear 43 CodeWizardAVR untitled cwp File Edit Help Cee GR SOB Program Preview USART Analog Comparator ADC SPI I2C 1 Wire 2wire 120 Chip Ports Extemal IRQ Timers LCD BitBanged Project Information LCD Port Chars Line 16 w PORT BitO AS LCD Pin 4 PORT Bit 1 RD LCD Pin 5 PORT Bit 2 EN LCD Pin 6 PORT Bit 3 Free PORT Bit 4 DB4 LCD Pin 11 PORT Bit 5 DBS LCD Pin 12 PORT Bit 6 DBB LCD Pin 13 PORT Bit 7 DB LCD Pin 14 Figure 1 14 The recommended method of wiring for connecting LCD 16x2
29. line of the MCU to the input of the MAX232 chip located on the development board The MAX232 is an integrated level converter which has to transfer signal levels from 0 5V TTL standard generated by the MCU to 10V 10V standard required by RS 232 serial communication interface Next please connect the output of MAX232 to data output line of the external DB9 connector located on the left side of the board Then please connect 9 pin serial cable to that connector The other end of the cable should be connected to the COM port socket in our PC computer 31 Then please compile and run the program Next please select Tools gt Terminal option In the lower part of the screen a terminal window will open Next please click the Connect button with the mouse In the terminal window a stream of data should appear Please analyze the contents of the transmission Please also note that the data received by the PC are generated just by the MCU CodeWizardAVR untitled cwp File Edit Help bee a 2 EEB Wc 1 Wire 2 Wire 120 LCD Bit Banged Project Information Chi Ports ExtemalIRQ Timers USART Analog Comparator ADC SP Program Preview O Receiver 4 Transmitter C Tx Interrupt Baud Rate 3600 v 2 Baud Rate Error 0 2 Communication Parameters 8 Data 1 Stop No Pary iv Figure 1 20 CodeWizardAVR window USART configuration dialog Next we should try to perform a voltage m
30. load files s7200 S7 200 manual_en pdf 7 K Kaminski Programowanie w Step7 Micro Win wyd 3 Gryf 8 Micro automation Simatic S7 200 Siemens Warszawa 2006 9 http www festo didactic com 43
31. n the following window should appear 15 CodeVisionAVR C cvayr2 bin test01 prj test01 c File Edit Search View Project Tools Settings Help Bes HOOG mf z 8h B K BR ROK EE Code Navigator SK CodeVisiontvR CE TE WE AN Bk s KANGE KGL FEA R Code Information E F E Notes test01 c 3 E Code Templates 7 EF Ry Clipboard History 4 EJ E ii Project test01 EJ Notes D test01 c Rl Other Files 15 16 17 18 19 20 21 Chip type Program type Memory model External RAM size Data Stack size ATmege Applic AVR Core Clock frequency Small 250 256 8 0004 NE Je o do while a B test0t c 14 Alar o t al 22 tt or to sth s sh htt hko ef Function Call Tree 4 3 24 i a p 5 24 include lt megal6 h gt ye 25 26 Declare your global variable for 27 be 28 void main void a switch ti case Messages Errors B warnings Messages Pe Fran Files 1 1 Insert Code Information may be incomplete as the file was not Compiled yet Figure 1 11 Compiler main window after running of the CodeWizard In the middle section marked text01 c you will see the listing of your first program Please shift the cursor to the last section of the program numbers of lines above 115 You will see the comment stating Place your code here Please type in the following code in that location
32. nd Power Engineering at Wroc aw University of Technology The main body of the book encompasses two parts the first is a brief course in microcontrollers and its applications and the second describes the principal applications of the programmable logic controllers PLC in mechatronics In both parts of the textbook some examples of programmes or applications were given starting from relatively simple tasks to more complex projects The prerequisites It is assumed that the reader knows basic algebra rules and is familiarized with both electrical circuits theory and fundamentals of electronic engineering especially logic circuits theory Some experience related to programming would also be an advantage 1 Microcontrollers 1 1 Introduction A control system could usually be regarded as a black box with multiple inputs and outputs processing input signals and producing as a response output signals The relation between input and output signals could be described solely by the hardware configuration of the system containing switches relays pushbuttons etc such a case could be described as a system with a hardware fixed algorithm one should note that every modification of a hardware fixed algorithm requires a complete rebuilding of the control system configuration In a more flexible configuration the control system has the constant structure but an algorithm of its operation is located in an external memory which i
33. ned in the main editor window Please note that at about line 26 the declarations concerning LCD display are generated Alphanumeric LCD Module functions asm equ _ lcd port 0x1B PORTA endasm include lt lcd h gt The declarations include both the information about the I O MCU port where the LCD was connected and the information about the led h library that will be necessary for programming LCD displays based on HD44780 chip The last part of code should include the following text LCD module initialization led_init 16 while 1 22 Place your code here 1 As usual we should place our own code after the relevant comment inside the last while loop We should start with putting the following command inside the loop lcd putchar A Then please enter Project gt Configure menu and select After Build bookmark then select After Build option and finally check Program the chip option Then please execute Project gt Build All command The project should be compiled and sent to the memory of the microcontroller and then the MCU will be restarted The result of the execution of our program should be the filling of LCD display with the letter A W should see the following contents of the LCD screen AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA Please note the cursor of the display is scrolled on the right just after the printing the next character onto the LCD screen In order to obtain only a single
34. ntroller which can be treated as a simple programmable device The general structure of a microcontroller see Figure 1 3 bears a significant resemblance to the Turing machine Instead of memory tape the structure uses a program memory containing cells described by numerical addresses The commands are cyclically fetched from the non volatile program memory ROM Read Only Memory then decoded and executed The decoding takes place inside the CPU Central Processing Unit which can be regarded as the brain of the microprocessor The results of computations measurements and other user data are stored in the volatile memory RAM Random Access Memory The speed of operation is determined by an external clock signal usually produced by quartz or RC oscillator The interface of the processor to the outside world is possible via bi directional input output ports I O ports These ports can be used for testing signals from switches sensors pushbuttons etc They can also be a source of signals switching on lamps buzzers displays and other devices INTERNAL BUS INPUT DATA ie HB OUTPUT MEMORY PORTS RAM CLOCK PROGRAM SIGNAL CPU MEMORY ROM Figure 1 3 The general structure of a simple microcontroller Please note the resemblance to the Turing machine In classic microprocessors RAM and ROM memories and I O ports usually are located in separate integrated circuits In order to build a
35. o serious hardware malfunction The power supply could be switched on only after proper attaching of all the necessary cables and after completion of the wiring of the developed circuit All the software examples presented hereafter were written using CodeVisionAVR C language compiler 11 CodeVision AVR C compiler CodeVisionAVR is a C cross compiler Integrated Development Environment and Automatic Program Generator designed for the Atmel AVR family of microcontrollers The tool was developed by HP InfoTech Company The program is a native 32bit application that runs under the Windows 95 98 NT 4 2000 and XP operating systems The C cross compiler implements nearly all the elements of the ANSI C language as allowed by the AVR architecture with some features added to take advantage of specificity of the AVR architecture and the embedded system needs The compiled COFF object files can be C source level debugged with variable watching using the Atmel AVR Studio debugger The Integrated Development Environment IDE has built in AVR Chip In System Programmer software that enables the automatic transfer of the program to the microcontroller chip after successful compilation assembly The In System Programmer software is designed to work in conjunction with the Atmel STKSOOIAVRISP AVRProg AVR910 application note Kanda Systems STK200 300 Dontronics DT006 Vogel Elektronik VTEC ISP Futurlec JRAVR and MicroTronics ATCPU Mega2000 development
36. on Please change operator to in your example and try to analyze the result 19 1 2 3 The Third project An LCD display routines An HD44780 Character LCD is a de facto industry standard liquid crystal display LCD display device designed for interfacing with embedded systems These screens come in a variety of configurations including 8x1 which is one row of eight characters 16x2 and 20x4 These LCD screens are limited to text only and are often used in copiers fax machines laser printers industrial test equipment networking equipment such as routers and storage devices Character LCDs can come with or without backlights which may be LED fluorescent or electroluminescent Character LCDs use a standard 14 pin interface and those with backlights have 16 pins The pinouts are as follows Ground VCC 3 3 to 5V Contrast adjustment VO or VLC Register Select RS RS 0 Command RS 1 Data Read Write R W R W 0 Write R W 1 Read Clock Enable Falling edge triggered Bit 0 Not used in 4 bit operation Bit 1 Not used in 4 bit operation Bit 2 Not used in 4 bit operation 10 Bit 3 Not used in 4 bit operation 11 Bit 4 12 Bit 5 13 Bit 6 14 Bit 7 15 Backlight Anode 16 Backlight Cathode O JOW MAW N o There may also be a single backlight pin with the other connection via Ground or VCC pin The two backlight pins may precede the pin 1 The nominal bac
37. pansion port Optional cartridge Communications J AA port ae 5 T O LEDs Fig 2 2 S7 200 CPU front panel indicators controls and connectors The manufacturer provides several S7 200 CPU models with a diversity of features and capabilities that help accommodate solutions for varied applications Table 2 1 briefly compares the most important features of available CPUs Table 2 1 Comparison of the S7 200 CPUs Feature CPU 221 CPU222 CPU224 CPU224xp CPU226 Physical size mm 90x80x62 90x80x62 120 5x80x62 140x80x62 190x80x62 Program memory with run mode edit 4096 bytes 4096 bytes 8192 bytes 12288 bytes 16384 bytes without run mode edit 4096 bytes 4096 bytes 12288 bytes 16384 bytes 24576 bytes Data memory 2048 bytes 2048 bytes 8192 bytes 10240 bytes 10240 bytes Memory backup 50 hours 50 hours 100 hours 100 hours 100 hours typical typical typical typical typical Local on board I O digital 6 IN 4 OUT 8 IN 6 OUT 14IN 10 OUT 14IN 10 OUT 24IN 16 OUT analog 2 IN 1 OUT Expansion modules 0 2 7 7 7 High speed counters single phase 4 at 30 kHz 4 at 30 kHz 6 at 30 kHz 4 at 30 kHz 6 at 30 kHz 2 at 200 kHz two phase 2 at 20 kHz 2 at 20 kHz 4 at 20 kHz 3 at 20 kHz 4 at 20 kHz 1 at 100 kHz Pulse outputs DC 2 at 20 kHz 2 at 20 kHz 2 at 20 kHz 2 at 100 kHz 2 at 20 kHz Analog adjustments 1 1 2 2 2 Real time clock Cartridge Cartridge B
38. pare an allocation list of inputs and outputs of the PLC to the corresponding sensors and actuators Task 2 Choose free buttons and an actuator from your MPS Prepare relevant algorithms using Step7 Micro Win software to execute the diagrams shown below use such functions as contacts coils timers counters etc Download consecutively your programs to the CPU and test its applications 40 Button 1 Button 1 t t l l l Button 2 i t t adstor O semi Se Cl A c d Button 1 l Button 1 l t t 0 5 o 5 Actuator Actuator EM t t e t t o 5 0 2 5 Actuator Actuator t J t g h Button 1 l Button 1 UU t t jo 2 5 8 11 14 117 d Button 2 io t Actuator j t Actuator Button 1 t Actuator N A A A A t Fig 2 8 Preliminary tasks testing of Simatic s fundamental functions 2 4 2 Detailed tasks 41 Be careful in case of incorrect or unfinished program implemented in PLC there is a risk of serious injury Station A the rollers distribution process Load six different rollers red black and silver to the storage Develop a LDR diagram to solve the following procedure The rollers are automatically pushed out from storage in case of free place on the position X see on the Fig 2 4 The TD200 panel shows current messages describing state of process ready to start process p
39. s often called a program memory The contents of this memory could be easily modified without the need for changing the hardware Such an approach allows an easy modification of the behaviour of the system without the need for its complete re construction The difference between these two approaches can be seen in Figure 1 1 INPUTS OUTPUTS INPUTS OUTPUTS gt co gt Fixed A gt algorithm gt co EN algorithm program PROGRAM MEMORY a b Figure 1 1 A comparison between a control system with a hardware fixed algorithm a and a programmable control system with an algorithm program located in an external memory b A programmable control system could be easily presented as an example of a so called Turing machine i e a device that sequentially reads information command from the program memory then executes it next stores the result of the computation and finally fetches the next command The general structure of a Turing machine is easily presented in Figure 1 2 The invention of the Turing machine in 1936 was a major scientific breakthrough that led directly to the invention of the stored program computer and microprocessor read write device 1 0 1 o0 0 1 memory tape 1 0 1 Figure 1 2 The general structure of the Turing machine CPU Central Processing Unit One of the best examples of a Turing machine could be a microco
40. s will be remembered and used in our next projects as default values 2 CodeWizardAVR untitled cwp DAR File Edit Help Beh S pl taB USART Analog Comparator ADC SPI 12C 1 Wire 2 Wire 12C LCD BitBanged Project Information Chip Ports Extemal IRQ Timers Program Preview Chip Almegal L Clock 8 BA MHz Check Reset Source Program Type Application Figure 1 9 CodeWizard window MCU type amp clock speed selection 14 The next step is to choose the direction of data transmission through the serial ports the port pins could act as outputs Out option selected or as inputs In option selected CodeWizardAVR untitled cwp File Edit Help beh se GB BB Program Preview ee USART Analog Comparator ADC SPI 120 wie 2Wite 20 LCD Bit Banged Project Information Chip _ Ports Ex Port B Port C Port D Data Direction Pullup Output Value BitO Out 0 Bio Bit1 Out Bit 1 Bit2 Out Bit 2 Bit3 Qut Bit 3 Bit 4 Bit 4 Bit 5 Bit 5 Bit 6 Out Bit 6 Bit 7 Bit 7 Figure 1 10 CodeWizardAVR window I O ports configuration dialog After setting all I O ports as outputs Out direction active please select the following CodeWizard menu option File gt Generate Save and Exit Then please type in the name of your first program for instance test01 Type in the same name two more times After the last operatio
41. t limitations met by the designers of embedded systems is the limited number of I O pins The problem is especially important in the context of data transmission over long distance where the cost of cabling is also an important factor The most efficient method of data transfer over a long communication line is a serial transmission In the process the information is sent one bit at a time sequentially The data format was shown in Fig 1 19 Serial communication is used for all long distance communication and most computer networks Most modern computer interfaces also utilize the serial data transfer USB FireWire SATA idle data bits data bits idle start stop start stop Figure 1 19 The data format in asynchronous serial transmission Wikimedia Commons The atMega MCU family has a built in dedicated universal serial asynchronous receiver and transmitter USART which can be used for data sending and receiving In this project we will try to use this device We should start with creating a new project Next please run the CodeWizardAVR tool and select USART bookmark Then please check Transmitter option Please select Baud Rate equal to 9600 bits second and set the following Communication Parameters 8 Data 1 Stop No Parity Please also set Mode Asynchronous Next please type in the following code include lt stdio h gt while 1 Place your code here printf A Before compilation please connect the TxD
42. the ADC is not used If the ADC is used it should be connected to VCC through a low pass filter AREF AREF is the analog reference pin for the A D Converter Additional information about the ATmega MCU family can be found in datasheets and excellent application notes published by the producer please refer to www atmel com Gotronik AVR prototyping board The AVR ATmega v1 prototyping board is an example of a simple development system that can be used both by students and experienced programmers during programming of Atmel AVR and ATmega families of 8 bit microcontrollers especially AT90S8535 ATMEGA8535 ATMEGA16 and ATMEGA32 chips 40 pin DIP case versions The board includes also a set of the most popular and useful peripheral devices All the connections can be made using flexible cables with snap on connectors Moreover the circuit board encompasses an universal test area with solder pads located in square 0 1 2 54 mm raster This area can be used for custom circuits built by the user The board was designed and is manufactured by the Gotronik Company Wroctaw Poland All the experiments described in this part of this textbook will use Gotronik AVR ATmega v1 prototyping board as the hardware platform The circuit board encompasses numerous peripheral devices The more detailed description can be found below The layout of the front panel of the module is shown in Fig 1 6 a m ass pa a MODUL U
43. topped alternatively by pushing the button mounted on the station using the chosen function key F1 F8 on the text panel TD200 or automatically respecting required time delays for the operator s safety Station C the rollers drilling process Load three rollers red or silver to the identification socket Develop a LDR diagram to solve the following procedure The rotary table starts and then stops in all of four correct positions During every stoppage one roller is blocking and drilling and concurrently the second is checking and punching In case of the absence of the roller the drilling process during next stoppage isn t performed The TD200 panel shows current messages describing the state of process ready to start process the socket is empty presence of the roller the drilling process is under way the roller is ready for collection amount of drilled rollers cycle time speed of the drilling machine etc When the process is stopped the TD 200 panel shows the current status of the station or displays demo connected with performing operations The task should be started and stopped alternatively by pushing the button mounted on the station using the chosen function key F1 F8 on the TD200 text panel or automatically respecting required time delays for the operator s safety Additionally by means of TD200 panel the rotary speed of the drilling machine should be controlled using Pulse Wave Modulation function of
44. uilt in Built in Built in Communications ports 1 x RS485 1 x RS485 1 x RS485 2 x RS485 2 x RS485 Floating points math Yes Digital I O image size 256 128 IN 128 OUT Boolean execution speed 0 22 microseconds instruction For delivery process and application requirements the S7 200 family can be equipped with many expansion modules which add additional functionality to the S7 200 CPUs Table 2 2 shows a list of some available expansion modules 35 Table 2 2 Expansion modules for the S7 200 CPU s Expansion modules Type Discrete modules Input 8x DCIN 8x AC IN 16x DC IN Output 4x DC OUT 4 x Relays 8 X Relays 8 x DC OUT 8 x AC OUT 4x DC IN 8 x DC IN 16 x DC IN 32 x DC IN Combination 4x DC OUT 8 x DC OUT 16 x DC OUT 32 x DC OUT 4x DC IN 8 x DC IN 16 x DC IN 32 x DC IN 4 x Relay 8 x Relay 16 x Relay 32 x Relay Analog modules 4x Analog IN 8 x Analog IN 4 x Thermocouple 2x RTD IN Input IN Output 2 x Analog OUT 4 x Analog OUT 4 x Analog IN Combination 4x Analog OUT Intelligent modules Position Modem Profibus DP Ethernet Ethernet IT Others AS Interface Siwarex The Text Display TD device can also be connected to the S7 200 CPU By means of Text Display monitor and change the process variables of controlled application is possible to view There are two programming options for connecting programming device the most common Personal Computer to S7 200 CPU
45. ushing out the roller handling on the X position the roller on the X position black roller on the X position the storage is empty amount of distributed rollers full cycle time etc When the process is stopped the TD 200 panel shows current status of the station or displays demo connected with performing operations The task should be started and stopped alternatively by push the button mounted on the station or using chosen function key F1 F8 on the text panel TD200 Station B the rollers recognition and selection process Load free roller red black or silver to the identification socket Develop a LDR diagram to solve the following procedure The roller is sensed by the sensors surrounding it In case of black or red rollers the workpiece leaves out of the station Otherwise the roller silver is moved up where its height is measured Next the roller is picked up on the conveyor whereby it leaves out of the station The TD200 panel shows current messages describing the state of process ready to start process the socket is empty the roller in the socket the result of the roller identification leaving out or handling upstairs of the roller result of height measurement moving by means of the conveyor amount of selected rollers full cycle time etc When the process is stopped the TD 200 panel shows the current status of the station or displays demo connected with performing operations The task should be started and s
46. y beyond the scope of this book please refer for instance to an excellent application report published by Texas Instrument 5 In our experiment we shall use a simple and cheap LM335 sensor manufactured by National Semiconductor Company LM335 is a precision voltage output centigrade temperature sensor with high sensitivity The device operates as two terminal Zener diode with a breakdown voltage directly proportional to the temperature at 10mV K LM335 operates from 40 to 100 C and has an initial accuracy of 1 C Basic Temperature Sensor yr TO 92 Plastic Package RI OUTPUT ADS 10 mv K Q 7 LM335 DS005698 8 0S005698 2 Figure 1 18 a A basic connection of LM335 temperature sensor b LM335 pinout plastic TO 92 case National Semiconductor In our experiment we should connect V terminal of R1 resistor to 5V voltage line the main voltage supply line of the development board the anode terminal of LM335 should be connected to GND terminal of the board The OUTPUT terminal of the LM335 sensor should be connected to PORTA 0 pin Please try to write a code that will measure the output voltage from LM335 sensor convert it to K and finally display the result on the LCD After running the program please try to change the temperature of the sensor by heating it with your fingers or cooling it in cold water 30 1 2 5 The Fifth Project Serial data transmission USART programming One of the most importan

Download Pdf Manuals

image

Related Search

Related Contents

Barclay Products TKCTR60-ORB2 Installation Guide  Ficha de Dados de Segurança LIM PEZA DE TRAVÕES – 20L  Asahi Pentax ZX-30 Operating Manual  rotex gsu - ROTEX Heating Systems GmbH    Philips Headphone extension cable SWA7536W  User Manual  Origin Storage 320GB 2.5" SATA  Apple Power Mac 073-0937 User's Manual  Istruzioni per l`uso Lavagna Elettronica UB-5338C  

Copyright © All rights reserved.
Failed to retrieve file