ZigBit RC Oscillator vs Temp vs Voltage
I've been evaluating the ZigBit modules from Atmel for use in a project I'm working on. I will need rock solid serial communications - I am not going to get that (at least not using Contiki OS, or even rolling my own) unless I do one of two things:
1) run at 1mhz - which I might be able to do - I'm not sure how well the different baud rates will work when running at 1mhz
2) Find some way to automatically trim the RC oscillator
3) Find a way to introduce an external clock - I don't think that this is a possibility.
Let me show why the internal 8mhz RC clock will be a non-starter for most people wanting to use Contiki OS.
First, I did my research and found that other people got things to work, pretty much - for example Here - that post was super helpful, but even after following it, my serial communications seemed, well, flakey.
After banging my head against the wall, I decided to try some stuff out -
Using the hello-world example in contiki, I added the following code to the main process:
(sorry about the image - I was having a bear of a time formatting the code in blogger - and yea, it's pin B7, not B5 as shown in the comments)
All this does is sets PIN B6 to output and sets the pin high (sanity check) and sets pin B7 to be a PWM output at 50% duty cycle - According to the ATMega1281 Datasheet - this should give us a output frequency of the input clock / 256.
(oh, by the way these are labelled as other stuff ---GPIO1 and GPIO2, pins 5 and 6 --- on the zigbit datasheet - I found a translation to the ATMega1281 here.)
I used my BusPirate to read the frequency output on that pin, here is what I got (average) 30844/hz but this is divided by 256, so my actual number is 7.896Mhz - hmmm within the 10% listed in the datasheet, but probably enough to mess up our serial communications, but look what happens when I go and hit it with freeze spray-
Down to 7.676Mhz - you are getting the point.AUX Frequency: autorange 30,852 HzAUX Frequency: autorange 30,877 HzAUX Frequency: autorange 30,875 HzAUX Frequency: autorange 30,870 HzAUX Frequency: autorange 30,626 HzAUX Frequency: autorange 30,275 HzAUX Frequency: autorange 30,134 HzAUX Frequency: autorange 30,095 HzAUX Frequency: autorange 30,043 HzAUX Frequency: autorange 30,047 HzAUX Frequency: autorange 30,012 HzAUX Frequency: autorange 29,986 HzAUX Frequency: autorange 30,020 Hz
I tried to adjust the dividers for the serial out in the contiki source, but none of them really got close to the right baud rate with the frequency I had, and even if I did - I might have wildly different temperatures in the environment where these things are going. I would hate to have everything suddenly stop working when it gets to 110 degrees in some auto body shop in Phoenix or something, or say Alaska in the dead of winter.
There is a way to calibrate the oscillator, OSCCAL - I suspect that the BitCloud software has a way to automatically trim the clock based upon the external 1Mhz clock that you can find on pin 10, but I was already thinking about moving on to a different platform - This just gives me that little extra push.
I may play around with the 1Mhz clock yet, but I am thinking about moving to an ARM STM32 paired with a Microchip MRF24J40 - the pair of those will run about half the cost of the ZigBit module, give me more horsepower and more control over the process.
Sigh, I just had to get that all off of my chest.


No comments:
Post a Comment