Home
fulltext - DiVA Portal
Contents
1. Reading the GPS device files DOS Diagnostic Test using the D A Quick Diagnostic test output while no probes are attached at the D A channel 0 DOS Diagnostic Test using the D A Quick Diagnostic test output while a probe are attached at the D A channel O Abstract The idea about the CyberBike came to Jens G Balchen the founder of the Department of Engineering Cybernetics at NTNU in the 1980 s He wanted to make an unmanned autonomus bicycle i e a bike that could run by itself The idea was picked up by Amund Skavhaug who started the CyberBike project in the late 80 s After being deffered for some years the CyberBike has again gained some attention This master s thesis is based on Hans Olav Loftum s and Lasse Bjermeland s theses at the spring 2006 and the autumn project of John A Fossum the same year The goal of the CyberBike project is to make the bike work as intended i e as an autonomous unmanned bicycle This thesis naturally share this goal although the bike did not become able to take its first autonomous trip within the thesis time frame At the start of the work the bike were already equipped with a suitcase of computa tional hardware on its baggage rack a small QNX Neutrino OS image was installed on the industrial PC mounted in the suitcase and drivers for the installed motors tacho
2. General Chipset SiRF Star III Frequency L1 1575 42 MHz C A code 1 023 MHz chip rate Channels 20 channel all in view tracking Sensitivity 159 dBm Accuracy Position 10 meters 2D RMS 5 meters 2D RMS WAAS enabled Velocity 0 1 m s Time lus synchronized to GPS time Acquisition Time Reacquisition Hot start Warm start Cold start 0 1 sec average 1 sec average 38 sec average 42 average Dynamic Conditions Altitude 18 000 meters 60 000 feet max Velocity 515 meters second 1000 knots max Acceleration Less than 4g Power Main power input Power consumption 4 5V 6 5V DC input 60mA Protocol Electrical level Baud rate Output messages level Output voltage level 2 85V RS 232 level 4 800 bps NMEA 0183 GGA GSA GSV RMC VTG GLL Table 4 2 Specific data for the GPS module from GlobalSat 56 CHAPTER 4 SUGGESTED SOLUTION litlle PCB creating experience this was not discovered until the soldering was done This resulted in a bad looking soldering side of the board The card was washed with methylated spirit and applied a new tin coat and the soldering points were reheated to improve the connections Probing all connections on the board by the multimeter see Section 6 1 1 showed that the connections were good even though the board looks bad on that side Figure 4 8 shows the soldering side of the board before and after
3. Y eod 5 2 hie A A A EA XE 5 8 Propulsi n Mot r s pe deme e Rer BAUER eene 5 4 New driver for DMM 32 AT 5 5 Pendulum limit switch final implementation 5 6 Emergency Stop Button DT A dedic NUM 5 8 Battetieso x Sak des xDD We ede 5 9 Driver SUMMA Y oe pei e a A UE qUeaoede Ge de Tests and experiments 6 1 Fest equipment o dare es ox T Multimeter a i214 ue eme rr e etd ge d tri 6 1 2 Oscilloscope s do a moo ER hex RR Eon 0 15 POWersources ie om RU IRE EIS aue sl 6 2 Phe pendulum motors a Rat eed Rub bue b RAS 0 3 COM ports suse isum don due ere Rep dise 6 3 1 Linux installation 2 2222 6 3 2 2 6 3 3 Tesine 1 6 34 Comment usu ee ee go ee daos 0 4 GPS driver testing a Oe a eq ds 6 01 4DMAME32S AT issues idea eG ae ae a de Ge quee Ge gos 37 37 37 37 44 48 49 52 52 52 54 54 57 58 59 o W gt 6 6 6 5 1 The DOS Diagnostic Test Utility from Diamond Systems Testing the control algorithm Discussion 7 1 7 2 7 3 7 4 7 5 Choice of storage medium
4. CyberBikePC 49 4 2 1 First attempt New OS image The buildfile velo_v2 build see appended CDROM Appendix A was made to include the changes mentioned in the list above Then the commands given in Loftum 2006 Section 4 2 and 5 2 1 were executed like shown in Printout 4 4 This generates loads of output not shown here No error messages were found in the output mkifs v velo_v2 build velo_v2 ifs Printout 4 4 Making OS image from buildfile Then the Compact Flash CF was removed from CyberBikePC and put into a USB card reader Having some hard times finding the card on the QNX host workstation the card reader was plugged into a laptop running Ubuntu Linux to be investigated Printout 4 5 shows the terminal input output from this indicating that the card is work ing as it should audun audislappis dev sudo mkdir mnt flash audun audislappis dev sudo mount t qnx4 dev sdb mnt flash audun audislappis dev 15 al mnt flash total 1928 drwxrwxr x 3 root root 4096 2006 06 05 drwxr xr x 9 root root 4096 2007 03 14 1 root root 2006 06 05 8 altboot 1 root root 251904 2006 06 05 bitmap 1 root root 1705616 2006 06 05 8 boot r r r 1 root root 8192 2006 06 05 8 inodes r r r 1 root root 2006 06 05 longfilenames Printout 4 5 Mounting CF card on Linux Plugged back into the QNX host machine the card reader with the CF card inserted had to be initialized This was done by the commands sho
5. IMU GPS xvi we qi ee ee a ee ES Debugging hardware Reflection le Further Work 8 1 8 2 8 3 8 4 8 5 8 6 8 7 Correction of the serial connection problem Wireless ethernet connection Line Optimization of devc dmm32at Videocamera Adaptive IMU signal converting Connection database Conclusion Contents on CDROM How to start the CyberBike system How to boot CyberBikePC in Linux How to boot CyberBikePC in DOS Connection tables 2 E 3 E 4 Terminal block outside suitcase Baldor 44 ce Bs dy emu Terminal Blocks J3 on DMM 32 AT Design of PCB 97 97 97 99 100 100 103 103 104 104 104 105 105 106 107 115 117 121 123 125 126 129 131 133 135 vi Abbreviations and acronyms A D AC ADC ATA AUAV Bash BIOS CDROM CF CPU D A DAC DC DDK DSP EEPROM EIDE Analog to Digital Alternating current Analog to Digital Converter Advance Technology Attachment Many synonyms and near synonyms for ATA exist including abbreviations such as IDE and ATAPI Also with the market introduction of Serial ATA in 2003 the original ATA was retroactively renamed Parallel ATA PATA Autonomus Unmanned Aerial Vehicle Bourne Again SHell Basic Input Output System C
6. 1 real T meas Setting the output 71 77 for i 0 i lt 2 i output devs i ret devctl fd 0 VELO_DEVCTL_SETVAL amp output sizeof output NULL if ret 1 fprintf stderr s tERROR when performing devctl on s t s n NAME velo devnames i strerror ret 96 CHAPTER 6 TESTS AND EXPERIMENTS Code sample 6 3 The bike start and bike stop functions in bike_io_wrapper c int bike_start int i int openflag 0 printf Running bike start procedure Wn the first 3 devices are motors and needs to be for 1 0 i NumVeloDevices 1 openflag i 3 O_RDWR O_RDONLY The first 3 devices are motors and will be written to fd i open velo devnames i openflag if fd i 1 perror open returned with error return fd il return 0 int bike_stop int i int retval 0 double output 0 printf Running bike stop procedure Nn for i 0 i lt NumVeloDevices i retval devctl fd 0 VELO DEVCTL SETVAL amp output sizeof output NULL if retval 1 fprintf stderr As NtERROR when performing devctl on s t s n NAME velo devnames i strerror retval if close fd i 1 retval EXIT_FAILURE return retval Chapter 7 Discussion An overview of the CyberBike s hardware situation at the end of the work on this thesis i
7. The Resource Manager itself has to register which part of the pathname space it whish to be responsible for The Resource Manager library provided by QSSL consists of some pieces e thread pool functions e dispatch interface e resource manager functions e POSIX library helper function The drivers devc imu devc velo devc dmm32at written by Loftum 2006 for the CyberBike are all made as Resource Managers The most important function calls in an RM are dispacth create creates a dispatch structure which is used for blocking on the mes sage reception iofunc init initializes the attribute structure used by the device The struc tures contain information about a particular device and it exists one per device name iofunc_func_init initializes the two data structures cfuncs and ifuncs which con tain pointers to the connect and I O functions respectively The library is provid ing default POSIX versions of functions for handling connect and I O messages and the iofunc_func_init is binding these to the given function tables supplied as arguments Portable Operating System Interface 16 CHAPTER 2 BACKGROUND resmgr attach creates a channel that the RM will use for receiving messages and talks to the PM to tell it which part of the pathname space this RM is going to be responsible for This is where the dispatch handle pathname and the connect and I O message handlers all get bound together resm
8. 5 5 Pendulum limit switch final implementation 71 devc dmm32at verbose autocal devc dmm32at Verbose mode devc dmm32at Autocalibration will be performed during init devc dmm32at If DMM 32 AT card still is buggy you should not do this while p in 38 on J3 is connected to anything DMM 32 AT Performing D A auto calibration DMM 32 AT Done D A autocalibration Offset Error 0 500 Gain Error 0 350 DMM 32 AT Performing A D auto calibration DMM 32 AT Configuration Mode 0 Offset Error 0 180 Gain Error DMM 32 AT Values for offset and gain met specified tolerance DMM 32 AT Configuration Mode 1 Offset Error 0 450 Gain Error DMM 32 AT Values for offset and gain met specified tolerance DMM 32 AT Configuration Mode 2 Offset Error 0 080 Gain Error DMM 32 AT Values for offset and gain met specified tolerance DMM 32 AT Configuration Mode 3 Offset Error 0 320 Gain Error DMM 32 AT Values for offset and gain met specified tolerance DMM 32 AT Configuration Mode 8 Offset Error 0 430 Gain Error DMM 32 AT Values for offset and gain met specified tolerance DMM 32 AT Configuration Mode 9 Offset Error 0 270 Gain Error DMM 32 AT Values for offset and gain met specified tolerance DMM 32 AT Configuration Mode 10 Offset Error 0 420 Gain Error DMM 32 AT Values for offset and gain met specified tolerance DMM 32 AT Configuration Mode 11 Offset Error 0 020 Gain Error DMM 32 AT Values for
9. Emergency i conl Button Switch 14 NC 1 2 Figure 5 7 Circuit diagram of how the emergency button is connected 76 CHAPTER 5 SOLUTION And from that the emergency switch was connected as shown in Figure 5 7 The button was mounted at the back of the suicase to let the operator stay behind the bike away from the moving pendulum and handlebars etc Testing of this safety function worked as expected and has shown to be useful in many cases For instance this button should be activated while starting up the system when the chain connecting the propulsion motor to the rear wheel is installed Else the bike might be moving a due to small disturbances during startup The propulsion motor seems to be the most unstable at this point because the speed controller on the motor controller card have some small stationary errors fluctuating with the various components temperature 5 7 Fan To give cooling to the PC and other boards and components a fan was mounted in the CyberBike suitcase wall This installation is particularly useful during tests of the bike when the suitcase should be closed An old and well worn 12V fan was an inexpensive and easy solution see Figure 5 8 To be able to get the bottom plate up from the the suitcase which is useful to access for instance the CF card slot under the Wafer 9371A a part of the bottom plate was cut out to make it pass the fan Figure 5 8 The cooling fan mounted a
10. Header J6 controls the D A output and jumpers are set like shown in Table 3 7 to give a bipolar 5V output range Other jumper settings could give 10V bipolar unipolar 0 5V or 0 10V or even programmable unipolar or bipolar see Diamond Systems Corporation 2003 p 10 The last pair of pins the R position controls the Power up reset mode and is left open to reset to mid scale in bipolar mode I O Register Map The DMM 32 AT occupies 16 bytes in the system I O address space In Diamond Sys tems Corporation 2003 chap 6 and 7 these registers are described This is interesting when the Universal Driver from the vendor is not used which is the case for the original devc dmm32at driver made by Loftum Furthermore some problems on the DMM 32 AT see Section 6 5 made it necessary to understand how these registers work hence a summary of these chapters is following next Digital to Analog 3 1 Hardware AGND 1 2 AGND Vin0 3 4 Vin 16 Vinl 5 6 Vin 17 Vin2 7 8 Vinl8 Vin3 9 10 Vin 19 Vin 4 11 12 Vin 20 Vin 5 13 14 Vin 21 Vin 6 15 16 Vin 22 Vin 7 17 18 Vin 23 Vin 8 19 20 Vin 8 Vin 9 21 22 Vin 9 Vin 10 23 24 Vin 10 Vin 11 25 26 Vin 11 Vin 124 27 28 Vin 12 Vin 13 29 30 Vin 13 Vin 144 31 32 Vin 14 Vin 15 33 34 Vin 15 Vout 3 35 36 Vout 2 Vout 1
11. NTNU Innovation and Creativity CyberBike Audun S lvberg Master of Science in Engineering Cybernetics Submission date June 2007 Supervisor Amund Skavhaug ITK Norwegian University of Science and Technology Department of Engineering Cybernetics Problem Description The Department of Engineering Cybernetics at NTNU wish to complete a project on an autonomous unmanned bicycle the CyberBike which have been subject to development by the department s students during the past few years Work that has to be done to reach this goal involves software development with real time requirements use of real time operating systems electronic hardware development and circuit analysis control theory mechanical engineering power electronics The candidate have to i a gain an understanding of the existing system independent basis point out and suggest what has to be done as far as time permits implement the suggested solutions Assignment given 08 January 2007 Supervisor Amund Skavhaug ITK CyberBike Master s thesis Audun Solvberg audunsol stud ntnu no Engineering Cybernetics Industrial Computing Supervisor Amund Skavhaug Hand in date June 8 2007 NTNU Norwegian University of Science and Technology Faculty of Information Technology Mathematics and Electrical Engineering Department of Engineering Cybernetics TRONDHEIM Preface Now my leg of the C
12. 37 38 Vout 0 Vref Out 39 40 A D Convert 41 42 Ctr 2 Out Dout 2 Dout 1 43 44 Ctr 0 Out Dout 0 Extclk Din 3 45 46 Extgate Din 2 Gate 0 Din 1 47 48 Clk 0 Din 0 5V 49 50 Dgnd Table 3 6 Header J3 analog I O pinout on DMM 32 AT Jumper settings Output Range 10 5 P B R 5V 0 1 0 1 0 Table 3 7 Header J6 configuration for D A output on DMM 32 AT 28 CHAPTER 3 SYSTEM DESCRIPTION The I O register map is shown in Table 3 8 Base address is set to 0x300 in this case due to the J7 settings mentioned earlier Base Write Function Read Function 0 Start A D conversion A D LSB bits 7 0 1 Auxiliary digital output A D MSB bits 15 8 2 A D low channel register A D low channel register readback 3 A D high channel register A D high channel register readback 4 D A LSB register Auxiliary digital input port 5 D A MSB channel register Update all D A channels 6 FIFO depth register FIFO depth register 7 FIFO control register FIFO status register 8 Miscellaneous control register Status register 9 Operation control register Operation status register 10 Counter timer control register Counter timer control reg readback 11 Analog configuration register Analog configuration reg readback 12 8254 8255 register 8254 8255 register 13 8254 8255 register 8254 8255 register 14 8254 8255 register 825
13. Auto Detect Hard Disks In the menu showing up the CF card should be visible as secondary master In the Advanced CMOS Setup make sure the PC is set up to boot from IDE 0 as it s first specified boot device Save and exit BIOS setup The CyberBikePC should now boot up in Linux Login as cyberbikerider with password deluxe same as the bicycle brand To get root privileges run the command through sudo or just type su to switch to super user The super user password is the same as the regular user to keep it simple and because it normally would be the same person To get back into QNX type halt as superuser or through sudo and shut the power off when told to Basic Input Output System 121 122 APPENDIX HOW TO BOOT CYBERBIKEPC IN LINUX e Remove the CF card e Insert the gray hard drive ribbon cable into the 44 pins EIDE connector on Wafer 9371A e Power up the PC again hit DEL to enter setup and do the same procedure as when booting Linux The hard drive should be detected as primary master e Sometimes it was experienced that the BIOS didn t detect the newly changed connections the first time but this was solved by booting down the pc power it off and boot up again If Linux is something that has to be used frequently and it is desired to keep both OSes available without all this rebooting a boot loader that makes the user choose which operating system to boot during startup should
14. Long series of probing with multi meter may sooner or later result in short circuiting of pins lying close to one another or probings with the multimeter set up incorrectly Therefore the connections in the system should be kept as easy to understand and as well arranged as possible If an earlier realization of how much additional connections and probing that had to be done a replacement of the connection system in the CyberBike s suitcase might have been a good idea An example is to replace the long pins from the Baldor TFM 060 06 01 3 with a connector for soldering on a PCB The circuit board would hold all the wires and route them correctly to connectors which in turn could be connected by short dedicated ribbon cables to DMM 32 AT and the terminal block on the suitcase s outside The layout of the PCB could have been simulated in software to point out and remove a lot of the errors before connecting it to the physical system Using a Programmable Logic Device PLD such as a FPGA s or GAL could also be done to ease tasks like the pendulum limit switches or simply to wire the connections between two points in software before burning the circuit to the PLD 7 5 Reflection Defects on the I O card DMM 32 AT used for data acquisition A D converting and to output motor reference voltages D A converting were pointed out during the work on this thesis These errors entry time and cause are unknown but what is known is
15. Tt is assumed that the turning rate is estimated through the measurement of the steering angle The heading state is therefore omitted in the A matriz and the turning rate is measured in the C matria from the steering angle and angular velocity This should be altered if the turning rate is measured with other principles such as a gyro This would have some impact on the solution of this thesis owing to the fact that a gyro actually is used to measure the yaw see Section 3 1 7 and Section 4 1 3 Matlab and Simulink model The main Simulink model made by Bjermeland 2006 is shown in Figure 2 4 To make the model work as it is supposed to it is necessary to run the files shown in Table 2 1 These files are automatically loaded into the Simulink model at initialization A simulation GUI is popping up when the simulation is finished see Figure 2 5 This could be deactivated in the menu that shows up when double clicking on the Plotting block located at the upper right corner in Figure 2 4 Number in sequence File gt Generates 1 load_parameters m gt parameters mat 2 initModel m gt bikesystem mat 3 get_lqg m kalman mat lqr mat gt speed mat Table 2 1 Matlab files to initiate the parameters used in the Simulink model The solver used in Simulink for this model is a Runge Kutta fixed step numerical algorithm see Egeland and Gravdahl 2002 chap 14 Graphical User Interfa
16. input 2 1 26 Ref Input X2 2 2 Pendulum 28 Current monitor 28 Tacho in 2 Pendulum 30 30 Disable input EmergencyButton con2 2 Pendulum 32 Fault out OC 32 Ref GND Connector 1 2 Pendulum 2 V DC 2 V DC 24V Battery Power source 2 Pendulum 4 Motor Al 4 Power Motor A1 Pendulum Motor V 2 Pendulum 6 Motor A2 6 Power Motor 2 Pendulum Motor V 2 Pendulum 8 DC 8 DC 1 Steering 10 NC 10 Current monitor 1 Steering 12 Tacho in 12 Fault out OC 1 Steering 14 Ref Input X2 3 14 Disable input EmergencyButton con2 1 Steering 16 Ref GND 16 Ref Input X2 4 1 Steering 18 V DC 18 V DC 24V Battery Power source 1 Steering 20 Power Motor 1 20 Power Motor Al Steering motor V 1 Steering 22 Power Motor A2 22 Power Motor A2 Steering motor V 1 Steering 24 DC 24 DC 1 Steering 26 DC OV Battery Power source 26 0V DC 1 Steering 28 V DC 28 V DC 24V Battery Power source 1 Steering 30 Fault out 30 Synchron input 1 Steering 32 14V 50mA out EmergencyButton conl 32 14V 50mA out Table E 3 Connection table for Baldor TFM 060 06 01 3 3 Terminal Blocks 131 E 3 Terminal Blocks APPENDIX CONNECTION TABLES 132 Outside Inside Card unit Pin Block Terminal Card unit Pin Comment Propulsion tacho Signal 1 1 BALDOR 2 4 Measurement signal for speed control on BALDOR card Potmeter steeri
17. As noted by Bjermeland 2006 p 90 the placement of the steering motor to the left of the frame is violating this symmetry But the introduction of the batteries which are heavy compared to most elements on the bike will have a considerable effect on the rear frame s center of mass It is also stated that constant velocity is a consequence of the linearized equations Another simplification is that the bike is moving on a level surface i e the pitch angle are assumed to be zero at all times 2 1 2 Modeling the different parts The position and parameters of the five rigid parts listed in the previous section are described as rotation and transformation matrices relative to an inertial frame 7 Then the rear wheel and rear frame and the front frame and front wheel are connected together to reduce the number of mass centers from five to three The positions of these mass centers are Rear frame and rear wheel Trw Zr Tm Yrw 2rQr 2 2 Zr where sin v cos 0 sin sin 0 sin cos v sin 0 sin v cos 6 CHAPTER 2 BACKGROUND 1 e Trw and yr forms the x and y component of the vector rL which is the position of the point where the rear wheel is in contact with the ground surface Z y and zr are the wheel position of the center of mass e is the lean angle of the rear wheel rear frame from the vertical e 1 is the rear frame s yaw an
18. Fun Your source for prototyping supplies online 2005 URL http www sparkfun com Accessed 16 Feb 2007 the free Encyclopedia Wikipedia Compactflash online URL http en wikipedia org wiki Compact_flash Accessed 3 Jun 2007 Xsens and MTx Low Level Communication Documentation Revision E Xsens Technologies B V Capitool 50 P O Box 545 7500 AM Enschede The Netherlands March 2 2005 URL http www xsens com Xsens and User Manual and Technical Documentation Xsens Technologies B V Capitool 50 P O Box 545 7500 AM Enschede The Netherlands revision g edition March 2 2006 URL http www xsens com 112 CHAPTER 9 CONCLUSION Litterature Alan Burns and Andy Wellings Real Time Systems and Programming Languages In ternational Computer Science Series Pearson Education Limited Edinburgh Gate Harlow Essex CM20 2JE England 2001 URL http www pearsoned co uk Brian W Kernighan and Dennis M Ritchie The C Programming Language Prentice Hall Software Series Prentice Hall P T R Prentice Hall Inc Upper Saddle River NJ 07458 second edition 1988 William Stallings Operating Systems Internals and Design Principles Pearson Prentice Hall Pearson Education Inc Upper Saddle River NJ 07458 5 edition 2005 113 114 CHAPTER 9 CONCLUSION Appendix A Contents on CDROM The contents on the appended CDROM is Code contains the drivers and various testprograms f
19. GPS is currently not used but available for future efforts made on this area Some hardware related tasks was carried out as connecting and implementing func tionality to the pendulum limit switches installation of a emergency stop switch and a power switch purchasing and installation of two 12V batteries and a cooling fan An operating system upgrade resulted in replacing the CyberBikePC s storage device a integrated circuit compact flash card with a mobile hard disk drive Installation of a motor for supply ing torque to the rear wheel included setup and tuning of a hardware based velocity controller in a Baldor TFM 060 06 01 3 servo module However this task is not to be considered as accomplished due to some unsolved problems on the system I O card s output channels giving the motor controller card its reference voltage A bike model and controller realized in Simulink was made by Bjermeland Hence communicaton between Simulink and the device drivers had to be established and this was realized by using S functions and Real Time Workshop Finally the controller could be connected to the actual bike but there was too little time left to explore this thor oughly and make the system work properly However a foundation is laid for further development of the control strategy hopefully storing a bright future for the CyberBike ii Chapter 1 Introduction 1 1 Motivation The work on the CyberBike started back in th
20. O Agnd to pendmotor Vref BALDOR 2 326 X2 2 D2 15 Connects I O Vout 3 da3 to pendmotor Vref via switches BALDOR 1 14 X2 3 DMM 32 AT 3 1 Connects I O Agnd to steermotor Vref BALDOR 1 a16 X2 4 DMM 32 AT 03 37 Connects I O Vout 1 dal to steermotor Vref BALDOR 2 b2 X2 5 DMM 32 AT 3 1 Connects I O Agnd to propmotor Vref BALDOR 2 22 X2 6 DMM 32 AT 113 38 Connects I O Vout 0 da0 to propmotor Vref Table E 4 Connection table for the terminal blocks X1 and X2 4 3 32 133 E 4 J3 on DMM 32 AT CONNECTION TABLES APPENDIX E 134 On DMM 32 AT Connected to Further connected to Comment Pin Name Block Terminal Card unit Pin 1 Agnd X1 17 Pendulum switch B2 In 1 Agnd X2 3 BALDOR 1 14 Vref steermotor 1 Agnd X2 5 BALDOR 2 b2 Vref propulsion motor 2 Agnd X1 13 Tacometer steering GND 2 Agnd X1 14 Tachometer pendulum GND 2 Agnd X1 25 Potmeter steering OV 2 Agnd X1 26 Potmeter pendulum OV 5 Input Channel 1 X1 2 Potmeter steering Signal 7 Input Channel 2 X1 3 Potmeter pendulum Signal 9 Input Channel 3 X1 4 Tachometer steering Signal 11 Input Channel 4 X1 5 Tachometer pendulum Signal 13 Input Channel 5 X1 6 Easy Available 19 Differential Input Channel 8 X1 8 X1 1 Propulsion tacho 20 Differential Input Channel 8 X1 9 X1 12 Propulsion tacho 35 Vout 3 X1 18 Pendulum switch B1 In 37 Vout 1 X2 4 BALDOR 1 a16 Vref steermotor 38 Vo
21. Power sources Left Farnell LS 30 Right TTi EL302T 6 2 The pendulum motor Fossum 2006 p 31 did not run a test drive on the pendulum motor in a decent way early in his project because the motor was mounted too elaborately But he states that the motor have been connected to a power source and tested in both directions to see that it worked Later he told that the motor was having trouble lifting the pendulum when the 2kg weight was placed in its outermost position and the pendulum was lying down to its side Therefore it was decided to unmount the pendulum motor to get a real test of it without the pendulum The way it was mounted made the work somewhat complicated 2 own words in Norwegian was p en skikkelig m te 6 2 The pendulum motor 85 and the pendulum had to be removed from the motor after both were unmounted from the bike Without load the motor seemed to work fine when applying 24V to its terminals Further the idea was to put the motor in a vise and use a torque wrench on the axis But the risk of damaging the motor by allowing too much current to flow through it while blocking the armature from rotating made another approach more attractive The alternative that came up was to tie a rope with a weight at its end on to the axis while the motor was set in the vise An approximation of how heavy the load would be had to be calculated The weight my is 2kg and have a length of about 9cm an
22. Some capacitators to avoid transients when the switch is trigged is probably wise Even if the switches are providing a high or low signal it should not be connected to the digi tal I O channels on DMM 32 AT without some current limiting circuitry or decoupling mechanism The D A output channels which is connected to the switches other end is capable of delivering more current than the digital I O can handle 4 5 1 Testing and debugging The soluton did not work as expected for the right switch B2 A lot of probing and testing was done to point out where the error was This appeared to be more difficult SUGGESTED SOLUTION CHAPTER 4 60 BALDOR Vref Vref a 2 a26 2 c26 DMM 32 AT Agnd Vout3 73 1 73 35 1 D2 gt gt 17 18 Terminal Block X1 19 20 15 16 1 Terminal Block X2 Pendulum 48 B2 Bl NO in NO i Pendulum frame Figure 4 11 Circuit diagram of first connecton of the pendulum limit switches Terminal block connections are indicated 4 5 Pendulum Limit Switches 61 than expected No wrong connections according to Figure 4 10 and Figure 4 11 could be detected It is worth noting that pin 1 on DMM 32 AT Agnd was connected to the input pins on B2 after the connection was forked off to supply the negative r
23. a resource manager see Section 2 2 2 based on the code for the Spark Fun IMU made by Loftum 2006 and the example code delivered with the kit from Xsens The latter was written in C making it a natural choice to use that language for the rest of the driver It had small impact on the code in this case First the example code was compiled in QNX to make sure it really was compatible The only change that had to be made was in MTComm cpp where non POSIX command had been used see codesample Code sample 5 1 The solution to the compile error was found by searching on OpenQNX A new C project was made in the QNX Momentics IDE called devc mt be fore the files MTComm cpp and MTComm h was copied into it with the changes shown in Code sample 5 1 Then the code from devc imu c and from mt example cc from the 66 CHAPTER 5 SOLUTION Code sample 5 1 The only change made in MTComm cpp to make it compile in QNX Disable hardware flow control options c_cflag CRTSCTS Changed to Disable hardware flow control options c_flag IHFLOW options c_flag IHFLOW vendor was merged into the master driver file devc mt cc to reuse some already tested and developed resource manager code and at the same time make use of the example calls to configure the MTi communication The resource manager was built around the same structure as in the Spark Fun IMU case Two threads were used waiting for re quests by the d
24. bad idea to mix the control and safety related functions toghether As an example consider the case where the control system stops as a consequence of a software error segmentation fault overflow etc the safety function might not be executed and the the last value written to the DMM 32 AT would remain on its output channels until it is powered down 4 5 Pendulum Limit Switches 59 Baldor Ref Ref DMM 32 AT Figure 4 10 Loftum s 2006 connection proposal for the pendulum limit switches Loftum 2006 also argues that the proposed hardware solution does not consume any CPU That is true but with an interrupt based solution the processing power used for this function would be minimal during normal operation This is based on the assumption that the pendulum angle is kept small when the CyberBike is operating under normal and stable conditions and that the limit switches are to be used only when the system is about to fail Figure 4 11 shows a circuit diagram of how the function was implemented at first It is the same system as shown in Figure 4 10 but with some added information on how it is connected via the terminal block X1 and which pins are connected where Even if the diodes is providing the pendulum angle limiting function the signal from the switches may still be connected to the input ports of the DMM 32 AT to provide information about switch activation to the control system software if it is desired
25. be installed An example of such a bootloader is grub but how the QNX compatibility is for that bootloader is neither explored nor tested Appendix D How to boot CyberBikePC in DOS The CyberBikePC is capable of booting from USB memory which makes a straightfor ward option to connecting CDROM or floppy drives to test the pc with other OSes Note changes to the BIOS settings could inflict the ability to boot from USB devices If such problems occur refer to Technology Corp 2006 chap 4 First an USB flash memory has to be configured to look like a DOS boot diskette This is the not so quite straightforward part of the task but at last a simple solution was found 1 Put an USB flash memory without any important content into an available USB connector on a PC running Windows XP Download windows_enabler zip from Hewitt 2002 or from the CDROM see Appendix A Unzip the file Make sure all files ends up in the same folder Start the application by double clicking on Windows Enabler exe An icon similar to the one just double clicked will show up in the system tray Left click on the icon in the system tray bar to activate the Windows Enabler application The icon should now be showed with the text On in the foreground Open My Computer in XP and right click on the icon representing the USB flash memory Choose format in the drop down menu In the window that now appears sele
26. channel 0 Then the positive probe of the oscilloscope was connected to J3 PIN38 to measure Vout 0 PIN40 Agnd was already connected to the oscilloscope s negative terminal 92 CHAPTER 6 TESTS AND EXPERIMENTS Running the same feature again gives a quite different output than earlier shown in Printout 6 5 Da is detected as 5 00V to 0 25V D A Output Expected A D Sampled A D Difference Pass Fail 0 16387 16385 2 PASS 1000 12188 8385 3803 FAIL 2000 7990 383 7607 FAIL 3000 3791 816 4607 FAIL 4000 406 820 414 FAIL Printout 6 5 DOS Diagnostic Test using the D A Quick Diagnostic test output while a probe are attached at the D A channel 0 The same behaviour can be observed when using the menu elements 4 D A Autocal Test and 10 D A User Select Test It looks correct when the positive oscilloscope probe is unconnected to Vout 0 and gets wrong when it is connected Setting the value to 4095 by 10 D A User Select Test while probe is unconnected gives a correct behaviour on screen range 5V and it says the output voltage is set to 4 995V But the voltage is measured to be about 0 25V Giving code 0 gives 5V output in any case Channel 3 and 1 works fine independent of the oscilloscope being connected and channel 2 doesn t work at all But it is only channel one who changes the range printed to the screen dependent on if it is connected or not In Section 3 1 4 it was stated that the B
27. computer which by the acquisition time of this project is performing most of the network activities with the CyberBikePC via Qnet Installing batteries to eliminate the other cables is also a part of the plan An RTOS developed by QSSL 2 CHAPTER 1 INTRODUCTION 1 3 Previous work The most important previous work to be mentioned here is the master s theses of Loftum 2006 and Bjermeland 2006 In Loftum 2006 basically the development of the bikes instrumentation system is described with installation of an industrial PC with QNX and creating drivers for the sensors and actuators Bjermeland 2006 is dealing with the dynamics and the mathematical aspects of the control system Fossum 2006 is describing some improvements and testing basically focusing on the work of Loftum 2006 For a further description of previous work on bicycle dynamics and modeling refer to Bjermeland 2006 chap 2 1 4 A comment on outline and language A comment on the outline of this thesis and the language used would be appropriate Both Chapter 2 and Chapter 3 is to be considered as background chapters describing theoretical studies and the CyberBike s state at the point where the work on this thesis started The next chapter is discussing some various alternative solutions which choices were made and what turned out not to work Then in Chapter 5 the final solutions are described A recommendation on further work is put in Chapter
28. disconnected from its pin on the DMM 32 AT s J3 header because the result of the autocalibration seems to be depending on the resistance on this pin This should not be a problem if the I O card gets repaired The autocal functionality is demonstrated in Printout 5 2 5 5 Pendulum limit switch final implementation The limit switches was finally connected like shown in Figure 5 4 schematic overview and Figure 5 5 detailed with terminal block connections indicated The most positive effect of the installation is that the motor will not be powered to try to push the pendel any further when it reaches its end position the frame This prevents 70 CHAPTER 5 SOLUTION Code sample 5 2 Core of the new dmm32at analog read dmm32at_analog_read functions and int dmm32at analog read double valptr int channel Step 1 Not shown includes some initialization of the A D setting structure depending on if it is a tachometer 10V or a potmeter 0 5V Step 2 setup the driver for A D operations dscADSetSettings dscb amp dscadsettings Step 3 perform A D conversioin and get sample dscADSample dscb amp dscsample adval int dscsample Step 4 not shown includes scaling of return value to a double value between 5 and 5 reused code from previous dmm32at driver int dmm32at analog write DSCDACODE val BYTE channel dscDAConvert dscb channel val return 0
29. ex PUIL TX 59018 PUW L 1 91 SI 07 61 81 LI lt gt zd Id cce 972 7 972 7 gmoa E LV Z WWa wod iva 74 CHAPTER 5 SOLUTION destroying the motor brushes which is a problem for DC motors in static operation When the pendulum motor is moving towards its endpoint it will still fall against the pendulum frame due to gravity and the speed it had when it reached the switch This was not an unexpected nor unintelligible result If the Baldor TFM 060 06 01 3 had been set up to control the speed of the pendulum motor instead of its torque the behaviour would probably be different The frame gets some rough treatment less than before but still it could be damaging to the equipment Maybe some rubber knobs to absorb some of the momentum when the pendulum hits the frame would improve this but this have not been tested In Section 4 5 connection of the switch signal into the DMM 32 AT was discussed as an option The reason for this was that it might could be used in the control system for detecting where the pendulum actually is and to calibrate the pendulum potmeter value from this signal in a startup procedure This is not implemented The most important reasons is e The switching mechanism is assumed to give a less correct impression of where the pendulum actually is than the potmeters for the particular angles The knob mounted on the pendulum bar to push the switches c
30. frame 4 The front frame handlebars and front fork 5 The inverted pendulum Figure 2 1 shows a simplified model of the CyberBike where the center of mass for all five rigid bodies are indicated This assumption neglects elasticity in the frame and other non ideal movements and deformations of the different bodies The orientation in space used in the model is shown in Figure 2 2 where the z axis is pointing upwards the x axis is pointing in the bikes running direction when the yaw angle 4 is zero CHAPTER 2 BACKGROUND Figure 2 1 Main parameters for the bike model Figure redrawn from Bjermeland 2006 Figure 2 2 Orientation within a right handed coordinate system 2 1 The CyberBike model 5 For small angles a rotation matrix could be approximated as shown in Equation 2 1 Re Rep Ry 0 Ro e cosy siny 0 cos 0 sind 1 0 0 snw cosy 0 0 1 0 0 cosp sing 0 0 1 SnO 0 cos0 0 sing coso 2 1 cos w cos 0 Sin W 4 sin 0 sin 4 cos v sin 0 sin 0 cos 0 cos 0 E N v 1 This makes the rotation matrix linear But it should be kept in mind that the model will give a large error when the system starts to operate at wider angles Another important assumption made is that the bike is symmetric at its lengthwise direction while in equilibrium This is not true for the real CyberBike
31. functionality could be used to investigate the IMU driver further The program qconn which was started at the CyberBikePC made it possible to monitor the CPU consump tion for each process there through the Momentics IDE running on the Development PC Windows XP When the serial driver was running alone it practically didn t use any CPU but as soon as the IMU driver was started they used together with the driver for terminal I O flushing printouts to the screen 100 of the available processing power This is problem because the devc velo devc dmm32at and the control algorithm RT Workshop generated code needs a significant part of the CPU time when the bike is operating Some code optimizations were performed with practically no seemingly improve ments The error was finally found to be a wrong argument passed to the IMU driver when opening the serial device The code for opening the serial device in devc imu c is shown in Code sample 4 2 Integrated Development Environment 4 1 IMU alternatives 41 The O_ NDELAY is specified as a parameter in the open call making the message passing operations read and devctl to this device non blocking Hence the reading thread in the IMU driver would check if there was any available data at the serial port and if not check again immediately Practically this thread was performing a busy loop doing less useful operations most of the time This also explains
32. measurement unit for stabilization and control of cameras robots vehicles and other equipment 3Department of Engineering Cybernetics Autonomus Unmanned Aerial Vehicle 4 1 IMU alternatives 45 Code sample 4 6 The second loop in devc imu new version Most of the error checking and terminal printouts are removed in this sample to increase readability Setting up the FORWARD qualifier for the serial device if tcgetattr fd amp termio 1 perror ImuThread tERROR when tcgetattr n termio c cc VFWD Z if tcsetattr fd TCSANOW amp termio 1 perror ImuThread tERROR when tcsetattr n while running if warningCnt gt 500 printf ImuThread tWarning high warning limit n warningCnt 0 tell the serial driver fd to return data in buffer within specified size and that it should be at least 34 characters or 1 10 second before timeout a Z is dropped missing iReadCnt readcond fd buffer sizeof buffer 34 0 0 A lot of error checking on iReadCnt not shown here Errors handled by printing an error message incrementing a warning counter variable and execute a continue to start at the top of the while loop again Find the A first bi 0 while buffer bi if bi gt iReadCnt 34 buffer bi 34 1 Z something is missing in the
33. occurrences of ZA between all the nonsense This indicates the end of a stream and the beginning of the next 40 CHAPTER 4 SUGGESTED SOLUTION Later when some adjustments of the IMU driver devc imu was tested the serial driver at the CyberBike devc ser8250 had to be restarted for a different reason Af terwards when the IMU driver was restarted it began to flush loads of measurements to the telnet terminal similar to the last two lines in Printout 4 1 Hence something is wrong about the way the serial driver is started at system boot In Loftum 2006 p 26 the buildfile for the OS image originally running at the CyberBike is shown Here we can see that the serial driver is executed with the option e which means that the stream is ASCII formatted The default option means raw output and this explains why the IMU driver suddenly worked when the serial driver was restarted without specifying any options Code sample 4 1 Part of the file buildfile velo build made by Loftum 2006 where specification of how the serial driver devc ser8250 should be started during system boot HEHHHHHHHHHHHH Script HEHHHHHHHHHHHH script script 4 display_msg QNX on Cyberbike seedres devc ser8250 e b57600 amp reopen dev serl This problem was part of the motivation for doing changes to the OS running at the CyberBikePC When the OS upgrade was done as described in Section 4 2 extended
34. start running 4 4 GPS For the CyberBike to know its absolute position a GPS module was suggested as a nice device The bike is considered to be used for PR purposes for the Department of Engi neering Cybernetics and a GPS installed on a bike which indeed is a bit uncommon extends the impression that the bike is utilizing cutting edge technology This gives room for some enhancements like using the GPS measurements for comparing and adjusting the speed measurements and navigation algorithms see Section 8 3 A GlobalSat EM 411 GPS module was ordered from ELFA 2007 for this pur pose Figure 4 7 shows this unit This is the same module used by Eriksen 2007 and Bjorntvedt 2007 in their master s theses Some benefits were drawn from the fact that three students at ITK were using similar GPS modules at the same time Figure 4 7 The EM 411 GPS module from GlobalSat The various messages that could be received and sent to the GPS module are defined in GlobalSat Technology Corporation Some specific data for the unit are given in Table 4 2 4 4 1 PCB Eriksen made a circuit diagram and PCB layout in Eagle which was also used in the Cy berBike project The layout files are included in the appended CDROM see Appendix A After etching and soldering the PCB it turned out that the photoresist was not properly removed before the tin coat was applied to the board but due to the candidates 4 4 GPS 55
35. that it resulted in a considerable retardation of the project s progression At the end the errors were partly bypassed by using channels that did work It turned out that the amount of errors inherent in the system were larger than expected at the starting point of the thesis work This in conjunction with the I O card 7 5 Reflection 101 and COM port problems and the late change of IMU strategy made too big impediments to reach the goal of a real outdoor CyberBike autonomous test run With the benefit of hindsight some questions that should be answered here is Were the choices made during this thesis reasonable Would other choices have got us closer to the goal As already pointed out the tasks involving GPS was performed somewhat too early considering that it ended up unused by the control algorithm by the end point of this thesis But if the CyberBike project is seen as a whole the introduction of the GPS is indeed useful and it was believed that the time left would be sufficient to implement useful functionality around it Also introducing the MTi at an earlier stage would have saved some development time on the original IMU This is maybe the most grave compliant to the completion of the work in this thesis But still it could be argued that the IMU had to be tested and used to explore its qualities and limitations Time is obviously generally involved in most of the issues discussed in this chapter The thesis write
36. the bike seems like the most obvious solution Some kind of remote control should be implemented anyway and an ethernet connection could be used to cover most of the demands in one link An antenna to be used for radio commuication is installed on the bike but is not being used recently But to base a solution on this technology would lead to difficulties in allocating enough bandwith to perform tasks including Real Time Workshop and the like mentioned earlier The easiest solution is probably a device to be plugged into the RJ 45 connector on the outer side of the suitcase sending the signal further through the air Then searching for WiFi cards with QNX compatible device drivers would not be an issue 8 3 Line of sight The GPS is now mounted and is communicating with the CyberBikePC but not used for anything particular Bjermeland 2006 states that a Line Of Sight LOS algorithm would fit for the bike Then a route could be given to the CyberBike by defining some waypoints and the placement calculations developed from the speed and heading angle measurements would be used to control the bike to reach these points The GPS would be necessary to correct and update the placement calculations along the way For a further description of the LOS algorithm refer to Fossen 2002 8 4 Optimization of devc dmm32at DMM 32 AT is not utilized the way it could The card has got the capabilitiy of using a FIFO memory scan sampli
37. the host It also supports different user specified baud rates and sensor update frequencies making it possible to optimize it better for the specified task Consequently there is reason to believe that the MTi would give a better result with less effort put into it than the Spark Fun IMU Hence it seems like a wise decision to start using the MTi instead of the original IMU Perhaps the MTi should have been included at an earlier stage in order to get closer to the goal of the project It should not be necessary to connect two IMU to the bike at the same time and if the MTi is present the original IMU is superfluous A voting mechanism could be implemented if both are to be used but for a non critical application like the CyberBike this is not very interesting generating an even more complex system with enhanced error possibilities 7 3 GPS When the GPS module was ordered it was not clear whether it should be used at all but it seemed like a practical and easy solution to order an extra similar module when Eriksen 2007 was sending his orders anyway He also made the layout of the PCB to connect it to a serial port which made creating the hardware easier Using his software for this project was also considered but when connecting the GPS to the CyberBikePC was about to be done using the resource manager for the IMU as a framework to get a QNX compatible driver seemed easier than to modify and integrate Eriksen s LabView solu
38. time before an A D operation is started in order to be sure to get the current data In the case of the current driver the FIFO is not enabled but actually it is still used in an one to one correspondence between sampling and reading where the FIFO contents never exceed one sample 6 6 Testing the control algorithm The control system made by Bjermeland 2006 was tested within a limited amount with the hardware Matlab S function for reading data from the devc velo resource manager was implemented and a first attempt to connect the data from the control algorithm was made Block diagram for the main blocks in the Cyberbike simulink model is shown in Figure 6 7 The main blocks is except The CyberBike just a rearrangement of the system made by Bjermeland 2006 The CyberBike block contains the S function block performing the driver communication and signal selection scaling and integrating For a tutorial in how to compile and use the S functions refer to appendices in Fossum 2006 The main code in the bike_io S function is found in the function bike io Outputs wrapper in bike_io_wrapper c and is shown in Code sample 6 2 device files are opened and closed in two functions called upon initialization and termination respectively These functions are shown in Code sample 6 3 Various results occured during the test runs of the code depending on how many devices the system was specified to sample from and a
39. type code have a special meaning Lenze 2002 13 small DC motor 12 permanent magnet motor with smooth housing 1 specification for A side for worm gearboxes SSN 55 describes the motor frame size 3 gearbox size 31 SSN31 2 motor frame form flange mounting 0 Specification B side no attachments e g brakes tachometers or pulse encoders Technical specification is shown in Table 3 9 Name Variable Value Unit Motor Rated power B 200 W Rated torque 0 64 Nm Moment of inertia J 32 cm Rated rotational speed Np 3000 rpm Outer diameter dout 80 mm Motor weight mass Mmot 3 7 kg Rated current I 11 8 A Armature resistance RA 0 19 Q Permissible radial load FR 340 N Permissible peak current 77 A Gear continuous torque 16 Nm Rated output torque 2 Nm Ratio i 5 Operating factor 5 15 Table 3 9 Specification for the propulsion motor and gear Motor for the inverted pendulum The pendulum motor is a ITT GR 63 x 55 according to Loftum 2006 Some specific data is given in Table 3 10 On the motor it is mounted a planetary gear with ratio 79 1 32 CHAPTER 3 SYSTEM DESCRIPTION Figure 3 8 The propulsion motor a Lenze Worm Geared motor Figure 3 9 The pendulum motor an ITT GR 63 x 55 TG11 with planetary gear Picture taken from Fossum 2006 Supply voltage 24V Nominal current Nominal rotating speed 3350min Table 3
40. 00 samples per second maximum sampling rate e 512 sample FIFO for reduced interrupt overhead e Auto calibration of all input ranges under software control Analog Outputs e 4 analog output channels with 12 bit resolution 5mA max output current e Multiple fixed full scale output ranges including unipolar and bipolar ranges e Programmable full scale range capability e Auto calibration under software control In addition the DMM 32 AT has 24 bidirectional digital I O lines a 32 bit counter timer for A D pacer clock and interrupt timing and a 16 bit general purpose coun ter timer both with programmable input sources and multiple board synchronization capability Headers In this section it is attempted to give a short explanation of the DMM 32 AT s 9 headers with respect to the most CyberBike relevant features An overview of the headers is given in Table 3 4 The analog I O pins are located at J3 and the digital ones at the J4 header The latter is unconnected in the CyberBike s case but should be ready for use if digital measurement units are to be connected in the future The analog input channels are configured as 16 single ended i e referenced to analog ground plus 8 differential i e measured by subtracting the low input from the high input by setting the J5 jumpers as shown in Table 3 5 The resulting pinout on the analog out header is shown in Table 3 6 Differential input is useful when common mode noise rej
41. 10 Specific data for the pendulum motor read from its nameplate 31 Hardware 33 Steering motor The steering motor is an ITT GR 53 x 58 TG11 Its specific data is given in Table 3 11 Figure 3 10 The steering motor ITT GR 53 x 58 TG11 Picture taken from Loftum 2006 Supply voltage 24V Nominal current 2 9A Nominal rotating speed 3000min Table 3 11 Specific data for the steering motor read from its nameplate 3 1 7 IMU Spark Fun The IMU see Figure 3 11 consists of a small 2x2 inch motherboard and 3 gyro cards see Figure 3 12 The motherboard contains a PIC16F88 with a built in DAC and a CD74HC4067 multiplexer The multiplexer is collecting the 5 measurements provided by each of the 3 gyro cards and sends them to the wC which in turn sends them out on its UARTI18 When the IMU receives an ascii character 7 it starts to deliver data over the serial connection The 34 bytes messages are delivered in a speed of 23 5Hz and have a 16Inertial Measurement Unit 17 microcontroller 18Universal Asynchronous Receiver Transmitter 34 CHAPTER 3 SYSTEM DESCRIPTION Figure 3 11 IMU with 6 Degrees of Freedom from Spark Fun Electronics Picture is copied from Loftum 2006 Figure 3 12 Gyro card for the IMU shown from both sides from Spark Fun 2005 3 2 Software 35 specified sequence The data stream begins with the ascii character A followed by the 16 DA
42. 1_4 zip online URL http www simtel net product php id 13585 cid 47 SiteID simtel net Accessed Jun 2007 111 Hans Olav Loftum Styresystem for kybernetisk sykkel instrumentering for styring av en tohjuls herresykkel Master s thesis Norges teknisk naturvitenskapelige universitet NTNU Trondheim June 2006 Joachim Marder online Jul 2001 URL http www jam software com software html Accessed 27 May 2007 Maxim Dallas Semiconductors MAXIM 5V Powered Multichannel RS232 Driver s Receivers Online 2006 URL http datasheets maxim ic com en ds MAX220 MAX249 pdf Accessed 06 Mar 2007 Tor Onshus Instrumenteringssystemer Institutt for teknisk kybernetikk NTNU Norges teknisk naturvitenskapelige universitet Trondheim 4 edition Januar 2006 URL http itk ntnu no ansatte Onshus _Tor OpenQNX OpenQNX The QNX Community Portal Site online URL http www openqnx com Accessed 3 Jun 2007 QSSL 10 Steps to your first QNX program Quickstart guide QNX Software Systems 127 Terence Matthews Crescent Ottawa Ontario Canada K2M 1W8 second edition Sept 2005 QSSL Usb software development kit online URL http www qnx com developers docs 6 3 0SP3 ddk_en usb copyright html Accessed 4 Jun 2004 QSSL Qnx developer support qnx documentation library online 2007c URL http www qnx com developers docs momentics6211_docs neutrino libl_ref Ac cessed 23 Apr 2007 Spark
43. 4 8255 register 15 8254 8255 register 8254 8255 register Table 3 8 DMM 32 AT I O Register Map from Diamond Systems Corporation 2003 chap 6 The available I O devices that can be accessed in the last 4 registers in Table 3 8 are depending on the last two bits in the BASE 8 REGISTER the MISCELLANEOUS CONTROL STATUS REGISTER 00 8254 type counter timer 01 8255 type digital I O 10 Reserved 11 Calibration The control bit settings are shown in front of the device name in the above list In the CyberBike s case the last setting is the most interesting because this is the one used in the initialization procedure of devc dmm32at The first register BASE 12 would then be the data register in an EEPROM read or write operation or a data register in a TrimDAC write operation The next BASE 13 would specify an address in the range 0 to 127 by its 7 LSB Register BASE 14 is used to initiate various commands related to auto calibration and register BASE 15 is used to set an EEPROM Access P Electrically Erasable Programmable Read Only Memory Least Significant Bit 3 1 Hardware 29 Key to help preventing accidental corruption of the EEPROM contents BASE 15 is also used to read back the FPGA Revision Code Analog ranges and resolutions The DMM 32 AT uses 16 bit for analog input which provides a resolution of 153uV per change in LSB when the full scale range is set to 5V as shown i
44. 4 3 1 Placement A new propulsion motor had to be mounted on the bike The intention was to place it where the old one was seated as shown in picture Figure 4 5 Figure 4 5 The CyberBike as it looked by the start of this work As it can be seen from Figure 4 5 the front mudguard is nearly touching the tachome ter on the motor The tachometer and its cables should be shielded from the front wheel in some way The solution to this was to mount the propulsion motor on the vertical tube Another problem that got solved by moving the motor was a conflict between the chain and the battery frame When the motor is located at the upside of the pedal gear it will not lower the chain and thus avoiding the conflict between the chain and battery frame as shown in Figure 4 6 The disadvantage by this solution is that the bike is getting an even higher center of gravity making it less stable Still this change should not make a crucial difference in the bikes stability 4 3 2 Connection to Baldor 060 06 01 3 The motor was connected to the Baldor 060 06 01 3 at the M1 and M1 pins This is documented in Table E 3 in Appendix E 4 3 Propulsion motor 53 Motor Hub gear Hub gear Motor Pedal gear Battery frame Totor gear Battery frame Figure 4 6 Left Chain is not in conflict with battery frame black part Right here we have a conflict When applying a voltage across th
45. 5232 blocks 1007616K Printout 4 7 Loading the OS image into the flash memory Printout 4 8 Message appearing on the CyberBikePC after the putting new OS image on the CF card dinit hb dev hd2 Printout 4 9 Solution suggested by Loftum 2006 but not sufficient this time 4 2 OS upgrade on CyberBikePC 51 Then several attempts of getting the CyberBikePC to boot from the flash card were done including e searching the internet for similar problems and suggestions e putting the old original image onto the CF card again e using IDE card readers in the slot on the QNX host workstation instead of the USB card reader e calling Loftum for help These attempts ended in an assumption that the card reader were playing tricks with the boot sectors on the CF card Loftum had used a different card reader but the QNX workstation most of the steps listed in his thesis and even the ifs file were the same Hence the card reader was causing the problems If another card reader was available and even better the same as Loftum used it should have been tried in order to ensure that the source of the problem to be found But after spending too much time trying to solve this problem alternative solutions became more attractive This included installation of a mobile hard drive and is described in Section 5 1 Compact Disk Read Only Memory 52 CHAPTER 4 SUGGESTED SOLUTION 4 3 Propulsion motor
46. 8 before the conclusion part in Chapter 9 This feels natural for a project with a considerable part of work left before it has reached its goal This thesis is written in English for two main reasons The first is that the candi date wanted to gain the experience on carrying out a large technical report in English realizing that the close future as an employee includes a considerable amount of writing on technical issues in this language And second the realization of an autonomous bicy cle controlled by using an inverted pendulum substituting a leaning rider has interests beyond NTNU and Norway Chapter 2 Background 2 1 The CyberBike model As previously mentioned Bjermeland 2006 has developed a mathematical model of the CyberBike and a control algorithm that has been tested in simulations on the mathe matical model To be able to connect the work done by Bjermeland and Loftum into a complete functioning system some understanding of the work done is necessary This section gives a short summary of the contents of Bjermeland 2006 The task of his thesis was to develop a model a controller and a simulator for the bicyle using steering and leaning the inverted pendulum as the manipulated variables 2 1 1 Important assumptions and simplifications Some assumptions and simplifications were made in the bike modeling process First the bicycle is divided into five rigid bodies 1 The front wheel 2 The rear wheel 3 The rear
47. 9UIOUDeT 601518 80119945 19390304 STeUIUII91 STBUTULIO J9MO T 128 APPENDIX CONNECTION TABLES Terminal Connection 16 17 18 19 20 21 22 23 24 25 26 Tachometer propulsion Potmeter steering signal Potmeter pendulum signal Tachometer steering Tachometer pendulum Tachometer propulsion GND Tacometer steering GND Tachometer pendulum GND Pendulum switch B2 NC out Pendulum switch B2 NO out Pendulum switch B2 in Pendulum switch B1 in Pendulum switch B1 NC out Pendulum switch B1 NO out Potmeter steering 5V Potmeter pendulum 5V Potmeter steering Potmeter pendulum Table E 2 Sorted two column version of Table 2 Baldor 129 E 2 Baldor CONNECTION TABLES APPENDIX E 130 Pin row Pin row a Axis Motor Pin Name Connected to Pin Name Connected to Connector 2 3 Propulsion 2 Ref Input X2 5 2 Ref Input X2 6 3 Propulsion 4 Tacho in X1 1 4 Disable input EmergencyButton con2 3 Propulsion 6 NC 6 Current monitor 8 NC 8 NC 10 NC 10 NC 3 Propulsion 12 Fault out OC 12 NC 3 Propulsion 14 Ref GND X1 12 14 NC 3 Propulsion 16 V DC 24V Battery Power source 16 V DC 3 Propulsion 18 Power Motor Al 18 Power Motor A1 Propulsion Motor V 3 Propulsion 20 Power Motor A2 20 Power Motor A2 Propulsion Motor V 3 Propulsion 22 DC OV Battery Power source 22 DC 24 NC 24 NC 2 Pendulum 26 Ref
48. ASE 15 is controlling an EEPROM Access Key Register In Diamond Systems Corporation 2003 p 25 it is stated that The user must write the value OXA5 binary 10100101 to this register each time after setting the PAGE bit in order to get access to the EEPROM This helps prevent accidental corruption of the EEPROM contents Assuming the PAGE bits mentioned is the last two bits in the MISCELLANEOUS CONTROL REGISTER BASE 8 P1 and this might be an error in the in the init_ dmm32at function in the original devc dmm32at driver code see Code sample 6 1 Code sample 6 1 The contents of init dmm32at in the DMM 32 AT driver devc dmm32at out8 BASE_ADDR MISC_CTL_REG 0x23 reset and calibration out8 BASE_ADDR MISC_CTL_REG 0x00 un reset out8 BASE_ADDR 0P_CTL_REG 0x00 operation ctrl reg out8 BASE ADDR AN CONF REG 0x39 5 5V bipolar 6 6 Testing the control algorithm 93 In the first code line the value 0x23 binary 100011 is set to this register The last two bits is controlling the paging of the calibration device to the last 4 registers in Table 3 8 It is set to zero straight afterwards in the second line but an error might have happened as a consequence of not writing the specified value 0xA5 to the EEPROM Access KEY REGISTER Another possible but probably insignificant error in the original devc dmm32at driver is that the FIFO memory never becomes reset This should be done each
49. C measurements 5 measurements from 3 units plus battery voltage shown in the following list 1 Pitch Rate out Pitch 2 5 V Pitch Temperature Pitch YFilter Pitch XFilter Roll Rate out Roll 2 5 V Roll Temperature O N C Ct A C N Roll YFilter o Roll XFilter E E Yaw Rate out N Yaw 2 5 V CD Yaw Temperature EN Yaw YFilter Yaw XFilter 16 Battery Voltage The data stream is ended with an ascii Z providing a simple way to synchronize the data stream 3 2 Software The operating system running on the CyberBikePC at the starting point of this thesis work was a minimal QNX Neutrino 0519 image set up by Loftum 2006 Only the most important features of the operating system was included in order to keep the system simple and small For instance no graphical user interface usually Photon in the QNX case was installed Some drivers were made to provide measurement data to the control algorithm These are shown in Figure 3 13 The drivers are made as resource managers each providing a set of device file names under the dev directory see Section 2 2 2 Operating System 36 CHAPTER 3 SYSTEM DESCRIPTION Control algorithm devc velo devc dmm32at devc imu DMM 32 AT IMU Sensors and actuators Figure 3 13 Schematic overview of
50. CyberBikePC When powering up the CyberBikePC DEL was hit to enter BIOS setup and the USB stick was entered as the first boot device Save and exit from the BIOS setup menu made the installation process begin shortly afterwards The installation procedure is made as a guided tour through the various settings by Ubuntu The only differences made from the default settings was to uncheck the Ubuntu desktop box to get a 88 CHAPTER 6 TESTS AND EXPERIMENTS minimal installation and to not set up a swap disk The latter choise was based on the fact that a normal compact flash card does not allow more than 10 000 to 1 000 000 write cycles Wikipedia and that the number of writing cycles to a Linux swap disk would probably exceed this limit fast and shorten the expected lifetime of the CF card The CyberBikePC was booted into Linux as described in Appendix C and a root user and a regular user cyberbikerider was created both with password deluxe to keep things simple 6 3 2 Testing of COM2 The serial ports were tested by simply reading from the serial devices at the terminal prompt like shown in Printout 6 2 Here the GPS device was used as the signal source for two reasons The first one is that it sends nice ascii coded messages at a slow and easy to read rate Second it does not need to receive any messages to start delivering data in contrast to for instance the Spark Fun IMU which needs to receive
51. F memory probably related to the card reader that was used This is described in detail in Section 4 2 5 1 1 Installation of hard drive ordinary Fujitsu MHK2060AT Fujitsu 1999 hard disk drive was mounted to the EIDE slot on the Wafer 9371A The disk was an older mobile 2 5 inch 44 pins ATA with approximately 6GB storage space This is not very much for a new laptop but for the CyberBikePC it should be more than sufficient The reasons for choosing this disk were simple It had already done its duty on a robot developed at ITK participating in an Eurobot competition some years ago and the disk was now unmounted and not used anymore hence a very cheap alternative for this project At this point the Fujitsu FMHK2060AT mobile hard disk was plugged into the stationary host workstation instead of its current disk drive and a QNX Neutrino RTOS 6 3 0 SP3 CD were put in its CDROM station The IDE slot at the workstation got 40 pins hence the 4 pins for powering up the disk needed to be connected elsewhere simple converter with a Molex plug for power was used for this purpose see Figure 5 2 QNX was then installed at the hard disk as described in QSSL 2005 chap 3 At the point where the installation procedure wanted to reboot the system for the first time the PC was entirely shut off instead of rebooted and the disk was unplugged from the PC and put into the CyberBikePC This was done because QSSL 2005 stated that Af
52. Hardware uec rq dene de eek es ei Ge onde 19 3 7 Power supply uox 9e Rok ee be ee eae ES 19 3 12 COMP LEE 2555 3 Seed Ga ab A a 19 o a Ay ent A 23 A O A A Rh Rab 24 3 1 5 Motor controller card 29 SILO MOtOrs 2o ees Bek ay Bo een 30 Spark E n ass ot ue Eq ance 33 iii 2225 SOOLGWALG 4 x Ace Monet AO ns c SANA e Suggested solution 4d IMU alternatives xot step ARD a ee ee ee 411 RS 232 to UART transceiver 412 Driver assuesi as GR Sha AE iex 41 3 Ose Xsens crags Ae deus Senda Gill cen 4 2 OS upgrade on the 4 2 1 First attempt New OS image 4 3 Propulsi n Moto nm Pe bee wok ee Dn ew eee 43 1 Placement ca A aka de Ree a 4 3 2 Connection to Baldor 060 06 01 3 4 4 GPS a ar ped o Dine 4 POB e LE deg 4 4 2 The devc gps 4 5 Pendulum Limit Switches 020002200004 4 5 1 Testing and debugging Solution 5 1 OS and storage upgrade 5 1 1 Installation of hard drive PZS MTI sati Midas
53. N COMBINATION DESCRIPTION 1 3 RS 232 3 5 2 4 RS 422 3 5 4 6 RS 485 Table 3 3 The Wafer 9371A JP4 settings to configure COM2 3 1 3 Storage When the work on this thesis started the CyberBike was equipped with a compact flash card CF as storage medium shown in Figure 3 5 This is a 1286 TwinMOS UltraX CompactFlash card with 140x reading transfer speed It is important that this speed is high to avoid creating a bottleneck in the execution speed 5Universal Serial Bus Giga Byte 24 CHAPTER 3 SYSTEM DESCRIPTION Figure 3 5 The Compact Flash card from TwinMOS 3 1 4 I O card To be able to read the measurements from the CyberBike s potmeters and tachometers into the CyberBikePC and to put out a control voltage to the motor controller card an I O card is needed A Diamond MM 32 AT 16 bit analog I O module referred to as DMM 32 AT from now on connected to the CyberBikePC s motherboard The Wafer 9371A see Section 3 1 2 via a PC 104 connector A picture of the card is shown in Figure 5 1 Figure 3 6 The DMM 32 AT card taken from Diamond Systems Corporation 2003 The DMM 32 AT s features are listed in Diamond Systems Corporation 2003 and the most relevant are listed here 31 Hardware 25 Analog Inputs e 32 input channels may be configured as 32 single ended 16 differential or 16 SE 8 DI e 16 bit resolution e Programmable gain range and polarity on inputs e 200 0
54. Operating System Interface The denotes the Unix or Unix like operating system origin of POSIX An RTOS developed by QSSL Was initially called QUNIX from Quantum UNIX QNX Software Systems Limited initially known as Quantum Software Systems see QNX Random Access Memory Resource Manager also known as device drivers and I O managers Real Time Operating System Single board computer Small Outline Dual In line Memory Module Universal Asynchronous Receiver Transmitter Universal Serial Bus microcontroller List of Figures 2 1 Main parameters for the bike model 2 2 Orientation within a right handed coordinate system 2 3 LQG control block diagram redrawn from Bjermeland 2006 2 4 Simulink block diagram of the bike model and the control system made by Bjermeland 2006 2 5 Screenshot of the simulation GUI constructed by Bjermeland 2006 2 6 Architecture of resource manager ice 4d re 3 1 Overview of the CyberBike s various hardware devices by the start of this 3 2 The ACE 890C power supply unit Picture copied from Loftum 2006 3 3 The Wafer 9371A SBC used at the CyberBike Picture taken from Lof AA A O A eh eio 3 4 The JP4 pin locations on Wafer 9371A 325 CompactFlash usc di e a 3 0 The DMM card oe
55. TS CTS _Disconnect Help 3 B C even C 1 5 C XON XOFF About 4 mak C 5 5 Quit 5 C space 2 C RTS on TX Settings Auto Dis Connect Time Stream lag customBR Clear AsCiltable Scripting cs Eco Set fi AutoStart Script CR LF 9600 27 Graph Remote Eos Gael Receive C HEX Dec Bin ASCII Hex EE 01011010 01000001 00000001 11111111 00000001 lt 0 gt 24 3 DZA lt 0 gt D lt 0 gt Transmit CLEAR Send File CR CR LF E3DTR ARTS Macros Set Macros 1 2 M4 5 MB M M8 MIO M11 M12 Rx 10411 Tx 1 Figure 4 2 Screenshot of terminal window listening to the IMU The terminal has problems coping with the speed of the IMU and the output on the screen is lagging somewhat When the IMU is reset by its own hardware button it takes some time before the terminal window has flushed its buffer to the screen This is assumed to be an indication that the IMU is delivering data at the specified speed But here it is important to note that the IMU is supposed to send an ascii character A before its 16 measurements and the character 2 see Section 3 1 7 From the terminal window it is difficult to see whether the IMU is delivering the correct data stream because the terminal interprets the measurements as ascii characters on the screen but we clearly can see
56. a 0x07 signal to start transmitting measurement output Printout 6 2 shows how the procedure was done on the COMI port at first to ensure that the GPS was delivering signal and that a command for setting the correct baud rate was used su lt enter password gt tt stty F dev ttySO ospeed 4800 ispeed 4800 cat dev ttySO GPGGA 004151 029 lt ctrl c to stop reading from the GPS Printout 6 1 Testing COM1 port before testing COM2 Then the GPS serial cable was connected to the second com port using the RS 232 connection at the serial cable shown in Figure 6 5 The same procedure was applied to this serial device as stated in Printout 6 1 No output was printed to the terminal By this it was concluded that the second serial port was defect Comment During this test the source of the problem was not found and the problem was not corrected in any way The return of the test was a strong indication that the error was 3This was actually not done correctly the first time and the installation process stopped unfinished due to memory shortage on the CF card This password was chosen by reading the front brand tag on the bike which says gl nd Perfekt deLuxe 6 4 GPS driver testing 89 stty F dev ttyS1 ospeed 4800 ispeed 4800 cat dev ttyS1 lt ctrl c to stop waiting Printout 6 2 Testing the COM2 port residing in the hardware in the Wafer 9371A Some testing and probin
57. a power source to the rightmost circular 4 pins connector at the suicase marked 24V either from the batteries or from an external power supply e g as showed in Section 6 1 3 Make sure the MTi is inside it s housing right behind the front wheel Plug a screen cable from an available screen to the VGA connector on the Wafer 9371A SBC Connect a keyboard into the PS2 connector at the Wafer 9371A Plug an ethernet cable into the RJ 45 slot on the outer side of the suitcase and into an available network connection slot Connect a mouse if wanted into the USB connector at the outside of the suitcase Make sure the USB cables connectors are connected to the 9 pins contact at the Wafer board inside the suitcase Make also sure that the hard drive are connected to the EIDE connector on the board The hard drive is placed under the motor controller card Baldor TFM 060 06 01 3 Connect the desired serial device to the available com port a D SUB 9 connector directly on the wafer board In the present moment of writing only this serial Enhanced IDE 117 118 APPENDIX HOW START THE CYBERBIKE SYSTEM 11 12 13 14 15 16 17 18 device is working The three available devices that could be plugged in are the MTi the IMU from Spark Fun and the GPS If the MTi is chosen make sure it is powered by the three pins contact from the ACE 890C This connector is
58. and stores the values in a measurement array The first loop is shown in Code sample 4 4 42 CHAPTER 4 SUGGESTED SOLUTION Code sample 4 4 The first loop in devc imu while running if ctp dispatch block ctp NULL fprintf stderr 4 s tblock error n NAME return EXIT_FAILURE dispatch handler ctp This shows some of the elegance of the QNX resource manager utility The dis patch block function call is blocking until someone performs a call to the IMU driver such as read write or devctl Then the default function for the requested operation is called unless a new function is registered for that operation In this case only a new read function imu read and a devctl imu devctl function is registered For instance if someone is trying to read the value from the roll gyro unit like shown in Printout 4 2 the dispatch block call wil unblock and the function read will be called This function is returning the requested value from the measurement array to the terminal Access to the measurement array is synchronized by a POSIX mutex val mutex cd dev imu roll cat rateout continues until hitting ctrl c Printout 4 2 Reading the roll rateout from the IMU device The second loop is reading from the serial device The old version i e the code as it was by the starting point of the work on this master s thesis is shown in Code sample 4 6 The first thing t
59. assing between the modules The code for instance for performing a read or write operation on a file will look like standard POSIX C The message passing part is done by the Neutrino C library which leads to the programmer not having to write message passing functions if he is developing code for a QNX system great benefit from the message passing architecture is that it is making network distributed systems act all the same as one node systems The messages could just as easily be sent to a module on another node as to the same node as opposed to traditional kernel systems where local and remote network services are implemented in a totally different way Modules are divided into servers and clients The key phrases used by Krten 2001 p 111 are e The client sends to the server e The client receives from the client e The server replies to the client When the client wants to send a request to a server it will get blocked until the server has completed the request and the client has got its answer First it has to establish a connection with the ConnectAttach function which returns a connection ID coid and then it could use this ID to send its message by the MsgSend function The server has to create a channel by using the ChannelCreate function This makes the clients able to connect via ConnectAttach Then the server will block on a MsgReceive until it get its request Then the cli
60. ation on the DMM 32 AT resource manager devc dmm32at like shown in Printout 4 10 the output on J3 pin 38 was not as expected The pin were measured by an oscilloscope see Section 6 1 2 Possible errors were e Hardware error in the DMM 32 AT as a consequence of possible connection mis takes causing too high currents or voltages on the output ports e Hardware error in the Wafer 9371A giving the I O card wrong instructions via the PC 104 connector e Software error in the way QNX is communicating with the I O card e Software error in the resource manager devc dmm32at 6 5 1 The DOS Diagnostic Test Utility from Diamond Systems By using the DOS Diagnostic Test utility included in Util dscud5 91 zip downloaded from Diamond Systems Corporation 2007 the possibility for errors in the devc dmm32at could be tested see Appendix D Running the menu element 9 D A QUICK Diagnostic Test gives the result shown in Printout 6 4 Both for A D and D A the tests passed and the range was correctly set to 5V D A is detected as 5 00V to 5 00V If not then board has error or is not calibrated correctly D A Diagnostic Test D A Output Expected A D Sampled A D Pass Fail 0 16384 16388 55 1000 8385 8382 55 2000 386 381 55 3000 7612 7618 PASS 4000 15611 15622 PASS Printout 6 4 DOS Diagnostic Test using the D A Quick Diagnostic test output while no probes are attached at the D A
61. au hea et ae ce 3 7 The CyberBike s motorcontroller card a Baldor 060 06 01 3 Seen both from the rear and the front Pictures copied from Loftum 2006 3 9 Propulsion motor s RR we RR PU 3 9 Pendul m mOtor 5 au ta Gore Steering MOOT qa deed dus e de doe dr gen Dr ie Ob bel 3 11 IMU with 6 degrees of freedom 3 12 Gyro card for th IMU 3 13 Scehmatic overview of drivers developed by Loftum 4 1 Photo of IMU and UART to RS232 converter mounted 4 2 Screenshot of terminal window listening to the IMU 4 35 Xsens io Ba ee EUR dux Ee 4 4 The MTi s S system shown relative to the G system Figure copied from PESE ae Beers es che ict eed m mou de eer us 4 5 The CyberBike as it looked by the start of this work 4 6 Conflict between chain and battery frame Single board computer 1 4 7 The EM 411 GPS module from GlobalSat 4 8 soldering side of the GPS board 0 o e 4 9 The component side of the GPS 4 10 Loftum s 2006 connection proposal for the pendulum limit switches 4 11 Circuit diagram of first connecton of the pendulum limit switches Termi nal block connections a
62. ce BACKGROUND CHAPTER 2 10 Bicycle Rider Dynamics Actuators measurements Plotting Controller observer psi_dot Reference n ly X Y Figure 2 4 Simulink block diagram of the bike model and the control system made by Bjermeland 2006 11 The CyberBike model 2 1 i i D i i i H da i i 1 2 1 Screenshot of the simulation GUI constructed by Bjermeland 2006 Figure 2 5 12 CHAPTER 2 BACKGROUND 2 2 Neutrino 13 2 2 QNX Neutrino QNX Neutrino is an RTOS made by QSSL The fundamental concepts of QNX Neu trino are message passing and resource managers and thus the description in the follow ing two section are mainly in regard to these subjects based on Krten 2001 chap 2 and 5 respectively 2 2 1 Message Passing The QNX family of operating systems has microkernel architecture and achieves scal ability by making all service providing components modular When installing a QNX Neutrino system its consisting modules should be as independent of each other that every module could be considered optional Thus it should be no problem to make the system as small or big as possible T he key behind this is the message p
63. ct check the Create an MS DOS startup disk box This option is by default not possible to use on a USB memory like this but here Windows Enabler comes into play Format the USB drive Right click on the windows enabler system tray icon and select Quit Stop and unmount the USB storage medium by left clicking on its system tray icon To start the CyberBikePC from the USB drive do the following 123 124 APPENDIX D HOW TO BOOT CYBERBIKEPC IN DOS 1 Insert the bootable USB device into the USB connector on the Wafer 9371A via the 10 pin to USB cable provided with the in the Wafer kit 2 Power up the CyberBikePC Hit DEL to enter BIOS setup 3 Choose the Advanced CMOS setup 4 A menu similar to the one showed in Figure D 1 appears Make sure the USB device is booted from before any other devices i e set 156 Boot Device to USB and 2nd Boot Device to IDE 0 5 Save and exit BIOS setup to restart system AMIBIOS SETUP A CED rik SETUP able Options Figure D 1 Screenshot of the Advanced CMOS setup menu taken from IEI Technology Corp 2006 To get back into QNX powering down the CyberBikePC remove USB device and power up again should be sufficient If not go into the BIOS setup again to make sure IDE 0 is specified as Ist Boot Device Appendix Connection tables This appendix provides tables covering most of the connections in the CyberBike projec
64. ction MsgRead to read out the rest of the message from the clients address space while the client is still blocked Similarly there exist a function called Msg Write which makes the server write into the clients address space This is useful e g in cases where the server is a 1 0 driver and the client asks the driver for several megabytes of data Then the server could write it directly into the clients buffer instead of constantly running with a huge memory allocated for such large requests To send multipart messages the IO V facilities in QNX could be used together with the corresponding Msg v functions e g MsgWritev and MsgReadv An IOV con tains a number of pointers to memory locations and these Msg v functions take an IOV and number of the vector parts as arguments instead of the buffer and its length Another mechanism of the message passing facility is pulses This distinguishes itself from the rest by the property that it is non blocking When a MsgHeceive returns 0 as receive ID it means that the message is a pulse With pulses only 40 bits of content can be sent In cases where a pulse is the only type of message one want to receive the MsgHeceivePulse comes into play Finally it is worth mentioning that QNX Neutrino is doing priority inheritance on the message passing threads to avoid priority inversion These terms might need a short explanation Priority inversion is the phenomenon that arises when a low prio
65. d is placed at the end of the lever pendulum see Figure 6 4 The lenght of the lever lp is approx 0 62m hence My 2kg 0 5kg Q w _ _ gt 9 cm 62 cm Figure 6 4 Sketch of the horizontal pendulum with weight at the end the weight s center of mass em w Would be about 0 57m which is the distance from the rotating center of the pendulum The lever itself mp is about 0 5kg and would have its center of mass at the middle of the lever that is 0 31m The center of mass of the two items can be derived by Tem w Tem p Mw May Mp 0 57m 0 31m 2kg 2kg 0 5kg Lem Temp 0 31m 6 1 0 52m A mass of 2 5kg on a lever 0 52m from the rotating axis gives the torque T Lem Fy Lem Mw Mp g 6 2 0 52m 2 5kg 9 81m s 12 8Nm which the motor have to deliver as a minimum to raise the pendulum In the case with a rope with a weight at the end tied to the motor axis the weight corresponding to 86 CHAPTER 6 TESTS AND EXPERIMENTS the pendulum would be T Meorresponding aa 6 3 axis 2 12 8Nm 9 81m s 0 01 130kg 6 4 approximating the axis radius to 1cm The inaccurate measurements the axis radius in particular will have a large impact on this calculation however the calculations show that with that load amount this is not the way to do the motor test Therefore the pendulum was mounted back to t
66. de in MTComm cpp to make it compile in QNX 66 5 2 Core of the new dmm32at analog read and dmm3 2at analog read FUNCLIONS A Ax nnd osi Ue undo artus od deas A 70 6 1 The contents of init_dmm32at in the DMM 32 AT driver devc dmm32at 92 6 2 The main code performing the I O operations to the actual bike in io wrapper c 95 6 3 The bike start and bike stop functions in bike_io_wrapper c 96 XV xvi List of Printouts 4 1 4 2 4 3 4 4 4 5 4 6 4 7 4 8 4 9 4 10 5 1 5 2 6 1 6 2 6 3 6 4 6 5 Terminal dump of CyberBike login and starting of IMU driver Reading the roll rateout from the IMU Listing the connected USB devices on a QNX system Making OS image from buildfile Mounting CF card on Linux Mounting CF on Loading the OS image into the flash memory Message appearing on the CyberBikePC after the putting new OS image on the ss noU Ree eed Solution suggested by Loftum 2006 but not sufficient this time Setting the control voltage for the propulsion motor by software Usage example of devc mt Usage example of new DMM 32 AT driver running autocalibration Testing the COMI port before testing COM2 Testing the COM2 port
67. drivers developed by Loftum 2006 Figure translated and redrawn with modifications from his master thesis Chapter 4 Suggested solution 41 IMU alternatives Information about how the CyberBike is moving is intended to be delivered to the con trol system by an Inertial Measurement Unit IMU An IMU from Spark Fun 2005 have already been bought by the Department of Engineering Cybernetics for this pur pose By the start of this work the IMU had just arrived from Spark Fun due to some reconditioning work Hence the first thing that had to be done was to test the unit An IMU driver had already been developed by Loftum 2006 but not thoroughly tested The IMU has a UART interface and this signal had to be transformed to a RS 232 signal to be able to communicate with the CyberBikePC 4 1 1 RS 232 to UART transceiver The firmware on the IMU is using the UART at baud rate of 57600bps The UART signals delivered from the IMU needed to get transformed to an RS232 signal to be connected to the Wafer 9371A For this purpose Maxim Dallas Semicon ductors 2006 is providing the iC MAX233CPP which is placed on its own PCB Over this connection the output data of 34 bytes is delivered to the CyberBike s computer A picture of this PCB is shown in Figure 4 1 and the layout could be found in Appendix F 4 1 2 Driver issues On the driver for the initial IMU from Spark Fun 2005 some problems were discov ered when the driver was sta
68. e 1980 s when Amund Skavhaug picked up Jens G Balchen s idea of developing an autonomously running bicycle The last few years the CyberBike have again got some attention The intention of the work behind this thesis is to complete the work of the CyberBike and take it to its first autonomous outdoor ride The Department of Engineering Cybernetics intentions is to use the bike to get publicity at stands and guided tours at the department The development of the theory behind the bike s dynamics is also an interesting subject owing to the fact that as far as the candidate of this thesis know has ever implemented an autonomous bicycle this way i e by controlling an inverted pendulum the steering angle and the propulsion speed 1 2 Problem The goal of this work is to get the bike running To do this the instrumentation system has to be completed A lot have been done at this point but a working measuring unit for acceleration and rotation have to be included in the system This was the last impediment for the predecessors of this thesis see Section 1 3 before the control system could be tested on the bike From there some modifications and improvements of the CyberBike and its control system are the main subjects of this work Some tasks are related to allowing the bike to move without cables attached A wireless ethernet card is supposed to replace the network cable between a stationary QNX workstation the host
69. e V and V pins there was no reaction on the motor neither through software see Printout 4 10 or through the I O card DMM 32 AT nor by simply connecting an external power source to the pins This last approach eliminated any potentially errors in the system somewhere above the motor controller card But when disconnecting the motor from Baldor TFM 060 06 01 3 and power it up directly from a power source it runs like expected Hence the motor controller card had to be investigated devc dmm32at verbose amp 1 577574 devc dmm32at Verbose mode devc dmm32at analog write Inode 1 devc dmm32at Writing voltage 2 500000 devc dmm32at Writing DMM value 3071 DMM 32 AT Writing Oxbff 3071 to channel 1 In another terminal window cd dev dmm32at analog out echo 2 5 gt dal Printout 4 10 Setting the control voltage for the propulsion motor by software In Baldor ASR 1988 it says that all the three motor axis have their own set of potmeters placed at the backside of the Baldor TFM 060 06 01 3 1 Tacho voltage scaling To use the word above here it is assumed that the whole system could be viewed hierarchical with the motors and actuators at the bottom then the hardware connected to these and then the motherboard with its CPU before the software lies on top 54 CHAPTER 4 SUGGESTED SOLUTION 2 Velocity loop gain 3 Current limit 4 Offset Tuning these finally made the motor
70. e it was decided to go for other alternatives instead The Baldor TFM 060 06 01 3 is capable of performing speed control by altering the jumper settings for the particular axis and connect a tachometer measurement back to the controller The propulsion tachometer s positive signal was connected to the motor controller card s pins 2 c4 via terminal 1 on block X1 and the negative signal was connected into 2 c14 via 1 12 To get some velocity measurement data in the software running part of the control system it was desired to keep the tachometer connected to the DMM 32 AT But using the existing setup for the propulsion tachometer into A D channel 0 would make the tachometer be connected to Agnd on the I O card which in turn is connected to the negative reference voltage on pins 2 c2 2 a26 and 1 a16 at the same time as it is con nected to Ref gnd on 2 14 at the Baldor card These pins seems to be unconnected inside the card Baldor ASR 1988 DMM 32 AT is set up to have 8 differential input channels previously unused The propulsion tachometer was connected into one of these channel 8 to avoid any ground loop problems The devc velo driver was updated to use the ad8 as its velocity mea surement device The propulsion motor controller is tuned by four potmeters at the Baldor TFM 060 06 01 3 s front side at the very back of the bicycle The parameters tuned by these potmeters are described in Section 4 3 Due to some prob
71. e sec double latitude double longitude double hdop double altitude double geoidseparation double pdop double vdop double speed double course meas_t In devc gps c the functions gps devctl and gps read are defined Both is locking the mutex the same way as shown in Code sample 4 8 before reading the requested data out of the measurement struct Some messages could be sent to the GPS module in order to configure and request specific data from the device These messages are not used in the current version of the driver because it was assumed that the CyberBike s GPS usage would be kept at a moderate level and only the basic functionality provided as default was desired The GPS resource manager is registering its device files under the dev gps direc tory and when the driver is running there will exist a file corresponding to each of the elements in the measurement struct in Code sample 4 7 58 CHAPTER 4 SUGGESTED SOLUTION Code sample 4 8 Example from parse gpgll on storing values in measurement struct Lock mutex if pthread_mutex_lock amp val_mutex printf s tCouldn t lock mutex n NAME measurements hour hour measurements min min measurements sec sec measurements latitude latitude measurements longitude longitude Release mutex if pthread_mutex_unlock amp val_mutex printf s tCouldn t unlock mutex n NAME 4 5 Pendulum L
72. ecified product and vendor specific protocol So far everything was working when the device was plugged into the USB port on the CyberBikePC the insertion function was called and tried to set up the device But from there things got complicated Receiving any data from the device was never accomplished in any way Seeking help on OpenQNX by reading a large part of the USB driver related threads gave no result However a lot of people seemed to be dealing with the same problem and by this it was realized that the task was too big to be solved within a reasonable amount of time in this project In the final solution the serial connection option was used instead of the USB cable 48 CHAPTER 4 SUGGESTED SOLUTION 4 2 OS upgrade on the CyberBikePC By the beginning of the work on this master s thesis the CyberBikePC were running a QNX Neutrino OS image as described in Section 3 2 This image developed by Loftum 2006 was minimal and just enough to get the CyberBikePC online and to run its programs Some enhancements to the image was desired to make development and testing a bit easier The desired features to get into an upgraded system were qconn the utility which makes connection from an IDE on a remote PC possible i e the Windows XP PC used for developing in this project By using qconn drivers for the CyberBike could be tested and debugged on the bikes own CPU while developed on another computer pidin lists threads
73. ection is desired First In First Out 8 Analog to Digital 26 CHAPTER 3 SYSTEM DESCRIPTION Name Description 1 PC 104 8 bit bus header J2 PC 104 16 bit bus header only used for interrupt level J3 Analog I O header includes trigger and ctr timer signals J4 Digital I O header J5 Analog input single ended differential configuration 16 D A unipolar bipolar full scale range configuration J7 Base address DMA level interrupt level bus width J8 Digital I O pull up pull down configuration J9 Test connector not used in normal operation Table 3 4 Overview of DMM 32 AT headers Taken from Diamond Systems Corporation 2003 p 5 Jumper settings Configuration 12 3 4 5 6 0 7 SE 8 15 DI 16 235E 1 0 0 1 0 1 Table 3 5 Header J5 configuration for analog in on DMM 32 AT In Table 3 6 the signal Vref Out is a 5 volt signal from the on board reference chip A D Convert could be used to synchronize multiple boards Dout 2 Dout 0 are digital output ports with counter timer functions Din 3 Din 0 are digital input ports with counter timer and external trigger functions 5V is connected to the PC 104 bus power supply and Dgnd is digital ground connected to the PC 104 bus ground Header J7 have jumpers set on position 7 and R which means that a 1 pull down resistor is connected to the IRQ line 7 Also a jumper is set on A to set the base address to default 0x300
74. eemed like a good option A noticeable amount of effort was put into this task but with no positive result Without going too deep into the details of this part it could be summarized as follows First a search for virtual com port drivers in the QNX system and on the internet was done without finding anything of particular interest But some references to the QNX USB Driver Development Kits DDKs from now on were found With a good framework as a basis the development of a custom made driver for the USB to serial converter seemed like an manageable task The DDK for a USB printer was downloaded from the QNX web page QSSL The web page provides three different USB DDKs mouse keyboard and printer Bulk transfer mode endpoints are only used by the printer DDK and therefore this was the most attractive starting point The information about the device configuration classes subclasses interfaces and endpoints for the USB device from Xsens was obtained using the command shown in Printout 4 3 usb vvv less Printout 4 3 Listing the connected USB devices on a QNX system This command shows that the device has three endpoints one control and two for bulk transfer one for in and one for out transmissions The DDK was imported to the QNX Momentics IDE and copied to a new project to be configured for the specific purpose The code was altered to only wait for incoming connections from the Xsens registered vendor id for its sp
75. eference signal to the other two motor axis If connected otherwise all the other motors would also stop when the B2 switch was activated Setting a voltage out to the pendulum motor had an impact on the other motors which indeed is undesirable When the propulsion motor was running at a low speed it stopped when activating B2 Also a voltage across the negative input references on Baldor TFM 060 06 01 3 was observed when B2 was closed Then it was realized that cutting the ground connection from DMM 32 AT to the motor controller card as done in D2 is not the same as setting the reference voltage to zero The internal circuitry of Baldor TFM 060 06 01 3 was playing a role in this case as well as the exact timing of when B2 cut the signal out on its normally closed NC output pin and connects the normally open NO output pin to its input pin To fully understand what went wrong a deep investigation of both devices should be made This investigation was not done Instead it was assumed that cutting off the ground connection between DMM 32 AT and Baldor TFM 060 06 01 3 was the mistake done here and an alternative circuit was designed to correct it This solved the problem Section 5 5 describes this solution A note on such failure situations and debugging is made in Section 7 4 62 CHAPTER 4 SUGGESTED SOLUTION Chapter 5 Solution 51 OS and storage upgrade Some problems occured during the upgrade of the OS image on the C
76. ent will be blocked while the server is processing the request The answer is sent by MsgReply which unblocks the client Real Time Operating System QNX Software Systems Limited 14 CHAPTER 2 BACKGROUND There is a need to follow a strict send hierarchy in a message passing environment This means that two threads should never send messages to each other Threads should be organized in levels where all sends goes from one level to a higher level This is to prevent deadlocks because if two threads could send messages to each other sooner or later they both will get blocked waiting for the other s to reply Sometimes situations where the send hierarchy would have to be violated arise Then the non blocking function MsgDeliverEvent comes into use As an example consider a client sending a time consuming request to the server but is not interested in being blocked while waiting for the server to finish its task Then it makes a struct sigevent which in turn is used by the server as an argument in the MsgDeliverEvent call to inform the client about its completion of the request Messages are always delivered in a priority order That is if two processes sends a simultaneous message then the entire message from the process with the highest priority is delivered to the server first When a message sent by the client is bigger than the buffer specified in the server s receive buffer the server could call the fun
77. ere the value was stored before it was read out from the device file Thanks to yvind Bjgrnson Langen which once had a similar problem the error was found The buffer that the gps_ read function was writing the output data to was defined as a local variable to that function At the end of the function an IOV see Section 2 2 1 was set up to send the data back to the requesting client This implies that the address of the buffer is handed over to the resource manager utility to be read back to the device file Then the gps read returns and its occupied memory space is free to be used by other functions When finally the data is transmitted to the receiving client some other function had been writing to to the memory where the return buffer was stored and the data was corrupted Furthermore to make the buffer a global variable instead of an autovariable solved the problem By closer inspection of the other resource managers developed for the CyberBike so far this error seemed to be done in all of them But obviously it have not made itself visible in all cases 6 5 DMM 32 AT issues 91 6 5 DMM 32 AT issues When the porpulsion motor was connected to the Baldor 060 06 01 3 see Section 4 3 2 some calibration of it was needed Then it was discovered that the DMM 32 AT was giv ing erroneous output from its D A converter This section covers a description of the debugging process of this card When performing a write oper
78. evice files would have correspond ing names like orientation q1 through orientation q4 in quaternion mode or all letters from orientation a to orientation i in matrix mode The latter is defined as shown in Equation 5 1 abe R d f 5 1 g h i The read and mt devctl functions are made to update the content in these files No mt_ write funtion is implemented by this resource manager A large set of messages defined by the MT protocol for configuring various aspects of the device see Xsens 68 CHAPTER 5 SOLUTION 2005 p 33 to be sent from the host to the devcie and hence a write function could be useful to control its behaviour from other programs like devc velo But to keep the system complexity at a moderate level it was decided that this was unnecessary If such configurations is wanted in the future this probably could be done throug hard coding it in the MTi driver or add some functionality in the MT_DEVCTL_SETVAL block in the mt devctl function 5 3 Propulsion motor In the CyberBike model by Bjermeland 2006 the bike velocity is not controlled by feedback of any measurements in software Also the model and controller is designed for being valid for a constant speed and on a level surface leading to less demanding control functions for this motor A simple controller i e PID in software would probably have done the job but using the available processing power a bit sparingly is preferred and therefor
79. frame Do error handling Lock mutex if pthread mutex lock amp val mutex printf ImuThread tCouldn t lock mutex n bi bi should now point to the element after A When measurement is int for ii 0 ii lt 16 iic measurements ii buffer bi lt 8 OxFF00 measurements ii buffer bi 1 amp bi 2 Release mutex if pthread_mutex_unlock amp val_mutex printf ImuThread tCouldn t unlock mutex n 46 CHAPTER 4 SUGGESTED SOLUTION 2 2 Local i MTi MTx co vertical y ordinate system S V Be co ordinate system G Local magnetic orth n co ordinate systems are right handed Figure 4 4 The MTi s S system shown relative to the G system Figure copied from Xsens 2006 The MTi is delivered with cables for RS 232 and USB communication the latter have a serial to USB converter attached to the cable some example applications and a MT Software Development Kit This includes a C class for low level communication which is the most important feature for this project Direct low level communication with the MTi RS 232 422 is recommended when real time requirements are presented An example code for this kind of communication which is compatible with and compileable in both for Windows and Linux is provided with the MTi This makes development of the driver for this device easier see Section 5 2 1 Output fr
80. g had already been performed which could be the reason for the damage see Section 7 4 Another possibility was the two jumpers connected on J4 but the writer of this thesis has not found any statements in IEI Technology Corp 2006 that indicates that this would be harmful to the Wafer 9371A 6 3 3 Testing of COM1 Very late in this project the first serial port also started to behave erroneously The MTi driver was not able to get through its initialization process and ended with the message No device connected But closer inspection of the output from the driver showed that it actually did open dev ser1 without problems It was not until the driver tried to send a message to put the device in config mode the error was returned A quick read on the serial device using the command cat dev ser1 flushed loads of output to the screen indicating that the device actually was transmitting something on the COMI port Then the CyberBikePC was booted into DOS as described in Appendix D with a terminal program tplus1_4 from Lightsey loaded into the USB stick The terminal was tested with the GPS module connected to the serial port Setting the baud rate to 4800 made the output from the GPS visible on the screen Then the IMU from Spark Fun was tested The baud rate was set to 57600 as done in Section 4 1 1 Pressing the reset button on the IMU sends some characters to over the serial connec tion and this was also the case this time B
81. gle heading Pendulum m Trw Tp p Yrw Spr 2 3 2p where e and zp is the position of the pendulum center of mass relative to the rear wheel to ground contact point e is the length of the pendulum from the rotating center to the pendulum center of mass e is the pendulum angle Front frame and front wheel my Tf Urw Tfr Zr 2 4 ef where e ry and zy is the position of the my related to the rear wheel to ground contact point e is the lenght from the front fork to the center of mass point measured in a T direction perpendicular to the front fork i e 5 from the horizontal forward x axis e 0 is the steer angle 2 1 The CyberBike model 2 1 3 Other important parameters To understand how to connect the Simulink model made by Bjermeland to the actual CyberBike an understanding of some of the various defined variables is needed Two important vectors used in the model are 91 m E fi f where 2 5 Pp 2 6 e is the leaning torque on the total system e is the leaning torque on pendulum rider e Mz is the steering torque Controller design The controller is designed to get a desired turn rate of the bicycle This rate is either measured or estimated through an observer described in Bjermeland 2006 chap 6 An LQG control strategy was employed whic
82. gr_context_alloc allocates a resource managers internal context block which contains information relevant to the message being processed resmgr_ block is the blocking call making the RM wait for a message from a client resmgr_handler is called once the message arrives from the client to process the request In Krten 2001 a figure of the big picture is shown which according to Krten contains almost everything related to a resource manager A version of this figure is shown in Figure 2 6 dev path1 E gt dev path2 chid connect functions jo open unlink MES mount io_readlilnk read thread 2 NS pool loop MEE ETT p E 1o write E NN N contro io devctl No 1 0 de MS m d functions Figure 2 6 Architecture of resource manager the big picture Figure redrawn from Krten 2001 OCB Open Context Block The resource manager receives certain well defined messages as can be seen from Figure 2 6 these can be divided into two categories connect messages and I O messages Connect messages are related to pathname based operations and may establish a context for further work The I O messages arrive after connect message and indicate the actual request from the client QSSL provides a set of POSIX helper func
83. h makes it possible to weigh the different error states of the physical system and penalize excessive use of the actuators i e motors in the CyberBike s case A principal block diagram of an LQG controller is shown in Figure 2 3 The observer states are shown in Equation 2 7 and 2 8 and the state space model of the system is described in Equation 2 10 and 2 11 Linear quadratic Gaussian control 8 CHAPTER 2 BACKGROUND gt y Plant gt 222 u i K Kalman i E 2 filter Ga LQG regulator Figure 2 3 LQG control block diagram redrawn from Bjermeland 2006 or 0 2 7 22 28 2 8 Mo 21 22 2 10 da M l K0 v K2 zi 90122 2 11 where e M isthe 3 x 3 Mass Matriz e KO is the 3 x 3 Velocity Independent Stiffness Matrix e K2is the 3 x 3 Velocity Dependent Stiffness Matrix e Cl 15 the 3 x 3 Velocity Dependent Damping Matrix e v is the speed vector 2 1 The CyberBike model 9 To trace all parameters in the matrices in Equation 2 11 back to variables introduced in the previous sections would require more space in this thesis than seems reasonable Thus for a further description of the elements in Equation 2 11 it is reffered to Bjer meland 2006 Then the Kalman filter is designed In Bjermeland 2006 60 it is stated that
84. he bikes first autonomous test run 8 1 Correction of the serial connection problem The problems in Section 6 3 need to be solved in some way or another Maybe the Wafer 9371A vendor Technology Corp is able to check and repair the board for a reasonable price but this has to be checked before mailing it all the way to Taiwan As the situation is right now there are three devices to be connected to the Cyber BikePC The two serial ports provided on the board are not sufficient to connect both IMUs and the GPS at the same time In that case some kind of serial port extension should be purchased An example of such a board is the CA 104 from MOXA AS which would fit in the PC 104 stack in the CyberBike s suitcase A USB to serial device might not be a good option owing to the fact that such devices have proved difficult to cooperate in QNX see Section 4 1 3 However this might not be of interest if the COM ports on the SBC gets repaired since one of the IMUs should be able to do the job The cost of the Wafer 9371A reconditioning must be weighted against the price on a new serial port extension board 103 104 CHAPTER 8 FURTHER WORK 8 2 Wireless ethernet connection The CyberBike is supposed to move around without any wires attached By now Matlab Simulink and Real Time workshop have been used to control the bike from a host ma chine To be able to keep the system like this installation of a wireless ethernet adapter on
85. he measurements to ready to use variables directly from the device hence better results were expected by using this unit By this it is believed that the CyberBike project is far closer to its finite goal yielding a better foundation for further development and progression on the project References ACT Batteries online URL http www actbatteries co uk Accessed 30 May 2007 Elektronix AS Ca 104 online URL http www elektronix no Produkter Kommunikasjon_RS_Ethernet PC _basert_serie_kommunikasjon Multi_port_ serie_kort Moxa_PC_104_ _forembeddedPC_systemer_ 1167 Accessed 4 Jun 2007 Baldor ASR Pulse Width Modulated Transistor Servodriver TFM Instruction Man ual Baldor ASR GmbH Dieselstrafe 22 D 8011 Kirchheim M nchen West Germany 1988 Version 1 11 07 88 Lasse Bjermeland Modeling simulation and control system for an autonomous bicycle Master s thesis Norwegian University of Science and Technology NTNU Trondheim June 2006 Edgar Bjorntvedt Instrumentering for autonomt ubemannet fly Master s thesis Norges teknisk naturvitenskapelige universitet NTNU Trondheim June 2007 Working title only The master thesis was unpublished when this thesis was written Canonical Ltd LiveUsbPendrivePersistent online URL https wiki ubuntu com LiveUsbPendrivePersistent Accessed 3 Jun 2007 Diamond Systems Corporation Diamond MM 32 AT 16 Bit Analog I O PC 104 Module with Autocalibration User Manua
86. he motor Then the motor could be tested with the actual load The test showed no problems lifting the pendulum with the 2 kg weight placed at the end from horizontal to vertical position The problem is residing somewhere else The Farnell power source see Section 6 1 3 was tuned to give a voltage and a current at approximately 24 V and 3 5 A respectively close to the nominal values for the motors 24V and 4A When the current was reduced to 1 A the motor could not manage to raise the pendulum The delivered current from the motor controller card should probably be the next place to check A current at about 2 A seemed to be sufficient but since the torque of the pendulum depends on this current it should be tuned to match the control system Later test runs with the Baldor card showed no problems on moving the pendulum as long as the current limit potmeter see Section 4 3 2 is tuned correctly 6 3 COM ports The Wafer 9371A is equipped with two serial COM ports where one is capable of receiving RS 232 signals and the other could be configured to receive RS 232 RS 422 or RS 485 by modifying the settings on jumper JP4 on the SBC Single board computer as shown in Table 3 3 Some problems occured with these serial ports during this project The first one to fail was the COM2 port The jumper configuring the second serial port was checked Jumpers connecting pin 1 3 and 2 4 were installed Due to Table 3 3 this is introducing so
87. igure 3 3 shows the computer used on the CyberBike project and in Table 3 2 a sum mary of its specific data extracted from the vendors website are listed The card is a Wafer 9371A Single board computer SBC with a 400 MHz Intel Celeron processor 256 MB SO DIMM and many different possibilities for con Mega Hertz Mega Byte 3Small Outline Dual In line Memory Module Random Access Memory 19 20 CHAPTER 3 SYSTEM DESCRIPTION Power supply unit psu Power source Power ACE 890C Power Single Board Computer 580 Ment Spark Fun IMU Water 9371A data Power PC 104 bus connection Card Reference signal Diamond MM 32 AT Measurement Propulsion motor Motor controller card PWM Power Steering motor Baldor TFM 060 06 01 3 Signal Pendulum motor Figure 3 1 Overview of the CyberBike s various hardware devices by the start of this work Figure 3 2 The ACE 890C power supply unit Picture copied from Loftum 2006 31 Hardware 21 Input Voltage 18 36VDC Input Current 7A RMS 24VDC Output Voltage Min load Max load Ripple amp Noise 5V 0 10 50mV 12V 0 2 5A 100mV 12V 0 0 5 100mV General Power 86W Efficiency 70 MTBF 251 000hrs Temperature 0 50 C Operating 20 85 C St
88. imit Switches This section describes the first step in implementing an angle limiting function on the inverted pendulum The purpose is to avoid that the pendulum motor is giving a torque that would move the pendulum to a bigger angle when it reaches its end positions These end positions are given by the frame mounted around the lower part of the inverted pendulum providing a physical obstruction when the pendulum tries to move too far away from its vertical position On this frame two limit switches were mounted but not connected to the motor in any way In the following a description of how these switces first were connected and why this was wrong For the busy reader only interested in how the implementation ended up refer to Section 5 5 Loftum 2006 suggested a way to implement the functionality for the switches The proposal included no software only two diodes to disallow reference voltages into the Baldor TFM 060 06 01 3 that would make the pendulum move further away from its vertical position if a switch is trigged The connection diagram is shown in Figure 4 10 Different alternatives were evaluated The first one evaluated was to connect the switches to the DMM 32 AT input ports and implement the safety function in software As soon as the signal from the switches could be observed by the software additional functionality could be added e g self calibrating of the pendulum angle in a start up procedure But it is generally a
89. ispatch block and dis patch_handler functions have been used instead of the corresponding resmgr_ func tions mentioned earlier For instance the function resmgr_ block which takes a vari able of type resmgr_context_t as an argument is a special case of the function dis patch block which takes a variable of the type dispatch_context_t in stead The resmgr versions should only be used with simple resource managers 18 CHAPTER 2 BACKGROUND Chapter 3 System description This chapter describes the state of the CyberBike at the point where the work on this thesis started First the various hardware devices are introduced and then a short summary of the code that was delivered with the project 3 1 Hardware An overview of the CyberBike s hardware units at the starting point is shown in Figure 3 1 Monitors Ethernet connections keyboards and mice are not shown The IMU and propulsion motor are included in the figure even though they were unmounted and not connected by the start of this thesis because a considerable effort were put into making them available to the CyberBike before this thesis started 3 1 1 Power supply The power supply unit used for DC DC converting transformation is a ACE 890C from Technology Corporation Specific data for this module is shown in Table 3 1 which is extracted from the vendor s website Technology Corp 2005 Figure 3 2 shows the ACE 890C 3 1 2 Computer F
90. ispatch block function call and the other reading data from the serial device storing it in a shared measurement array This array is protected by a mutual exclusive semaphore mechanism provided by POSIX The word merge used above is strictly speaking a simplification This operation included some rewritings variable and function name changes e g from read to mt_read etc type changes debugging and testing to get things correct Usage The example code requested user inputs during initialization to set up the correct serial device if calibration and or orientation data should be presented on the screen and if the orientation data should be given as rotation matrices quaternions or Euler angles These settings could now be set from the command line as arguments to the driver insted of via scanf function calls during initialization usage example of the driver is shown in Printout 5 1 devc mt vv m3 f2 s dev ser2 Printout 5 1 Usage example of devc mt This would start the driver in noisy mode showing both calibration and orientation data using the COM2 serial port Starting the driver in verbose mode v will only show debug related information and not the measurements usefile is compiled into the driver enabling the use devc mt command to give an explanation of how the driver is started with its various options similar to other QNX programs 5 2 MTi 67 The CyberBike is
91. l V2 64 8430 D Central Ave Newark CA 94560 2003 URL http www diamondsystems com Diamond Systems Corporation Online support manuals drivers technical community online May 2007 URL http www diamondsystems com support Accessed 23 May 2007 DtC Lenze as online May 2007 URL http www dtc no Accessed 25 2007 EAO Condensed Catalogue Experts in Human Machine Interfaces EAO AG Tannwaldstrasse 88 4601 Olten Switzerland 2007 URL http www eao com global en products condensedcatalogue byseries UK_English EAO_SERIES_ 44 SWITCHES ENGLISH pdf Downloaded from vendor web site 24 May 2007 109 110 CHAPTER 9 CONCLUSION Olav Egeland and Jan Tommy Gravdahl Modeling and Simulation for Automatic Con trol Marine Cybernetics AS P O Box 4607 NO 7451 Trondheim Norway second edition Jun 2002 URL http www marinecybernetics com ELFA online 2007 URL http ww elfa se no Accessed 9 Mar 2007 Mikael Eriksen AUAV Ground Station correct this reference Master s thesis Norwegian University of Science and Technology NTNU Trondheim June 2007 Working title only The master thesis was unpublished when this thesis was written Thor 1 Fossen Marine Control Systems Guidance Navigation and Control of Ships Rigs and Underwater Vehicles Marine Cybernetics AS P O Box 4607 NO 7451 Trondheim Norway 1 edition Dec 2002 URL http www marinecybernetics com John A Fo
92. lems with the DMM 32 AT output channels see Section 6 5 the tuning of the motor was not applied very success fully A small offset seems to appear sometimes as the components in the system gets warmer and the motor tend to be rotating with very low speed even if the reference voltage is set to zero A proper tuning of the bikes velocity controller is left undone as reasonably good velocity control seems to be unattainable as long as the DMM 32 AT is giving unstable output 3Proportional Integral Derivative controller 5 4 New driver for DMM 32 AT 69 5 4 New driver for DMM 32 AT During the work on this thesis some problems with the CyberBike s I O card was dis covered Section 6 5 describes this process in detail Several errors was discovered Both in hardware and software When searching for ready made download software from the vendor as an attempt to eliminate the devc dmm32at resource manager as an error source it was discovered that Diamond Systems Corporation 2007 provided a universal driver library for QNX systems Why this library wasn t used in the first place is unknown Studying the dmm32at_ analog write implementation in dmm32at c compared to the description of how to perform a D A con version in Diamond Systems Corporation 2003 p 36 showed that it probably would have been wise This erroneous code have been used on the bike for a long time It might have caused the hardware errors but it is nei
93. made such that it has ground on pin 1 and 3 and Vcc on the pin in the middle This is to avoid destroying the device if plugging it in upside down Push the power button If an external power source is used it should be set to 24V Make sure it could deliver enough current Rememember that the motors are capable of using 11 84 2 94 4A 18 7A at rated speed The fuses on the batteries are chosen to be 15A which should be more than sufficient for the load applied to the motors in this case If the suicase is closed be careful if cables are hanging out make sure the fan is running The fan is a bit noisy and therefore a switch placed at the foremost left corner in the suitcase is made such that the fan stops when the suitcase is open The QNX Neutrino login screen should appear on the screen Press the Superuser icon or type root No password is needed If another PC with the QNX Momentcs IDE are to be used for development go through the QNX Quickstart guide QSSL 2005 to set up the host system the target system CyberBikePC should not be altered The emergency button should now be deactivated by turning it counterclockwise if some output on the motors are desired Start the drivers on the target machine by typing devc dmm32at devc imu devc mt devc gps devc velo in a terminal window The devc velo has to be started last Device files should be accessible from the dev directory when the dri
94. me ters and potmeters were written An Inertial Measurement Unit IMU was intended to supply the control system with the necessary information about rotation acceleration and position and the unit was purchased for the purpose Also a driver was written but not properly tested The IMU had to be installed and connected to the control system The bike s control theory was developed but had never been put into action outside computer simulations due to the lack of acceleration measurements The various tasks that had to be addressed emerged as the development process ad vanced First the IMU had to be connected to the system by making a signal tranceiver circuit A small printed circuit board was designed and laid out mainly to include a MAX233CPP iC Then the DB 9 serial connector on the bikes single board computer Wafer 9371A could be used to read the UART signal from the IMU as RS 232 Then some testing had to be done and drivers updated A better and more advanced IMU referred to as the MTi was added to the project This unit needed no signal converting circuitry but driver development and testing still had to be done To enhance the CyberBike s navigation opportunities a GPS module was purchased A signal transceiving circuit similar to the one for the IMU was made for this unit as well as software to read out the measurements from the device By the end of this thesis no navigational algorithms are made hence the
95. me ambiguity The 2 4 connection is indicating that the RS 244 is used and the 1 3 connection set RS 232 It is worth noting that the RS 232 connection was actually working under these circumstances earlier in the project The jumper closing pin 2 4 was removed in order to be sure to use the RS 232 signal The cable used to connect to the COM2 port is shown in Figure 6 5 All lines were tested by the beeping function on the multimeter to check for some broken wires or connections but it seemed to be fine 6 3 ports 87 Figure 6 5 The serial cable provided with the Wafer 9371A to be connected to the COM2 header Then the BIOS settings were evaluated to be sure that no other devices was set up to use the specified address for the ports The settings were COM1 on 3F8 and COM2 on 2F8 as expected and no IrDA or ASK IR was enabled This had to be tested in another operating system to be sure QNX was not playing a part in this error 6 3 1 Linux installation Linux was installed at the compact flash card by using a USB memory stick as a source The stick shown in Figure 6 6 was borrowed from another student ready configured and set up by the procedure described in Canonical Ltd The Fujitsu hard drive was disconnected in order to be sure not to owerwrite the QNX installation when installing Linux on the CF i Figure 6 6 The USB memory stick used as source storage medium when installing Ubuntu Linux on
96. n Equation 3 1 5V 5V 153uV 3 1 The value returned by the A D converter is a two s complement number in the range 32768 to 32767 Because the input range of the A D is fixed This is regardless of the input range Four analog outputs are provided by a 12 bit DAC This gives the resolution shown in equation Equation 3 2 The resolution is the smallest possible change in output voltage in this case 5V 5V a g 32 Auto calibration The DMM 32 AT is equipped with an octal 8 bit TrimDAC and high precision low drift reference voltages on the board Whenever the programmer decides to call for it this circuitry works in conjunction with the driver software to perform an auto calibration The optimum TrimDAC values for each input range are stored in EEPROM For A D calibration the entire process takes about one second for each input range The Universal Driver software provided by the Diamond Systems Corporation have two specific functions for this purpose dscADAutoCal and dscDAAutoCal and a stan dalone DOS program to enable calibration without any programming 3 1 5 Motor controller card The motors on the CyberBike are powered through a Baldor TFM 060 06 01 3 see Figure 3 7 A summary of the specific data for this card is extracted from Baldor ASR 1988 e 4 quadrant operation e 360 Watts possible continuous output power Field programmable gate array 13 Analog to Digital Co
97. nd most demanding parts of the work to be done To be more concise the driver for the 1 card DMM 32 AT needed a thorough investigation and rewriting the propulsion motor connection and setup had to be completed the IMU initially used in the CyberBike project from Spark Fun Electronics needed a UART to RS232 signal transceiver circuit to enable measurement transmission The same IMU also needed some code maintenance to work properly and the pendulum motor needed functionality implemented to its already mounted limit switches Finally some pure hardware related tasks were carried out These included installa tion of a fan for cooling the electronic devices in the control system batteries to power up the system without using cables and an emergency stop switch Some attempts to use the measurements from the various devices together with a previously developed CyberBike model and controller in Simulink using S functions were performed But to get any specific test results from this not sufficient time was left for the exercise When the first IMU from Spark Fun was installed and tested it was realized that 107 108 CHAPTER 9 CONCLUSION a large effort on converting and calibrating the data received from the unit had to be done to be able to use the measurements to controlling the bike It was then decided to try the other and more advanced IMU the MTi instead This unit contains its own digital signal processor converting t
98. nd how much of the model of Bjermeland 2006 that was included The current model appended on the CDROM is terminated after just a few samples There has not been done enough testing to point out where the problem resides The first that came in mind was that the sampling rate was too high 0 028 compared to the calculation computing task that had to be performed The Wafer 9371A CPU is only running at 400 MHz which is no problem to exhaust running a complex matlab code with observer and a bike model Further testing on this was discontinued by the occurrence of the last COM port problems discussed in Section 6 3 2 TESTS AND EXPERIMENTS CHAPTER 6 94 Reference psi_dot Model of Bicycle Rider Dynamics Path Control System Integer Delay Speed reference The CyberBike Plotting XY Graph Figure 6 7 The main blocks in the CyberBike Simulink model 6 6 Testing the control algorithm 95 Code sample 6 2 The main code performing the I O operations to the actual bike in bike_io_wrapper c Reading the CyberBike for i 3 i lt NumVeloDevices i ret devctl fd i VELO DEVCTL GETVAL amp meas sizeof meas NULL if ret 1 fprintf stderr As NtERROR when performing devctl getval fon 4s ths n NAME velo devnames i strerror ret else
99. ng Signal X1 2 DMM 32 AT J3 5 Input Channel 1 Potmeter pendulum Signal X1 3 DMM 32 AT J3 7 Input Channel 2 Steer tacho Signal X1 4 DMM 32 AT J3 9 Input Channel 3 Pendulum tacho Signal X1 5 DMM 32 AT 3 11 Input Channel 4 X1 6 DMM 32 AT 3 13 Input Channel 5 7 X1 1 X1 8 DMM 32 AT J3 19 Connects propulsion tacho to I O Vin 8 differential input X1 12 X1 9 DMM 32 AT 11320 Connects propulsion tacho to I O Vin 8 differential input X1 10 X1 11 Propulsion tacho GND X1 12 BALDOR 2 c14 Measurement ground for speed control on BALDOR card Steer tacho GND X1 13 DMM 32 AT J3 2 on I O card Pendulum tacho GND X1 14 DMM 32 AT 3 2 on I O card Pendulum sw B2 NC out X1 15 D2 X2 2 Connected to positive side of Diode 1 and X22 Pendulum sw B2 NO out X1 16 D2 Connected to positive side of Diode 2 Pendulum sw B2 In X1 17 X1 19 Series connection of the two switches Pendulum sw B1 In X1 18 DMM 32 AT 3 35 Vout on I O card Pendulum sw B1 NC out X1 19 X1 17 Series connection of the two switches Pendulum sw NO out X1 20 D1 Connected to negative side of Diode 1 X1 21 X1 22 Potmeter steering 5V X1 23 DMM 32 AT 3 39 Vref out on I O Potmeter pendulum 5V X1 24 DMM 32 AT 113 39 Vref out on I O Potmeter steering OV X1 25 DMM 32 AT 3 2 on I O card Potmeter pendulum 0V 1 26 DMM 32 AT J3 2 on I O card BALDOR 2 26 X2 1 DMM 32 AT 3 1 Connects I
100. ng any problems during the work on this thesis 7 2 IMU Choice When the first IMU from Spark Fun was ready and connected to the Simulink controller via S functions it was realized that a lot of tuning and calculations of the IMU data had 97 98 CHAPTER 7 DISCUSSION Power source Batteries Fan Power POW Ese Reference signale Power supply unit psu ACE 890C Power Single Board Computer SBC Wafer 9371A Measure Ment data PC 104 bus connection Card Diamond MM 32 AT Motor controller card Baldor 060 06 01 3 Propulsion motor PWM Power signal Steering motor Pendulum motor Rotational velocity feedback GPS Spark Fun IMU MTi 7 21 Measurement Figure 7 1 Overview of the CyberBike s various hardware devices by the end of this work 7 3 GPS 99 Suitcase wall or other steady mounting point me Elastic rubber band Figure 7 2 Suggestion for better physical mounting of the disk drive to be done in order to make them useful The MTi contains its own digital signal processor giving the user the possibilities to choose between different representations of the data If Euler angles is chosen as is the case for the CyberBike the device is sending calibrated ready to use roll pitch yaw angles to
101. ng with a programmable time between samples between 20 and 5s interrupt based sampling for controlled rate sampling and channel range sampling The CyberBike s control algorithm is supposed to use a constant sampling rate of all input signals for every step and this could have been performed a lot more efficient by using some of these features provided by the I O card In Diamond Systems Corporation 2003 p 31 an overview of different sampling methods are described and for which types of application the different methods fit But before this is investigated further the CPU utilization for the driver should be evaluated to decide if this is really needed If the current sampling method makes the driver satisfy the real time constraints considerations on delay and jitter for the las soon as more serial interfaces added to the system variation in delay 8 5 Videocamera 105 CyberBike and the total CPU utilization on the CyberBikePC is sufficiently low when all the necessary drivers are running it might not be worth the effort 8 5 Videocamera It would be interesting to see and record the trip from the CyberBike s point of view when the bike is going for an autonomous ride For this purpose a simple web camera would be sufficient An analog camera with its own unit for transmitting data is assumed to be the simplest solution here to ease installation and to avoid an overload of the WiFi connection and the CyberBikePC
102. nverter Digital to Analog Converter 30 CHAPTER 3 SYSTEM DESCRIPTION e 6A continuous phase current e 24V nominal DC1 bus voltage which makes it possible to operate it from two 12V batteries in series circuit e Double eurocard format e Internal power supply accepting 24 to 65 V as input e Differential reference input to avoid ground loops e Short circuit proof between the outputs and to ground e Bandwith from DC 0 Hz up to 2 5 kHz z 14 7 of the switching frequency of the pulse width modulated output signal e Ca 80 96 efficiency Figure 3 7 The CyberBike s motorcontroller card a Baldor TFM 060 06 01 3 Seen both from the rear and the front Pictures copied from Loftum 2006 3 1 6 Motors There are three motors installed on the CyberBike to perform three different tasks make the CyberBike move forward propulsion change the steering angle and change the pendulum angle Propulsion motor The propulsion motor was not installed when the writer of this thesis took over the CyberBike but it was acquired and available at the start of the project be able to connect and use the motor correctly some information about it was collected and Direct Current 31 Hardware 31 a slightly more detailed presentation of this motor than the other two follows in this section Figure 3 8 shows the motor from DtC Lenze as 2007 motor type 13 121 55 3 2 0 with worm gear SSN31 The digits in the motor
103. o deserves an acknowledgement for being oblige and helpful on the tasks involving part and device mounting Mikael K Eriksen shared his knowledge and PCB layout on the GPS part and the Eurobot guys Gunnar Kjemphol and Kristian M Knausg rd spared an DMM 32 AT I O card and hard disk drive for the CyberBike It really helped me getting further on the project And at last but not least I would like to thank my girlfriend Marte for keeping the faith even though the amount of my time and mind used on this project at times have gotten out of hand Trondheim June 2007 Audun Solvberg ii Contents Abbreviations and acronyms vii List of Figures xi List of Tables Xiii List of Code samples List of Printouts xvii 1 Introduction 1 Motivations owe Reed X es 1 1 27 Problema ta A A RUE A A A 1 1 9 Previous WOPK a oe 2 14 comment on outline and language 2 2 Background 3 2 1 The CyberBike model 3 2 1 1 Important assumptions and simplifications 3 2 1 2 Modeling the different parts 5 2 13 Other important 7 2 2 QNX Neutrino and EE Se dS 13 2 2 1 i i SG REGE ee 4 13 2 2 2 Resource Managers olov WR UR eR 15 3 System description 19 3 I
104. o note about this code is the busy while loop at the start looking for an A in the measurements read from serial device the variable fd is a file descriptor passed to the thread in the pthread_create call and is the same as the serialFD variable in Code sample 4 3 The second thing is the synchronization mechanism a POSIX mutex which is locked at the start of the loop and unlocked afterwards This lock s purpose is to protect 4 1 IMU alternatives 43 Code sample 4 5 The second loop in devc imu old version while running Waiting for start character A if verbose printf ImuThread tPolling n while iReadCnt read fd amp buffer 1 lt 0 buffer A Lock mutex if pthread_mutex_lock amp val_mutex printf ImuThread tCouldn t lock mutex n For each of the 16 16 bits measurements Fetching 2 8 bit values for each measurement and shifting putting them into the measurement array if verbose printf ImuThread tRead for ii 0 11 lt 16 ii while iReadCnt read fd buffer 1 lt 0 measurements ii buffer lt 8 amp OxFF00 while iReadCnt read fd amp buffer 1 lt 0 measurements ii buffer amp if verbose printf d measurements ii if verbose printf n Release mutex if pthread_mutex_unlock amp val_mutex printf ImuThread
105. offset and gain met specified tolerance DMM 32 AT Configuration Mode 12 Offset Error 0 724 Gain Error DMM 32 AT Values for offset and gain met specified tolerance DMM 32 AT Configuration Mode 13 Offset Error 0 022 Gain Error DMM 32 AT Values for offset and gain met specified tolerance DMM 32 AT Configuration Mode 14 Offset Error 0 456 Gain Error DMM 32 AT Values for offset and gain met specified tolerance DMM 32 AT Configuration Mode 15 Offset Error 0 052 Gain Error DMM 32 AT Values for offset and gain met specified tolerance Printout 5 2 Usage example of new DMM 32 AT driver running autocalibration 72 CHAPTER 5 SOLUTION DMM 32 AT BALDOR Vout3 Agnd Vref 03 35 134 2 26 2 26 Pendulum 5 B2 B1 2 gt EM in in 4 MSN NC NC y Figure 5 4 Overview of the pendulum limit switches final connection circuit diagram 73 suorj2ouuoo euru UOTJOUUOD euy pyas yru umpnpuoed oy jo 6 6 9INSIJ ion lementat imp t switch final imi Pendulum 1 5 5 eure1j ON ON ON s gt 5 2
106. om the MTi is given from a calculation of the orientation between a sensor fixed S and an earth fixed G reference co ordinate system The local earth fixed reference system is defined as a right handed Cartesian co ordinate system with e X positive when pointing to the local magnetic North e Y positive pointing westward according to the previous point e Z positive along the vertical axis The output reference co ordinate system could be reset to an object fixed reference system in four different ways 1 Heading reset redefines the global coordinate s x axis while the z axis is main tained along the vertical Global reset resets all global axes to point in the direction of the current 5 coordinate system Object reset defines how the sensor is oriented with respect to the coordinate axes to which it is attached Alignment a combined object heading reset 41 IMU alternatives 47 The data could be received as rotation matrices Euler angles roll pitch yaw quaternions It is important to note that choosing Euler angles could cause some trouble due to a mathematical singularity when the pitch angle is close to 90 but in the CyberBike s case this should not be an issue Connection As mentioned earlier the MTi could be connected using both USB and RS 232 Due to some problems with the serial ports described in Section 6 3 attempts to make the MTi communicate with the CyberBikePC via USB s
107. ompact Disk Compact Disk Read Only Memory Compact Flash Central Processing Unit Often just reffered to as the Processor Digital to Analog Digital to Analog Converter Direct Current Driver Development Kit Digital Signal Processor Electrically Erasable Programmable Read Only Memory Enhanced IDE Integrated Drive Electronics see ATA vii FIFO FPGA GB GPS GUI 1 O IOV IDE IMU ITK ksh LED LOS LSB LQG MB MHz NC NTNU OCB 05 PID First In First Out Field programmable gate array type of PLD Giga Byte 1024 Mega Bytes MB Global Positioning System Graphical User Interface integrated circuit Input Output I O vector Integrated Development Environment Inertial Measurement Unit Department of Engineering Cybernetics acronym formed by the Norwegian name Institutt for Teknisk Kybernetikk Korn SHell Ligth Emitting Diode Line Of Sight Least Significant Bit Linear quadratic Gaussian control Mega Byte 1024 Kilo Bytes KB Mega Hertz Normally Closed Norwegian University of Science and Technology the acronym is formed by the Norwegian name of the university Norges teknisk naturvitenskapelige universitet Open Context Block Operating System Printed Circuit Board Proportional Integral Derivative controller viii PLD PM POSIX QNX QSSL RAM RM RTOS SBC SO DIMM UART USB uC Programmable Logic Device Process Manager Portable
108. or the bike Available drivers are e devc dmm32at e devc dmm32at old e devc gps e devc imu e devc mt e devc velo Connection diagrams contains an Excel spreadsheet with the source of the various connection diagrams presented in Appendix E and generated TFX files Eagle PCB layout contains the Eagle files for both signal transceiving PCBs made in this project GPS and IMU Litterature includes electronic versions pdf of some of the articles manuals and datasheets relevant for the CyberBike matlab contains files to make Real Time Workshop cooperate with QNX Report contains this report with figure sources IAXTEX files and final pdf Scripts contains some small scripts made to do often performed operations in QNX Particularly the nfs script have been useful Simulink contains some simulink models with S functions to communicate with the CyberBike s drivers Software contains software used such as the various programs and libraries provided by the DMM 32 AT s vendor programs to make a DOS bootable USB stick Ter minals NFS server program etc 115 116 APPENDIX A CONTENTS ON CDROM Appendix How to start the CyberBike system This chapter is intended to give a flying start of how to start the system 1 10 Push the emergency button and make it stay in activated position no torque on motors Put the power switch in off condition a zero is visible at the top of the switch Connect
109. orage Dimension 152 4 x 89 x 39mm Table 3 1 Specific data for ACE 890C Figure 3 3 The Wafer 9371A SBC used at the CyberBike Picture taken from Loftum 2006 22 CHAPTER 3 SYSTEM DESCRIPTION Parameter Value Product WAFER 9371A Form Factor 3 5 SBC CPU ULV Intel Celeron 400 Display CRT 36 bit TTL 2x18 bit LVDS I O Interface 1x EIDE 1 FDD optional floppy drive connector 1 52 Keyboard connector 1 52 Mouse connector 1x RS 232 422 485 1 RS 232 1x LPT parallel port connector Ethernet 10 100Mbps RTL8100C USB 2x USB 1 1 Audio ALC655 5 1CH IrDA 115kbps WDT 1 255 sec Power Consumption 5V 2 01A ULV Celeron 400 256MB Dimension 5 7 x 4 Table 3 2 Specific data for Wafer 9371A 31 Hardware 23 nection as shown in the Table 3 2 PC 104 devices screens USB mice keyboards USB sticks hard drives and serial communication devices can easily be attached to the Wafer 9371A and communication with the device is made simple by an Ethernet con nector is set up to be using RS 232 signals but COM2 could be configured to com municate on RS 232 RS 422 or RS 485 by modifying the jumper JP4 settings on Wafer 9371A The location of JP4 is showed in Figure 3 4 and the pin configuration is showed in Figure 3 3 Figure 3 4 The JP4 pin locations on Wafer 9371A Figure taken from Technology Corp 2006 PI
110. overs a relatively large area which makes the switches closed for a wide range of angles e It is desired to keep the connection complexity in the CyberBike s suitcase as low as possible to ease maintenance and debugging e No particular need for the information from the switches were detected in the control system But it should be noted that the work in this thesis does not include sufficient amount of testing and tweaking of the control algorithm to claim that the pendulum angle calibration functionality is not needed 5 6 Emergency Stop Button The 3 DC motors have the potential to being dangerous to people around In an industrial environment such moving devices as rotating gears with chains and swinging bars have to be put inside boxes or behind covers The CyberBike is not equipped with many safety related devices and installations Before serious testing is done at least an emergency stop button should be mounted A button switch and a front adapter for mounting was ordered from ELFA 2007 and is shown in Figure 5 6 The switch part is of type From Baldor ASR 1988 p 1 it could be found that It 1s possible to switch off the power stage on each axis via the disable inputs The motor is without torque in this condition 5 6 Emergency Stop Button Figure 5 6 The emergency stop button and switch Picture taken from EAO 2007 Baldor 2 a4 2 a30 1 a14 1 c32
111. propulsion motor and gear 2 31 Specific data for the pendulum motor read from its nameplate 32 Specific data for the steering motor read from its nameplate 33 CPU consumption for the old and new version of devc imu approximate i oc 41 Specific data for the GPS module from GlobalSat 55 Specific data for the ATU12 35 batteries from ACT Batteries TT Terminal block outside suitcase 127 Sorted two column version of Table 128 Connection table for Baldor 060 06 01 5 130 Connection table for the terminal blocks X1 and X2 132 Connection table for J3 on 3 134 xiii XIV List of Code samples 41 Part of velo build where boot options for devc ser8250 is specified 40 4 2 Opening of the serial device in devc imu NDELAY is specified 41 4 3 Opening of the serial device in devc imu correctly Al 4 4 The first loop in devc imu 42 4 5 The second loop in devc imu old version 43 4 6 The second loop in devc imu new version Most of the error checking and terminal printouts are removed in this sample to increase readability 45 4 7 The type of the measurement struct defined in gps h 57 4 8 Example from parse gpgll on storing values in measurement struct 58 5 1 The only change ma
112. r hereby take the opportunity to emphasize that debugging in instru mentation systems like the CyberBike s do take a lot of time It is important to note that a lesson learned by the work in this thesis is that very often none of the parts in the system could be fully trusted Using several hours trying to find errors in newly self written software usually considered to be the most obvious place to start more than once resulted in discovering that the error was lying in a hardware unit fully operative until recently and believed to be thoroughly tested 102 CHAPTER 7 DISCUSSION Chapter 8 Further Work This chapter describes what has to be done next and what could be interesting to get implemented An attempt to set the various tasks in a prioritized order is suggested here The first task to be assigned to the projects subsequent student should be to get the defect hardware to work properly This includes the serial ports on the Wafer 9371A see the following section and the output channels on DMM 32 AT The decision on how to solve it has to be made quite early in the work on a new thesis If a solution involving recondition of existing hardware is to be carried out make sure that the hardware will be returned within reasonable time This said it is believed that a fifth year student at ITK effectively and rationally putting an effort into the CyberBike project during the spring term project would be able to execute t
113. r is the bias vector u is the sampled voltages s Kj u br 8 1 It is also noted that the model actually used by Xsens is much more complicated than the Equation 8 1 and that their model is continously being developed alternative way to develop the model or the parameters in the above equation would be to use an adaptive algorithm reading the data from the IMU and from the actual known accelerations and rotation speeds The suggestion for further work given in this section is not yielding the CyberBike project any real progression as long as the MTi is available It is mentioned here because 106 CHAPTER 8 FURTHER WORK it might be an interesting task to be assigned as a separate project or thesis in the future or if sharing the MTi between two or more projects gets too complicated 8 7 Connection database If serious reorganizing or adding of several connections and devices to the CyberBike s suitcase it might be worth to consider using a database tool to keep the documentation of the connections up to date In Appendix E some tables showing the connections are presented These probably get out of date as soon as hardware related upgrades are done to the CyberBike Parts of the information are presented in more than one table This complicates the update process of the documentation and makes it harder to keep an overview However if changes to the hardware has to be made an update of the existing tables is probably p
114. re indicated 5 1 The Fujitsu MHK2060AT hard drive 5 2 40 to 44 pins IDE connector converter 5 3 The MTi protective 5 4 Overview of the pendulum limit switches final connection circuit diagram 5 5 Circuit diagram of the pendulum limit switch final connection with ter minal block connections indicated 5 6 The emergency stop button and switch Picture taken from EAO 2007 5 7 Circuit diagram of how the emergency button is connected 5 8 The cooling fan mounted at the CyberBike s suitcase 5 9 The fan switch mounted to be activated when suitcase is closed 5 10 Connection diagram for the batteries 5 11 12V battery from ACT Batteries 5 12 The power switchz Linee dew RU ae tcs 5 13 Schematic overview of the CyberBike s drivers by the end of the work on thiszthesis iuo uk Rm Er eer knee rar t 6 1 Escort EDM 168 Multimeter a o o e 6 2 Hameg HM507 oscilloscope 6 3 Power Sources ose a murum Dog Re 6 4 Sketch of the horizontal pendulum with weight at the end 6 5 The serial cable provided with the Wafer 9371A to be connected to the COM header otras a eek a dix 6 6 The USB memory stick used as source storage medi
115. referable Onshus 2006 chap 16 is describing how documentation of large control systems should be done and mentions a few examples on computer assisted documentation soft ware packages Using these would probably be an overkill in this case but maybe simpler alternatives exist to be used in the CyberBike s case Chapter 9 Conclusion A project on an autonomous unmanned bicycle the CyberBike has been going on at the Department of Engineering Cybernetics ITK at NTNU for some years The goal of the project is to make the bike ride on its own by controlling the steerangle the bike s velocity and an inverted pendulum substituting the leaning rider To achieve this three motors are used to apply torque to the steering the rear wheel and the pendulum But to control these measurement devices and a calculating unit is necessary as well as a controller The work on this thesis includes various tasks mainly focusing on software and hardware development for the instrumentation parts of the control system A part of the assignment was to find out what had to be done Measurements from two new devices have been made available to the controller an Inertial Measurement Unit IMU and a Global Positioning System module GPS Some devices already included or partly attached to the system needed further development to work properly with the rest of the system This introduced code and hardware maintenace tasks as some of the biggest a
116. rity thread is con suming all available or preventing other threads from consuming CPU time even if higher priority threads are ready to run On a single processor machine there is no such thing as absolute simultaneous processing 8Input Output I O vector The character is here used as a wildcard and could be replaced for instance by Write Send Reply or Read Central Processing Unit 2 2 QNX Neutrino 15 Priority inheritance is the solution provided by Neutrino and is a feature that makes a receiving thread inherit the priority of the highest of all blocking clients For an explanation on how problems of priority inversion could occur and why in heritance is the solution to the problem refer to Krten 2001 2 2 2 Resource Managers Resource Managers RM are simply programs with some well defined characteristics which have the goal of presenting an abstract view of a service The abstraction is based on the POSIX specification RM will almost exclusively be dealing with file descriptor based functions Clients that whish to use an RM usually initiates the communication by an open or fopen call In QNX Neutrino such a call is routed as messages to the Process Manager PM which will return which resource manager s that suits the open call i e which file was specified as argument Then a request to the referred RM is sent When the RM replies the open call returns
117. rted on the CyberBikePC in verbose mode like shown in Printout 4 1 Printed Circuit Board 37 38 CHAPTER 4 SUGGESTED SOLUTION Figure 4 1 Photo of the IMU and UART to RS232 converter card mounted in the Cy berBike s suitcase audun audislappis report telnet 129 241 154 76 Trying 129 241 154 76 Connected to 129 241 154 76 Escape character is gt 7 gt login root devc imu verbose amp 1 57360 devc imu Verbose mode devc imu Opening serial port devc imu Port opened File desc 3 ImuThread I m alive Filedesc 3 ImuThread Polling devc imu Running ImuThread Read 522 522 522 522 522 522 522 522 522 522 522 522 522 522 522 522 ImuThread Polling Printout 4 1 Terminal dump of CyberBike login and starting of IMU driver 4 1 IMU alternatives 39 From there the terminal displays measurements only occasionally and not in the speed at 23 5Hz as stated by Spark Fun 2005 Nevertheless the diode on the IMU is still lit indicating that the unit is in operation The first thing to check is if the IMU has ceased delivering the specified amount of measurements The IMU was connected to the Windows XP development host PC s serial port RS232 to see if something was wrong with the unit In Figure 4 2 the output of the terminal window is shown 7 Terminal v1 9b 20041226 by Bray Data bits Parity Stop bits Handshaking none 1 none odd R
118. running on the node and which state they are in devc ser8250 options the serial driver was executed with wrong options specified in the boot script see Section 4 1 2 and this should be corrected in this version of the OS image updated drivers some adjustments on the drivers have been performed and the up dated versions should be put on the new image devc gps driver for the GPS5 wireless ethernet driver driver for the wireless Ethernet card keyboard setup the keyboard connected to the CyberBike has a Norwegian layout but the CyberBikePC is assuming it is English which makes typing a bit difficult i e the letters on the actual keyboard does not correspond with the letters appearing on the screen while typing kshre the developer of the new OS image is familiar with Linux and Bash terminal setup Hence some settings to be performed during boot were preferable to make the ksh shipped whith QNX Neutrino to appear a bit more like Bash e g TAB completion and some aliases 15 18 F and l other additional commands common Linux Unix and QNX programs commands to make life easier e grep print lines matching a pattern e find search for files in a directory hierarchy e less similar to more but enables backwards movements in the file e make links between files e waitfor wait for a name to exist QNX Global Positioning System Bourne Again SHell Korn SHell 4 2 OS upgrade
119. s CPU consumption A webcamera with USB interface would require support from the QNX Neutrino system running on the CyberBikePC and hence might also generate some additional compatibility problems To get the best possible real time properties on the system the load on the CPU should be lower than 100 and this is also a relevant argument for not letting the camera signal go through the CyberBikePC s CPU 8 6 Adaptive IMU signal converting In Section 7 2 it was argued that the MTi is a far better solution than the original IMU from Spark Fun But since the original IMU already is purchased and available it could be interesting to put some effort into making it a better device releasing one or the other to other projects If an algorithm similar to the one running at the MTi s DSP could be derived the IMU s utility value would increase From Xsens 2006 it could be read that the physical sensors inside the MTi are calibrated according to a physical model of the sensors response to various physical quantities Temperature is named as an example The combo boards the three cards with embedded accelerometers and gyros on the Spark Fun IMU also provides temper ature measurements included in the 16 values transmitted from the IMU motherboard Xsens 2006 states that the basic model used at the MTi is linear and according to the relation given in Equation 8 1 where is a unique gain matrix given by the factory calibrations b
120. s illustrated in Figure 7 1 It is put here to be comparable to Figure 3 1 to see the achieved hardware extensions during this work Switches and buttons are not shown 7 1 Choice of storage medium The reasons for choosing the hard drive instead of the flash card have been described in detail in Section 4 2 1 Generally it could be stated that the choice was made to get a quick solution to the OS image problems The disk is mounted at the suitcase s bottom plate beneath the motor controller card One thing that have been left to possibly be discovered during future testing is if the hard drive could put up with the disturbances imposed to it The suitcase and its content would probably be exposed to shaking and mechanical vibration from the pendulum and rapid changes in steering angle wheels running at an uneven surface could cause vertical perturbations and even worse if the bike collides or tips over many kinds of mechanical shocks could occur A better mounting solution might partly solve the problem An example is shown in Figure 7 2 where elastic rubber bands or another suitable material is used to damp the disk housing accelerations relative to the bikes movements The reason for not mounting it this way was partly because there is little space left in the suitcase But unfortunately the most crucial reason was that it was not thoroughly considered when the disk was mounted This could lead to future problems but was not yieldi
121. ssum Instrumentering og datasystemer for autonom kybernetisk sykkel Master s thesis Norges teknisk naturvitenskapelige universitet NTNU Trondheim Dec 2006 Fujitsu MHJ2181AT MHK2120AT MHK2090AT MHK2060AT DISK DRIVES PRODUCT MANUAL Fujitsu Limited Fujitsu Learning Media Limited 22 7 Minami Ooi 6 Chome Shinagawa Ku Tokyo 140 0013 JAPAN 1999 Manual code C141 E088 03EN GlobalSat Technology Corporation PRODUCT USER MANUAL GPS RECEIVER ENGINE BOARD EM 411 16 No 186 Chien 1 Road 235Chung Ho City Taipei Hsien Taiwan R O C URL www globalsat com tw Stephen Hewitt online 2002 URL http www angelfire com falcon speedload Enabler htm Accessed 29 May 2007 Technology Corp Wafer 9871A 3 5 Profile Wafer Embedded Board User Manual Rev 1 1 Jan 2006 Technology Corp 86W DC24V Input Open Frame AT Power Supply online 2005 URL http www ieiworld com en Product IPC asp model ACE 890C Accessed 30 May 2007 Rob Krten Getting started with QNX Neutrino 2 00 a guide for realtime program mers PARSE Software Devices 278 Equestrian Drive Kanata Ontario K2M 1C5 CANADA 2nd edition Aug 2001 ISBN 0 9682501 1 4 URL http www parse com Lenze Lenze Operating Instructions Lenze GmbH amp Co KG Small drives Postfach 10 13 52 D 31763 Hameln 1 0 edition Jun 2002 URL http www dtc no filer Manualer 20Lenze Manual 208m E5motorer 20AC DC PM 2Bgear 20GB pdf Scott Lightsey tplus
122. t A lot of information is presented in more than one table to make it easier to get an overview of connections while debugging making additional connections etc This should be kept in mind when updating or changing the tables to keep the documentation consistent see Section 8 7 The tables here is made in Microsoft Excel and exported to I3TEX by an excel2latex macro see Marder 2001 and the enclosed CDROM see Appendix A 125 126 APPENDIX CONNECTION TABLES E 1 Terminal block outside suitcase Legend NO Normally Open NC Normally Closed B1 left switch B2 right switch BX in connected to DMM 32 AT BX NC out connected to positive side of diode BX NO out connected to negative side of diode 127 Terminal block outside suitcase E 1 ose2jms IPISINO old T A AQ 8 19915 1939704 AG 8ULI00 19397304 qNO ON Ig Pyas umn npuoq UI Z Pyas un npuoq jn0 ON ZY Pras umn npuoq UNO 8012995 IJOWO unpnpusd 193ouroqoe T yeusts 19391304 2 61 lr I 9 VG CC 0 8T 91 VI 01 8 9 AQ UnInpued 19391304 umppued 193911304 jno ON Pas um npuoq UI 1g un npuoq jno ON cg Pyas um npuoq um npuod IN UOISTndoxrd 580119938 JI91
123. t the CyberBike s suitcase It turned out that the fan was a bit noisy and sitting beside it while developing and testing was a annoying To solve this a switch shown in Figure 5 9 was mounted to cut the power when the suitcase is open 5 8 Batteries During the development process a power source from Farnell shown in Figure 6 3 was used but for activities which includes forward motion of the bike two sealed lead acid 4Normally Closed 5 8 Batteries 77 Figure 5 9 The fan switch mounted to be activated when suitcase is closed batteries from ACT Batteries was ordered It was important that the batteries were either sealed or were using gel instead of acid There is no guarantee that the bike would stay on its wheels on every test run Battery acid leaks has to be avoided The sealed batteries seemed to be less expensive than the gel batteries and gives about the same amount of safety A tradeoff between size weight cost and amount of ampere hours had to be made The ATU12 35 model was chosen The specification for these batteries are given in Table 5 1 Variable Size unit Nominal voltage 12 V Rated Capacity 35 Ah Length 195 mm Width 130 mm Case height 154 mm Total height including terminal 184 mm Approximate weight 10 5 Kg Table 5 1 Specific data for the ATU12 35 batteries from ACT Batteries The batteries were placed in their dedicated frame on each side of the bike Cable shoes that
124. tCouldn t unlock mutex n 44 CHAPTER 4 SUGGESTED SOLUTION the measurement array from being read from by the imu read function mentioned above at the same time as it is written to by this thread When the A is found the loading of data into the measurement array is done by at least 32 sequential read operations on the serial device The reason for using the readcond function instead of read was because an rec ommendation from the QNX online library reference QSSL 2007c about readcond This function is an alternative to the read function for terminal devices providing additional arguments for timed read operations These additional arguments can be used to minimize overhead when dealing with terminal de vices 4 1 3 IMU Xsens MTi At ITK a more advanced and more expensive IMU was acquired mainly to be shared among two master projects the CyberBike and a project on development of an AUAV4 see Bjorntvedt 2007 The MT IMU from Xsens Motion Technologies is shown in Figure 4 3 Figure 4 3 The MT from Xsens with integrated DSP and magnetometer In Xsens 2006 chap 1 1 it is stated The MT is a miniature gyro enhanced Attitude and Heading Reference Sys tem AHRS Its internal low power signal processor provides drift free 3D orientation as well as calibrated 3D acceleration 3D rate of turn rate gyro and 3D earth magnetic field data The MTi is an excellent
125. ter rebooting your hardware will automatically be detected and because it was known that both the QNX host PC and the CyberBikePCwere x86 intel based computers and hence they could possibly use the same basic parts of the 1 Advance Technology Attachment Compact Disk 63 64 CHAPTER 5 SOLUTION Figure 5 1 The Fujitsu MHK2060AT hard drive shown both from its over and under side A piece of plexi glass is glued to the underside of the disk to ease mounting Figure 5 2 40 to 44 pins IDE connector converter 5 2 MTi 65 installation When the CyberBikePC was powered its hardware was detected and a fully working QNX installation were running on the bike s baggage rack computer The disk was finally mounted at the bottom plate in the suitcase below the Bal dor TFM 060 06 01 3 to utilize space 5 2 The MTi was connected to the Wafer by a serial cable into COMI A protective housing for the device was made to put the device in This is shown in Figure 5 3 It was aimed at mounting it as low as possible in order to keep it away from the shaking from the pendulum and to be close to the position where the roll angle is defined in the control system Ideally the MTi should have been placed at the point where the rear wheel is touching the ground but obviously this is hard to implement in real life Figure 5 3 The MTi protective housing 5 2 1 Driver The software driver for the MTi was made as
126. the resoldering Figure 4 8 The soldering side of the GPS board Left before resoldering Right after The component side of the PCB looks somewhat better and is shown in Figure 4 9 It could be seen from this figure that a voltage controller a LED a resistor two capacitors two headers a DB 9 connector and two screw terminals for Vcc and Gnd is soldered to the board How the GPS module is connected is also shown Figure 4 9 The component side of the GPS board 10Ligth Emitting Diode 4 4 GPS 57 4 4 2 The devc gps driver The driver for the GPS was made as a resource manager similar to the devc imu with a serial device reading thread and a resource manager thread handling client requests When a gps message is received it is parsed by the functions in gps messages c called by the serial device reading thread There exist one parse function for each message that could be received These functions stores the values received in local variables until they by the end of each function locks a mutex before the parsed values are stored in a mea surement struct Code sample 4 7 shows the measurement struct and Code sample 4 8 shows an example on the writing process to the measurement struct taken from the parse gpgll function Code sample 4 7 The type of the measurement struct defined in gps h typedef struct meas int date int hour int min int numberofsatellites int satellites 12 doubl
127. ther explored nor discussed further in this thesis Changing the code to use the uscud Diamond Systems Corporation s Universal Driver affected mosly the dmm32at c file The resource manager and thread setup was kept as it was The libdscud5 a had to be copied into a place where the QNX Momentics IDE s compiler could find it In the case for the installation on the Windows XP PC used for development on the CyberBike the library was placed in C QNX630 target qnx6 usr include dscud5 and dscud5 and m for the math library was added to the LIBS variable in the devc dmm32at projects makefile common mk How to use the universal driver is described thoroughly in Diamond Systems Cor poration 2007 by API and examples The core of the code for the new read and write functions are shown in Code sample 5 2 The actual code performs error handling ini tialization and resetting of global variables scaling of the return value in the read case and some printouts s if in verbose mode not shown here The library from Diamond Systems provided functionality for auto calibration which was at first put in the initialization function for the driver But because of the hardware errors described in Section 6 5 this had to be put in a separate function dmm32at_ autocal An option to be used from the command line when starting the driver was then added to make use of the autocalibration utility This should only be used with the da0 chan nel
128. tion The GPS functionality implementation process including making the PCB solder the components making the communicating software and mounting the unit to the suitcase went reasonably well without too much time spent on debugging and coding Still Actually the Spark Fun IMU is still mounted on the CyberBike in case the MTi gets unavailable The MTi is at this point in time as mentioned in Section 4 1 3 shared with another project 100 CHAPTER 7 DISCUSSION reading and understanding the module s manual writing the message parsing code and etching and soldering the PCB takes some time At the end the information from the GPS was not used in the control algorithm as planned Maybe it was unwise to spend time at all on this task but the time spent on the GPS development at this stage is hopefully saved in the subsequent 7 4 Debugging hardware As noted earlier for instance in Section 4 5 Section 6 5 and Section 6 3 some hardware related errors have occured during the project The downside of such errors span much wider than just the wasted time on debugging In situations like the one described in Section 4 5 the complete overview of what the various connections in the system actually does was lost This leaves the system in a very dangerous state Voltages and currents above the absolute maximum ratings for the hardware may destroy iCs and other circuit components A human weakness is that they make mistakes
129. tions in the resource manager library that performs a lot of the work of dealing with these messages The function iofunc func init mentioned earlier initializes a list of these to the resource manager but the functions one might want to give some extra functionality or different behaviour i e the functionality one actually whish to achieve in the RM 2 2 QNX Neutrino 17 could afterwards be overridden Here the function calls iofunc _ default where is meant to be replaced by the corresponding function e g read write or devctl might come in handy The devctl function mentioned above is important in regards to the subject of Resource Managers The function name is an abbreviation for ConTroL and is used by the client to control aspects of the RM The devctl function takes the following five arguments fd is the file descriptor of the resource manager that is receiving the devctl request is the command itself consisting of 2 bits describing the direction of the data transfer if any and 30 bits describing the command dev_data_ptr is a pointer to a data area for sending to receiving from or both nbytes is the size of the dev_data_ptr data area dev_info_ptr is an extra information variable that can be set by the RM The CyberBike drivers devc dmm32at devc velo and devc imu all implements their own version of devctl In most of these drivers a set of dispatch context alloc d
130. um when installing Ubuntu Linux on CyberBikePC 6 7 main blocks in the CyberBike Simulink model 7 1 Overview of the CyberBike s various hardware devices by the end of this 7 2 Better physical disk drive D 1 Screenshot of the Advanced CMOS setup menu taken from IEI Technol ogy Corpa 2000 a as o A A ee Schematic design of POB 22 Layout PEB all layers x v rl a Sa a te od Layout of PCB bottom surface print F 4 Layout of PCB top surface xii 124 List of Tables 2 1 3 1 3 2 3 3 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 4 1 4 2 5 1 2 4 5 Matlab files to initiate the parameters used the Simulink model 9 Specific data for ACE 890C 21 Specific data for Wafer 9371A 22 The Wafer 9371A JP4 settings to configure COM2 23 Overview of DMM 32 AT headers 26 Header J5 configuration for analog in on DMM 32AT 26 Header J3 analog I O pinout on 32 27 Header J6 configuration for D A output on 32 27 DMM 32 AT I O Register Map from Diamond Systems Corporation 2003 chap Ope Sox aed auct dU aep ar Ye dod ag dete a 28 Specification for the
131. using the default settings for the driver which is both calibration and orientation data the latter given as Euler angles Using Euler angles yield some singularities when the pitch angle is reaching 90 which makes quaternions or rotation matrices a better choice for some users This is not a problem in this project and Euler angles is chosen to integrate with the controller made by Bjermeland 2006 Output from the resource manager is provided through the device files registered under the dev mt directory In default mode this includes the files dev mt calib acc x holding acceleration in x direction m s e dev mt calib acc y holding acceleration in y direction dev mt calib acc z holding acceleration in z direction dev mt calib gyr x holding rate of turn in x direction rad s dev mt calib gyr y holding rate of turn in y direction dev mt calib gyr x holding rate of turn in x direction dev mt calib mag x holding the magnetic field in arbitrary units in x direction normalized to earth field strength dev mt calib mag y similar in y direction as for the x dev mt calib mag z as for x and y direction dev mt orientation roll the roll angle measured in degrees between 1809 and 180 dev mt orientation pitch the pitch angle 0 dev mt orientation yaw holds the heading angle w dev mt samplecounter a timestamp put in the message from the MTi device If another orientation output mode is chosen the d
132. ut 0 X2 6 BALDOR 2 a2 Vref propulsion motor 39 Vref out X1 23 Potmeter steering 5V 39 Vref out X1 24 Potmeter pendulum 5V Table E 5 Connection table for J3 on DMM 32 AT Appendix Design of PCB 135 APPENDIX F DESIGN OF PCB 136 L T T 19945 ber EL 200220727 2 1MOLL NIZL 1701 LNOLY NIY 1nOCH 10 20 22 A A CO A ZO EEZXYN y Figure 1 Schematic design of 137 e Audun S lvberg p Figure F 2 Layout of all layers showed Mm Audun S lvberg CA ITK NTNU 12 02 2007 _ UW 2 2 BORE 000 0000 RS232 IMU 5 0000000000 oy 0000000000 Em Figure F 4 Layout of PCB top surface print
133. ut trying to put the device in measurement state by sending 0x07 to the device did not work 6 3 4 Comment It is not done sufficient testing to ensure that the COM port is corrupted But there are strong indices that the transmit line on the port is damaged since the GPS is acting as it should but as soon as data is to be sent back to a device it does not work 6 4 GPS driver testing While testing the GPS driver some abnormal results occured The following debug process gained some knowledge about how to get the resource managers to work better 90 CHAPTER 6 TESTS AND EXPERIMENTS and is therefore described here When devc gps was running the content in its registered device names were garbled as could be seen in Printout 6 3 cd dev gps out cat altitude X0000 X0000 X0000 X0000 X0000 X0000 X0000 X0000 X0000 X0000 X0000 X0000 X0000 cat utctime hour 000000000000000000000000000000000000000000000000 Printout 6 3 Reading the GPS device files The GPS was sending its data and starting the driver in verbose mode showed that it was parsing the messages and that it tried to write to its device files The values can be seen in Printout 6 3 After some debugging it was discovered that if a fixed long value were put in the buffer to be written to the device some of it was shown in the file but parts of it was garbled This indicated that something else was writing to the memory location wh
134. ver summary 81 5 9 SIS9Y uo YIOM Jo pue y Aq SIOATIP 8 9 14 1 4 JO MOTAIOAO ILWIS 8T 9 S10 enjoe pue 5105095 ILN ANI LV CE NNWNG 5 8 WIY IOZ e 82 CHAPTER 5 SOLUTION Chapter 6 Tests and experiments 6 1 Test equipment 6 1 1 Multimeter The multimeter used during the work on this thesis is an Escort EDM 168 with serial number 11116249 see Figure 6 1 The multimeter has got the most usual functions expected from such a device including voltmeter amperemeter ohmmeter DC and AC setting capacitance measurements connectivity check beeping etc Figure 6 1 Escort EDM 168 Multimeter 6 1 2 Oscilloscope An oscilloscope of type Hameg HM507 Analog Digital Scope see Figure 6 2 with the serial number 021540457 was used in cases where the multimeter was inadequate e g to check if a RS 232 signal could be detected on a wire Alternating current 83 84 CHAPTER 6 TESTS AND EXPERIMENTS Figure 6 2 Hameg HM507 oscilloscope 6 1 3 Power sources Two power sources were used a Farnell LS 30 Autoranging Power Supply and a TTi EL302T Triple Power Supply with serial numbers 000666 and 256134 respectively Both are shown in Figure 6 3 Figure 6 3
135. vers are successfully started An NFS server have been used to share files between the development host and the CyberBikePC If this is not set up an NFS server is put on the CDROM appended with this thesis Setup instructions could be found in Fossum 2006 Vedl 5 Some scripts to make working with the CyberBikePC easier is put on the CDROM see Appendix A For instance the nfs_script which takes the last octet in the IP address as an argument assuming the first three octets stays the same inside NTNU for a while Norwegian University of Science and Technology 119 19 To start developing from Matlab and Real Time Workshop see appendices in Fos sum 2006 for quick introduction tutorials 20 For developing in QNX see Section 2 2 Krten 2001 and QSSL 2007c 120 APPENDIX HOW START THE CYBERBIKE SYSTEM Appendix How to boot CyberBikePC in Linux When testing the COM ports at the Wafer 9371A another operating system was desired to make sure that QNX was not the one to blame for the non working COM2 port An Ubuntu Linux installation is now kept on the CF card see Figure 3 5 To boot into Linux do the following Power down the PC Remove the hard drive ribbon cable from the EIDE slot on the Wafer 9371A Insert the compact flash card into it s slot inder the Wafer 9371A Slim fingers are advantageous to get it in place Power up the PC Hit DEL to enter BIOS setup Choose
136. were big enough for the batteries terminal screws were pinched to three wires making the connection that can be seen in Figure 5 10 Two fuse holders with 15A fuses were soldered on to the wire close to the positive terminals to provide protection from short circuiting and similar events The right battery and its fuse are shown in Figure 5 11 Now a switch is useful to be able to power down the system without disconnecting any wires This is mounted on the suitcase s foremost wall and the positive wire from the batteries are cut connected via this switch as seen from the connection diagram in Figure 5 10 The switch is shown in Figure 5 12 78 CHAPTER 5 SOLUTION Baldor card ACE Circular 4 pole connector Suitcase wall Power switch 15A Fuse 15A fuse E 2V battery 2V battery Figure 5 10 Connection diagram for the batteries 5 8 Batteries 79 Figure 5 11 12V battery from ACT Batteries The 15A fuse and its fuse holder is soldered to the wire close to the positive battery pole Figure 5 12 The power switch 80 CHAPTER 5 SOLUTION 5 9 Driver summary To compare the state of the CyberBike s software by the start and the end of this work a figure comparable to Figure 3 13 is used to give an overview Dri
137. why the code optimization didn t give any results the busy loop would eat up all the freed CPU time Code sample 4 2 Opening of the serial device in devc imu O_ NDELAY is specified printf s tOpening serial port n NAME if serialFD open SERIAL DEVICE 0 RDWR O_NOCTTY O_NDELAY 1 printf s tUnable to open port n NAME exit 1 else printf s tPort opened File desc d n NAME serialFD tcsetattr serialFD TCSAFLUSH 0 Changing the second code line in Code sample 4 2 as shown in Code sample 4 3 solved the problem Code sample 4 3 Opening of the serial device in devc imu correctly if serialFD open SERIAL_DEVICE O_RDWR O_NOCTTY 1 The CPU consumption for the serial driver and the IMU driver in common was now reduced from 100 to approximately 14 as shown in the old version column in Table 4 1 The new version percentages is when running the imu driver whith the improvements mentioned above CPU consumption old version new version devc imu 2 5 0 05 devc ser8250 11 1 Table 4 1 CPU consumption for the old and new version of devc imu approximate values These improvements were based on the use of the function readcond instead of read The IMU driver is made by two threads running in loops the first one is handling the requests required by a QNX resource manager and the second one is reading from the serial device
138. wn in Printout 4 6 An important note here is that io usb was started with the duhci option as opposed to dehci suggested by Loftum 2006 The earlier mentioned problems on finding the CF card on the QNX machine arose because of this difference The reason is probably that another card reader was used in this case than in Loftum s When the CF card was inserted into the CyberBikePC again a message like shown in Printout 4 8 appeared on the screen This message is similar to the one described in Loftum 2006 p 59 and means that no OS signature is found Loftum solved this by running the command shown in Printout 4 9 but that approach did not solve the problem this time 50 CHAPTER 4 SUGGESTED SOLUTION io usb v duhci amp 1 1339429 devb umass Path 0 QNX USB Storage target 0 lun 0 Direct Access 0 Generic USB SD Reader Rev 1 00 target 0 lun 1 Direct Access 0 Generic USB CF Reader Rev 1 01 1 Done io usb v duhci devb umass cam pnp verbose 1s dev hd dev hd0 dev hd0t79 dev hd1 dev hd2 mount t qnx4 dev hd2 mnt flash 15 mnt flash altboot boot longfilenames nel bitmap inodes Printout 4 6 Mounting card QNX fdisk dev hd2 dinit h f velo_v2 ifs dev hd2 DINIT You have specified the raw disk not a partition continue y n y Using loader usr qnx630 target qnx6 x86 boot sys ipl diskpc2 flop Disk dev hd2 contains 201
139. yberBike relay race is over The development process of ITK s autonomous unmanned bicycle however still has to run some more laps But the last semester it certainly have been approaching its goal hopefully close enough for the next student working on it to get the CyberBike up and running Some valuable personal experiences has been gained during my work on this project One of the most important is the lowering of my own threshold for working with hardware By the start of this thesis etching my own circuit board was nothing I d ever expect to do Furthermore during the work on this project I have been facing a lot of hardware problems This was clearly not desirable but at the end some important lessons around debugging have been learned Isolating an error in order to point out where it resides should be a self explanatory approach to every debugging process Still the true value of it has never looked as clear to me as after the work on this thesis Here I would like to thank Amund Skavhaug not just for being an inspiring and flexible supervisor through my past year here at NTNU but also for being an encouraging and friendly person giving me challenging and interesting tasks My next acknowledgement goes to yvind Bjgrnson Langen my office neighbour for spending a lot of time on giving advice lending me his soldering tools and giving a hand when I needed assistance Hans J rgen Berntsen and Terje Haugen at the ITK workshop als
Download Pdf Manuals
Related Search
Related Contents
Provision-ISR DA-372CSVF-3 surveillance camera 15, 20, 36 J Mains Energizer User Manual Charging Beginning to Use Your Device Android and Windows User Manual Copyright © All rights reserved.
Failed to retrieve file