TinyOS-2.x zigbit serial communication

As mentioned in the previous post, due to the fact that we were downloading the Motorola S-record file ‘main.srec’ via Serial Bootloader (using meshprog on Linux), fuse bits were not getting updated. If we had used JTAG interface (e.g using DRAGON Kit) and aurdude, this would have happened. S-record can have application code as well as fuse bit setting, unlike Intel Hex format.

This meant that the default TinyOS setting of 8 MHz for clock rate was not appropriate for this since Meshbeans are set for 4 MHz by default. So to get the Serial Communication working, we had to make the following changes:

1. Check the following  in

tinyos-2.x/tos/platforms/meshbean/hardware.h

=> change clock rate to 4 MHz by

#define MHZ  4

=> Change here the default baud rate, if you need – 57600 works fine for me

#define PLATFORM_BAUDRATE 57600L

2. make sure that:

“The file chips/atm128/Atm128Uart.h contained some wrong constants, which produce  strange results. The correct ones can be found in the ATmega 1281 datasheet and are:
ATM128_38400_BAUD_8MHZ_2X = 25
ATM128_57600_BAUD_8MHZ_2X = 16”

This change would not have effect on 4 MHz clock that we are using but its best to correct them anyway. Anyother Baud Rate combination can also be added.

I must add here that give a choice use a crystal which gives less errors  – e.g. 3.6864 MHz instead of 4 MHz , similarly 7.3728 MHz instead of 8 MHz. (See the ATMega128a manual).

3. With these changes done, now one can try TestPrintf utility. Do read this README file :

http://www.tinyos.net/tinyos-2.x/apps/tests/TestPrintf/

I was first looking at serial data using MiniCom – this was producing some unprintable characters including what is expected. One has to use the Jave client to get the proper message displayed as output of Printf command. I used the following command to get the data displayed right:
java  net.tinyos.tools.PrintfClient  -comm serial@/dev/ttyUSB3:57600

Here /dev/ttyUSB3 is the port to which my meshbean module was connected vis USB port.

This would give the this  output in a loop:

Hi I am writing to you from my TinyOS application!!
Here is a uint8: 123
Here is a uint16: 12345
Here is a uint32: 1234567890

Author: Prabhat Ranjan

Prof. Prabhat Ranjan is Vice Chancellor, D Y Patil International University, Akurdi, Pune. He was heading India's Technology Think Tank, TIFAC(tifac.org.in) as its Executive Director since April 2013 to April 2018. Earlier he was Professor at Dhirubhai Ambani Institute for Information and Communication Technology, Gandhinagar (DA-IICT) since 2002. He was educated in Netarhat School(near Ranchi), IIT Kharagpur and Delhi University. He received his Ph D from University of California, Berkeley where he carried our research on “Nuclear Fusion” at Lawrence Berkeley Laboratory during 1983-86. He immediately returned to India after this and carried out research in Nuclear Fusion area at Saha Institute of Nuclear Physics, Calcutta and Institute for Plasma Research(IPR), Gandhinagar. He played a major role in India’s Nuclear Fusion program and was Project Leader of the largest operational Indian Fusion Reactor, ADITYA, at Institute for Plasma Research from 1996-2002. His current interests include applications of Wireless Sensor Network to Wildlife, Planetary Exploration (Chandrayaan mission), Nuclear Fusion, Healthcare, Agriculture etc. He has received National Science Talent Search Award, IBM Faculty Innovation Grant and HP Innovate 2009 award, NPEDP-Mphasis Universal Design Award 2012, Bihar Gaurav Samman 2012 etc.

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x