{"id":750,"date":"2014-12-26T11:58:51","date_gmt":"2014-12-26T11:58:51","guid":{"rendered":"http:\/\/ava.upuaut.net\/?p=750"},"modified":"2014-12-28T15:14:57","modified_gmt":"2014-12-28T15:14:57","slug":"getting-started-with-ublox-part-2","status":"publish","type":"post","link":"https:\/\/ava.upuaut.net\/?p=750","title":{"rendered":"Getting started with Ublox Part 2 &#8211; Setting Airborne Dynamic Model"},"content":{"rendered":"<p>Ok firstly we need to switch the RX&amp;TX connections over on the board as we were passing through to the in board Serial to USB chip. <span style=\"text-decoration: underline;\"><strong>This is important, don&#8217;t do this and nothing will wor<\/strong><strong>k <\/strong><\/span><\/p>\n<p>So amend the wiring as follows :<\/p>\n<p>Arduino 5V to GPS Board 5V<br \/>\nArduino GND to GPS Board GND<br \/>\n<strong>Arduino Pin 0 (RX) to GPS Board TX<\/strong><br \/>\n<strong>Arduino Pin 1 (TX) to GPS Board RX<\/strong><br \/>\nArduino Pin 2 to GPS Board EN<\/p>\n<p>Load the following code up on your Arduino (close down U-Center at this point as it will be hanging on to the serial port). \u00a0This code is derived from Jon Sowman and Joey flight computer CUSF\u00a0https:\/\/github.com\/cuspaceflight\/joey-m\/tree\/master\/firmware<\/p>\n<p>This code opens the serial port, send the binary command to set the dynamic model, waits for confirmation this has been acknowledged by the GPS. Once done it just drops to the main loop where it just blinks the Status LED once a second to indicate success.<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n#include &lt;util\/delay.h&gt;\r\n\r\n#define GPSENABLE 2\r\n#define STATUSLED 13\r\n\r\nvoid setup() {\r\n pinMode(GPSENABLE, OUTPUT);\r\n pinMode(STATUSLED, OUTPUT);\r\n Serial.begin(9600);\r\n _delay_ms(500);\r\n digitalWrite(GPSENABLE, HIGH);\r\n _delay_ms(500);\r\n setGPS_DynamicModel6();\r\n}\r\nvoid loop() {\r\n digitalWrite(STATUSLED,!digitalRead(STATUSLED));\r\n _delay_ms(1000);\r\n}\r\nvoid setGPS_DynamicModel6()\r\n{\r\n int gps_set_sucess=0;\r\n uint8_t setdm6&#x5B;] = {\r\n 0xB5, 0x62, 0x06, 0x24, 0x24, 0x00, 0xFF, 0xFF, 0x06,\r\n 0x03, 0x00, 0x00, 0x00, 0x00, 0x10, 0x27, 0x00, 0x00,\r\n 0x05, 0x00, 0xFA, 0x00, 0xFA, 0x00, 0x64, 0x00, 0x2C,\r\n 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\r\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0xDC };\r\n while(!gps_set_sucess)\r\n {\r\n sendUBX(setdm6, sizeof(setdm6)\/sizeof(uint8_t));\r\n gps_set_sucess=getUBX_ACK(setdm6);\r\n }\r\n}\r\nvoid sendUBX(uint8_t *MSG, uint8_t len) {\r\n Serial.flush();\r\n Serial.write(0xFF);\r\n _delay_ms(500);\r\n for(int i=0; i&lt;len; i++) {\r\n Serial.write(MSG&#x5B;i]);\r\n }\r\n}\r\nboolean getUBX_ACK(uint8_t *MSG) {\r\n uint8_t b;\r\n uint8_t ackByteID = 0;\r\n uint8_t ackPacket&#x5B;10];\r\n unsigned long startTime = millis();\r\n\r\n\/\/ Construct the expected ACK packet\r\n ackPacket&#x5B;0] = 0xB5; \/\/ header\r\n ackPacket&#x5B;1] = 0x62; \/\/ header\r\n ackPacket&#x5B;2] = 0x05; \/\/ class\r\n ackPacket&#x5B;3] = 0x01; \/\/ id\r\n ackPacket&#x5B;4] = 0x02; \/\/ length\r\n ackPacket&#x5B;5] = 0x00;\r\n ackPacket&#x5B;6] = MSG&#x5B;2]; \/\/ ACK class\r\n ackPacket&#x5B;7] = MSG&#x5B;3]; \/\/ ACK id\r\n ackPacket&#x5B;8] = 0; \/\/ CK_A\r\n ackPacket&#x5B;9] = 0; \/\/ CK_B\r\n\r\n\/\/ Calculate the checksums\r\n for (uint8_t ubxi=2; ubxi&lt;8; ubxi++) {\r\n ackPacket&#x5B;8] = ackPacket&#x5B;8] + ackPacket&#x5B;ubxi];\r\n ackPacket&#x5B;9] = ackPacket&#x5B;9] + ackPacket&#x5B;8];\r\n }\r\n\r\nwhile (1) {\r\n\r\n\/\/ Test for success\r\n if (ackByteID &gt; 9) {\r\n \/\/ All packets in order!\r\n return true;\r\n }\r\n\r\n\/\/ Timeout if no valid response in 3 seconds\r\n if (millis() - startTime &gt; 3000) {\r\n return false;\r\n }\r\n\r\n\/\/ Make sure data is available to read\r\n if (Serial.available()) {\r\n b = Serial.read();\r\n\r\n\/\/ Check that bytes arrive in sequence as per expected ACK packet\r\n if (b == ackPacket&#x5B;ackByteID]) {\r\n ackByteID++;\r\n }\r\n else {\r\n ackByteID = 0; \/\/ Reset and look again, invalid order\r\n }\r\n }\r\n }\r\n}\r\n\r\n<\/pre>\n<p>So there you go that&#8217;s the module in Dynamic Model 6 \u2013 Airborne &lt; 1g which is generally the one you want for High Altitude ballooning. If your application is rocketry there is mode 8\u00a0\u2013 Airborne &lt; 4g. Its quite viable to drop back to mode\u00a03 &#8211; Pedestrian when below 9km in altitude. The airborne modes have large positional deviation, whereas the pedestrian modes have small deviation. Airborne modes are still perfectly accurate enough to locate a payload.<\/p>\n<p>Ok so what next ? You have a choice at this point you can write a parser to read NMEA GNGGA strings to obtain your location information, you can use a prebuilt library that does this such as TinyGPS or finally you can use the UBX protocol to poll the module for information. I&#8217;ll discuss using UBX in the next article.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ok firstly we need to switch the RX&amp;TX connections over on the board as we were passing through to the in board Serial to USB chip. This is important, don&#8217;t do this and nothing will work So amend the wiring &hellip;<\/p>\n<p class=\"read-more\"><a href=\"https:\/\/ava.upuaut.net\/?p=750\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-750","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/ava.upuaut.net\/index.php?rest_route=\/wp\/v2\/posts\/750","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ava.upuaut.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ava.upuaut.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ava.upuaut.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ava.upuaut.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=750"}],"version-history":[{"count":7,"href":"https:\/\/ava.upuaut.net\/index.php?rest_route=\/wp\/v2\/posts\/750\/revisions"}],"predecessor-version":[{"id":766,"href":"https:\/\/ava.upuaut.net\/index.php?rest_route=\/wp\/v2\/posts\/750\/revisions\/766"}],"wp:attachment":[{"href":"https:\/\/ava.upuaut.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=750"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ava.upuaut.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=750"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ava.upuaut.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=750"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}