{"id":278,"date":"2017-11-28T22:04:22","date_gmt":"2017-11-28T22:04:22","guid":{"rendered":"http:\/\/www.burningimage.net\/cattrack\/?p=278"},"modified":"2023-07-22T07:56:57","modified_gmt":"2023-07-22T06:56:57","slug":"it-works","status":"publish","type":"post","link":"https:\/\/www.burningimage.net\/cattrack\/it-works\/","title":{"rendered":"It works!!!"},"content":{"rendered":"<p>The time has finally arrived, let&#8217;s test CatTrack on Buttons.<\/p>\n<p>It doesn&#8217;t seem to bother him anyway!<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-448\" src=\"https:\/\/www.burningimage.net\/cattrack\/wp-content\/uploads\/2019\/01\/buttons-with-cattrack-1024x768.jpg\" alt=\"\" width=\"500\" height=\"375\" srcset=\"https:\/\/www.burningimage.net\/cattrack\/wp-content\/uploads\/2019\/01\/buttons-with-cattrack.jpg 1024w, https:\/\/www.burningimage.net\/cattrack\/wp-content\/uploads\/2019\/01\/buttons-with-cattrack-300x225.jpg 300w, https:\/\/www.burningimage.net\/cattrack\/wp-content\/uploads\/2019\/01\/buttons-with-cattrack-768x576.jpg 768w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/p>\n<p><!--more--><\/p>\n<p>Open it up and you can see the li-ion battery (see <a href=\"https:\/\/www.burningimage.net\/cattrack\/gps-cat-tracker-power-source\/\">Choosing a Power Source<\/a>) connected to the back of the PCB with the PIC alongside it. \u00a0The two LEDs are in the top left, although in order to save power they&#8217;re disabled in software, save for flashing once on power-up. \u00a0You can see the light purple coloured area on the right of the PCB where the copper has been etched away for the antenna on the reverse. \u00a0The battery sits on top of the ground plane just under this area.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-295\" src=\"https:\/\/www.burningimage.net\/cattrack\/wp-content\/uploads\/2017\/11\/inside-cattrack-2.jpg\" alt=\"\" width=\"500\" height=\"375\" srcset=\"https:\/\/www.burningimage.net\/cattrack\/wp-content\/uploads\/2017\/11\/inside-cattrack-2.jpg 2048w, https:\/\/www.burningimage.net\/cattrack\/wp-content\/uploads\/2017\/11\/inside-cattrack-2-300x225.jpg 300w, https:\/\/www.burningimage.net\/cattrack\/wp-content\/uploads\/2017\/11\/inside-cattrack-2-768x576.jpg 768w, https:\/\/www.burningimage.net\/cattrack\/wp-content\/uploads\/2017\/11\/inside-cattrack-2-1024x768.jpg 1024w, https:\/\/www.burningimage.net\/cattrack\/wp-content\/uploads\/2017\/11\/inside-cattrack-2-1440x1080.jpg 1440w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/p>\n<p>Flip it over and we can see the front of the PCB. \u00a0The soldering looks a little shoddy, but bear in mind all of the small components are 1.0 x 0.5 mm and have been soldered by me by hand on the dining room table! \u00a0The white sticky pads are used to hold the PCB off the bottom slightly such that the GPS antenna (the thing with OriginGPS written on) doesn&#8217;t contact the plastic.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-296\" src=\"https:\/\/www.burningimage.net\/cattrack\/wp-content\/uploads\/2017\/11\/inside-cattrack-1.jpeg\" alt=\"\" width=\"500\" height=\"375\" srcset=\"https:\/\/www.burningimage.net\/cattrack\/wp-content\/uploads\/2017\/11\/inside-cattrack-1.jpeg 2048w, https:\/\/www.burningimage.net\/cattrack\/wp-content\/uploads\/2017\/11\/inside-cattrack-1-300x225.jpeg 300w, https:\/\/www.burningimage.net\/cattrack\/wp-content\/uploads\/2017\/11\/inside-cattrack-1-768x576.jpeg 768w, https:\/\/www.burningimage.net\/cattrack\/wp-content\/uploads\/2017\/11\/inside-cattrack-1-1024x768.jpeg 1024w, https:\/\/www.burningimage.net\/cattrack\/wp-content\/uploads\/2017\/11\/inside-cattrack-1-1440x1080.jpeg 1440w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/p>\n<p>In order to allow me to communicate with CatTrack ahead of designing the basestation unit, I&#8217;m using a CC1125 development board. This allows me to transmit and receive arbitrary packets to\/from CatTrack directly from my PC, simulating the basestation. \u00a0Annoyingly TI&#8217;s software doesn&#8217;t seem to support macOS, so I&#8217;ve fired up my Windows machine.<\/p>\n<p>The interface looks like this:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-282\" src=\"https:\/\/www.burningimage.net\/cattrack\/wp-content\/uploads\/2017\/11\/transmitting.png\" alt=\"\" width=\"2024\" height=\"1280\" srcset=\"https:\/\/www.burningimage.net\/cattrack\/wp-content\/uploads\/2017\/11\/transmitting.png 2024w, https:\/\/www.burningimage.net\/cattrack\/wp-content\/uploads\/2017\/11\/transmitting-300x190.png 300w, https:\/\/www.burningimage.net\/cattrack\/wp-content\/uploads\/2017\/11\/transmitting-768x486.png 768w, https:\/\/www.burningimage.net\/cattrack\/wp-content\/uploads\/2017\/11\/transmitting-1024x648.png 1024w, https:\/\/www.burningimage.net\/cattrack\/wp-content\/uploads\/2017\/11\/transmitting-1440x911.png 1440w\" sizes=\"auto, (max-width: 2024px) 100vw, 2024px\" \/><\/p>\n<p>Zooming into the radio packets I am transmitting, we can see the following:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-281 aligncenter\" src=\"https:\/\/www.burningimage.net\/cattrack\/wp-content\/uploads\/2017\/11\/transmitting-again.png\" alt=\"\" width=\"289\" height=\"156\" srcset=\"https:\/\/www.burningimage.net\/cattrack\/wp-content\/uploads\/2017\/11\/transmitting-again.png 950w, https:\/\/www.burningimage.net\/cattrack\/wp-content\/uploads\/2017\/11\/transmitting-again-300x162.png 300w, https:\/\/www.burningimage.net\/cattrack\/wp-content\/uploads\/2017\/11\/transmitting-again-768x414.png 768w\" sizes=\"auto, (max-width: 289px) 100vw, 289px\" \/><\/p>\n<p>They are broken down thus:<\/p>\n<ol>\n<li><span style=\"color: #ff0000;\">The message type<\/span> (see <a href=\"https:\/\/www.burningimage.net\/cattrack\/writing-the-code\/\">Writing the Code<\/a>\u00a0for the list of message types I&#8217;ve defined). \u00a00x03 is Beacon Mode, so I will expecting a short message back from CatTrack telling me the battery voltage.<\/li>\n<li><span style=\"color: #0000ff;\">The message counter<span style=\"color: #000000;\">. \u00a0Because I haven&#8217;t yet designed the basestation, I&#8217;ve hard coded this to &#8216;1&#8217; for the time being and commented out the RF-replay checks in the CatTrack code.<\/span><\/span><\/li>\n<li><span style=\"color: #ff9900;\">The number of replies to send<\/span>. \u00a0This tells the collar to send back 24 (0x18) battery voltage messages.<\/li>\n<li><span style=\"color: #ff00ff;\">Some check bytes<\/span>. \u00a0I&#8217;ve got two bytes free at the end (the encryption is donein 64-bit blocks), so I&#8217;ve arbitarily filled these with 0x0a and 0xec. \u00a0The collar checks these bytes after decrypting the transmission to ensure it decrypted correctly.<\/li>\n<\/ol>\n<p>Clearly the encryption isn&#8217;t yet turned on &#8211; I&#8217;ve commented that out in the code too. \u00a0It&#8217;ll be too difficult to use the encryption from a development board. \u00a0I&#8217;ll switch it on once I&#8217;ve designed the basestation.<\/p>\n<p>CatTrack sits in its low-power sleep mode most of the time, waking the receiver up once every 16 seconds. \u00a0Therefore in the worst-case scenario, I&#8217;ll need to send 32 messages &#8211; one every 500ms in order to ensure that CatTrack receives a message when it wakes up.<\/p>\n<p>Let&#8217;s switch to the &#8216;Receive&#8217; tab and see if we receive anything back&#8230;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-286 aligncenter\" src=\"https:\/\/www.burningimage.net\/cattrack\/wp-content\/uploads\/2017\/11\/received-data-1.png\" alt=\"\" width=\"314\" height=\"302\" srcset=\"https:\/\/www.burningimage.net\/cattrack\/wp-content\/uploads\/2017\/11\/received-data-1.png 596w, https:\/\/www.burningimage.net\/cattrack\/wp-content\/uploads\/2017\/11\/received-data-1-300x289.png 300w\" sizes=\"auto, (max-width: 314px) 100vw, 314px\" \/><\/p>\n<p>Hurrah!!! \u00a0This decodes thus:<\/p>\n<ol>\n<li><span style=\"color: #ff0000;\">Device ID<\/span>. This is a function of how the CC1125 operates. \u00a00x10 is the the device ID of the basestation, so all other CatTracks in the vicinity know to ignore this message.<\/li>\n<li><span style=\"color: #0000ff;\">Message count<\/span>. \u00a0I requested 24 (0x18) replies, so I&#8217;ll get 24 replies, 0x00 to 0x17.<\/li>\n<li><span style=\"color: #ff6600;\">Battery voltage<\/span>. \u00a0I&#8217;ve coded this in BCD so it&#8217;s easy to read in hex. \u00a0This means the battery voltage is 3.78V. \u00a0Plenty of life left!<\/li>\n<li><span style=\"color: #ff00ff;\">Received Signal Strength Indicator (RSSI)<\/span>. \u00a0This tells me the power that the signal was received at, in dBm. \u00a0The lower the number, the further away Buttons is. \u00a0It&#8217;ll range from around -125 dBm to -30 dBm.<\/li>\n<\/ol>\n<p>Now that we know we have plenty of bttery life left, let&#8217;s send a &#8216;GPS position request&#8217; and see what comes back. \u00a0The message to be sent from the basestation to CatTrack is exactly the same as the 0x03 beacon request above, but 0x03 is replaced with 0x01.<\/p>\n<p>At first, this is what the collar sends us back:\u00a0<img loading=\"lazy\" decoding=\"async\" class=\" wp-image-288 aligncenter\" src=\"https:\/\/www.burningimage.net\/cattrack\/wp-content\/uploads\/2017\/11\/gps-data-coming-back.png\" alt=\"\" width=\"622\" height=\"260\" srcset=\"https:\/\/www.burningimage.net\/cattrack\/wp-content\/uploads\/2017\/11\/gps-data-coming-back.png 1126w, https:\/\/www.burningimage.net\/cattrack\/wp-content\/uploads\/2017\/11\/gps-data-coming-back-300x125.png 300w, https:\/\/www.burningimage.net\/cattrack\/wp-content\/uploads\/2017\/11\/gps-data-coming-back-768x321.png 768w, https:\/\/www.burningimage.net\/cattrack\/wp-content\/uploads\/2017\/11\/gps-data-coming-back-1024x427.png 1024w\" sizes=\"auto, (max-width: 622px) 100vw, 622px\" \/><\/p>\n<ol>\n<li><span style=\"color: #ff0000;\">Device ID<\/span>. \u00a0As before.<\/li>\n<li><span style=\"color: #ff9900;\">Hours<\/span>. \u00a00x14 is 20, so 8 pm.<\/li>\n<li><span style=\"color: #0000ff;\">Minutes<\/span>. 29 minutes past the hour.<\/li>\n<li><span style=\"color: #ff00ff;\">Seconds<\/span>. 48 seconds into the minute.<\/li>\n<li><span style=\"color: #00ccff;\">Counter<\/span>. Every GPS message from the module is counted. \u00a0We only transmit one module every ten seconds, so this counter increments by 10 each time.<\/li>\n<\/ol>\n<p>All of the zeros in the middle is the position information. \u00a0We&#8217;ve not yet got a GPS lock so they&#8217;re all zero. \u00a0We wait a few minutes, and then&#8230;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-292 aligncenter\" src=\"https:\/\/www.burningimage.net\/cattrack\/wp-content\/uploads\/2017\/11\/gps-received.png\" alt=\"\" width=\"603\" height=\"127\" srcset=\"https:\/\/www.burningimage.net\/cattrack\/wp-content\/uploads\/2017\/11\/gps-received.png 1064w, https:\/\/www.burningimage.net\/cattrack\/wp-content\/uploads\/2017\/11\/gps-received-300x63.png 300w, https:\/\/www.burningimage.net\/cattrack\/wp-content\/uploads\/2017\/11\/gps-received-768x162.png 768w, https:\/\/www.burningimage.net\/cattrack\/wp-content\/uploads\/2017\/11\/gps-received-1024x216.png 1024w\" sizes=\"auto, (max-width: 603px) 100vw, 603px\" \/><\/p>\n<p>We&#8217;ve found Buttons!!! (I&#8217;ve blanked off the last 24 bits of each latitude and longitude)<\/p>\n<ol>\n<li><span style=\"color: #ff0000;\">GPS quality<\/span>. \u00a00x01 indicates that we have GPS lock.<\/li>\n<li><span style=\"color: #0000ff;\">Latitude<\/span>. \u00a0This is a signed 32-bit integer, in the decimal form ddmm.mmmm. \u00a0We multiply by 10000 before sending. \u00a00x03100000 translates to 51 degrees, 38.0224 minutes.<\/li>\n<li><span style=\"color: #ff9900;\">Longitude<span style=\"color: #000000;\">. \u00a0A signed 32-bit integer in the form dddmm.mmmm. Again, multiplied by 10000. 0xffe00000 translates to -2 degrees, 9.7152 minutes.<\/span><\/span><\/li>\n<li><span style=\"color: #ff00ff;\">The number of satellites we&#8217;re locked on to<\/span>. \u00a0Five in our case.<\/li>\n<li><span style=\"color: #339966;\">The Horizontal Dilution of Precision (HDOP)<\/span>. \u00a0We use this to assess how accurate our fix is. \u00a0The lower the better. \u00a0Anything less than 2.0 is good. \u00a0Less than 3.0 is generally &#8216;ok&#8217;. \u00a00x17 equates to 23 which means an HDOP of 2.3 (we multiply it by 10).<\/li>\n<\/ol>\n<p>I&#8217;m\u00a0really happy with how CatTrack is performing. \u00a0Currently it looks like I&#8217;m going to have many months of battery life as the Li-Ion battery has only dropped from 4.2 V to 3.8 V in around 6 weeks.<\/p>\n<p>Now I need to ditch the CC1125 development board and get on with making the basestation! \u00a0That way I&#8217;ll be able to turn on the encryption and RF replay protection. \u00a0I&#8217;ve quite a few ideas on how to implement the basestation too which I&#8217;ll share in a future post.<\/p>\n<p>I&#8217;ll do some tests to see what kind of range I&#8217;m getting too.<\/p>\n<p>I need to make sure I keep the momentum up. Now that CatTrack is working (albeit with a development board as the basestation), it&#8217;s tempting to take my foot off the gas, but I don&#8217;t want to do that, I want a full solution, including the basestation!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The time has finally arrived, let&#8217;s test CatTrack on Buttons. It doesn&#8217;t seem to bother him anyway!<\/p>\n","protected":false},"author":1,"featured_media":297,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[20,58,52,55,4,80,56,79,17,59,22,25,16,49,46,7],"class_list":["post-278","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-posts","tag-antenna","tag-battery","tag-cat","tag-cattrack","tag-cc1125","tag-code-rolling","tag-collar","tag-encryption","tag-gps","tag-li-ion","tag-origingps","tag-pic","tag-protocol","tag-rf","tag-tracker","tag-transmitter"],"_links":{"self":[{"href":"https:\/\/www.burningimage.net\/cattrack\/wp-json\/wp\/v2\/posts\/278","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.burningimage.net\/cattrack\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.burningimage.net\/cattrack\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.burningimage.net\/cattrack\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.burningimage.net\/cattrack\/wp-json\/wp\/v2\/comments?post=278"}],"version-history":[{"count":17,"href":"https:\/\/www.burningimage.net\/cattrack\/wp-json\/wp\/v2\/posts\/278\/revisions"}],"predecessor-version":[{"id":452,"href":"https:\/\/www.burningimage.net\/cattrack\/wp-json\/wp\/v2\/posts\/278\/revisions\/452"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.burningimage.net\/cattrack\/wp-json\/wp\/v2\/media\/297"}],"wp:attachment":[{"href":"https:\/\/www.burningimage.net\/cattrack\/wp-json\/wp\/v2\/media?parent=278"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.burningimage.net\/cattrack\/wp-json\/wp\/v2\/categories?post=278"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.burningimage.net\/cattrack\/wp-json\/wp\/v2\/tags?post=278"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}