Just a quick update, Atmel outlines the trim process in this document - They describe a one time calibration process where they do a binary search using a 32khz reference signal to get the correct OSCCAL - then write it into a byte on a EEPROM to use later.
Using the above document, it might (as I suspected) be possible to do this in real time, so that as temperature changes, the clock speed is updated.
Hutspot is a dutch dish with a mixture of potatoes and carrots. This is a mixture of stuff I want to blog about, both professional and personal.
Monday, June 24, 2013
Sunday, June 23, 2013
Problems with ZigBit serial communications
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.
Tuesday, June 18, 2013
ZigBit with avrdude and Bus Pirate
Full disclosure, I haven't exactly 'programmed' the zigbit yet, but I do seem to be able to communicate to it with it using avrdude with a buspirate.
I found a few posts on this, but I think there were some errors in them. I wanted to post what worked for me in case it helps someone.
The board is my own breakout board - but all pins listed here are the pins on the actual ZigBit module.
I have the 'seed' cable, and not the 'sparkfun' cable:
I of course have GND and 3.3v hooked up to their proper places -
GND - 9,22,23
3.3v - 24,25 (I use a bypass cap and a ferrite bead as indicated in the datasheet)
MOSI (grey) goes to 38
MISO (black) goes to 39
CS (white) goes to 8
and CLK (violet) goes to pin 1
Unless I'm looking at things wrong (Its late :-) - it is different than what is posted In this post by Atmel.
I am hoping to use Contiki OS on this - I am looking at a post Here.
Subscribe to:
Posts (Atom)

