U-blox GNSS Modules and RTK

In last few years use of High Precision Positioning systems gained popularity in variety of application e.g. construction, agriculture and GIS. High precision GNSS systems with horizontal accuracy in centimeters helped in precision agriculture for planting in accurate positions as per plan and auto guidance for tractors. AutoGuidance in big farms helps farmers to save fertilsers and herbicides by preventing unnecessary reapplication over same patch of field. Vertical accuracy of GNSS service helps for land leveling applications.

But How they achieve centimeter level Accuracy. Do they use sane satellites ? Do they use same hardware architechture ?

Yes they use same satellites and same hardware but the methods to get the cordinates is different. They are generally called correction methods. In normal GNSS receivers there are various errors

  1. Satellite Clock Error
  2. Orbit Shift/ In accuracy in Laser Marking
  3. Variable Propagation Delay due to ionsperic variations
  4. Noise sourced from other sources
  5. Multipath Error

Few of these errors are static over time which can be easily corrected with a reference data of the Final cordinates or the PRN and azimuth angles. The oldest method use this technique its called Differential GPS or DGPS (DGNSS in Generic terms). Lets list out the correction techniques

  1. DGPS
  2. PPP
  3. RTK

The most accurate coorection method is RTK which need RAW Data from GNSS modules. Most of the GNSS?GPS module with RAW data costs very high and most of them are not available for individual buyers. Now these ublox Neo Series GPS Chips available abundantly in online shopping sites. These modules cost approx $15 or INR 1000/- . Although none of them seems to be a genuine product. The first one i ordered online was a ublox Neo-m8n which was a Neo-6M  when received so i returned the item. Next time i purchased Neo-6M from local market(Chandni chowk) which was  a ublox-7 version chip inside !! Again i ordered another one from amazon (REES52 Neo-7) this was a actual Neo-6 (but i was expecting Neo-7 inside )

Now how did i enabled RAW data from both Chips, The chips are not assumed to output RAW data as per the manufacturer and even they declare the discussion of related things on there official forum as illegal discussion. Fetching RAW data from these chips are actually a user level hack. They have some debug codes to check working of there GPS engines which spits out the RAW data and the exports decoded it as the data they actually need.

As the names are very confusing i tried the wrong commands from the ubloxraw page at last got the correct ones and some commands sniffed from the ucenter +serial sniffer. The ublox 7 series chip uses TRK-TRKD5+NAV-CLOCK+NAV-TIME to get RAW Data where as ublox 6 version chip gets the RAW data directly as RXM-RAW

For ublox 7 Proto 14.3(TRK-TRKD5+TRK-SFRBX+NAV-CLOCK+NAV-TIMEGPS Parser)
Change baudrate
B5 62 06 00 14 00 01 00 00 00 D0 08 00 00 00 C2 01 00 01 00 01 00 00 00 00 00 B8 42
B5 62 06 01 03 00 03 0A 01 18 5D
B5 62 06 01 03 00 03 0F 01 1D 67
B5 62 06 01 03 00 01 22 01 2E 87
B5 62 06 01 03 00 01 30 01 3C A3
For ublox 6 7.03 (RXM-RAW+RXM-SFRB)
ubx only
b5 62 06 00 14 00 01 00 00 00 d0 08 00 00 80 25 00 00 07 00 01 00 00 00 00 00 a0 a9 b5 62 06 00 01 00 01 08 22
////////////////////////////////////Key Code//////////////////////////////////////////
b5 62 09 01 10 00 c8 16 00 00 00 00 00 00 97 69 21 00 00 00 02 10 2b 22
b5 62 09 01 10 00 0c 19 00 00 00 00 00 00 83 69 21 00 00 00 02 11 5f f0
!HEX b5 62 09 01 10 00 c8 16 00 00 00 00 00 00 97 69 21 00 00 00 02 10 2b 22
!HEX b5 62 09 01 10 00 0c 19 00 00 00 00 00 00 83 69 21 00 00 00 02 11 5f f0
////////////////////////////////////Key Code//////////////////////////////////////////
Enable ubx raw
    b5 62 06 01 03 00 02 10 01 1d 66
Enable ubx sfrbx
   XXXXX b5 62 06 01 03 00 02 13 01 20 6c
    b5 62 06 01 03 00 02 11 01 1e 68
For RTKlib startup command .cmd file
!HEX b5 62 06 00 14 00 01 00 00 00 d0 08 00 00 80 25 00 00 07 00 01 00 00 00 00 00 a0 a9 b5 62 06 00 01 00 01 08 22
!HEX b5 62 09 01 10 00 c8 16 00 00 00 00 00 00 97 69 21 00 00 00 02 10 2b 22
!HEX b5 62 09 01 10 00 0c 19 00 00 00 00 00 00 83 69 21 00 00 00 02 11 5f f0
!HEX b5 62 06 01 03 00 02 10 01 1d 66
!HEX b5 62 06 01 03 00 02 11 01 1e 68
!HEX b5 62 09 01 10 00 c8 16 00 00 00 00 00 00 97 69 21 00 00 00 02 10 2b 22
!HEX b5 62 09 01 10 00 0c 19 00 00 00 00 00 00 83 69 21 00 00 00 02 11 5f f0
!HEX b5 62 06 01 03 00 02 10 01 1d 66
!HEX b5 62 06 01 03 00 02 11 01 1e 68
Some screenshots from the RTKNAV with NEo-7 and RTCM correction data from colombo srilanka. I have also tried RTK with Neo-6 as base directly coonected to laptop and Neo-7  connected over bluetooth but the accuracy was not good enough.
Now i want to test with genuine Neo-m8p chips but u-blox don’t want to sell modules to individuals they want only bulk buyers.
rtk3 rtknow

Electronic Design Abbreviations

ZVS: In a quasi-resonant zero-current/zero-voltage switch (ZCS/ZVS) “each switch cycle delivers a quantized ‘packet’ of energy to the converter output, and switch turn-on and turn-off occurs at zero current and voltage, resulting in an essentially lossless switch.”[32] Quasi-resonant switching, also known as valley switching, reduces EMI in the power supply.

TBU: Its a tradename of Transient Blocking Unit (TBU™) Electronic Current Limiter designed by bournes. TBU technology is designed to block a transient through a current disconnecting mechanism rather than diverting or shunting the surge to ground. This blocking technology virtually eliminates latency in the circuit protection design which results in surge protection for sensitive electronic equipment within nanoseconds.

AFE: Analog Front End

AMR: Automatic meter reading

APD: Avalanche Photo Diodes

BIST: Built-in self-test.

Baseline: The electrical signal from a sensor when no measured variable is present. Often referred to the output at no-load condition.

Beyond-the-Rails: Beyond-the-Rails™ Maxim’s name for a feature of an IC that can process inputs and provide output voltages that exceed the supply rails. The feature is achieved through on-chip integration of necessary supply rails.

Microsoft Serial ballPoint autoinstall

I have been using avr microcontrollers for last 1 year but never faced this problem. Yesterday I was trying to connect a Arduino mini pro with a USB-Serial interface(supplied by Decagon, DevName DecagonUCA, Chip:Silabs CP2024).  I have used this same device in same configuration several times in last 3/4 months.

But only change in code yesterday was that i was throwing some data continuously as the chip powers up. The Operating System (Win7) detects a new device Microsoft serial ballpoint. Now this makes two problems.

  1. The new device uses the serial port you are using. Makes it busy so you can’t use it.
  2. The device assumes the sensor readings you are sending as mouse pointer positions, so it moves the pointer randomly(assuming your data is random) and creates mouse clicks. Now you can’t uninstall the device as your mouse pointer is not in your control.

I removed the USBSerial cable and searched the name of the driver installed, google displayed a number of forum users complaining about this problem. https://www.google.co.in/search?q=microsoft+serial+ballpoint Most of the users are using USB GPS device. I guess any device which continously sends alpha numeric data confused as serial ballpoint. Anyway i want to know what is the actual serial ballpoint protocol

———————————–Serial BallPoint Protocol Start——————————————————–

The old MicroSoft serial mouse, while no longer in general use, can be employed to provide a low cost input device, for example, coupling the internal mechanism to other moving objects. The serial protocol for the mouse is 1200 baud, 7 bit, 1 stop bit, no parity. Every time the mouse changes state (moved or button pressed) a three byte “packet” is sent to the serial interface. For reasons known only to the engineers, the data is arranged as follows, most notably the two high order bits for the x and y coordinates share the first byte with the button status.
D6 D5 D4 D3 D2 D1 D0
1st   byte  1  LB  RB  Y7  Y6 X7 X6
2nd byte  0  X5  X4  X3 X2 X1 X0
3rd  byte  0  Y5  Y4  Y3  Y2 Y1 Y0
LB is the state of the left button, 1 = pressed, 0 = released.
RB is the state of the right button, 1 = pressed, 0 = released
X0-7 is movement of the mouse in the X direction since the last packet. Positive movement is toward the right.
Y0-7 is movement of the mouse in the Y direction since the last packet. Positive movement is back, toward the user.
Sample C code to decode three bytes from the mouse passed in “s”, the button and position (x,y) are returned.

s should consist of 3 bytes from the mouse
void DecodeMouse(unsigned char *s,int *button,int *x,int *y)
*button = ‘n’; /* No button – should only happen on an error */
if ((s[0] & 0x20) != 0)
*button = ‘l’;
else if ((s[0] & 0x10) != 0)
*button = ‘r’;
*x = (s[0] & 0x03) * 64 + (s[1] & 0x3F);
if (*x > 127)
*x = *x – 256;
*y = (s[0] & 0x0C) * 16 + (s[2] & 0x3F);
if (*y > 127)
*y = *y – 256;


  • http://paulbourke.net/dataformats/serialmouse/
  • Alternative: https://www.kryslix.com/nsfaq/Q.12.html

———————————–Serial BallPoint Protocol End——————————————–

Solution 1, (NoSerialMice):

  1. To disable the detection of devices on COM ports in Windows NT/2000/XP: Go to: My Computer – Right Click – Properties | Advanced tab | Startup and Recovery – Settings | Edit. Make a backup copy of the Boot.ini file, (copy and paste in another location)
  2. Remove the hidden, system, and read-only attributes from the Boot.ini file. (Use Windows Explorer and right click on file, then properties.)
  3. Using a text editor (such as Notepad) open the Boot.ini file.(Double click on file, or right click and choose Notepad from the “Open With” option.)
  4. Add “/NoSerialMice” to the end of each entry in the [operating systems] section of Boot.ini. See the example below for more information
  5. Save Boot.ini and quit Notepad
  6. Shutdown and restart Windows

NOTE: The /NoSerialMice option is not case sensitive.

Solution  2: Disable serial mouse

You can disable serial mouse when its connected, but mostly in this type problem the mouse pointer keeps oscillating randomly so you can’t choose the device manager or disable the device.

AVR Mk-II for Aurduino and back to AVRStudio

Drivers in desktop operating systems are not so simple as the embedded drivers, some times it take hours to solve the driver issues specially with the USB Debuggers.

Few Days back i was using arduino for low power applications, so excluded all the supporting components like programmers, UART link and used AVR ISP MkII for programming. But  arduino(open source program) use libusb(opensource) where as avrstudio(copyrighted) use jungo(propietory) for usb interface. And this needs the mkII driver to be changed to libusb. mkii will be a libusb device and in device manager it will show under libusb class. Here is some supporting link




Now if i want to revert back to old driver, i tried to uninstall and delete the mkII driver(libusb), then reinstalled avrstudio again. But nothing happened. No driver found for mkII.

Now i found this blog with similar issue, they were using a debugger from freescale using jungo based usb driver changed to libusb. The part i was missing is jungo deiver install. In device manager there should be component “Jungo driver” permanently in the list whether any debugger attached to port or not. I got the location of the driver in “C:\Program Files (x86)\Atmel\AVR Tools\usb64” mine is 64 bit OS it may be usb for x86

Now another trick about how to install the driver, right click computer name in device manger then choose “add legacy hardware”. Select manually find the driver select all driver(dont srelect any specific) now choose “have a disk” . Now show the path to the folder containing windrv6.sys now it will install Jungo windriver. Now if you have avr studio installed plugin the programmer mkII, it will automatically install the mkII driver.


Driving a laser diode

These diodes are not like normal Light Emitting diodes (LEDS), these diodes can use all the available power if not controlled. So it need to be attached to a current controlled DC source.

The Laser Diode(LD) module contains an Photo diode inbuilt, which monitors the output light intensity and used as a feedback for the control circuits. The terminals from laser diode are

  1. Laser Diode Cathode (LDA)
  2. Photo diode Anode (PDA)
  3. COMMON Positive


This is a simple description of cheapKeyChain Lasers that are sold for 5 bucks or so.The laser diode head has three pins labeled: LDC (Laser Diode Cathode), PDA (Photo Diode Anode) and COM+ (common Positive Terminal).Inside the laser diode head we find the laser diode itself and a photodiode, used to regulate the laser diode current with an external feedback loop.


A Schematic from MAXIM










Power Saving in 8 bit AVR

With increasing popularity of battery powered portable devices microcontroller manufacturers started making the controllers more efficient for the specific purpose. For battery powered devices the most important and common parameter is the power consumption. There are some applications like remote weather loggers which run for years with a set of AA batteries, which needs average power consumption to be in nano amps.

To accomplish these power consumption levels the manufacturers introduced a new feature with different names, Microchips Nanowatt, Texas Instruments MSP430 series and from my favourite atmel its Picopower. All these techniques may work differently but the objective is same.

Atmels AVR 8bit has the following 6 Modes

  • Idle
  • ADC Noise Reduction
  • Power save
  • Power Down
  • StandBy
  • Extended Standby


sleep modes in 8 bit AVR


For the New controllers with PINChange interrupt the following table(Pinchange added as a wake up source)

for the controllers with pinchange interrupt
for the controllers with pinchange interrupt

Now what about the coding,

There are inbuilt functions for all the related job in WinAVR, so you can use the same in AVR Studio or Arduino. There are few arduino libraries e.g.  jeelib (github.com/jcw/jeelib)  for arduino based on the winavr functions, but i think the base winavr functions are best.

just include <avr/power.h> and <avr/sleep.h>

avr/sleep.h includes macros set_sleep_mode(MODE), sleep_enable(), sleep_disable(), sleep_cpu().

#define sleep_enable() \
do { \
} while(0)
#define sleep_disable() \
do { \
} while(0)
#define sleep_cpu() \
do { \
__asm__ __volatile__ ( sleep \n\t :: ); \
} while(0)


#define sleep_mode() \
do { \
sleep_enable(); \
sleep_cpu(); \
sleep_disable(); \
} while (0)


and avr/power.h includes functions for disabling peripherals. function to enable each peripheral,  function to disable each peripheral, function for disabling all, function to enable all.

in simple codes


#include <avr/sleep.h>

….code lines…




these above two lines are enough to make a device sleep.

but before going to sleep you must enable interrupt and a method for wake-up from sleep mode, additionally you can disable the brownout detector (for least power consumption) in run time from the codes, but this functionality is available for some specific chips in pico series although you can disable it outside of the code by setting the fuse bits.

Example code

#include <avr/interrupt.h>
#include <avr/sleep.h>
if (some_condition)
However arduino people found a bug in the above code, if u r planning to wake up through a interrupt, and normal case we dettach the interrupt in the ISR, so if the interrupt is triggered before the system goes to sleep, the system will sleep without a wakeup hook. So modified the code as below. They modified the sequence and added disable_sleep in ISR which will inhibit the previous case.
attachInterrupt(0, pin2_isr, LOW);
/* 0, 1, or many lines of code here */
/* wake up here */
void pin2_isr()
pin2_interrupt_flag = 1;


Interrupts on AVR

Interrupt is neither same  for all hardware’s nor for the compilers. Some hardwares support multi level interrupt or nested interrupt and some chips use single interrupt flag. The Atmel architecture interrupt works as following

1. As Interrupt triggered processor finishes pending instruction

2. Stops fetching further instruction

3. Clear Global interrupt enable bit(This is why arduino denies nested interrupt, but you can use)

4.  Push PC(program counter) on stack

5. Jump to interrupt vector(specific address where the corresponding interrupt handler expected to be)

6. Next is the ISR code in case of C compiler do a lot job for you and if you are using assembly all that have to do youself.

Push the status register to stack and also any other register that you may use in this ISR block

Execute the actual ISR handler code i.e. whatever you want to do when the specific interrupt occours

When the actual task is done, rollback the things you changed i.e. POP the stack to status register and other register you had pussed

7. Now last assembly code RETI which rollback the PC from stack and Reenables Global Interrupt

So in the whole process all except the step 6 and 7 are automatic user need not worry about the steps.


ISR in C

use variables with volatile type modifier other compiler optimiser may think the varible is static(assuming not changed in main())

  • Keep the ISR code as short possible in execution time not in length.
  • Don’t activate or deactivate interrupt inside ISR
  • Don’t call another function that uses interrupt

Now the above rules are for the ideal people, you can do it if u know what the hardware and the compiler does. Suppose you have to do some of the banned things immediately after the interrupt triggered, i have to methods one is the method being ideal another is to break the rules.

A.If your main loop contains things that only run when a interrupt is triggered and interrupt are not overlapping, in this case u can set special flag to activate a part of main code (code u want to run in ISR), the flag need to set in the original ISR and cleared in main loop part of ISR.


B. Next method is really complicated. You need to mess with the hardware and the compiler, you know when interrupt occurs global interrupt enable is cleared ,PC pushed to stack by hardware and Status register and other registers moved to stack by compiler, So here

if you want to get another interrupt you have to set GIE and if interrupt occours it will again push pc and but the compiler part is complex.

Some people make multilevel interrupt with software. The main interrupt handler acts as the first interrupt handler which catches the interrupt event and stores necessary data and exit ISR(the basic isr) and start the secondary interrupt handler. exiting the fast interrupt handler triggers RETI so all interrupts resumed.


MSP430 with IAR

First of all the question is why IAR why not CCS or GCC, here is my answer

You are learning all these not just for fun, if it is then you may with gcc also. but if you are learning both for fun and career then you should prefer one which is used by industry, and both TI’s CCS and IAR EW costs same, so why not choose the one with multiple compilers in the Same IDE design although they sold all of them individually.

Download the installer from IAR Systems page . Now you can install this with two different modes One is code size limited version Second is full Version Time limited Licences validity. Now click Project-> Create New Project, Now you can choose the language C, C++ or assembly and for c and C++ you can choose template or project with main().

Anyway all these things are useless for geeks  like you. The real question is the headers and the libraries, where are the standard functions and MACROs, how is the C C++ standard differ from other C standards(although embedded C is always a NonStandard C).

Step 1 should be to download The Family User Guide, like if i am using MSP430F149, i should read MSP430x1xx Family User Guide i.e. www.ti.com/lit/ug/slau049f/slau049f.pdf

Default UI based project adds io430.h this includes it need you to define your chip name in define statement i.e. #define MSP430F149

But i will prefer to add the specific header file instead of these chains i.e. msp430f149.h with hardware description of the specific chip.

For delay you may use __delay_cycles(x), which gives delay of x instruction cycles, and one instruction cycles duration=(1/MCLK frequency in Hz)Seconds


Variety of capacitors available in market, some times I discover alien components on PCBs from Big companies. Some are don’t look like capacitors. Some are specific to some unique job, if u replace with another one it may not work at all like the low ESR capacitors in DC DC converters.



A ceramic capacitor is a two-terminal non-polar device. The classical ceramic capacitor is the “disc capacitor”. This device pre-dates the transistor and was used extensively in vacuum-tube equipment (e.g., radio receivers) from about 1930 through the 1950s, and in discrete transistor equipment from the 1950s through the 1980s. As of 2007, ceramic disc capacitors are in widespread use in electronic equipment, providing high capacity and small size at low price compared to other low value capacitor types.

Multilayer ceramic capacitors are increasingly used to replace tantalum and low capacitance aluminium electrolytic capacitors in applications such as bypass or high frequency switched-mode power supplies as their cost, reliability and size becomes competitive. In many applications, their low ESR allows the use of a lower nominal capacitance value



An electrolytic capacitor is a type of capacitor that uses an electrolyte (an ionic conducting liquid) as one of its plates to achieve a larger capacitance per unit volume than other types, but with performance disadvantages. All capacitors conduct alternating current (AC) and block direct current (DC) and can be used, amongst other applications, to couple circuit blocks allowing AC signals to be transferred while blocking DC power, to store energy, and to filter signals according to their frequency. The large capacitance of electrolytic capacitors makes them particularly suitable for passing or bypassing low-frequency signals and storing large amounts of energy. They are widely used in power supplies and for decoupling unwanted AC components from DC power connections.

Aluminum electrolytic capacitors are constructed from two conducting aluminum foils, one of which is coated with an insulating oxide layer, and a paper spacer soaked in electrolyte. The foil insulated by the oxide layer is the anode while the liquid electrolyte and the second foil acts as the cathode. This stack is then rolled up, fitted with pin connectors and placed in a cylindrical aluminum casing. The two most popular geometries are axial leads coming from the center of each circular face of the cylinder, or two radial leads or lugs on one of the circular faces.


Polyester film

This capacitor uses a thin polyester film as a dielectric. Not as high a tolerance as polypropylene, but cheap and handy, temperature stable, readily available, widely used. Tolerance is approx 5% to 10%. Can be quite large depending on capacity or rated voltage and so may not be suitable for all applications. Temperature stability is poorer than paper capacitors. Usable at low (AC power) frequencies, but inappropriate for RF applications due to excessive dielectric heating.







Tantalum Capacitors


Tantalum capacitors are polarised and have low voltage ratings like electrolytic capacitors. They are expensive but very small so they are used where a large capacitance is needed in a small size such as mobile phones or laptop computers. These capacitors have increasingly become an important as the demand for ever smaller electronic gadgets has grown. Columbite-tantalite – coltan, for short, the ore from which tantalum is refined is mined in Australia, Egpyt. The high demand for the ore has also financed civil wars in the Democratic Republic of the Congo. A UN security council report charged that a great deal of the ore is mined illegally and smuggled over the country’s eastern borders by militas from neighbouring Uganda, Burundi and Rwanda providing the revenue to finance the military occupation of the Congo.


Metalized Polyster Film

No polarity, dielectric made of Polyester or DuPont trade name “Mylar”. Good quality, low drift, temperature stable. Because the electrodes are thin they can be made very very small. Good all-round capacitor.Care is necessary, because the component lead easily breaks off from these capacitors. Once lead has come off, there is no way to fix it. It must be discarded.





Polystyrene capacitors


No polarity, is used as a dielectric. Constructed like a coil inside so not suitable for high frequency applications. Well used in filter circuits or timing applications using a couple hundred KHz or less. Electrodes may be reddish of color because of copper leaf used or silver when aluminum foil is used for electrodes.

Excellent general purpose plastic film capacitor. Excellent stability, low moisture pick-up and a slightly negative temperature coefficient that can be used to match the positive temperature co-efficient of other components. Ideal for low power RF and precision analog applications







MICA Capacitors

This type is an extremely accurate device with very low leakage currents. It is constructed with alternate layers of metal foil and mica insulation, stacked and encapsulated. These capacitors have small capacitances and are often used in high frequency circuits (eg. : RF circuits). They are very stable under variable voltage and temperature conditions. Tolerances range from +/-0.25 to +/-5 percent. Capacitances range from 1 pf to 0.01 uF, with maximum voltage ratings from 100 V to 2.5 k

SMD Codes Transistor Capacitor Resistor

SMD_codesSMD the surface mount devices are the smallest footprint componets. These are enough small to have some surface area write its name in full. So the manufacterers use unique code for each component which are 2/3 alphanumeric characters.

resistance value from SMD resistors easy easy with three digit codes as it is same as the three ring color code. But no data about tolerance. Capacitors also same as SMD resistors for only the capacitance data in pf range capacitors.

am compiling a small book on the common components till search from these sheets.

download this pdf file    http://xtronix.in/SMD_Component_Code.pdf



you can search here http://www.marsport.org.uk/smd/mainframe.htm