• No results found

The software used in the development of the LMS system were:

MPLAB – An integrated development environment (IDE) designed by Microchip specifically for their brand of MCU’s.

Elnec – Software designed to transfer compiled hex and assembly files to the target processor via a programming device.

HI-TECH PICC-18 – A C compiler designed for integration into MPLAB to allow C programming of PIC 18F MCU devices within the environment.

4.6.1 Interaction of Software

The interaction of the software in the development of the main MCU in the system was that the PICC- 18 compiler becomes embedded into the MPLAB IDE making use of the excellent IDE and the C compiler. The C compiler is supplied with it’s own IDE but due to personal preference and familiarity the MPLAB version was used. The MPLAB version has it’s own simulator embedded into the environment which was ideal for simulating small blocks of tricky code. When a program was compiled the resulting hex file was imported into the ELNEC software and after setting up basic programming parameters the target processor becomes programmed. In reality this process was done hundreds of times before the final version of code was programmed. This is because an easier way to develop a system is to write small blocks of code and check its functionality within the hardware. Sometimes the code doesn’t perform to expectations and has to modified and reprogrammed. When other pieces of code are written it all has to interact with other code and on occasion this doesn’t happen as envisaged. This modular approach to development can appear slow and cumbersome initially but can save much time and heartache at a later stage.

functionality. Their objective was to check I/O ports and follow simple instruction to construct a 10 bit number and setup the on board PWM module accordingly.

4.6.2 The C Compiler

As previously mentioned in section 3.6 the compiler used in developing the software for the main MCU was the HI-TECH PICC-18. This compiler was chosen after research was done on all competitive compilers. Figure 3.6 summarises HI-TECH’s advertisement of the compiler. One main advantage is the ANSI C compatible. This allows for other blocks of C code to be seamlessly imported from other C environments. One huge advantage of using a C compiler as opposed to assembly language is time spent in development particularly when writing mathematical formulae. Even basic program flow becomes much quicker and less tedious. In time gone by some embedded programmers would refuse to use C compilers believing to be more in control writing assembly as C compilers could never produce as efficient code as they could program in assembly format. However, in more recent times C programmers for microprocessors and microcontrollers have improved significantly thus HI- TECH claiming their compiler equals or betters assembly code in terms of memory efficiency and system speed

HI-TECH PICC-18

HI-TECH PICC-18™is a powerful C compiler for the Microchip PICmicro® PIC18 family of microcontrollers. HI-TECH PICC-18 upholds the robust and efficient tradition of a long line of PICmicro compilers from HI-TECH Software, delivering unrivalled code density combined with excellent reliability. Tightly tuned to the PIC18 architecture, it allows firmware development in a fraction of the time, but with no greater use of RAM or ROM, required for conventional assembly language programming.

HI-TECH PICC-18

Compiler Features:

 ANSI C - full featured and portable

 Efficient - equals or betters hand-written assembler code

 Reliable - mature, field-proven technology

 Modular - includes full object code linker and library manager

 Cost-effective - productivity gains rapidly repay purchase cost

 Compatible - integrates into the MPLAB®IDE, MPLAB ICE2000 and 4000, ICD2 and most 3rd-party development tools

 Library source - for standard libraries and sample code for various peripherals and applications

 Complete - includes macro assembler, preprocessor and one-step driver

HI-TECH PICC-18 allows you to concentrate on developing your application, and eliminates much of the detailed, low-level coding effort. Our commitment to quality customer service ensures that you will have access to timely and accurate technical support when needed.

PICC-18 is constantly updated to support new PICmicro devices as they become available, and the ANSI C basis of the compiler protects your code investment.

4.6.3 Flowcharts of code execution Start Initialize System LCD In tro M essa ge Enable Watchd og have sett ing s b een

m odified

Buzze r Be ep

Chec k for m enu up dates

value s

Chec k for men u up date s Interlo c k c hec k Do control loop Che ck sa fety pa ramete rs Sto re ne w EEPROM value s Softwa re Reset

Load Para mete rs

YES NO Menu Up date d NO YES EXPANDED IN FIGURE 4.15

Start EXPANDED IN FIGURE 4.18 C onve rt c h annel 1 ADC PID loop ch1 Convert c hannel 2 ADC PID loop c h2 Wa it for 1 seco nd Inte rrup t

Has inte rrup t Oc curred

Return NO

YES

Figure 4.15 : Flowchart of LMS control loop code execution