I’ve also integrated the Atmega328P version of the WidgetBoard into the Arduino development environment so please update your boards.txt with the one from SVN.
I have successfully re-compiled and re-flashed the firmware source to remove the console on ttyS0, as suspected the console attached to ttyS0 was the root of my problems, now avrdude will talk to the WidgetBoard!
and here is my WidgetBoard booting my test blinky on ContikiOS as seen by the gateway ttyS0
now back to writing the contiki radio driver…..
I’ve had some mixed success with the serial port hack on the Airlive device since my previous post.
After setting up the uclib development environment I have now successfully compiled avrdude so I can program the RFM12WidgetBoard located inside the device, however I had a couple of issues when trying to talk to the WidgetBoard.
Nothing happens when trying to query the WidgetBoard…data is going out the serial port but nothing being returned.
First problem I found….crossed Tx and Rx due to a silkscreen error on the WidgetBoard, the silkscreen for TxO and RxI are wrong way around on the PCB.
After fixing this problem and re-testing Avrdude it’s still not working….so further testing…..
Serial port is definitely working and I now have a serial console to the device. When I connect up a terminal program via my FTDI USB ttl serial cable I can see the boot process and logon to the console via ttyS0, which is probably one of my problems, the bootloader may be getting confused by the console chatter.
The trace below confirms this. I’ve re-flashed the WidgetBoard with my blinky example from the Contiki port, besides blinking the LEDS it also outputs a string “There is” to the serial port, you can see by the trace what the WidgetBoard is sending, and the output sent back by the console.
By default this kernel has the console attached to ttyS0 (see my previous post and the dmesg dump) so one of my next steps will is to recompile the kernel and disable the serial console access attached to ttyS0.
The WidgetMesh network development for the Widgets is now underway, the last couple of days I’ve been learning how everything fits together in Contiki OS, as far as drivers go and how they communicate with the upper stacks, lots of looking through existing code. I now have a reasonable idea of how things should work and how I need to write my driver.
That said the biggest problem with the WidgetMesh is going to be on chip resources, especially with the ATMega168 and maybe even the ATMmega328P, I’m not looking at running an IP stack on the mesh (well at least not yet), but the gateway/coordinator device needs to keep track of the nodes in the network. It’s role is to manage node associations, link forming and routing within the mesh, so this will require more ram than most of the nodes will have, especially in larger networks. It’s also the gateway to the world for the data collected.
I’ve been scratching my head as to what I’m going to use. I was leaning towards an ARM7 hooked up to a RFM12 or WidgetBoard, something along the lines of a make controller as I have a couple at home from past tinkering, or one of these ARM9 devices running Linux, the MMnet1001, from Propox, Both these have onboard Ethernet and plenty of resources for what I want. But it turns out that I had a solution at home already, in the form of an Airlive NAS device, WMU-6000FS. The Airlive NAS comes with Ethernet, WIFI and x2 USB ports, also PATA or SATA hard drive, all this runs from a 12V supply, so I could also run this from a SLA battery.
The Airlive WMU-6000FS is a not so great NAS device that I evaluated for work project involving offsite replication. The project was eventually shelved.
The great thing is that it runs embedded Linux, after a bit of research found that I can re-flash the current device easily with a distribution from http://mgb111.pradnik.net/ will allow me to make changes to the system, whereas the current flavour is embedded and is Read only, all changes are lost at boot, however no documentation anywhere regarding serial ports, or in fact if one exists onboard.
I proceeded to re-flash the board with FW C009-M2 Advanced firmware, this gave me console access, once in I checked that Linux is detecting a Serial Port.
-bash-3.2# dmesg | grep ttyS0 Kernel command line: rw console=ttyS0,38400 ttyS00 at 0x03f8 (irq = 4) is a 16550A -bash-3.2#
A UART is being detected and is used by the system as a console.
Here are the memory and CPU as reported by dmesg, so plenty of resource for what I want.
Initializing CPU#0 Calibrating delay loop... 44.33 BogoMIPS Memory: 29984k/32768k available (1418k kernel code, 2396k reserved, 337k data, 56k init, 0k highmem) Checking if this processor honours the WP bit even in supervisor mode... Ok. Dentry cache hash table entries: 4096 (order: 3, 32768 bytes) Inode cache hash table entries: 2048 (order: 2, 16384 bytes) Mount cache hash table entries: 512 (order: 0, 4096 bytes) Buffer cache hash table entries: 1024 (order: 0, 4096 bytes) Page-cache hash table entries: 8192 (order: 3, 32768 bytes) CPU: After generic, caps: 00000000 00000000 00000000 00000000 CPU: Common caps: 00000000 00000000 00000000 00000000 CPU: Cyrix Cx486SLC
This can only mean one thing. Time for surgery!
Disassembly is very easy, two screws at the rear allow the extruded aluminium case to slide off , at least it’s solid. Inside is a 1TB drive that I had swapped out with the original some time ago, so If all goes to plan then I’ll have plenty of storage available for the Wireless Sensor Network.
I love it when designers of hardware have fore thought to design in for future expansion, adding a second antenna is going to be simple enough, just drill out the rear cover to suit, actually the cover already as the markings on the inside for this.
Search for the Serial Port
Prime serial port candidate CN2 (10 pin socket centre of shot) , The processor (top left) is an RDC 3210, a 486 equivalent. The datasheets (no longer available from RDC website, but found via Google) tells me that the CPU has a single onboard UART that the pin outs coincide with the rough location of the CN2 header, either it CN2 or part of the larger connecter, but I doubt it.
Continuity tests of CN2 confirm that this in indeed the serial port, some further checking and voltage measurements confirm everything I need is there. Whoot!
|5||Serial In (Rx-I)|
|8||Serial Out (Tx-O)|
Adding the WidgetBoard
I moved the Wi-Fi antenna SMA across to the spare and added in an SMA pigtail to suit a 915Mhz GSM antenna that I use for my WidgetBoards.
Next wire in the Serial port to an external header
WidgetBoard trying out it’s new home with SMA pigtail connected. Actually this is the first of my Widgetboards to use the Atmega 328P processor.
I used the third spare antenna connecter on the right for an external reset button for the WidgetBoard, may not be required, but hey, if the DTR reset does not work at least I can force the issue.
All wired up and safe and sound in a simple card surround to stop any shorts from happening.
All boxed up to see how it all all goes together, 2.4Ghz and 915Mhz antennas side by side and reset bottom right.
The next step is to get minicom and do some further testing, along with getting a version of avrdude working from the Linux console, this will allow me re-flash the WidgetBoard locally if the need arises.
I’m still alive…… Its been awhile between blog entries, unfortunately this is the busiest time of the year for me at work, the few months after the Australian financial year, projects are kicking off due to funding etc. There is however light at the end of the tunnel and I’m hoping to get back to geeking very soon
I thought I’d let you know that a) I’m still alive, and b) what’s been happening on the development front.
I now have the Hello-world application up and running on the Atmega168 @10Mhz, no radio drivers or anything else for that matter just yet. For those interested it’s been checked into SVN. I’m learning a lot about Contiki and how it all fits in together (i.e. I know that I don’t know much at all about it)
On the hardware front the next iteration of the Widgetboard is idle, though pretty well stable as far as the design goes (might be a couple of small tweaks before boards get made). I just need time and resources to get the next round of PCBs ordered and tested.
Noteworthy design changes include:
- Standard smd or PTH crystal footprint, allows the use of a standard HC49 crystal of your choice.
- Lots of changes to the board supply side of things. Board voltage supply input range from 0.7V to 16VDC (probably beyond to 20VDC but just to be on the safe side…) The core components are still powered @ 3V
- Minor changes based from user feedback of the current board.
- A couple of optional onboard sensors to utilise the normally unused A6 and A7 analogue only ports, these can be disabled via onboard solder jumpers if these ports need to be used for something else, but has a temperature and light sensor, so the widget board can be used as a basic standalone wireless sensor.
I’ve been meaning to run off another batch of WidgetBoards and have been waiting for some processors, a month ago 40 Atmega328P processors arrived after a 5 week backorder, according to my vendor these were hard to get, hopefully supply issues will settle down after production catches up with the the initial demand for Atmega328P.
All future widget boards will now have this processor as the default in the next batch of boards I make.
Sample parts I’ve been ordering for various future projects have been steadily rocking up and sitting in my ever growing inbox, the RFM22 arrived some time ago and I’ve not yet had time to play with them either sigh
Well, back from a short break away (kid free woohoo!) and onto some widget builds. I thought I’d document how I do my widget construction. I actually find building SMD devices much easier than the PTH variety.
I have all my components in some neat snap together containers, this allows me to have everything at hand for the build.
[Click on images for larger size)
1) Solder paste is applied to the boards sparingly, ready for component placement
2) Components placed on each board, I usually do a board at a time. You will see x3 boards without any RF modules, these will be added at a later time depending on what band is required.
My SMD toaster oven setup.
The toaster oven is unmodified straight out of the box connected to the PID temperature controller.
PID Ramp controller with Solid State Relay output driver from E-Bay, that allows me to store up to 64 different temperature/time steps, each step can have their own PID parameters. The ramp controller allows me to set and store my solder temperature profiles and when enabled will cycle through the temperature profile.
The PID controller is installed in an external SCSI case I salvaged from an old external tape drive.
The thermocouple is a K-type with the shroud removed to give a fast response to temperature changes, I also have it wired to a spare PCB to give me a good indication of the PCB surface temperature in the oven
Rear of PID controller case, I’ve wired a power point directly a 10A solid state relay and fuse. The SSR is driven by the PID output, so power is only applied when heat is required. This allows me to use any unmodified toaster oven.
Batch ready for baking, carefully placed onto tray so no components are moved in the process.
All I do now is start the Temperature controller and let it do the rest (after closing the door) Since the Toaster oven is unmodified in any way I just turn it’s temperature knob to the max temperature and the same goes for it’s timer. The bottom power light turns on when temperature controller is heating.
My hi-tech fuse and bootloader programmer ready for programming. The headers give me good connections and allows for easy changeover.
Fuse and bootloader being programmed
For the next version of the widget, I’m planning to have an on board boost regulator. This design will allows the widget to run from just about any voltage source as low as 0.7v (so NiMh will be fine) and up to 5.5v, this boost regulator in conjunction with a standard LDO regulator will give me a nice input voltage range of 0.7v – 12V. Before I finalise the design I wanted to test things to see how well it’ll work.
I ordered in a couple of battery holders from Polou with an integrated boost regulator, since the widgets are designed for 3.3v operation I ordered this model http://www.pololu.com/catalog/product/796, that provides a 3.3v 100mA supply from a single AA battery, I’m not too sure what the minimum voltage is, but is running fine on a single NiMh cell.
Well today they arrived and I now have one hooked up to my solar powered widget. Installation was simple as the small pcb on the rear of the battery holder allows me to direct access to the cell contacts, so I soldered the solar cell +ve and –ve on the respective contacts.
From some previous tests with my solar powered widget, I was finding that the batteries would start charging when the solar cell output reached around 2.8 –2.9v, this is fine for during the day with the solar cell in direct sunlight, now with the single cell I’m finding that inside under artificial light I’m charging at around 1.5v, with plenty of overhead left.
You can see below the voltage output of the boost regulator is ~3.3v (3.322 to be exact) and the voltage from my solar cell is ~1.52v, this is inside under some standard down lights while writing this post at the kitchen table (actually one of the down lights is dead so I could expect a little more output from the cell)
Just to try something different I removed the battery, seeing if the regulator could run direct from the solar cell, unfortunately it doesn’t, I doubt the cell in the current light conditions can provide enough start up current for the regulator, I will however try it in the natural sunlight tomorrow.
With the addition of the boost regulator, and the widget in max power savings between sensor reading (when asleep widget is drawing 1.5uA, which is most of the time) then the widget should run indefinitely from the single cell….or maybe I could just get away with a solar cell and a super cap now there’s a future project….
Just thought I’d post an update on what’s happening in the widget development world.
Limited Production Run
I have a very limited number of widget kits available for purchase. This limited batch of widget kits also include a bare prototype personality at no cost with each widget to get you started in your wireless applications.
Introductory price of $US25ea (or $20ea for 5+) include headers, bare prototype boards, 10Mhz low profile crystal, switch, all smd components are pre-assembled and tested, latest bootloader and RFM12 test program loaded.
SMA Pigtail: $2.50 for externally mounting SMA antenna.
SMA Edge: $2.50 for mounting SMA antenna onto PCB
SMA R/A antenna 900Mhz only: $4.50 to suit SMA connectors above
CR123 Battery Holder: $2.50
I’ve yet to get full details and pictures available or a means to order online yet, so contact me in the mean time if you’re interested, please let me know the band of the RF module required when ordering, e.g 915Mhz, 868Mhz or 433Mhz.
The v1.1 of the widget bootloader for 8Mhz and 10Mhz boards are now available in the download area. These have been updated to incorporate the onboard LEDS and provide visual indication when entering the bootloader.
Source now in SVN
All the arduino source that I’ve changed for the widgets is now in SVN on the project page. This includes:
- Bootloader source.
- modified boards.txt that include the 8 and 10Mhz versions of the RFM12Widget.
- Modified wiring_analog.c to read Widget battery voltage.
This can be checked out/copied directly to your arduino install directory by overwriting the existing files. The arduino environment will need to be restarted for the boards.txt file to take effect.
I’ve started incorporating the user feedback into the next revision of PCBs. Still a bit of work to be done on the PCB layouts.
Started preliminary design for a simple mesh network.
Ultimately I would like to have the ability for the widgets to provide Zigbee type functionality (not compatibility) along with frequency hopping as standard, that is transparent to the application. Only very early days so far.
I want to deploy widgets around the home, both inside and out, so I needed to find something that would allow some protection from the environment to the electronics, cheaply and easily.
On the weekend while doing some shopping I found the solution in the kitchen area of the local discount store, at $1.50 a piece it was the right fit for the job. They probably won’t like U/V in the long run, but will see how they go, at that price I can replace cheaply.
(click picture for more details)
Waterproof/Dustproof housing with easy access to the internals.
This will be the standard sensor node housing. The widget Boards and battery pack are fixed via velcro so I can easily remove for reprogramming etc.
I still need to look at airflow of sorts for temperature, humidity and pressure sensors, will probably look at putting a couple of small vents in, this will compromise the waterproofing.
To mount these I can put some velcro on the back and mount it on any horizontal or vertical surface.
Open and showing details of SMA pigtail connection, batteries (x2 AA side mounted) and widget board velcroed to the container (personality board removed)
Same as above, but this is for my outside sensor nodes where I’ve mounted a Solar Cell sealed on the outside, I did some initial testing and there was a filtering effect of the plastic lid and the cell, so I decided to put the cell on the outside to get maximum efficiency, it was a pretty messy job after I used silastic to seal everything, the cell now has a smear of silicone haze across it that is appearing very difficult to remove. So in future I think I’ll live with the slight degraded Cell performance and mount it inside, where it fits perfectly, that way I can use a couple of blobs of hot glue to fix the cell to the lid.
In my previous blog entry I described adding a solar cell to the widget and how I could measure the voltage produced by the Solar Cell, however I still need to monitor actual battery voltage easily, and preferably with not a lot of additional hardware.
Problems reading ones own voltage.
Measuring ones own voltage has a couple of problems:
You can’t just measure VCC directly, i.e. you can’t connect an analog pin to VCC. The reason is the battery voltage varies, and since the default AREF is tied to VCC you will always read VCC unless you use some form of a reference not tied to VCC.
I can also use a reference diode and a resistor between VCC and GND, to form an external reference voltage, the diode has a known voltage drop across it so this can be measured using the default AREF. We can calculate the battery voltage by measuring the volt drop across the diode. While this will work, the circuit will always consume a small amount of power, even when not being used, remember I want to get as much life out of my batteries as possible. So it rules this out as a solution.
For the same reasons as 1) I can’t use a simple voltage divider and the default AREF. As the voltage varies so too will my readings.
I can use a simple voltage divider and the internal 1.1v bandgap reference for my AREF, the same as I used for my solar cell voltage monitor in the previous blog entry. Again this will work, but also as in 2) this will always consume some power even when not being used, so is ruled out as a solution in this case.
No Extra components?
We can however measure VCC voltage with no external components by simply reading the value of the internal bandgap reference voltage (1.1v) which is always fixed regardless of the battery voltage, and by using the default AREF which is tied to VCC, so will vary as the battery voltage changes. We now have a way of measuring the voltage change against a fixed reference.
V_BAT = (VREF * 1024) / analogRead(14);
|fixed reference voltage in this case 1.1v, but could be referenced to an external reference.|
|raw ADC reading from MUX channel 14|
You might see in the above formula, that analogRead() function is reading channel 14. But analogRead() only supports channels 0-7 right?
Correct, but what we are doing is to read the internal ADC channels after we make a small change to the Arduino source code.
Changes to “wiring_analog.c”
To take an ADC measurement of the internal bandgap we need to switch to ADC MUX channel 14 (23.8.1 in reference manual). However to do this with the arduino wiring library we need to make changes to “wiring_analog.c” as per http://code.google.com/p/arduino/issues/detail?id=10. This change allows us to read from all ADC MUX channels, internal and external.
Once you’ve made the change to “wiring_analog.c” then use the following example sketch to read your VCC/Battery Voltage.
When this method won’t work.
If you have a voltage regulator or a protection diode inline between your battery and VCC, then this will only show the voltage at VCC, not the true battery voltage.
If you have a voltage regulator then you will always read what it puts out, and not give a true indication of battery voltage. I guess you could still use the method as a form of low battery measurement. i.e. when the battery falls below regulation values I guess the regulator will fail to regulate and you should get a lower than normal reading. however I haven’t tested this theory.
If you only have a protection Diode then measure the volt drop across it and compensate in your calculations, it will still give you a good indication of battery voltage.
Some other uses for this method is for auto-calibration of sensors as described by ladyada(you need to go to the bottom of the page)
The other day when playing around with different fuse settings on the Widget Board, I incorrectly wrote the wrong values, oops one bricked board However all is not lost.
With a second working Widget Board and a simple Arduino sketch , I used the following procedure to recover from my mishap.
First I installed the following sketch onto a working Widget Board
What this sketch does is generate a 1.2MHz clock signal on the INT1 port of the Widget Board. (Click the picture below to see the the full trace )
Next I attached this signal to the XTAL1 pin (Pin 7) of the AtMega168v on the bricked board (I just held it against the crystal pin).
While holding this connection on the pin, I then fired up AVR-DUDE and rewrote the correct fuse settings, after confirming that the fuse values could be read back I then remove the wire and everything was back to normal.
So all is not lost
Version 1.0 of the boards is progressing to the point where I’ll be starting work on v1.1, integrating user feedback and any issues on the tracker, I’ve put a few up there so please check them out, comment or add your own. Issue Tracker.
I’m extremely happy to say that everything has progressed really well, there are not any show stoppers with the board and as they stand are very usable. The range of the RF with the units I’ve tested is brilliant, mainly inside, I’m hoping to do some tests over the weekend outside.
The rest of my components finally arrived yesterday and I now have fully complete boards, the low profile crystals look really slick, alas I’ve decided not to keep them in the next board revision and opted for a more generic and cheaper HC49 type crystal. There are a few more changes, but check out the Issue Tracker.
In the Wild
A few of the extra PCB I sent out are finally arriving at their intended destinations and hopefully everyone will have time and skills to build them. For those that have already built them I have received some great feedback. Looking forward to their test results.
Last night I installed the crystals on all my boards and they are now running after re-programming the fuse bits. I’ve also re-compiled the lily pad boot loader for 8Mhz and 10Mhz along with updating the Arduino board files, I will have them online in SVN shortly.
I’m also assuming that you know how to program your fuse bits and they are correctly programmed. The fuse values I’m using are found below in the boards.txt file. I don’t have to remind you that programming incorrect fuse values can potentially BRICK your board. If you’re unsure please ask on the discussion group.
You need to have the correct boot loader up and running on your Strobit first. I’ve yet to test the boot loader programming from the Arduino environment as I do all mine manually using avrdude, but here are the hex files, the 8Mhz is for if you don’t use a crystal, the 10Mhz is if you have the crystal installed.
Below is the boards.txt found in the Arduino hardware directory, just copy and paste into this the boards.txt and restart the Arduino environment.
Then select the Widget Board of choice from the TOOLS|Board menu.
I’ve started to document the Wireless Widget Board in the wiki, documentation is currently all over the place, but slowly getting there. Currently I’m working on the build instructions so those of you that I’ve sent PCBS to can at least have a parts list.
I’ve also put up an initial bill of materials. But it would be great if someone can do a Octopart BOM and share it.
Initial building instructions can be found here: http://code.google.com/p/strobit/wiki/Rfm12BuildingInstructions with more to come.
I had a chance to grab a few photos of the progress so far, also helps that most of my components that I had on order arrived today so the boards has been kitted out with all the headers. Now I can plug the prototype personality in, still waiting on my crystals, switches, and diodes.
This gives an idea of size. (I don’t have big hands either) This board has a 900MHz 2dB GSM SMA antenna, prototype personality board installed and battery holder for CR123A Lithium battery.
Different battery options, using x2AA with a switched battery pack soldered onto the board.
The SMA connector is a standard PCB straight SMA connector that has been soldered onto the edge of the board. The board have been designed for the Sparkfun PCB edge mounted SMA connector (SKU: WRL-00593), however I found that a standard PCB SMA connector will do the same job, the distance between the centre pin and the ground pins is the same thickness as the PCB and all the pins line up with the Sparkfun footprint, the centre pin fits perfectly and so do the two bottom ground pins, only difference is the two top ground pins don’t get soldered.