Da e: 29-01-2010
P ojec Name: TT Race Da a Logge
Au ho (s): Da id Auñon Plandoli
Jose Mª Galla do Robles
2
Con ac In o ma ion
Clien
T iCAT Racing
Ad ess: P/A S oomboo kade 27-28
8701 KA Bolswa d
Tel : 0515-576491
Email: in o@ ica acing.nl
Con ac o
Wal e Jansen
Email: [email p o ec ed]
Coach
Ma ien Van Wes en
Email: [email p o ec ed]
Au ho (s)
Da id Auñon Plandoli
Email: knzi[email p o ec ed]
Jose Ma ia Galla do Robles
Email: [email p o ec ed]
3
Summa y
This epo is made o accomplish he demand om T iCAT Racing mo o ace eam.
They sugges i i was possible o c ea e a de ice capable o log da a om a mo o bike
du ing a ace o es ing seasons, men ioning some o he simila sys ems ou on he
ma ke , bu is eally expensi e. Taking an ini ial idea, we hough abou one way o
design a sys em capable o sa is y he demand o ou con ac o , ying o educe cos s
on he design.
A his poin we accep he p ojec o e ed by T iCAT acing eam. Known he se e al
issues ha hey ha e abou he design and s udying he di e en ways o make i , he
design is s a ing o be hough . The con ac o needs ha he sys em has o be
capable o s o e he da a in o a SD ca d, his da a a e: posi ion, eloci y, RPM,
co ne ing angle and lap ime o a mo o bike in a ci cui ace. Fo sol e his issues we
hough abou mic op ocesso s, GPS’s, and o he kind o possibili ies, a i ing o one
possible solu ion.
Now he solu ion o design ques ion is sol ed, i is possible o design a sys em capable
o accomplish he demands o he con ac o , wi h a mic ocon olle PIC18F4550 and a
GPS Uni , one Accele ome e , and p og amming a complex p og am on C o
mic ocon olle s i is possible a i e o a solu ion.
When we s a o build he i s p o o ype and we decide o es i a p oblem appea s,
no enough space in ROM memo y. Du ing he implemen a ion pa , we a i ed he
conclusion ha we made an e o choosing he mic op ocesso PIC18F4550, his e o
is because he ROM memo y. The p og am ha we a e using is oo big, and he ROM
memo y o he mic op ocesso PIC18F4550 i ’s no enough o con ain all he p og am.
As a esul o he sho ime disposed o make he p ojec , and he e o s made a he
end, i is no possible o change he design, he p o o ype is build and we a e ying o
make i un. I he p ojec could be con inued o ano he s uden s o ano he
enginee s, he bes idea o s a , is change he mic ocon olle o ano he wi h he
minimum esou ces needed by he C p og am.
4
Index Pag.
Con ac in o ma ion 2
Summa y 3
1. In oduc ion 7
2. Goals 8
3. Analysis 9
3.1 Theo y o Da a Logging 9
3.2 TT Race Da a Logge 9
3.3 Func ionali y 9
3.4 File Fo ma 10
3.5 In e ace 11
4. S udy o possibili ies 12
4.1 Co ne ing, Angle de ec ion and s udy o G a i a ional o ces (G’s) 12
4.2 Angle de ec ion by ange Finde 17
4.3 Powe Supply 19
4.4 Re olu ions pe minu e (RPM) and Engine Con ol Uni (ECU) 19
4.5 Speed and Posi ion 20
4.6 S a /End Beacon Line 20
4.7 Calcula ion ime o 100 i s me e s 21
5. Ha dwa e Requi emen s and solu ions 22
5.1 Mo he Boa d/Co e 22
5.2 GPS Uni 22
5.3 Display 26
5.4 Accele ome e 26
5.5 Remo able memo y 26
5.6 USB In e ace 28
5.7 Powe Supply 28
6. TT Race Da a Logge P o o ype 29
6.1 Design 29
6.2 In e ace 29
6.3 Algo i hm 30
6.4 Implemen a ion 34
6.5 C Code 35
6.5.1 Files and unc ions G aph 35
6.5.2 PC- Mic ocon olle In e ace Diag am 36
6.5.3 USB “Plug&Play” 37
6.5.4 P ojec Files A chi ec u e 38
6.5.5 Da a Logging unc ions, ile dependences and explana ions 39
6.5.6 LCD Display 40
5
Pag.
6.6 Impo an C Code Spo s 40
6.6.1 Boo Loade emapping ec o s 41
6.6.2 File managemen 41
6.6.3 Speed ac o con e sion 42
6.6.4 Au o Shu -Down a e 60 seconds o non ac i i y 42
6.6.5 Non ebounding bu on sys em 43
6.6.6 USB asks 43
6.6.7 SD socke and SPI connec ion De ini ions 44
6.6.8 LCD po de ini ions 45
6.6.9 NMEA con igu a ion sys em 45
6.6.10 TT Race Da a Logge S a es 46
6.6.11 GPS S a es 46
6.7 Schema ic 47
6.8 Componen pin wi e connec ion in he p o o ype 48
6.8.1 SD Socke and pin connec ions 48
6.8.2 GPS pin assignmen 49
6.8.3 Display pin assignmen 50
6.8.4 Accele ome e pin assignmen 51
6.8.5 Mo he Boa d SBU44UC 51
6.9 Con igu a ion o he connec ions in he p o o ype 54
6.9.1 SD pin connec ions 54
6.9.2 GPS pin connec ions 54
6.9.3 Display pin connec ions 55
6.9.4 Accele ome e pin connec ions 55
6.10 P o o ype Pic u es 56
6.11 Sub-De ices Loca ion inside he P o o ype 58
6.12 Dimensions & O ien a ion 59
6.12.1 TT Race Da a Logge loca ion and posi ion on he mo o bike 60
6.13 Tools 61
6.14 Componen s 62
6.14.1 Mo he boa d SBC44UC 62
6.14.2 GPS Uni 63
6.14.3 Accele ome e 63
6.14.4 LCD 16x2 Display 64
7. Budge 65
7.1 Budge o ou P o o ype and expe imen al equipmen 65
7.2 Budge o a P o o ype 65
8. Obse a ion & E alua ion 66
6
Pag.
9. Recommenda ions 67
9.1 Dimensions 67
9.2 Powe Supply 67
9.3 SD socke wi h USB chipse included 68
9.4 Mic ocon olle 69
9.5 Da a ile P ocessing and Google Maps 70
10. Li e a u e 71
11. Annex 72
SBC44UC Mo he Boa d Da ashee
Accele ome e (ADLX335) Da ashee
GPS Uni (EM-408) Da ashee
Display (GDM1602K) Da ashee
1 CD wi h all sou ce code & so wa e ools o design i
7
1. In oduc ion
Since many yea s, p o essional eams om he high end o he TT Mo o bike Races a e
spending housands o Eu os ying o ge e icien sys ems ha could p o ide de ailed
in o ma ion abou he beha io o a mo o bike and his pilo du ing a p o essional ace.
They wan In o ma ion like angle o co ne ing, ho izon al accele a ion, b ake p essu e,
eal ime ideo s eaming and eco ding o moni o he mo emen s o he pilo , e c…
These sys ems a e eally expensi e and hey a e only designed o imp o e he
pe o mance o he bike and he d i ing skill o he Pilo . They a e c ea ed by eams o
expe enginee s wi h a huge p esupposi ion.
Ac ually, ama eu aces a e becoming p og essi ely mo e usual and mo e people a e
in e es ed o ace in a ci cui . Like a p o essional aces, o imp o e hei skill i would
be a ac i e o use some echnology ha gi es o you in o ma ion abou he beha io
o you sel and you mo o bike has had du ing he ace. We ask ou sel es i i would
be possible o design a cheap, easy, emo able and small de ice ha o e s he
maximum u ili ies, senso esou ces and bes pe o mance ha can be o e ed a his
momen wi h low p ice. This de ice could no be expensi e because ama eu d i e s
compe e o un o medium le el aining. I means hey usually don’ ha e any sou ce
whe e hey can p o ide money o imp o emen s in hei mo o bikes as he
p o essional eams ha e wi h he sponso s and he ad e isemen .
To comple e his accomplishmen is needed a p e ious s udy o he s a emen s ha
we ha e o ake ca e ela ed abou p ocessional aces. Fo example: beha io o a
mo o bike, s uc u e o a mo o bike, how i wo ks, en i onmen whe e i is and he
o ces su e ed du ing a ace. Also a s udy o wha he echnology o e s a his
momen and he money ha ’s equi ed o ge i .
These s udies a e mean o answe his ques ion: Wha can be o no be done? Ha e
been answe ed his ques ion and go a good, cheap and e icien answe , we will
p oceed designing an algo i hm and implemen ing i in o a P o o ype. This P o o ype
has o be able o make da a logging om a TT Race Mo o bike. Ge ing Da a om
di e en senso s placed on he mo o bike.
T ica acing is a Duch mo o ace eam ha o e s o us he possibili y o design one o
hose sys ems, gi en o us some in o ma ion abou he mo o bike and also he aces,
wi h a minimum budge o design a p o o ype capable o do his wo k.
8
2. Goals
The main goals a e ocused in he s udy he possible solu ions and build a design o a
Da a Logge o accomplish:
- Easy in e ace Da a logging o ama eu d i e s
- Non des uc ible da a collec o
- Low p ice
- Easy ins alla ion
Like in p o essional aces da a logging is based in collec da a om he bike and he
d i e o make a s udy o i .
This de ice has o be able o p o ide da a abou :
- Speed, RPM
- Accele a ion
- Ho izon al G Fo ces
- Angle
- Posi ion on he ci cui
- Ch ono Time Global/ i s 100m
The design is made o ama eu d i e s and has o be easy o ins all.
- Easy downloading da a (USB, Remo able Memo y)
- Easy o ins all (Lap op, Mobile Phone)
This de ice is hough o ama eu cus ome s, i has o be cheap and eliable. The idea
is o keep a design be ween he accu acy and he p ice, wi h enough pe o mance and
e iciency bu low cos .
Implemen his design in o a P o o ype g an ing all he equi emen s men ioned.
9
3. Analysis
3.1 Theo y o Da a Logging
The e m “Da a Logging” means collec in o ma ion abou some en i y o e en du ing
ime in ela ion wi h his physical p ope ies o posi ion. This in o ma ion gene a es
da a ha has o be s o ed o la e s udy. “Da a Logge ” is an elec onic de ice ha
eco ds da a o e ime o in ela ion o loca ion ei he wi h a buil
in ins umen o senso o ia ex e nal ins umen s and senso s. Inc easingly, bu no
en i ely, hey a e based on a digi al p ocesso (o compu e ), gene ally a e small,
ba e y powe ed, po able, and equipped wi h a mic op ocesso , in e nal memo y o
da a s o age, and senso s.
3.2 TT Race Da a Logge
TT Race Da a Logge should be an elec onic de ice capable o collec and s o e da a
om nea by senso s. I ’s mean o wo k wi h a mo o bike, logging da a abou he
beha io and he posi ion du ing a ace.
3.3 Func ionali y
The main idea is o gene a e a ile wi h all he in o ma ion abou you las ack, s o ed
in one S anda d emo able memo y (SD /MMC) in TXT o ma .
A leas is needed a de ice capable o s o e da a du ing 30 minu es o acking ace.
Di ide in se e al iles.
This Tx ile con ains all he da a showed as a clea ly able wi h all he alues in
columns wi h a s ep o 1/5 second.
Fi s con ains a able wi h he Global ime alues since he beginning o he ace o he
end. A he end o he ile, shown he a e age ime calcula ed o he 100 me e s.
The syn ax o he able s o ed in he TXT ile is shown below.
16
Alpha “α” is he inclina ion angle o he mo o bike, as we know ou design wi h an
accele ome e gi es o us he esul an G o ce on each axis, knowing he alue o he
G o ces X axis G Fo ce ec o and Z axis G Fo ce ec o , we could calcula e he alue o
he angle α.
Equa ion:
𝛼= an−1 X axis G Fo ce ec o
Z axis G Fo ce ec o
As a esul o he calcula ions, we ge he angle, also wi h he G o ces we could
make a s udy o he ci cui ace.
I ’s possible o make a g aph wi h he esul s o he G o ce samples, and know
how he i es a e su e ing in he ace, he samples will desc ip he global o ces
du ing he ace.
He e one example o all samples aken on a aining session (no ou s).
Figu e 3 : G o ce samples
In o de o see and unde s and he g aph we know ha he pa o he igh means
u n le and le means u n igh .
17
Gy oscopes il senso s and a e ools ha a e capable o calcula e he angle be ween
an al eady known poin o ano he in 3 planes o he space. They a e
mechanical/elec ical ools i means some none desi ed o ces applied o hese senso s
a e going o change he co ec unc ionally o hemsel es. On he o he hand, he
accele ome e s gi es he accele a ion on 3 Axes. Knowing he o ce s G’s on he
mo o bike and how o calcula e he angle om hem an accele ome e is a good
choice.
Ad an ages Rela i e cheap o he equi ed po poises.
Disad an ages Rela i e Accu acy.
4.2 Angle De ec ion By Range Finde
Range Finde is a ool capable o measu e he s aigh dis ance be ween wo
poin s. A lase ange inde wi h enough accu acy (3, 4 me e s) will do he job. Placed
and s ongly hold a he chassis o he bike, we can know he dis ance be ween he
bike and he oad, i means, wi h igonome ic calcula ions, also he desi ed angle. I ’s
a lase and he undesi ed g a i y o ces a e less ha m ul o his unc ionali y han a
mechanical componen bu a e a lic ed by elec omagne ic ields.
Ad an ages Ex emely high Accu acy, ideli y and pe o mance.
Disad an ages Ex emely high p ice, housands o Eu os. Big Size and
weigh .
Lase Rage Finde Calcula ion example
Figu e 4 : Angles used o calcula e he co ne ing angle
18
Tha pic u e abo e shows he si ua ion o he lase s on he mo o bike. We need
minimum 2 lase s placed a bo h sides o calcula e he angle. The lase s a e he
segmen s A and C. And he desi ed angle is Del a. The lase s a e posi ioned making a
90º angle be ween each o he .
We can ound Del a using igonome ic equa ions because he lase s p o ide he
alue C and A all he ime.
The calcula ions a e:
Wi h A and C:
𝐶
𝐴= an 𝛾 → an−1𝐶
𝐴= 𝛾 ;
Wi h Gamma: 𝛽=90° ; 𝛾=𝑘𝑛𝑜𝑤𝑛 ; 𝛼= ? ;
180° = 𝛽+ 𝛾+ 𝛼 → 𝛼=180 − 𝛽− 𝛾;
Wi h Alpha: 𝜏=45° ; 𝛼=𝑘𝑛𝑜𝑤𝑛;
180° = 𝜏+ 𝛼+ 𝛿 → 𝛿=180 − 𝜏−𝛼 ;
We ha e go 𝛿;
I ’s possible o ge he desi ed angle only wi h a i hme ic calcula ions.
19
4.3 Powe Supply
I would be in e es ing o design an au onomous and in e nal powe supply sys em o
imp o e pe o mance and u ili y. In eg a ing his sys em, TT Race Da a Logge ge s
comple e au onomy and has he possibili y o wo k on his own.
A powe supply is compounded by a echa geable ba e y, a cha ging sys em, and
ol age egula o s o deli e he desi ed ol age o all he sub-de ices.
4.4 Re olu ions pe Minu e (RPM’s) and Engine Con ol Uni (ECU)
I consis s on a coope wi e o clamp coiled o hold o he ECU’s Rpm cable s ealing he
signal ha is a eling h ough he cable, al eady ins alled in all mo o bikes. How is
equi ed, his is a non des uc ible way o ge he signal om de ECU.
I we ha e he signal om he wi e, we can coun he pulses gene a ed by he ECU and
calcula e he equency by an A/D con e sion.
The ollowing pic u es show he p ocedu e
Figu e 5: cable connec o s o he ECU’s cable
20
Also i ’s possible o do he same p ocedu e bu di ec ly o he wi e o he Spa k plug
bu i ’s necessa y some kind o ci cui p o ec ion because he ampe es gene a ed by
he spa k plug a e eally high and no accu a e. I we know he amoun o cylinde s, we
could know he e olu ions pe minu e.
In conclusion he bes way o ge he RPM’s is om he ECU.
NOTE:. I ’s o e ed only a heo e ical design and way o implemen a ion bu i won’
be implemen ed in he p o o ype as con ac o ’s eques because is an inaccu acy
sys em. I needs lo o es ing and p o o yping.
4.5 Speed and Posi ion
The e’s no bes op ion han a GPS o ge he Posi ion. Is Accu a e enough, cheap and
also g an s he speed, da e and ime o ou sys em.
I ’s possible o ge he speed om one o he cables om he ECU wi h he same
p ocedu e as he RPM’s.
4.6 S a /End Beacon Line
Pic u e 4: The wo P ese Poin s o he beacon line.
To ge a p ese beacon line, i is necessa y o do i like is shown in he p e ious Pic u e,
i s necessa y wo p ese ing poin s. We could make and imagina y line knowing he
di e ence be ween hem.
21
4.7 Calcula ion ime o 100 i s me e s
Pic u e 5: Vec o s wi h a module o 100 me e s
In o de o know he ime o he i s 100 me e s made by a pilo in a ace, i is possible o
calcula e i by di e en ways. We decide o do i by a ec o ; TT Race Da a Logge has o
calcula e e e y sample he module o he ec o gene a ed be ween he s a posi ion and he
cu en posi ion , when he ec o module size is equal o 100 me e s, he de ice s o e he
ime ealized in hose 100 me e s.
The manne o do i is calcula ing e e y sample he “δ|P|” di e en ial o he module , gi ing
an accu acy module ec o . Then compa ing he alue o his ec o o he ciphe 100m we
ob ain he ime expended o i .
22
5. Ha dwa e Requi emen s and Solu ions
As a esul o he p e ious in es iga ion we decide ha ou TT Race Da a Logge has o
include he ollowing sub-de ices o g an he desi ed unc ionali y.
5.1 Mo he Boa d / Co e
Ou Da a Logging de ice needs o p ocess he amoun o da a gene a ed by he
senso s, i means we need some kind o p ocesso o unde s and and s o e his da a.
The bes and cheap op ion is a mic ocon olle p og ammed in assemble o ou
pu poses. We can ound he mic ocon olle i sel bu i ’s necessa y o design he
connec ions and he en i onmen be ween he mic ocon olle and he senso s.
Ano he and as e way is o use a s anda d p o o yping boa d ha al eady has all o
ha .
5.2 GPS Uni
To Know he posi ion, s aigh accele a ion, da e and ime is needed a GPS uni .
A S anda d GPS ecei e uni wi h an enna wo king wi h a digi al p o ocol RX, TX, in
USART mode, wi h enough sample a e o ge he posi ion, he speed, he accele a ion
and ime om he sa elli es.
T y o design some sys em onboa d o ge he alue o he speed and s aigh
accele a ion i would be edundan . GPS o e o us he bes way o ge his
in o ma ion. I ’s quick and exac .
GPS Accu acy -
Ini ializa ion S a – Less han 5-30 seconds
Sample Ra e- 1 Mhz
Range - 5 o 10 me e s (Bes on he ma ke )
The mos GPS uni s on he ma ke a e wo king wi h NMEA p o ocol and I is equi ed a
p e ious s udy o his p o ocol o ensu e a co ec design.
23
5.2.1 The NMEA Sen ence
GPS da a comes in a da a s eam o m known as NMEA sen ences. NMEA is he
uni e sal s anda d o in o ma ion coming om GPS sa elli es. In pa icula , he NMEA-
0183 is o in e es o ou p ojec . In o de o use any o he da a you mus know wha
kind o da a you need. These sen ences include all kinds o in o ma ion abou he
posi ion, ime, and di ec ion o he ecei e and his in o ma ion is usually displayed
on a sc een o deli e ed o a de ice o compu e . Se e al sen ences a e deli e ed o
he ecei e a once. These sen ences a e upda ed e e y 1 millisecond o e e y se e al
seconds depending on he ecei e and he use. Each sen ence con ains a di e en
kind o da a s eam. Some ypes and examples a e lis ed below.
Sen ence
Desc ip ion
$GPGGA
Global posi ioning sys em ixed da a
$GPGLL
Geog aphic posi ion - la i ude / longi ude
$GPGSA
GNSS DOP and ac i e sa elli es
$GPGSV
GNSS sa elli es in iew
$GPRMC
Recommended minimum speci ic GNSS
da a
$GPVTG
Cou se o e g ound and g ound speed
Table 1: Desc ip ion impo an kind o NMEA sen ences
The GPGGA and GPVTG example a e he mos use ul because ou da a logge cans
inco po a e he imes, and da e as well as he posi ion, and speed. Mos ecei e s
ansmi each ype o sen ence consecu i ely, each one beginning wi h a dolla sign
and ending wi h a ca iage e u n. The GPGGA example and i s cha ac e is ics is lis ed
below.
Table B-2 con ains he alues o he ollowing example:
GGA-Global Posi ioning Sys em Fixed Da a
Signal no acqui ed:
$GPGGA,235947.000,0000.0000,N,00000.0000,E,0,00,0.0,0.0,M,,,,0000*00 Example
Signal acqui ed:
$GPGGA,161229.487,3723.2475,N,12158.3416,W,1,07,1.0,9.0,M,,,,0000*18
24
Table B-2 GGA Da a Fo ma
Table 2: Da a o ma
Field
Example
Commen s
Sen ence ID
$GPGGA
GGA P o ocol Heade
UTC Time
092204.999
hhmmss.sss
La i ude
4250.5589
ddmm.mmmm
N/S Indica o
S
N = No h, S = Sou h
Longi ude
14718.5084
dddmm.mmmm
E/W Indica o
E
E = Eas , W = Wes
Posi ion Fix
1
0 = In alid, 1 = Valid SPS, 2 =
Valid DGPS, 3 = Valid PPS
Sa elli es Used
04
Sa elli es being used (0-12)
HDOP
24.4
Ho izon al dilu ion o
p ecision
Al i ude
19.7
Al i ude in me e s acco ding
o WGS-84 ellipsoid
Al i ude Uni s
M
M = Me e s
Geoid Sepe a ion
Geoid sepe a ion in me e s
acco ding o WGS-84
ellipsoid
Sepe a ion Uni s
M = Me e s
DGPS Age
Age o DGPS da a in seconds
DGPS S a ion ID
0000
Checksum
*1F
Te mina o
CR/LF
25
VTG-Cou se O e G ound and G ound Speed
Example : $GPVTG,309.62,T,,M,0.13,N,0.2,K*6E
Name
Example
Uni s
Desc ip ion
Message ID
$GPVTG
VTG P o ocol
Heade
Cou se
309.62
Deg ees
Measu ed heading
Re e ence
T
T ue
Cou se
Deg ees
Measu ed Heading
Re e ence
M
Magne ic
Speed
0.13
Kno s
Measu ed
Ho izon al Speed
Uni s
N
Kno s
Speed
0.2
Km/h
Measu ed
Ho izon al Speed
Uni s
K
Kilome e s pe
Hou
Checksum
*6E
<CR><LF>
End o message
e mina ion
Table 3 : VTG- sen ence explana ion
Ou so wa e on he PIC18 will ead each cha ac e looking o he dolla sign. Once
his has been de ec ed as he incoming cha ac e , all o he ollowing cha ac e s a e
examined one by one in he PIC18, looking o he GPGGA sequence. I his sequence is
no ound hen he en i e sen ence is igno ed un il ano he dolla sign is de ec ed. I
he sequence is ound, hen he PIC18 will wai un il i ecei es he pa icula da a o
in e es . Tha da a is hen s o ed in he s a ic RAM o he PIC18 o u u e use. Once all
o he da a o in e es has been acqui ed om he sen ence, he PIC18 will igno e all o
he o he da a and wai o he GPS o eques he da a. Once a eques has been
de ec ed, hen he PIC18 jumps o a ‘ ansmission o da a’ ou ine. I he e is no
eques o he da a om he GPS, hen he PIC18 will wai o he nex se o sen ences
and upda e i s da a wi h he new sen ences a i ing om he ecei e .
A e he GPS da a has been s o ed on he PIC18, i wai s o a signal om he
mic ocon olle o ansmi he da a. The PIC18 uses a pin o ansmi he clock pulses
and a pin o ansmi he da a bi s. A beginning clock pulse will signal he s a o he
da a. E e y clock pulse a e wa ds on he clock pin will ha e a co esponding da a bi
on he da a pin a he same ime. The e o e, he mic ocon olle mus be able o ead
he da a while i is ecei ing a clock pulse. The clock pulse will emain ac i e o 3
mic oseconds. A e all he da a has been ansmi ed, he PIC18 will emain wai ing
o a signal om he mic ocon olle o e ansmi he da a o begin a new da a
e ie al om he GPS ecei e i he iming sequence has passed.
The NMEA sen ence is b oken up in o many di e en pa s. The only pa s ha a e o
in e es a e he UTC Time, Longi ude and La i ude. This da a will be sen along wi h ou
senso s da a in o de o make he desi ed 200ms cycle.
32
6.3.1 TT Race Da a logging main Flow g aph
33
6.3.2 GPS S a e Flow G aph
34
6.4 Implemen a ion
Algo i hm
The implemen a ion o he algo i hm o he TT Race Da a Logge is p og ammed wi h
embeds code and C language. Following he ypical s uc u e o an embed p ojec
wo king wi h iles in *.h (Lib a ies) and .c (Includes) ex ensions.
6.4.1 TT Race Da a Logge Fi mwa e’s diag am
Yellow – Da a logge Fi mwa e. Embed iles desc ibing he algo i hm o he Da a
logging ope a ions. I con ains he Ope a ions o Da a p ocessing (GPS, Analog Inpu s
and) and Da a Calcula ion (Angle, Speed, Posi ion. File c ea ion and da a s o ing). Also
con ains he con igu a ion iles o he mic ochip o wo k as a Da a Logge and Ca d
Reade . (En i e con igu a ion o he chip esou ces I/O and Boo loade ) .
O ange – File Sys em Fi mwa e. G oup o iles ha con ains he de ini ions and
unc ions o manage FAT16 Tables , necessa y o wo k wi h he SD ca d.
Whi e – USB Fi mwa e. Package holding unc ions and decla a ions abou s anda d
USB 2.0 communica ion. Only beha io al code is he e. This i mwa e g an s he de ice
o wo k wi h all win/Mac 32/64 bi s Ope a i e sys ems.
G een – Mass S o age D i e Fi mwa e. Package o iles gi ing o ou TT Race Da a
Logge he iden i y o a S anda d Mass S o age De ice. I means you can ead he
memo y inside ou de ice when you plug i wi h a compu e .
35
Blue – USB Physical In e ace. Files con igu ing he SPI communica ion o he chip o
wo k h ough USB in e ace.
USB In e ace and SD Ca d
The whole USB and SD Ca d in e ace is designed wi h he Mic ochip’s USB 2.0
Fi mwa e and “Mass S o age D i e Fi mwa e” Lib a ies.
6.5 C Code
6.5.1 C Files and unc ions G aph o Mic ochip’s i mwa e
This g aph o e s a quickly o ien a ion o he dependences be ween iles and unc ions
used by he beha io o an USB 2.0 Communica ion and SD Ca d.
36
6.5.2 PC - Mic ocon olle In e ace Diag am. Files and Lib a ies
This diag am gi es a global s uc u e abou he in e ace be ween he Mic ocon olle
and he Compu e . We can obse e he iles used by he ope a i e sys em inside he
compu e and he iles included in he mic ocon olle . All he iles equi ed by he
compu e a e p o ided by he ope a ion sys em. The lib a ies needed by he
mic ocon olle o an SD in e ace a e assembled wi h he en i e code o he Da a
logge . They we e p o ided by Mic ochip and a e able in he p ojec di ec o y.
Diag am. PC - Mic ocon olle In e ace
37
6.5.3 USB “Plug&Play”
To ge a co ec USB 2.0 unc ionali y as a “Plug&Play” de ice (USB Au o de ec ion) is
needed a con inuous e esh o he USB po . Calling he unc ion USBD i e Se ice().
This is possible implemen ing a loop inside he main low code be ween he Da a
Logging asks, calling pe iodically he men ioned unc ion. An easy g aph is shown
below.
38
6.5.4 P ojec Files A chi ec u e
39
6.5.5 Da a logging unc ions, ile dependences and explana ions
Main.c
o Sys em Ini ializa ion
Ini AD : Con igu es AN0,AN1 and AN2 o he accele ome e axes x,y,z
Se ial_ini : Ini ialize he se ial communica ion wi h GPS
Sys em_ini : Con igu e All I/O
Ini FAT : Ini ialize he SD Ca d In e ace
mIni Swi ch3 : Con igu e Swi ch 3
mIni Swi ch2 : Con igu e Swi ch 2
o USB
USBTasks : USB asks o USB au o de ec ion, called pe iodically
P occessIO : SD Tasks o don’ lose he connec ion
o Da alogging
DoADC : Main da a logging unc ion. A/D con e sion, calcula ions, da a
o ganiza ion and ile c ea ion
o LCD
Lcd_ini : Ini ialize LCD
Lcd_clea : Clea LCD
Lcd_go o : Mo e LCD cu so
Lcd_w i e : W i e cha ac e on LCD
o GPS
gps_ini : Ini ialize GPS and USART communica ion
gps_posi ion : Ge he posi ion om he GPS, la i ude and longi ude in
loa o ma
Da alogge .c
o Ini FAT
Socke ini ialize : Ini ialize he SD socke and emains ac i e always
o ReadFile : Read One exis en ile s o ed in he SD ca d(Op ional)
o DoADC
gps_ ecei e: Ge ime, da e, speed and posi ion in cha o ma
i oa : W i es a a iable in SD bu e
40
Se ial.c
o Se ial_ini
Se ial_baud : Se Se ial communica ion’s baud a e
Se ial_enable : Enable se ial communica ion
o Se ial_send : Send a s ing h ough he se ial comunica ion
o Se ial_ ecie e : Recei e a single by e om he GPS
gps.c
o gps_baud : Se GPS baud a e
o gps_se _p o ocol : Send a s ing wi h he con igu a ion o he GPS
o gps_ini
se ial_baud
se ial_send
o gps_ ecei e
se ial_ ecei e
se ial_send
sys em_se _ ime : se he sys em ime in cha o ma
se _posi ion : logs a waypoin posi ion in cha o ma
sys em_se _da e : se da e in cha o ma
se _speed : se speed in cha o ma
o gps_ posi ion
se ial_ ecei e
se ial_send
6.5.6 Display
41
6.6 Impo an C Code Spo s
6.6.1 Boo loade Remapping Vec o s
I s necessa y o emap hese ec o s o a co ec boo loade unc ionali y. Boo
loade is s o ed om 0x0000 un il 0x0800 ROM memo y add esses.
Code ound in sys em.h
6.6.2 File managemen
Sp in , p in s he cu en da e as ile name and also he en i e s ing o be s o ed in
his ile. Time and ime old a e compa ing each o he o implemen 1/5 second s ep
o s o e he s ing in o he ile.
Code ound in da alogge .c
48
6.8 Componen s pin wi e connec ion in he p o o ype
6.8.1 SD socke and pin connec ion
Pin
#
Pin Name
SD Signal Func ion SD
Mode
SPI Signal Func ion SPI
Mode
Cable colo
1
DAT3/CS
Da a Line 3
Chip Selec /Sla e Selec
[SS]
Red
2
CMD/DI
Command Line
Mas e Ou /Sla e In
[MOSI]
B own
3
VSS1
G ound
G ound
Black
4
Vdd
Vol age Supply [2.7 o
3.6 ]
Vol age Supply [2.7 o
3.6 ]
Whi e
5
Clock
Clock
Clock [SCK]
G ey
6
Vss2
G ound
G ound
Pu ple
7
DAT0/D0
Da a Line 0
Mas e In Sla e Ou
[MISO]
Blue
8
DAT1/IRQ
Da a Line 1
Unused o IRQ
G een
9
DAT2/NC
Da a Line 2
Unused
O ange
Table 5: SD ca d and socke pin connec ions.
No e:
Tha pin con ac s 3 and pin 4 a e bi longe han he o he pins. This allows pin 3 [Vss],
and pin 4 [Vdd] o make con ac in he socke be o e he o he pins. Allowing, G ound
and powe o be connec ed i s o he SD socke . Pins CLK, CMC, DAT0, DAT1, DAT2,
and Vss make connec ion a e pins 3 and 4 make con ac . Pin 1, DAT3 makes con ac
las . O cou se pins 3 and 4 a e also he las pins o lose con ac wi h he socke .
Figu e: SD ca d pin loca ion
Figu e: SD ca d Socke
49
6.8.2 Gps pin assignmen
Pin
#
Pin name
Cable colo
1
Enable/Disable
G ey
2
G ound
Pu ple
3
RX
Blue
4
TX
G een
5
VCC
Yellow
Table: Gps pin and cable assignmen
Pin Explana ion
Enable/Disable: On / O
VCC: (DC powe inpu ) This is he main DC supply o a 3.3V powe module boa d.
TX: This is he main ansmi channel o ou pu ing na iga ion and measu emen da a
o use ’s na iga ion so wa e o use -w i en so wa e.
RX: This is he main ecei e channel o ecei ing so wa e commands o he engine
boa d om SiR Demo so wa e o om use -w i en so wa e.
GND: GND p o ides he g ound o he engine boa ds. Be su e o connec all g ounds.
Figu e: GPS pin conec o
50
6.8.3 Display pin assignmen
Pin
#
Symbol
Func ion
Colo
1
VSS
GND
Red
2
VDD
+5V
B own
3
V0
Con as
adjus men signal
Black
4
RS
H/L Regis e selec
Whi e
5
R/W
H/L Read/W i e signal
G ey
6
E
H/L Enable signal
Pu ple
7
DB0
H/L Da a bus line
Yellow
8
DB1
H/L Da a bus line
O ange
9
DB2
H/L Da a bus line
Red
10
DB3
H/L Da a bus line
B own
11
DB4
H/L Da a bus line
Blue
12
DB5
H/L Da a bus line
G een
13
DB6
H/L Da a bus line
Yellow
14
DB7
H/L Da a bus line
O ange
15
A
+ 4.2V o LED
“ No connec ion
needed”
16
K
Powe supply o BKL(0V)
“ No connec ion
needed”
Table 6: Display pin and cable assignmen
No e: in he p o o ype he Da a bus line is di ided in wo di e en buses, i means 2
buses o 4 pin each one. The i s 6 pins om he Display a e connec ed oge he in
one bus because a e he con ol bi s o he Display.
51
6.8.4 Accele ome e pin assignmen
Pin #
Pin name
Func ion
Colo
1
ST
Sel - es
-No connec -
2
Z
Z axis
G een
3
Y
Y axis
Blue
4
X
X axis
G ey
5
GND
G ound
Black
6
VCC
Supply Vol age (1.8 V o 3.6
V).
Red
Table 7: Accele ome e pin and cable assignmen
No e: ESD CAUTION ( o de ice manipula ion)!
ESD (elec os a ic discha ge) sensi i e de ice. Cha ged de ices and
ci cui boa ds can discha ge wi hou de ec ion. Al hough his p oduc
ea u es pa en ed o p op ie a y p o ec ion ci cui y, damage may
occu on de ices subjec ed o high ene gy ESD. The e o e, p ope ESD
p ecau ions should be aken o a oid pe o mance deg ada ion o loss
o unc ionali y. I ’s impo an o know his in o ma ion on ime o
manipula e he accele ome e .
6.8.5 Mo he boa d pin assignmen
Figu e: Mo he boa d (SBC44UCR) pin loca ion
52
CON2 Daugh e Boa d Connec o
CON1 Daugh e Boa d Connec o
Daugh e
Boa d
Po
Pin
Signal
Daugh e
Boa d
Po
Pin
Signal
T0
Po 0 o he MCP23008 I/O
expande (i assembled)
T4
Po 4 o he MCP23008 I/O
expande (i assembled)
T1
Po 1 o he MCP23008 I/O
expande (i assembled)
T5
Po 5 o he MCP23008 I/O
expande (i assembled)
T2
Po 2 o he MCP23008 I/O
expande (i assembled)
T6
Po 6 o he MCP23008 I/O
expande (i assembled)
T3
Po 3 o he MCP23008 I/O
expande (i assembled)
T7
Po 7 o he MCP23008 I/O
expande (i assembled)
SIG0
No connec ion
GND
G ound
SIG1
No connec ion
+5V
Regula ed 0.5A 5V supply
B0
PIC pin RB2 – has 5K pull-up
esis o .
VIN
Un egula ed inpu ol age
B1
PIC pin RB3
CLR#
PIC pin /MCLR
B2
PIC pin RB0
A0
PIC pin RA0
B3
PIC pin RB1
A1
PIC pin RA1
B4
PIC pin RB4
A2
PIC pin RA2
B5
PIC pin RB5
A3
PIC pin RA3
B6
PIC pin RB6 – also used o
ICP (1)
A4
PIC pin RA4
B7
PIC pin RB7 – also used o
ICP (1)
A5
PIC pin RA5
C4
PIC pin RB0 – po pin
assigned o I2C (2)
C0
PIC pin RC0
C5
PIC pin RC7
C1
PIC pin RC1
C6
PIC pin RC6 – can be used
o RS232/RS485 TX
C2
PIC pin RC2
C7
PIC pin RC7 – can be used
o RS232/RS485 RX
C3
PIC pin RB1 – po pin
assigned o I2C (2)
D2
PIC pin RD2 (4)
D0
PIC pin RD0
D3
PIC pin RD3 (4)
D1
PIC pin RD1
D4
PIC pin RD4 (3)
E0
PIC pin RE0
D5
PIC pin RD5 (3)
E1
PIC pin RE1
D6
PIC pin RD6 (3)
E2
PIC pin RE2
D7
PIC pin RD7 (3)
GND
G ound
Table 8: Mo he boa d CON1, CON2 pin assignmen
53
No e:
(1) Po Pins B6 and B7 a e also used o in ci cui p og amming, and o
en e boo loade mode! I hey a e used, and he boa d should s ill be in
ci cui p og ammable, make su e hei impedance is g ea e hen a 1000
ohms!
(2) Po Pins C3 and C4 a e connec ed o PIC po pins RB0 and RB1, hose
po s can be used o he I2C bus. When no I2C de ices a e used
(ex e nal EEPROM o MCP23008 I/O expande o example), hese po s
can be used as gene al pu pose I/O pins.
(3) I a se ial FRAM chip is assembled, hese pins will be used o
communica e wi h i . By de aul , he e is no FRAM chip assembled, and
hese pins can be used o gene al pu pose I/O pins. Pin D4 has a 5K
pull-up esis o connec ed o i !
(4) PIC po pins RD2 and RD3 a e also used o “USB Sel Powe Sense”
and “USB Bus Sense” inpu s. I his unc ionali y is no equi ed, hey can
be used as gene al pu pose I/O pins. They bo h ha e a 47k esis o ha
will pull i high o low, depending on how he boa d is cu en ly powe ed.
54
6.9 Con igu a ion o he connec ions in he p o o ype
6.9.1 SD pin connec ions
Pin
#
Pin Name
Cable colo
Mo he boa d
Pin
1
DAT3/CS
Red
B5
2
CMD/DI
B own
B3
3
VSS1
Black
G ound
4
Vdd
Whi e
3.3V
5
Clock
G ey
B2
6
Vss2
Pu ple
G ound
7
DAT0/D0
Blue
B4
8
DAT1/IRQ
G een
-No connec ion-
9
DAT2/NC
O ange
-No connec ion-
Table 9: SD ca d pin connec ions.
6.9.2 Gps pin connec ions
Pin
#
Pin name
Cable colo
Mo he boa d Pin
1
Enable/Disable
G ey
C2
2
G ound
Pu ple
G ound
3
RX
Blue
C6
4
TX
G een
C7
5
VCC
Yellow
3.3V
Table 10: Gps pin connec ions
55
6.9.3 Display pin connec ions
Pin
#
Symbol
Colo
Mo he boa d Pin
1
VSS
Red
G ound
2
VDD
B own
3.3V
3
V0
Black
G ound
4
RS
Whi e
D0
5
R/W
G ey
D4
6
E
Pu ple
D1
7
DB0
Yellow
E0
8
DB1
O ange
E1
9
DB2
Red
E2
10
DB3
B own
E3
11
DB4
Blue
-No connec ion-
12
DB5
G een
-No connec ion-
13
DB6
Yellow
-No connec ion-
14
DB7
O ange
-No connec ion-
15
A
“ No connec ion needed”
-No connec ion-
16
K
“ No connec ion needed”
-No connec ion-
Table 11: Display pin connec ions
6.9.4 Accele ome e pin connec ions
Pin #
Pin name
Colo
Mo he boa d
Pin
1
ST
-No connec ion-
-------------
2
Z
G een
A0
3
X
G ey
A1
4
Y
Blue
A2
5
GND
Black
G ound
6
VCC
Red
3.3V
Table 12: Accele ome e pin connec ions
6.9.5 Swi ches connec ions
Colo
Mo he boa d pin
Swi ch 2
Pu ple
RB6
Swi ch 3
G een
RB7
Table 13: Swi ches pin connec ions.
56
6.10 P o o ype Pic u es
Pic u e 5: USB and he powe supply connec ions.
Pic u e 6: Two swi ches o manage he powe supply.
57
Pic u e 7: Connec ions inside he de ice.
64
6.14.4 LCD 16x2 Display
Table 14: LCD cha ac e is ics
Complemen s
Daugh e ’s boa d o expand buses and connec ions
Powe supply AC o DC
Recha geable Ba e y Li-On
SD Ca d Socke
Memo y
Vol age Regula o s
Bu ons
Cables
Model.
LCM-S01602DTR/A
Lumex Op o/Componen s Inc
Display Type
TN - Twis ed Nema ic
Display Mode
Re lec i e
Display Fo ma
16 x 2
Cha ac e Fo ma
5 x 8 Do s
Cha ac e Size
5.56mm H x 2.96mm W
Backligh
Wi hou Backligh
Viewing A ea
66.00mm L x 16.00mm W
Ope a ing Tempe a u e
0°C ~ 50°C
Vol age – Supply
5V
Do Size
0.56mm W x 0.66mm H
65
7. Budge
Budge o ou p o o ype and expe imen al equipmen
Componen
Cos (€)
SBC44UC BOARD x 2
84.04 €
GPS
44.17 €
ACCELEROMETER
20.99€
DISPLAY
12.35€
DEVICE BOX
7.95€
OTHER COMPONENTS
(CABLES/CONNECTORS)
30€
PROTOBOARD
19.95€
No VAT included
219.45€
TOTAL €
Table 15: Empi ical Budge
Budge o build a p o o ype
Componen
Cos (€)
SBC44UC BOARD
42.02€
GPS
44.17 €
ACCELEROMETER
20.99€
DISPLAY
12.35€
DEVICE BOX
7.95€
OTHER COMPONENTS
(CABLES/CONNECTORS)
10€
LITTIUM BATTERY
25.00€
SD CARD
20€
No VAT included
182.48€
TOTAL €
Table 16: Ideal Budge
Wi h an a ailable budge o 1000 Eu os and a maximum expendi u e o 219.45 Eu os
we ha e managed o signi ican ly educe cos s, and design a de ice only wi h ha .
The e a e simila de ices ou in he ma ke cos s a ound 3000 Eu os.
66
8. Obse a ions & E alua ion
A his poin , and wi hou possibili y o ha ing been es ed success ully he ull
algo i hm designed o he p o o ype, we a e sa is ied wi h he done. We ha e no had
he oppo uni y o change he design due o he sho pe iod o ime which we ha e
p o ided.
Design has been ailo ed o mee he demands o he con ac o , we ha e made and
s udied a design o i , in heo y he design is well implemen ed, bu due o las minu e
p oblems on he size o he ROM o he mic ocon olle , i is no able o success ully
pe o m he es s necessa y o comple e he inal design.
Assessing he p oblems we had ha e, we concluded ha he only way o sol e hese
p oblems is o change he chosen mic ocon olle by one wi h mo e esou ces,
enough o accomplish he needs o he p og am we ha e done.
67
9. Recommenda ions
9.1 Dimensions
This design is in ended as a p o o ype, a e he p o o ype is es ed and ge ing he
desi ed esul , i ’s possible o edesign he boa d, designing a new boa d wi h all he
componen s loca ed in he same plane, making he design as small as he echnology
pe mi s, i means less cos and less space.
9.2 Powe Supply
TT Race Da a Logge cans be ed by USB o ex e nal DC inpu , bo h a 3.3 Vol s, bu as
we al eady said be o e, an in e nal an au onomous powe supply wi h a ba e y and
cha ging sys em will imp o e he comple e design.
We o e a design o his sys em. Is no implemen ed bu i could be easily o do i .
NOTE: Pins 1,2,16 a e swi ching he s a e, IDLE, ON, OFF and a e connec ed o he
main Chip. I ’s no necessa y o be exac ly RB po , i could be ano he .
Figu e 6: Ba e y managemen ci cui schema ic
68
9.3 SD Socke wi h USB chipse included
One o he issues encoun e ed so a , was he lack o p og am memo y space inside he CHIP
used (PIC18F4550). One solu ion o minimize signi ican ly he size o he en i e p og am is use
a be e socke o SD ca d, wi h an USB/FAT16 in e ace chipse included. I o e s he
ad an age o s o e he whole USB in e ace and FAT16 ile sys em gi ing mo e eedom and
space o he mo he boa d, o e ing he possibili y o include mo e ea u es o he TT Race
Da a logge .
Pic u e 11 – Mic oSD Socke wi h USB/FAT16 in e ace included.
Model: DOSonCHIP FAT16/32 IC
69
9.4 Mic op ocesso
TT Race Da a Logge needs a complex p og am o un, his means ha his will use a
lo o ROM memo y o s o e i . Du ing he s udy o he possibili ies we ound his
p oblem, is caused because he main p og am is la ge o s o e i in o he PIC18F4550,
because o his ou p o o ype is no unning as well as we wan .
We couldn’ es i and know i he algo i hm o he p og am is ok. Du ing he pa o
he design we ound se e al p oblems, we asked Mic ochip abou his p oblems, hey
ied o sol e i and ound a solu ion, bu inally, he bes choice is change he
mic op ocesso (PIC18F4550) o ano he wi h mo e capaci y, and mo e esou ces.
PIC18F4550 has 32Kb o ROM memo y, a leas is needed he double, so minimum is
needed a mic ocon olle wi h a memo y ROM > 64 Kb. Is p oposed one
mic op ocesso o con inue he p ojec . PIC18F87J50 amily should be enough wi h
mo e han he double o esou ces. I has 3.800 Kby es o Ram Memo y.
To con inue wi h his p ojec will be necessa y some changes in he wi e connec ions
and he code, o y o habi ua e o ano he chipse .
70
9.5 Da a File P ocessing and Google Maps
TT Race Da a Logge g an s he posi ion o he mo o bike using a s anda d and in e na ional
coo dina e’s o ma ha could be ead by some easy high le el so wa e. Ac ually Google
o e s e y in e es ing so wa e called “Google Ea h/Maps API” ha has he en i e wo ld
mapped by hei sa elli es s o ed in his da abase. This so wa e is capable o , easily; make a
emapping o he coo dina es gene a ed by he TT Race Da a Logge showing hem on a map
wi h an inc edible esolu ion and accu acy. This so wa e is assembled by his own language;
his compile is made by Google and is open sou ce bu no o ee. You can p og am you
own unc ions and u ili ies inside you maps, designing ace s, ou es and lo s o mo e
ea u es, making i mo e in e ac i e and easy o use. Also has a good beha io and
compa ibili y wi h o he languages like C, C++, ja a o lash and i s inside a mobile phone. I ’s
easy, powe ul and high ecommended ool o u he high le el so wa e design o p ocess
he da a ile gene a ed by TT Race Da a Logge .
Figu e 7: Example o Google Ea h API So wa e, showing he TT Race Ci cui in Assen - Ne he lands
71
10. Li e a u e
The nex web links a e some pages used o do ou p ojec
- h p://www.aim-spo line.com
- h p://www.gpsin o ma ion.o g/dale/nmea.h m
- h p://en.wikipedia.o g
- h p://www.mic ochip.com/
- h p://www.edaboa d.com/
- h p://www.xilinx.com/i p/xilinx10/isehelp/pim_c_in oduc ion_spi_con igu a ion.h
m
- h p://www.digi ale-elek onik.de/shopsys em/
- h p://www.mic ochip.com/s ellen /idcplg?IdcSe ice=SS_GET_PAGE&nodeId=1824&
appno e=en532040
- h p://elm-chan.o g/docs/mmc/mmc_e.h ml
- h p://mbed.o g/p ojec s/cookbook/wiki/SDCa d
- h p://www. i. i/midcom-se ea achmen guid-
b469d17c67e60d4e3dbb25b0d099ad68/TN15_SPI_In e ace_Speci ica ion.pd
Books used
Ti le: PIC Mic ocon olle s
Au ho : Milan Ve le
Numbe o pages: 394
Publishe : mik oElek onika; 1s edi ion (2008)
Language: English
72
11. Annex
This epo has o be ollowed by a CD whe e he use cans ind he whole C Code and
he necessa y so wa e ools o design i (MPLAB IDE, C18 Compile and Fi mwa e’s
Lib a ies). Also is included all da ashee s abou in eg a ed componen s, no added o
his epo cause hei size.