Sunday 25 February 2018

LORA: RF SX1278 Review

This weekend, I did a prototype project using LORA SX1278 for a 433MHz project. A friend of mine sent me two XL1278 module.



When I received the modules, I was so excited to test it. I have experience with TI CC1101/CC430 and NRF905 and I would like to do a comparison in terms of development time.

Upon reading the datasheet, everything is very straightforward. With the SX1278 datasheet's help, I was able to develop my C++ SX1278 driver and make it work with TI MSP430 FRAM microcontroller. Unlike, TI CC1101/CC430, I don't need any tool like SmartRF studio to get all the settings. I can just do a register computation for the frequency. Everything is straightforward with this LORA chip.

Since I don't have a spectrum analyzer, I used my $9 USB RTL-SDR (Software Defined Radio) to capture signals in the air. 


I used Spektrum (link) to see if there are any activities in the air if I transmit something. This Spektrum is pretty basic and it does it's job. I just hope that it would have a hold function like a normal spectrum analyzer (like holding a peak detection). But still, it is a very helpful tool. I don't need to buy a spectrum analyzer. :D

Spektrum Interface (not an actual picture from my experiment)

Continuing with my experiment, when there is no one transmitting, RSSI levels are at -137dBm. I tried transmitting something (I used Spreading Factor of 7 and I am transmitting 128 packets in one shot) and the receiver got a 128byte packet at -19dBm.  That is pretty impressive. I haven't done my Friis equation transmission equation analysis yet but looking at this data, I believe we can achieve very far range with this one.

This is a very good module. However, I may need to try some other antenna and I may need to design a quarter wave monopole antenna by hand before doing our range test.

-Jeff


(I don't own any of the picture, please see the link)
Image from: https://www.ebay.com/itm/433-LoRa-SX1278-Long-Range-RF-Wireless-Transceivr-Module-SX1276-5Km-For-Arduino-/322929644930
https://www.rtl-sdr.com/spektrum-new-rtl-sdr-spectrum-analyzer-software/


Friday 9 February 2018

Textwrap: Impressive python module

I am currently reverse-engineering an audio analysis algorithm which computes for the statistical variance. I needed to get around 100,000 A/D data points from the MSP430's FRAM microcontroller so that I can inject it to my unit test. With that, IAR gives me a TI-TXT format.

example:
@10000
30 20 40 50
60 70 80 90

I needed to convert this to a C array so that I can place this inside my C++ code. Here are the steps I did:

1. I extracted all the data and placed them inside a list which is very easy to do using split, appending "0x" and using join. The output will be like this:
"0x30, 0x20, 0x60"  so on so forth

2. My problem with the above string is that it will take only one line of my C++ code which I feel won't look nice as I don't want to be scrolling horizontally as much as possible. I thought of creating a python algorithm to put newlines nicely without cutting a whole string like:
0x30, 0x20 ,0x
60, 0x70, 0x8
0, 0x20

Then I discovered python already covers it for me via textwrap module which I think is a smart algorithm. So now, I won't have any broken string and it will be printed nicely:

0x30, 0x20 ,0x60,
0x70, 0x80, 0x20

More information on how to use it here:  https://pymotw.com/2/textwrap/

Saturday 3 February 2018

Why TortoiseGit is so amazing

I had been using Git for a very long time and this is the best version control system that I ever used. In the past, I used centralized version control system: CVS, SVN, Visual SourceSafe, and TFS.  I heavily use TortoiseGit and I use git bash only if the feature isn't there on TortoiseGit . I also develop in Linux and I used Samba share drive or VirtualBox network share to be able to access my source code outside of Linux, so that I could use TortoiseGit on my codes.

Here is how Git changed my development style and quality of my code:
  • Personal code review before committing - In TortoiseGit, it is very easy to see the diff of your current code change and the last commit via the included UI diff tool (I also use an external tool called WinMerge which is more faster). This diff will direct me to the exact place where I did my modification and this gives me a chance to have a second look if I accidentally forget or misplace something like reverting some debug compilation symbols that shouldn't be on production release.

    I noticed that git bash users (at least from the people that I know of) never do personal code reviews before committing and I think it is because it is not very straightforward to do so like in Tortoisegit. There was a project in my previous company where the developer unintentionally added a code which made the software release very unstable. They found out that some test snippets were included on the commit. A quick review of the software before commit will save tons of headaches.
  • Stash - I love this feature. This helps me move through different git branches without committing my modified file and instead stash saving it and popping it out if I need to continue working on the modified files.
  • Reviewing codes from other committers - It is very easy to review code from other committers via git log compare revision on TortoiseGit. This helps me review other developers work.
  • Revert on TortoiseGit - whenever I do code review, and if I see that some of the codes needs to go back to its original state, I can just simple do a revert on the commit windows dialog box of TortoiseGit. 
  • Very easy to merge codes
  • Bisect - I used this only once. But bisect feature is very impressive.
  • Distributed- being distributed is a very very very very very good thing. I commit often and sometimes, I don't have an internet connection. With this, I can commit anytime and once I have an internet connection, then that's the time I can push to the git server.

These are the things that I really like  in TortoiseGit which I had been using for many years. It is very simple and yet powerful.