Thursday, 2 May 2013

Windows Commandline & Batch file tricks Part 1

Here are some little useful Windows command line tricks that could be used in batch files. 


This example will loop only a set number of times, Also useful for counting the number of times a loop has run.

@echo off

 set counter=1

:loop
 echo looped %counter% times
 echo do something
 if %counter% == 10 goto end 

 set /a counter=%counter% +1
goto loop

:end 
 echo Loop ran %counter% times



Filename friendly date, Sometimes you want to use the current date to generate a filename so can't use %date% as you normally get something like "Thu 16/05/2013". An easy way to reformat it to YYYYMMDD is as below.   


@echo off
 set today=%date:~10,4%%date:~7,2%%date:~4,2%
 echo %today%

 echo and a sample file
 echo %date% %time% >>%today%.log




Detect if Windows 32/64 bit. Some times you need to know if the script is running on a 32 bit or 64 bit version of Windows from the commandline. This allows the scripts to do different things depending upon the version of Windows.(Like use the "C:\Program Files (x86)\"path instead of "C:\Program Files\") 


@echo off
if defined ProgramFiles(x86) (
 echo Is 64 bit version of windows
) else (
 echo Is 32 bit version of windows
)



Monday, 4 February 2013

Gardening for geeks Part 1

Problem:

I like many like to grow things, normally herb and a few small fruit shrubs but the problem I run into is that 

Outside It can be too hostile for some plants. They have to deal with Melbourne weather (-5C to 45C, hot & dry) and a larger array of insects and animals that will eat anything.

Inside It can be too dark for most plants and the amount of space near windows could be limiting or none existent  (I commonly see dying plants on people office desks due to lack of light or care) 


Solutions:

Outside I could put together a greenhouse but this does not really sound like one of my projects, I might have to do this for winter to protect some of my small fruit shrubs from the winter frost/wind.

Inside I could setup some grow lights but I am not keen of large Kilowatt lighting commonly used with indoor hydroponics systems. Instead I would like something a lot smaller/cheaper/power efficient. I know it should be possible to use LEDs which are small, cheap and power efficient. I have read about experiments that NASA was doing with growing with red/blue LEDS (most plants reflect green not absorbing it hence they look green) so I thought I would give it a try.    


Project:

Goal
Is to see if I can grow under artificial light using only a small amount of power creating a smart USB powered plant for my office desk.  

Method
I will try and grow lettuce using red and blue LEDs as the light source, To figure out which light they like more I will have red LEDs on one side and blue on the other side as plants normally grow towards the light.

To mount the LEDs I will just use breadboards so I can easily change the LEDs to try other colors. I would be interested to know how well you could grow plants under light like IR which is not visible to humans (for those that don't want a glowing plant on their desk) 

Adding smarts, I would not mind making the grow environment completely controllable. So this would include using an Arduino to control the lighting, a water pump and monitor some sensors (like soil moisture, ambient light). Adding a internet connection and web interface is also on the list of features (maybe even a IP camera too)

   
Questions

  • Can you grow lettuce upside down with the lights under it? I think it would just look cool on you office desk to see a plant happily growing upside down. It would look outright trippy to see you growing upside down from your ceiling.
  • How low can the power consumption go? 
  • Which light source is best (IR, Red, Blur, UV)?
  • If I was on a space ship how much space/power would I need to feed my self? but as I am not a fan of eating only lettuce I might have to do something on the lines of the bellow
    Lettuce>Rabbit>Me
    Lettuce>Grubs>Chicken>Me
  • Would it be better to do it underwater?
    Algae/water plants>Fish>Me


Monday, 29 October 2012

Garden Gnome update


I presented my Gnome project the other night at a meetup and he gathered enough interest to win me a $500 gift voucher :). Seems people like the idea of a house/yard full of little wireless nodes crammed with sensors and RGB leds with the ability to respond to events. 

I I do like the idea of having pot plants change color if I get an email (different plant per email account) or a yard that glows red if someone is detected in there at night.

Monday, 22 October 2012

Projects of interest

Hi Peoples,

I have 3 projects that I am starting on but want to gauge interest levels. 
All 3 projects will be the basses for other bigger projects.
Projects 2 & 3 are the easiest as I have already done them before in concept.

Project 1 has the most potential in my mind but requires me to work with an overseas vendor with less control over the project. 


Project 1, Arduino Wifi access point shield/Cloud connected Arduino.
Backgound:
Currently you can get Wifi shields and network shields for Arduinos but the Arduino lacks the resources to use the full potential of the these, this includes full featured web pages and full network stack. 

In looking for ways to bridge my RFnodes to the internet I have played around with openWRT and using Arduino to control pocket sized Wifi routers. I have come across small Wifi device that can be used as a accesspoint or in client mode, has 1mb of web space and has a TTL UART for connecting serial devices like an Arduino. The serial port can be used to pass data back to a web service allowing you to have a cloud connected Arduino project. As it only uses the TTL RX/TX pins you have all you other pins free for you project and only requires you to include code if you want to configure the Wifi shield.
You can create web pages in the shield that would allow you to send data to Arduino project and has support for a camera, so you can even create a wifi controlled pan/tilt camera.
  
Goal: 
Bridge Arduino projects to the internet via Wifi.
Make it easier for internet controlled Arduino projects with web interfaces and support web services/cloud services.

Specs:
802.11BG router with support for AP/STA mode
TTL UART
1MB user space for web pages and scripts


Risks&issues:
Still scoping




Project 2, Arduino with H-bridge and Bluetooth

Backgound:
I am looking to make a small PCB with an Atmega88/168/328 with support for the Arduino IDE. The design will be based around the RFnode but without the radio and a 2 channel H-bridge and TTL Bluetooth UART module in its place.

The board will support 2 bidirectional motors and with Bluetooth can be paired and controlled by almost any smartphone.

So making something like a little robot tank that is controlled by your phone will be an trivial task.

Board will be programmed via USB using the V-USB, This also supports making the board act as a HID keyboard/mouse/...

Goal: 
Create a low cost small Bluetooth Arduino with onboard H-Bridge.
By creating a
standard smartphone compatible Bluetooth robot board we might get some more app developers onboard.

Specs:
+ V-USB Arduino (http://www.obdev.at/products/vusb/index.html)
+ 2 channel H-Bridge with support for 2 motors
+ Bluetooth UART module

Risks&issues:
+ Cost to assemble may make this non-economical unless can get numbers



Project 3, Low cost Atmega88 based Arduino 

Backgound:
There have been a few Attiny boards starting to popup that support the Arduino IDE. These boards use the Attiny instead of the Atmega as they are cheaper but do not have all the features of an Atmega. Not only do they not have as much Ram/Flash/Eprom but are also lacking support for some Arduino functions.

An Atmega88 is compatible with a Atmega168/328 and so the Arduino IDE but almost the same price as the Attiny. It should be possible to create a low cost Adruino clone for less then $5 worth of parts. 


Goal: 
Low cost Atmega88 Arduino board for less then $5

Specs:
+ Atmega88(6k application space)
+ V-USB Arduino (http://www.obdev.at/products/vusb/index.html)


Risks&issues:
+ SMD parts (to hard for most people to solder)
+ Cost to assemble may make this non-economical and more expensive then a full feature Arduino unless can get done in large numbers



Thursday, 11 October 2012

A smarter garden Gnome

A smarter garden Gnome.


Still a work in progress but meet one of my garden gnomes. 

I still need to print him a better case to mount the soil moisture pins better and make him more presentable in general.  


At his heart he is powered by one of my RFnodes so he is wireless and has an array of sensors that he reports on back to the network. He currently reports back the light levels, soil moisture, temperature, humidity and having a RGB led that make him glow any color I can have him signal the plants status or as being network I can use the RGB led to make him (and his friends) signal anything the network want him to.

I have some small PIR motion sensors I also want to mount as his nose and print a case that can house the bigger batteries required by the RGB led.



Thursday, 27 September 2012

Recover Arduino Sketch

How to recover an Arduino sketch from after a program crash or system crash.

I was working on some code today then after making a heap of code changes and uploading to boards I walked away from my computer without saving my Sketch. 

Due to some other things I was doing at the time Windows crashed and I had not saved my code yet. After a reboot I confirmed that my code was gone but I did not like the idea of that so went digging for it. I know the Hex file is compiled to the %temp% folder so the Sketch must be there too.

So Start>Run>%temp%

which took me to C:\Users\remote\AppData\Local\Temp\

Then I sorted the folders by date modified and then found this one was timestamped about the same time I last compiled my code.
C:\Users\remote\AppData\Local\Temp\build262859921630184205.tmp\

Opening the folder I see a few C++ files and one of them had the same name as my sketch but with a C++ extension. It was my Aduino Sketch it did have a few things added to it to make it C++ compatible (void's) but is was the code I thought I had lost. 


Tuesday, 25 September 2012

Getting ready for more Rapman upgrades


I have received more parts so soon it will be time to try some more 3D printer mods.

Besides more screws, bolts, washers, bearings and plastic I received a few more parts to use.


  • 30mm 12volt fans. One problem I have with my Rapman is that the extruder overheats and jams when printing sometimes. To overcome this issue I upgraded the part cooling fan and ducted it to cool the extruder more then the part and added a 80mm fan to the side of the printer to help cool everything. This mostly works but effect the head heat up time but helps with  part cooling(on one side). With the smaller fans installed to only the parts that need them I should be able to control the thermals better and be able to get better print quality.
  • LEDs. I am going to add some better lighting around the printhead to help the camera (as I normally leave the room lights off).
  • PTFE TEFLON Tubing. Having a 470gram stepper motor and all the extra supports for it on a printhead seems a little silly to me. I thought that a goal would be to reduce the printheads mass so you don't have to counter/fight as much inertia. So if I mount the fillament feed away from the printhead I and feed the fillament to the printhead via the PTFE tube I should be able to have a printhead that is less then 30% it's current mass. This will allow me to improve the movement speeds of the printhead while reducing the power required to move it and reduce the strain/wobble from the printhead's inertia.
  • New hotend. The hotend on the Rapman comes sealed in fire cement, on my printhead it is crumbling and leaving what looks like sand everywhere.  It is about time for me to replace. I have resurrected the old printhead a few time already but as the resurrections are becoming more involved and makeshift I am expecting it to soon hit a point where I just need to let it die in peace. After it dies I might use it to recycle my waste PLA back into fillament.       
It is now getting to a point where I can almost make a whole new printer, so that might be were this project ends up. I think it should be easy to make a lowcost PLA 3D printer that is a fraction of the price of the current 3D printers available. By limiting it to PLA and dropping the printhead mass you should be able to lower the stepper motor size and power requirement which would allow you to use smaller motors and motor drivers so you could use lower cost of everything leaving you with a smaller cheaper 3D printer.  

Saturday, 22 September 2012

Tinkercad Gnome


I recently discovered https://tinkercad.com.

A very user friendly online CAD application that allows you to quickly design 3D objects and download them as STL files ready for 3D printing. 


Here is a Gnome I created in just a few minutes.
https://tinkercad.com/things/9NMMuTF6O3s-gnome


and here is him after I printed.

The Tinkercad UI is very straight forward and basic and only takes a few minutes to learn and master.


Now for the next step of adding RFnodes to them to create my Gnome army









3D Printer setup

I have upgraded my 3D printer setup.

Now instead of him sitting on a cardboard box he has his own rack and I can have the spools of plastic hanging above him (need to get more plastics to fill the space) 


I have also added one of the routers with openWRT, some LEDs for lighting and a Logitech c270 HD webcam so I can remotely keep an eye on him.  

I am in the process of upgrading his printhead to support better cooling for the extruder and printed part also will have a few built in lights and maybe a small camera.

Once I get my Makibox printer I might have to expand the setup even more.




Wireless mesh-able RGB lights and a ATMEGA88


I thought I might test out using the Atmega88p-20au instead of the Atmega168 as a processor for my RFnode. The Atmega88 is a cheaper version of the Atmega168 with only half the flash. 

I had tried using a Atmega8 before but found it did not run too stable at 3.3volts which I need to do to support USB. The Atmega8 datasheet said it  needs 4.5 - 5.5 volts but I was going to give it a go anyway, It did work but I found that about 1 in 5 times I when flashing it I would get an error and would have to retry.


Reading the datasheet the Atmega88 is identical to the Atmega168 with the main differences being just the amount of flash/ram. So hardware wise I did not need to make any changes except the IC but from a software side I did have to change my code a fair amount to get it down to 6KB. The Atmega does have 8KB of flash but I am using 2KB of that for the bootloader.  

After removing all the sleep/watchdog functions and cutting back the meshing support I was able to get my code to less then 6KB and still be left with a wireless mesh-able RGB light with a just enough code space left to added a few basic sensors. 

This version of the board I made it easier to add a STA301A so it would be easy for me use this board to drive brighter and more power hungry lights or devices around the home and have them all wirelessly controllable from my tablet/phone.