Tuesday, June 22, 2010

My CHDK source

To many of my readers this page won't make much sense. I apologize that and please skip to my next blog topic if you are not interested in controlling a canon camera.

People have been asking for this source code. Here it is. I am going to make this easier to copy for CHDK programmers and easier to skip over for wind turbine people soon.


--[[

@title security cam 5

rem Based on work done by MLuna - based om MX3 sample script
rem and based on work done by Matthew Kime in the area of automatic file deletion
rem Tested on A590

rem Shot without auto-focus/with auto-focus/continuously (need to put in continuous mode manually)
rem T implies test mode with MD cells drawing and no shots taken
@param a Shot (0=nf/1=f/2=c/3=t)
@default a 1

rem How long the shutter button will be pressed in continuous mode
@param b Continuos shoot (secs)
@default b 10

@param c Threshold (0-255)
@default c 5

@param d Compare Interval (msecs)
@default d 20

@param e Compare Interval (secs)
@default e 0

rem If this value is too small, the camera goes continuously shooting after the 1st shot.
rem Experiment with this value to find one fitted to your needs
@param f Begin Delay (secs)
@default f 5

@param g Pix step(speed/accuracy adj)
@default g 5

@param h Columns
@default h 6

@param i Rows
@default i 6

rem Frame width in which no MD is performed (in cell units)
@param j Dead frame
@default j 0


]]


-- set eyefi to zero without eyefi card
eyefi = 1
-- filemax is the number of pictures to leave on the sd card when cleaning up old pictures

filemax=5

Dirname = "A/DCIM/102CANON"

-- function definitions


function getCurrentDir ()
local dir = os.listdir("A/DCIM", false)
if(dir) then
local count = table.getn(dir)
--if(dir[count] ~= customDir) then
print("getCurrentDir: ",dir[count])
return "A/DCIM/"..dir[count]
--else
--print("getCurrentDir:A")
--return nil
--end
else
print("getCurrentDir:B")
return nil
end
end


function getNumberOfFiles ()

local dir = os.listdir( Dirname, false)
if(dir) then
local count = table.getn(dir)
return count
else

return 0
end
end





function getNewFile()
local dir = os.listdir(Dirname, false)
if(dir) then
local count = table.getn(dir)
if(dir[count] ~= 0) then
local itemCount = 0
repeat
itemCount = itemCount + 1
if (string.sub(dir[itemCount],1,3) == "IMG") then
io.write("getNewFile loop count: "..itemCount.."\r\n")
return dir[itemCount]
--return "A/DCIM/100CANON/"..dir[itemCount]
end
until itemCount == count
end
end
end

function deleteImgFiles()
local dir = os.listdir(Dirname, false)
if(dir) then
local count = table.getn(dir)
if(count ~= 0) then
local itemCount = 0
repeat
itemCount = itemCount + 1

if (string.sub(dir[itemCount],1,3) == "IMG") then
io.write("delete: "..dir[itemCount].."\r\n")
os.remove(Dirname.."/"..dir[itemCount])
end
until itemCount == count
end
end
end

function deleteOldFiles()
local dir = os.listdir(Dirname, false)
if(dir) then
local count = table.getn(dir)
if(dir[count] ~= 0) then
local itemCount = 0
repeat
itemCount = itemCount + 1

if (string.sub(dir[itemCount],1,3) == "IMG") then
io.write("delete: "..dir[itemCount].."\n")
os.remove(Dirname..dir[itemCount])
end
until itemCount == count
end
end
end



log = io.open("A/intlog.txt","a+")
io.output(log)

deleteImgFiles()





if a<0 then
a=0
end

if a>3 then
a=3
end

if c<0 then
c=0
end

if d<0 then
d=0
end

if e<0 then
e=0
end

if g<1 then
g=1
end

if h<1 then
h=1
end

if i<1 then
i=1
end

if j<0 then
j=0
end


-- Conversions secs to msecs
b=b*1000
e=e*1000
f=f*1000

d=d+e

-- This is the timeout in msecs. After this period, the motion trap is rearmed.
T=600000

-- Parameters for the Dead Frame
J=j+1
H=h-j
I=i-j

t=0

print( "press Shutter to Stop")



while ( 1 ) do



rectangles = 0

rectangles = md_detect_motion( h, i, 1, T, d, c, 1, t, 1, J, J, H, I, 0, g, f)


t=rectangles


if a==0 and t>0 then click( "shoot_full") end


if a==1 and t>0 then shoot() end

--if ( a>0 and a < 3) then
-- local currentFile = getNewFile()
-- -- currentfile was nil once so I added a test for this
-- if( currentfile ) then

-- local fileCreatedDate = os.date("%m%d%H%M%S")
-- os.rename("A/DCIM/100CANON/"..currentFile,"A/DCIM/100CANON/"..fileCreatedDate..".JPG")
-- print(currentFile.."|"..fileCreatedDate..".JPG")
-- io.write(currentFile.."|"..fileCreatedDate..".JPG\r\n")
-- end

-- end


-- continuous mode shooting
if a==2 and t>0 then
X=get_tick_count()
press("shoot_full")

while (V
U=get_tick_count()
V=(U-X)
end

release( "shoot_full" )

end

-- Test Mode Output
if a==3 then

if t>0 then
print( "Detected cells: ",t)
else
print( "No detection in 10 min!" )

end

t=0

end

-- delete old files because eyefi card will fill up over time
-- This code can be removed when eye-fi adds an autodelete option
if ( eyefi ) then
while(getNumberOfFiles() > filemax) do

--delete image until we have room for 50(or filemax) new ones

local filecounter = getNumberOfFiles()

local dir = os.listdir(Dirname, false)
os.remove(Dirname.."/"..dir[1])
io.write("deleting: "..dir[1].."\r\n")
end

end



-- end of main while loop

end




print("END")








Thursday, June 3, 2010

Back in the USA


Wind Power in Kenya

While solar seems popular, for some reason wind turbines cannot be found even though they have some very wind regions. This is one of the reasons that I joined Ace and went to Kenya to bring wind power to the country. The only wind turbines we saw were 10KW Bergey units used to power cell phone repeaters in the desert (see photo above). These turbines are over $40,000 USD with tower and installation and just aren't affordable for most Kenyans. That's why we brought our line of OEM Wind Power turbines to Kenya. (pictures coming soon).



Well, I'm back from Kenya now and I can tell you one thing; I'm never going to complain about a pothole in a road again.

Kenya is a country which is expanding rapidly in a financially and industrially, but they are not upgrading their infrastructure rapidly enough. On the road from Nairobi to Garissa, Kenya, our little Toyota was nearly done in several times by pot holes and washouts from the recent rainstorms.

Wednesday, May 26, 2010

First Wind Turbine in Garissa, Kenya



Here is a video of a most beautiful place in Kenya where we just installed a wind turbine earlier this week.

Monday, May 24, 2010

Bringing Wind Power to Kenya-Part 1


I have spent the last few weeks in Kenya, Africa, to bring wind power to this country. Kenya has many very windy areas but has very few wind turbines. Additionally, the power grid is not dependable and in areas like Garissa, the grid is simply a large multi-megawatt diesel generator.

In a cooperative effort with Ace Energy Solutions ( www.acewindenergy.com ), a Kenyan and American company, I traveled to Kenya and installed several wind turbines in Kenyan homes. I will be publishing videos and pictures of our journeys and experiences on this blog.

Friday, May 14, 2010

New Magnetic Levitation Axle

We have high hopes for a new Vertical Axis Wind Turbine (VAWT) design we are working on. This wind turbine research is a cooperative effort between Berezin Technologies,LLC and Dr. Sanza Kazadi of the Jisan Research Institute ( www.jisan.org ). This is a simple, rugged drag based design modeled after a anemometer. The axle is using a patented technology developed by Dr. Kazadi ( http://www.google.com/patents/about?i... ). PWM Axial Flux generator is being developed now and product will be available for sale in July 2010.




Sunday, April 25, 2010

Cool Website - yougetsignal.com - full of insight

I just traced an IP at http://www.yougetsignal.com/tools/visual-tracert/. Check this out by putting in a IP or the name of a website. I was traced the IP of a wind power associate in Australia using the site above.

The key is to do a proxy trace, not a host trace (options given at the site above) because the proxy trace shows how an internet packet gets from your computer to the remote website or computer.

The results of this trace add a node for each router (piece of internet communications equipment) the your information bounces over as it travels from one computer to another.

As it shows you this information, it zooms in and shows your street or satellite views of a worldwide map in kind of an animated presentation of reverse look-up data. The thing I found very interesting was that whether I was doing a host trace from the websites computer in California, or proxy trace from my computer in New York state, both paths crossed in Singapore and seemed to bounce through the Pacific on islands and countries which we do business with, and not bouncing through a single country in which we have strained relations.

Also, packets don't necessarily travel the same way you would fly a plane. On the way to Europe, one packet went from New York, jumping through four hops around Los Angeles metropolitan locations, to Florida, back to Los Angeles, and then finally oversees to Europe.

It calls this process of visualizing the traditional "trace route" an "approximate geophysical trace" and in one case, it showed a server which I know to be in China, as being in Germany. Don't take this site as gospel, but is very interesting and quite fun to use.

Thursday, April 1, 2010

Six Barrel Savonius

I just put up a new video of our six barrel Savonius Wind Turbine. This is a vertical axis wind turbine which uses three times as many barrels as our previous turbine. Next step is to make electricity and I think this one is going to be able to put out in excess of a kilowatt,