LEGO MINDSTORMS TUTORIAL

2y ago
22 Views
2 Downloads
1.57 MB
203 Pages
Last View : 9d ago
Last Download : 3m ago
Upload by : Joanna Keil
Transcription

LEGO MINDSTORMSTUTORIALModule NXTESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.netLEGO MINDSTORMS TUTORIALOutlineESWEEK [DRAFT: Final PDF is uploaded after Sunday] 2009http://nxtgcc.sf.netRasmus Ulslev Pedersenrup.inf@cbs.dkNXT.1

The presentation overview.LEGO MINDSTORMSTUTORIALESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.netOverview LEGO c MINDSTORMS c NXT from a communityand user standpointHardware Description of NXT hardware from a developerperspectiveSoftware Description of NXT software with the aim ofperforming a firmware replacementNote 1: LEGO has sponsored a NXT 2.0 kit, which we willmake a draw for at the end of the tutorial.Note 2: LEGOr, MINDSTORMSrare trademarks of LEGOr.The tutorial contains pictures from Atmel ARM7documentation, and from LEGO documentation.Note 3: There is additional material included: Many slides aresupplementary and included for future reference.OutlineNXT.2

LEGO MINDSTORMSModule NXTESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.netLEGO MINDSTORMSESWEEK [DRAFT: Final PDF is uploaded after Sunday] 2009http://nxtgcc.sf.netRasmus Ulslev Pedersenrup.inf@cbs.dkNXT.1

OutlineLEGO MINDSTORMSESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.netNXT.2

LEGO MINDSTORMSAimESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.net Includes as USB, SPI, and I2C How the open source universe around Lego Mindstorms NXT is structuredTalk about a world that stretches from high-schools toadults and from building bricks to programming inassemblerEmphasis on the overview and the programming aspectsReaders will be able to see where in the NXTprogramming spectrum their interest match mostUse the tutorial to get started with open sourceprogramming on NXTNXT.3

IntroductionLEGO MINDSTORMSESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.net Description of open source hardware and software LEGO business models are discussed The old RCX NXT in several (online) communities Overview of how NXT can be programmed in differentenvironmentsNXT.4

Source and Documents by LEGOLEGO MINDSTORMSESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.netNXT Firmware Open Source Complete software for the NXTfirmware, which can be compiled with acompliant C compilerSoftware Developer Kit A kit with software for controlling NXTremotely from a host computer. It includes adescription of the NXT virtual machine.Hardware Developer Kit Description of the possible sensorand actuator interfaces for NXT. This isextensively used by thirdparty sensor vendors.Bluetooth Developer Kit It includes the communication protocolfor controlling NXT over a Bluetooth connection.NXT.5

SchematicsLEGO MINDSTORMSESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.net Lego published the schematics Can see which pins of the ARM7 MCU is connected towhat ports Lego uses Orcad for its schematics, which is a commercialprogramNXT.6

Analog/Digital ProtocolsLEGO MINDSTORMSESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.net NXT features both analogue and digital interfaces to its sensors.Sensors are based on an analogue to digital conversionSignals are fed into the ARM processor for furtherprocessingDigital sensors are made with an I2C compliant protocolI2C is a two wire protocol that allows for up to 127 deviceson the shared busNXT.7

NXT-G BlocksLEGO MINDSTORMSESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.net LEGO provides a proprietary programming language forLEGO MINDSTORMS NXT called NXT-G G implies it is a graphical programming language Places NXT-G programming blocks in a sequence thatinvolves the usual programming constructs such as loops,branches and computations Tutorials and small videos with instructions for a given taskShow NXT-G.NXT.8

Firmware SourceLEGO MINDSTORMSESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.net LEGO MINDSTORMS NXT comes with an open sourceoperating system Operating system is written in ANSI C Source code fundamentally access the physical layer suchas input and output ports of the ARM processor Another part provides an abstraction layer to theseservices Operating system is a traditional round robin scheduler Services each a number of modulesNXT.9

Modules OverviewLEGO MINDSTORMSESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.net Each module is centered on a logical or a physical unit in NXTExample: the display or the user interfaceThe virtual machine a logical moduleEach time the virtual machine is serviced it will execute anumber of bytecodesA 1 ms period (system tick) services all modulesNXT.10

Fantom PC/Mac InterfaceLEGO MINDSTORMSESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.net LEGO has released an interface both for the PC and theMacintosh Linux is not supported at this point Firmware image in NXT is updated via a USB cableconnection NXT is programmed from NXT-G either over USB orBluetoothNXT.11

Business ModelsLEGO MINDSTORMSESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.net LEGO earns money on NXT by selling the kit itself Licences to educational institutions are also revenuesource First version of LEGO MINDSTORMS NXT was releasedin the beginning of 2007 A second version appeared in the fall of 2009 (biannualrelease schedule:-)?) Shipped with a different set of standard sensors (colorsensor)NXT.12

LEGO SYSTEMS LEGO partly produce LEGO MINDSTORMSESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.netand package NXT ontheir factory in BillundStaff around NXTdevelopment is not bigFirmware developmentteam is in control of thesoftware developmentNational Instruments(NI) designs the NXT-GenvironmentNXT-G transferring itsbytecode-compiledprograms to NXT forstorage and subsequentexecutionNXT.13

LEGO Design Routines Lego has a group of LEGO MINDSTORMSESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.netpeople who has theprivilege of talkingdirectly to LEGO staffUnder non-disclosureagreements (NDA)First group of MCPs(MUP) were a selectgroupUsed as a soundingboard for the ideas thatwent into developing thefirst LEGOMINDSTORMS NXT.MCP 4 is commencingas we speakNXT.14

Firmware ReleasesLEGO MINDSTORMSESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.net NXT is a complex product compared to other LEGOproducts Requires focus on quality Updated versions released on the official MINDSTORMSwebsite First firmware had the version number 1.1 (or 1.0.) andthe current released version for NXT 2.0 is versioned 1.28NXT.15

Partners many institutions, companies, groups, andindividuals have a stakein NXTNational Instruments ispresumably the mostimportantMIT, Tuft, CarnigieMellon, and others arealso activeOthers such asnxtprogramsNumber of large eventsThis includesBrickfestThere has also been aMINDSTORMS NXTSumo CompetitionLEGO MINDSTORMSESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.netNXT.16

Sensor Partners and Independent ManufacturesESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.net A limited number of third-party sensorsexistsHitechnic, Mindsensors,and VernierHitecnic produces itssensors in a standardLEGO sensor housingMindsensors make itssensors available indifferent shapes andformsVernier specializes innatural sciencesexperimentsDCPLEGO MINDSTORMSVernierrNXT.17

LEGO MINDSTORMSStandard SensorsESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.net Input and output portsfeature a 6-wire RJ12connector Ultrasonic distancemeasurement sensor, alight intensity sensor, asound sensor, a touchsensor, and motors(a) Light(d) Touch(b) Motor(e) Ultra(c) Sound(f) NXT-GStandard Lego Mindstorms NXTsensors and a NXT-G blockNXT.18

Some Mindstorms HistoryLEGO MINDSTORMSESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.net 10 years since Mindstorms was released First LEGO Mindstorms was the LEGO RCX: Successful LEGO intended it to be a closed source product, but. It was soon hacked:-) The open source strategy was pursued even more with thepresent LEGO Mindstorms A Goldplated NXT and a limited edition Black NXT wasproduced in relation to the 10 year anniversaryNXT.19

NXT DevelopmentLEGO MINDSTORMSESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.net Development of NXT started in the 2004 Initial group was Ralph, Steven, John, and David First prototypes were circulated on a limited number basis inside the current MUP group and a select few outside thatgroupMUP: Jan 2006, 5 peopleMUP II: Nov. 2005, 11 peopleMDP: 2006MCP II: 31 persons, 100 chosen from 10000 applicantsMCP III: 2008-2009MCP IV: Commencing.NXTGCC was created during the fall of 2006NXT.20

Lego EducationLEGO MINDSTORMSESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.net Lego has a website for educational activities Strong focus on university segment LEGO MINDSTORMS NXT comes in educational sets Rechargeable battery and extra building pieces Sold with site licences that accompany the NXTNXT.21

Mindstorms CommunityLEGO MINDSTORMSESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.net MINDSTORMScommunity is large anddiverse Blogs, forums, largeevents, books, the MCPprogram and more NXTStep and theNXTasy blogs Lugnet is a large LEGOfanclubNXT.22

SchoolsLEGO MINDSTORMSESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.net Many schoolsparticipate in FirstLEGO League A tournament wherecurrent theme is playedout The idea is to haveadults lead or mentor ateam of children aged9-14 (16 outside the US) NXT is used to completea challenge put out bythe FLL managemenNXT.23

NXT Alternatives NXT is not completely LEGO MINDSTORMSESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.netalone.Sun Spots fromSun/OracleFisher-Technic offers anew robot controllerwhich is is based on anARM9 processorrunning at 200MHzVarious evaluation kits:mbed, IAR, etc.However, it is difficult tomatch dealer network,community, and historyof LEGONXT.24

Embedded ProgrammingLEGO MINDSTORMSESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.net A central micro processor controls NXT A second small micro processor assisting it Code is compiled to machine instructions which areexecuted one at a time NXT allows for firmware updates, which is the basis foralternative operating systemsNXT.25

NXT Firmware NXT actually consists oftwo different firmwaresLEGO MINDSTORMSESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.net The main firmwarecontrols the interactionwith the user, and radiocommunication to otherNXTs An ATmega48generates the pulsewidth modulation(PWM) signals for thethree motors It also provides inputregarding the state ofthe push buttons on theNXT Host side SDK whichallows for interactionwith the NXT via a DLLNXT.26

Firmware EnhancementsLEGO MINDSTORMSESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.net Firmware enhancements are possible only because Legoreleased the software as open source IAR is a commercial compiler used by LEGO It was recently released in a free version for Mindstorms The other option for programming the existing firmware isto use GCCNXT.27

Firmware Replacements A growing number of firmware replacements available Examples: lejos, NQC, pbLua, and RobotCLEGO MINDSTORMSESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.net A different example is TinyOS leJOS is based on a small virtual Java machine. It is afirmware replacement that allows for Java programming onLego Mindstorms NXT. There is extensive support in formsof tutorials, well-developed APIs, and Netbeans/Eclipseprogramming IDEs at the leJOS website. Lua is a scripting language (see Lua website). It is said toperform faster than other scripting languages. RalphHempel has ported Lua to Lego Mindstorms NXT andlabeled it pbLua Not eXactly C (NXC) is language similar to C. It issupported on Lego Mindstorms NXT by John C. Hansenand available fromhttp://bricxcc.sourceforge.net/nbc/. It is builton top of the Next Byte Codes (NBC) compiler. It is afirmware replacement.NXT.28

Hardware Developer KitLEGO MINDSTORMSESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.net Lego provides the schematics and drawings for the NXThardware Good for programming the ARM7 Useful for developing a new sensorNXT.29

IAR Toolchains and CompilersLEGO MINDSTORMSESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.net The free IAR compiler can be downloaded from IAR’shomepage It is an industry strength programming environment calledEmbedded Workbench It interacts with a JTAG programmer connected to LegoMindstorms NXT via the IAR C-SPY debugger The visualSTATE program interacts with the C-SPYdebugger to give a graphical view of the debuggingsessionNXT.30

GCCLEGO MINDSTORMSESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.net The GCC compiler canbe downloaded from thenxtgcc home page It is an arm-elf-gcccompiler There exists severalgood toolchains such asWinArm, CodeSurgeryetc.NXT.31

NXTLEGO MINDSTORMSESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.net NXT with touch, sound,light, and ultrasonicinput sensors The three motors on theoutput ports are alsoshown NXT’s main microprocessor (MCU) is anAT91SAM7S256NXT.32

LEGO MINDSTORMSNXT InsideESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.net (a) ARM7 MCU (b) ATmega48 MCU (c) CSR BlueCore4 Bluetooth radio(d) SPI bus andtouchpad signals(e) high-speed UARTbehind input port 4(f) output (generallymotor) port(g) USB port, (h)four-button touchpad(i) 100x64 LCD displayNXT with important hardwarehighlightedNXT.33

ARM7LEGO MINDSTORMSESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.net Characterized by a number of modes, exception types, and interruptsAssociated with each mode is a current program statusregister (CPSR)Each exception and interrupt type is associated with apriority6 privileged modes named system, svc, abort, fastinterrupt, interrupt, and undefined modeThey can all modify the CPSRThe unprivileged user mode cannot modify the CPSRNXT.34

ARM7 Registers The CPSR defines the characteristics of the current modeLEGO MINDSTORMSESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.net It can mask (ie. not allow) interrupts and fast interrupts The CPSR includes a flag whether the ARM7 is executing thumb code or arm codeThere is a register file which includes 37 registersEach register is 32 bit wideEach mode uses 17 registersRegisters R0-R12 are shared between usr, sys, svc,abt, irq, and und modesThe fiq mode has its own banked version of the R8-R12registersAll modes have their own stack pointer and link/returnpointer: R13 and R14The program counter, pc, is placed in R15NXT.35

LEGO MINDSTORMSARM and Thumb Instruction SetsESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.net The ARM instruction setis 32 bit Thumb instruction set is16 bit Most of the code in NXTis compiled toward theThumb instruction set Thumb code is moredense than ARM Exception and interrupthandlers are compiledto ARM codeDemo ARM compilation.NXT schematicsNXT.36

LEGO MINDSTORMSARM PinsPCBPort/pinARM7 pinARM7 6PA30AD7ESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.net Port 1 through 4 are mapped to general purpose inputoutput pins Most ARM7 pins are multiplexed Pin 6 on inout port 1-3 both can serve as GPIO pins andas an analog to digital converter (ADC) The Lowspeed module use the GPIO pins to bit-bang anI2C protocolNXT.37

Memory Layout Flash memory is initially mapped to address 0x0000 0000 Flash is also accessible at address 0x0010 0000LEGO MINDSTORMSESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.net NXT immediately branches to the reset handler that is defined in CStartup.SIt uses a temporary stack in the RAM areaThe reset handler sets up the stacks for the interrupthandler (IRQ), the undefined instruction handler (UND)stack, and the user stack (USR)USR stack is used when the normal code executesThe USR stack is used when the normal code executesIRQ stack is obviously used when the IRQ handler isinvoked: it branches to the correct interrupt service routine(ISR)Controlled by writing the address of that ISR into theadvanced interrupt controller (AIC) source vector register(SVR)Example: each of the three timers (TC0, TC1, TC2) havean ID, and that ID is used as index in the AIC SVR vectorNext: Memory LayoutNXT.38

LEGO MINDSTORMSMemory LayoutFlash (.text)Reset interrupt vector (boot)ESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.netRAM (.data)Remap0x0000 00000x0020 0000Reset interrupt vector-Undefined instruction vector-Software interrupt vector-Prefetch abort vector-Data abort vectorReservedReserved-IRQ vector-FIQ vectorIRQ handlerAdvanced interrupt controller(IRQ mode)Reset handlerUndefined instruction handlerUsed as breakpoint entry(Undefined instruction mode)ARM compiled codeReset handler(Supervisor mode)Thumb compiled codeFlash 256 KB.fastrunC code to run in RAMI.e. Interrupt service routines.bssZero initialized variablesRAM 64 KB0x0010 0000NXT file systemFree spaceUser stackDescending stacksReset handler stackUndefined handler stackIRQ handler stackNXT file handlesNXT file version0x F000 0000Memory mapped peripheralsTWI (I2C), SPI, USART, etc.Notes about the NXTGCC memory layout figure:Not drawn to scaleStrikethrough: not used in standard firmwareInterrupt and exceptions is handled in assemblerSome details omitted for clarity0x FFFF FFFFNXT.39

LEGO MINDSTORMSMemory LayoutFlash (.text)Remap0x0000 0000Undefined instruction vector-Software interrupt vector-Prefetch abort vector-Data abort vectorReservedReserved-IRQ vector-FIQ vectorIRQ handlerAdvanced interrupt controller(IRQ mode)Reset handlerReset handler(Supervisor mode)Thumb compiled code.fastrunC code to run in RAMI.e. Interrupt service routinesFlash 256 KB.bssZero initialized variablesNXT file systemFree spaceUser stackReset handler stackDescending stacksARM7) are fullydescending stacks Using the instructionsSTMFD and LDMFD Postfix FD depicts thatwe are working with afull descending stackUndefined instruction handlerUsed as breakpoint entry(Undefined instruction mode)ARM compiled code The stacks on NXT (i.e.0x0020 0000Reset interrupt vector-RAM 64 KB0x0010 0000Reset interrupt vector (boot)ESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.netRAM (.data)Undefined handler stackIRQ handler stackNXT file handlesNXT file version0x F000 0000Memory mapped peripheralsTWI (I2C), SPI, USART, etc.Notes about the NXTGCC memory layout figure:Not drawn to scaleStrikethrough: not used in standard firmwareInterrupt and exceptions is handled in assemblerSome details omitted for clarity0x FFFF FFFFTODO: Show code with descending stacksNXT.40

Undefined Instruction Stack SetupLEGO MINDSTORMSESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.net Undefined stack setup in Cstartup.S The illegal memory access (ABT) stack is set up beforethe undefined instruction stack/* Set up Undefined Instruction Modeand set UND Mode Stack*/.EQU UND STACK TOP, (ABT STACK TOP - ABT STACK SIZE)msrCPSR c, #ARM MODE UND I BIT F BITmovsp, r0 /* Init stack UND */subr0, r0, #UND STACK SIZENXT.41

Post BootLEGO MINDSTORMSESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.net Remapping of address 0x0000 0000 such that it is nowthe RAM and not the flash that is accessible from address0x0000 0000 Main reason for this is that we need to service interruptseven when the NXT flash-based file system is beingwritten to Remapping the memory ensures that the interrupt vectortable is access in RAM all interrupt service routines are linked into the .fastrunsegmentShow segments in file.NXT.42

NXT RunningLEGO MINDSTORMSESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.net Mostly taking place in the Thumb compiled code The user code is executed in user mode [TODO: Tjek] Interrupt is asserted from one of the ARM7 peripheralsources then that interrupt service routine takes over Most peripherals in NXT are associated with a softwaremoduleNXT.43

ModulesLEGO MINDSTORMSESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.net Each module is built from an header file, a C file, and .iomfile Layered in a hardware physical layer (HPL), and ahardware abstraction layer (HAL) HAL files start with the letter c followed by an underscore,while the HPL files start with the letter dNXT.44

LEGO MINDSTORMSNXT Software Modules and ARM7 HW PeripheralsNameARM ationAVR via I2C/TWISPIGPIO, PWM, ADI2C, AICMCGPIO, PWMAVR via I2CSSCPITSPI, GPIOUDP, UART, SPIMain control4 buttonsLCD displayVirtual machine4 input portsAVR communicationFile managementI2C emulationMotor controlLoadspeaker controlMenu systemOperating system tickCommunication controlUSB, RS485, and BTESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.netAbbreviations: I2C:Inter-integrated circuit, TWI:Two-wire interface, roller,MC:Memorycontroller,SSC:Synchronious serial controller, PIT:Periodic interval timer, SPI:Serial peripheral interface, UDP:USB device port, and UART:Universal asynchronous receivertranceiver.NXT.45

NXT ModulesScheduler This is the main scheduler: m sched. It works ina round robin fashion with a 1 ms system tick. Itwill call each of the modules listed below usingfunction pointers. There is an initialization phasein which each module’s cInit method is called.Then the system starts calling the cCtrl methods.Termination is done via calls to CExit.Button It handles the four buttons on top of NXT.Principle: It uses the AD converter peripheralButton 0 is read as? Button 1-3 is read as an ADconverted value.CMD This is the Lego virtual machine. It reads theexecutable files stored in flash and creates aRAM space for runtime information. The rxe filecontains bytecode instructions, bytecodescheduling, and run-time data.Comm It takes care of the BT, USB and the Highspeedport. Peripherals used: SPI to BT, USB, andUSART in RS485 mode.LEGO MINDSTORMSESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.netNXT.46

NXT ModulesDisplay It is code for accessing the pixels of the 100 x 64pixel display. It is possible to both set pixels, writecharacters, and strings (it is a matter ofabstraction). There is a font included with theNXT. There are eight text lines on the display. Itaccesses the serial peripheral interface (SPI)hardware peripheral. The SPI works by writingdata to a slave (the display in this case) over themaster out slave in (MOSI) line. It receives datafrom the slave over the master in slave out line(MISO). The data flow is synchronous and isregulated by a serial clock (SPCK) line. Thedisplay receives a command from the ARM7specifying which line is to be written, and then itreceives the actual data for that line.Input The input sensors are plugged into the 4 inputports on NXT. NXT will know which type ofsensor is plugged into a port. It can be atemperature sensor, sound, lowspeed, and soon. The lowspeed sensor is an I2C/TWIcompliant sensor. It uses two general purposeLEGO MINDSTORMSESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.netNXT.47

NXT ModulesIOCtrl This module controls the booting and powerdown sequences of NXT. It will write to the AVRwhat the power should be and what the PWM forthe motors should be. The IOCtrl module usesthe I2C(TWI) hardware peripheral to relay thisinformation to the AVR. It also uses theadvanced interrupt controller (AIC), by having itcall an I2C handler routine.Loader File management is achieved by the loadermodule. It reads, writes, creates, and deletesfiles in the NXT flash. It resides in the upper partof the flash memory starting from the value of thememory address STARTOFUSERFLASH ind loader.h. It uses the memory controller (MC)peripheral module of the ARM7. One specialthing about the flash read and write is that writesare done on a per page basis, and it is notpermitted to read from the flash memory duringthis process. Therefore, the methods thatperform erase and write of flash pages areplaced in RAM. This is achieved by marking theLEGO MINDSTORMSESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.netNXT.48

NXT ModulesLowspeed An I2C compliant device can be connected toone of the four input ports. The lowspeed modulehandles the communication and recognizes theconnected sensor as either the standardultrasonic device, or a custom device. It uses anIRQ handler that is invoked via the AIC hardwareperipheral: It utilizes the pulse width modulationcontroller (PWM) peripheral to generate theclock. A four channel I2C compliant interface iscontrolled via this interrupt source. The Ultrasonic sensor is one such sensor.Output Motors are connected to NXT through the threeoutput ports: A, B, and C. The modulecommunicates the motor output to the AVR viathe I2C bridge. It is managed by struct, which ispassed to the AVR from the ARM7 that controlsthis communication line. The information thatcontrols the motors are an output mode and aPWM frequency for each motor. Equallyimportant, the ARM7 uses the interrupts of thethree timer channels to monitor each of the threeLEGO MINDSTORMSESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.netNXT.49

NXT ModulesSound A loudspeaker with 8 bit resolution is controlledby the sound module. It plays sounds which arefiles residing in the NXT file system. Each timecCtrl method of the sound module is called, thenit either plays a sound, continues to play asound, or closes the sound file that has beenplayed. The module utilizes the synchronousserial controller (SSC) hardware peripheral. Withthe SCC providing the AC signal((SOUND ARMA from PA17) to the SPY0030Aaudio driver, NXT can play sounds. It uses theperipheral DMA controller (PDC) to handle thetransmission of the bitstream to the speaker.UI The module manages the menu system, selectedfiles, icons, animations, etc. on NXT. It respondswhen an user press on of the buttons on NXT.Timer NXT is programmed around a system tick of 1ms. This property is supported by the timermodule that use the periodic interval timer (PIT)hardware peripheral to maintain a 1 ms counter.LEGO MINDSTORMSESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.netNXT.50

ProcessLEGO MINDSTORMSESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.net Changes needed to make the source code compile withan arm-elf based GCC See details in ConvertNxtGcc.java program First versions of NXTGCC were error-prone IAR supports, and Lego uses, nested flexible arraymembers GCC does not support this Key was to change the nested flexible array to become afixed size nested arrayNXT.51

LEGO MINDSTORMSNested ArrayESWEEK [DRAFT:Final PDF isuploaded afterSunday] sb;.UBYTEPixelsY;/*nxtgcc converter*/UBYTEData[1];}/*nxtgcc converter*/attribute (( packed ))BMPMAP;NXT.52

OverviewLEGO MINDSTORMSESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.net Easiest way to debug NXT is to use the light sensor We can find the memory location that controls the GPIOpin Other choices is to use a JTAG debuggerNXT.53

LEGO MINDSTORMSLight sensor PortESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.net//Turn on an input port#define ON(port){*AT91C PIOA SODR PORT TO PIN(port);}Turn on a light sensor on an input port for low-leveldebuggingLight sensor schematics: Show how toturn on the light sensorNXT.54

Display DebuggingLEGO MINDSTORMSESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.netExample (from c cmd.c):{// LCD DEBUG STARTcnt ; // a static counterUBYTE DebugString[50];sprintf(DebugString,"Debug info: %d", cnt);if(cnt 1){cDebugString(&DebugString[0]);}}//LCD DEBUG ENDShowing a debug string in the displayNXT.55

GDB DebuggingLEGO MINDSTORMSESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.net We may think (initially) that we have stopped the processor A break point can be inserted into the code using the GCCinline assemble syntax/** Trigger a breakpoint exception.*/ramfunc void bsp breakpoint(void) {//asm volatile (".word 0xE7FFDEFE");NXTGCCBREAK;}NXT.56

GDBLEGO MINDSTORMSESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.net GDB is the debugging system that is connected to GCC GDB system offers a remote debugging system USB driver to use is the Fantom SDK Fantom C files, there is a section with ëxtern C" Read and write methods for arbitrary bytes Allows for an implementation of the GDB remotedebugging protocol Debugger is arm-elf-gdbNXT.57

GDB Remote ProtocolLEGO MINDSTORMSESWEEK [DRAFT:Final PDF isuploaded afterSunday] 2009http://nxtgcc.sf.net It includes a one-byte checksum Comes after the # in the packet Problem is that the Fantom DLL does not like if we try toread from the USB if there is not something to read We read two characters (checksum) NXTGCC

First LEGO Mindstorms was the LEGO RCX: Successful LEGO intended it to be a closed source product, but. It was soon hacked:-) The open source strategy was pursued even more with the present LEGO Mindstorms A Goldplated NXT and a limited edition Blac

Related Documents:

LEGO, the LEGO logo, the minifigure, DUPLO, the SPIKE logo, MINDSTORMS and the MINDSTORMS logo are . Book about astronauts ; LEGO, the LEGO logo, the minifigure, DUPLO, the SPIKE logo, MINDSTORMS and the MINDSTORMS logo are . You may find several ideas for short physical activities for students through a simple web search. Design a .

First LEGO Mindstorms was the LEGO RCX: Successful LEGO intended it to be a closed source product, but. It was soon hacked:-) The open source strategy was pursued even more with the present LEGO Mindstorms A Goldplated NXT and a limited edition Blac

Simulation for LEGO Mindstorms Robotics By Yuan Tian The LEGO MINDSTORMS toolkit can be used to help students learn basic programming and engineering concepts. Software that is widely used with LEGO MINDSTORMS is ROBOLAB , developed by Professor C

2 Lego Mindstorms – A little history Originally launched 1998 The Lego Mindstorms Robot Invention System (RCX “Brick”) Simple visual programming system Reverse engineered Major update 2006 Lego Mindstorms NXT Open source hardware & fi

Introducing the NXT generation In 1998 the LEGO Group revolutionised the world of educational robotics with a pioneering product concept - LEGO MINDSTORMS Today LEGO MINDSTORMS for Schools is used in more than 25,000 educational institutions worldwide from primary schools to universities.

Internet: www.LEGO.com Annual Report 2018 is published for the LEGO Group by Finance and Corporate Brand Communications. Design: Kontrapunkt Print: Rosendahls Printed copies: 50 LEGO, the LEGO logo, the Minifigure, DUPLO, the FRIENDS logo and NINJAGO are trademarks of the LEGO Group. 2019 The LEGO Group. LEGO Star Wars & Lucasfilm Ltd.

continued and computers were become smaller, as in 1998 Lego introduced the first Lego Mindstorms and Robotics Invention System. This kit included not only the usual Lego parts, but also a programmable brick, called the RCX. The main component of the RCX is a Hitachi H8 microcontroller. In 2000 Lego relea

Advanced Financial Accounting & Reporting Accounting concepts Accounting concepts defi ne the assumptions on the basis of which fi nancial statements of a business entity are prepared. Certain concepts are perceived, assumed and accepted in accounting to provide a unifying structure and internal logic to accounting process. The word concept means idea or notion, which has universal .