My Hobby Room

If I did'nt record the work (software and hardware) made before by a certain method, when fixing, I will be troubled very much. Because, I cannot understand by what reason I chose it and I suffer troubles very much.

It is especially on a program, for example, "Why did I use this function?" "The unnecessary program code exists?" When I find a more smart and beautiful program code, I sometimes repent of failure. If it does not record the plan of a circuit, it will be troubled very much by later.

I have much forgetfulness recently.


Circuit

PIO1:Put a trigger into the input of VB-EX50
PIO2:Turn a fan with LED
PIO3:Charge time control to a charge battery
EXP:Power supply to a PhoMos relay (3V 2mA)

The trigger from PIO1
    To IN2 of VB-EX50
        On of PhotoMos relay
            DC5V supply to a Feeding machine (time adjustment by camera server)

The trigger from PIO2
    A fan's power supply

Bird detector of sensor
    To IN1 of VB-EX50
        Direction of a camera is changed.

Since there is supply from a solar cell and a charge battery daytime, it turns a fan and LED, but because of stop supply the light with LED is not turned.

Close up

 

T&D Pro Digito Development set(Archives)

I purchased by better-known Akizuki electronic commerce. Generally we use a Lan-RS232c protocol converter, an Ethernet digital output board, etc., in order to operate by remote control via a network. These greatest common fault is that only the person who logged in by administrator authority and root authority can do control of apparatus. It is difficult for the site visitor to input "ID" and "PASSWORD" personally, and to operate a screen which is not user-friendly. Furthermore, if "ID" and "PASSWORD" of root authority are showed, the danger that a setup will be changed will occur and manager of system2 will be troubled very much.

Then, Pro Digio appears. This module has HTTP server ability, we can make it operate as cgi and ssi by description of a script. This is a very wonderful function. There are IO terminal, USB memory connector, com port, and CF card in external input and output, and it is just all sorts of colorful functions. These can be accessed via a browser and furthermore, we can control the connected peripheral equipment.

This time, I am using it for control of a thermometer & hygrometer ,fan with led , motor of feeding machine, battery charger and a live camera server. If a mechanical relay is used, we will become controllable electrical goods with large power consumption, such as a cleaner and an electric light.

This script resembles c language system very much, and if you mastered c and java, I think that you can simply program.

Function main()
{
var fd ;
var size ;
var rtn ; //dummy
var now ;
var open_time ;
var close_time ;
var int_time ;
var last_time ;
var next_time ;
var time1 ;
var time2 ;
var t2 ;
var str_time ;
var str ;
var flag_t ;

flag_t=0;
now = getrtctime() ;
time1 = getdatestring("yyyy/MM/dd") ;
time2 = gettimestring("HH:mm:ss") ;
last_time = time1 + " " + time2;

t2=int(left("%time2%",2));
if ((t2<6)||(t2>14))
{
flag_t=1;
}

fd=fileopen("B:\\wrnlog.txt","r");
rtn=fgets("B:\\wrnlog.txt",str,1);
fileclose(fd);
if (str=="1")
{
flag_t=1;
}

if (flag_t=="1")
{

webprint("<HTML>");
webprint("<meta http-equiv=\"refresh\" content=\"
1; url=javascript:history.back()\" />");
webprint("</HTML>");
break ;
}
// else
// {

setport(7,1) ; //PIO[7]:Output

putport(7,0) ; //PIO[7]inishalize
putport(7,1) ; //output
sleep(1*1000) ;
putport(7,0) ;

//log file output
fd=fileopen("B:\\wrnlog.txt","w");
if(fd<0)
{

fd=filecreat("B:\\wrnlog.txt");
if(fd<0)
{
error("fileCreatErr");
return;
}
}

rtn=filewrite(fd,"1");
if(rtn<0)
{
error("FileWriteErr");
fileclose(fd);
return;
}

fileclose(fd);

event("TIMER","C:\\www\\scripts\\resetfile.wcr","",
2*60*60*1000,0,1,60*1000);

fd=fileopen("B:\\lastfeedtime.txt","w");
if(fd<0)
{
fd=filecreat("B:\\lastfeedtime.txt");
if(fd<0)
{
error("fileCreatErr");
return;
}
}

rtn=filewrite(fd,last_time);
if(rtn<0)
{
error("FileWriteErr");
fileclose(fd);
return;
}

fileclose(fd);

webprint("<HTML>");
webprint("<meta http-equiv=\"refresh\" content=\"
1; url=javascript:history.back()\" />");
webprint("</HTML>");
// {
}
Script of Feeding

It is function call from the button "Feeding"

Variable declaration

 

 

 

 

The time which pushed the button is acquired and it checks in possible time.


 

 

 

 

Since flag at the time of the ability to perform last time is saved at the file, this file is opened, and checked flag.
 

It is pio output when a flag check is passed.


 

 

 

 

 

 

Interval 1000msec (1sec)
 

 

A state is written in a flag file.

 

 

 

 

 

 

 

function call of the script which sets flag to true 2 hours after.

performed time is written in a file.

Script of measurement in Thermometer & Hygrometer 

Function main()
{
var dat[] ;
var str
var temp ;
var temp_i
var temp_f
var hum ;
var hum_i
var cnt ;
var port ;

// sirial connection-------------------------------
port = 2 ;
sioctrl(port, 1200) ;
siorxclr(port) ;

sioputb(port, 0x00) ;
// sleep(100) ;

sioputb(port,0x0B) ;
// sleep(100) ; //

cnt = siogetd(port, dat[], 10,1000) ;

if ( arg[0] == "T=1" ) {
temp = dat[2] + (dat[3] << 8) ;
temp_i = (temp / 10) - 100 ;
temp_f = temp - ((temp_i + 100) * 10) ;
str = "%temp_i%.%temp_f%" ;
}
else if ( arg[0] == "T=3" ) {
temp = dat[2] + (dat[3] << 8) ;
temp_i = (temp / 10) - 100 ;
temp_f = temp - ((temp_i + 100) * 10) ;
str = "%temp_i%.%temp_f%"
str = int(str) * 9 / 5 + 32 ; //華氏温度
str = left("%str%",4);
}
else
{
hum = dat [4] + (dat[5] << 8) ;
hum_i = (hum / 10) - 100 ;
hum_i = (hum_i * 100) / 92 ;
str = "%hum_i%" ;
}

webprint("%str%") ;
}
"ONDOTORI"TR-72S data reading script

 

 

 

 

 

 

 

 

 

 

Celsius degree

 

Fahrenheit degree

 

 

/92 are compensation of humidity

Humidity compensation was correctly completed in the detailed measurement data analysis of Mr. S who lives in M city. I borrow this place and give thanks.

Function main()
{

var fd ;
var str ; //
var rtn ; //dummy
var now ;
var last_time ;
var next_time
var time1 ;
var time2 ;
var yy_t ;
var mm_t
var dd_t ;
var hh_n ;
var mm_n ;
var ss_n ;
var t2 ;
var diffsec ;
var difftime ;

now = getrtctime() ;
time1 = getdatestring("yyyy/MM/dd") ;
time2 = gettimestring("HH:mm:ss") ;
last_time = time1 + " " + time2;

fd=fileopen("B:\\lastfeedtime.txt","r");
if(fd < 0){
error(" error");
}else{
rtn=fgets("B:\\lastfeedtime.txt",str,255);
}

fileclose(fd);

t2["year"]=int(left("%str%",4));
t2["month"]=int(mid("%str%",5,2));
t2["day"]=int(mid("%str%",8,2));
t2["hour"]=int(mid("%str%",11,2));
t2["minute"]=int(mid("%str%",14,2));
t2["second"]=int(mid("%str%",17,2));

diffsec=difftime(now,t2);

if( diffsec > 2*60*60 ){
difftime="Yor can feed now";

} else {
diffsec=2*60*60-diffsec;
hh_n=diffsec/(60*60);
hh_n=int(uintstr(hh_n))
mm_n=diffsec-hh_n*(60*60);
mm_n=int(uintstr(mm_n/60));
ss_n=diffsec-hh_n*60*60-mm_n*60;

difftime="%hh_n%" + "H" + "%mm_n%" + "M" + "%ss_n%" + "S";
}
webprint("%difftime%") ;
}
This script is for displaying on "Time until the next time" on a feeding  pop up windows.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

When possible, here message is displayed on web

In addition to these, this system is operating with the following scripts.

The script which turn a fan and led
flag change after fixed time progress
Connect with a SNTP server for every hour, and it is time compensation.
In order that the file on a flush memory disappear at reset, script creates the file of time and flag
displays the present time
turn off fan compulsorily in 5 minutes

There is the small part which must do soldering iron by oneself. The person who is weak in a soldering iron has a half finished product, but it is expensive. I made myself in order to make it because of "MOTTAINAI". When I changed a base circuit of internal mother board of a note PC, I was tense for remodeling , but this work was close work since it.


Feeding Machine

The first machine (failure)

 

Feeding through a pipe to a bird table

The top of a fan is a Sensor 

I bought this with the mail order. I decomposed immediately and remodeled. Since the supply container of food is transparent, my favorite is that the check of residual quantity is easy.

However, the motor gear circumference were quite cheap, and it was often unstable that a gear was not engaged. Price 18000 yen were purchased by 10000 yen.
I think the product about a total of 2000 yen order with in contents by control part 500 yen , drive part 500 yen, and plastic main part 1000 yen.

If 1000 yen is taken out with the Robot hall of Tsukumo at Akihabara, you can buy a better Japanese-made drive portion at it. I will be a creation schedule about No. 2 in the future.

A stand is a Hinoki native of Hinohara village. Very good incense does it.

Voice reception

Voice reception is impossible in the java viewer. t is possible. by the PC version (application type), but  It must download and install. Then, CANON offers SDK KIT as a development support tool, I made the program only for voice reception using VisualBasic6.0.

I am moved to hear a call of bush warbler (I hardly know other birds although it is shameful) well unexpectedly. A microphone also gathers the sound of the car running a road...

Security

The server is applying in the two-set organization of a camera server and the HTTP server of ProDigio. Since it is employment of the Memory base which both does not have a hard disk, security is high.
Since the powerful script is built in ProDigio, if cracking by the hacker, there is a danger of becoming a very dangerous virus dispatch base and a step.
Therefore, since the writing to Flush Memory is forbidden by Dip on a ProDigio board, except for a thief, rewriting is impossible. Unlike the common PC base server of HDD use, this employment is safe.

NAT address port conversion of a router is used by Fixation IP address. Since the ftp server of ProDigio has changed the port, I can't access to ftp server in the PASV mode from outside. Although I know the cause somehow, it is inconvenience a little. Port is close now.

Cooperation with Multi-terminal VB-EX50

The system connected the EXP output of ProDigio to OUT1 of VB-EX50, and has controlled the motor. Direct control is possible for a system via a PhotoMOS releyAQZ105), however, even when it is small changing motor rotation time, in order to have to carry out  rewriting of a program, Memory write-in release, Debug work, ftp transmission, ReDebug work, and protect on Memory writing again, it's too much of a bother.

Since the output time of VB-EX50 makes a setting change easy arbitrarily from the administrator screen of a camera server to 0 - 30 seconds, although a circuit is complicated, its management is easy and it is good!

Infrared sensor of people(bird?) UltraHyperSensitivity/Wide- Narrow angle Powersaving Infrared sensor Kit Ver.2

The output of a sensor is connected to IN1 of VB-EX50, and if a bird come, a camera will automatically turn to feeding stations. At this time, camera photograph a still image automatically then for 10 seconds. I choose the best shot and update it on my website.

This KIT had originally the mechanical relay of a coil. however, a mechanical relay has large power consumption, and large drive electric power is a fault. Although the electric power supply of the Infrared sensor was carried out from the solar cell panel, it did not move in the beginning. Then, the relay is changed and applied to a PhotoMOS relay.

Mechanical relay (Right edge)

PhotoMOS relay changing

Sequential Switcher

PinP screen(Mac)

Music Box

It is possible to see both the images of a waterfall and birds simultaneously by the television monitor inside the building. Two video signals are outputted to a monitor using the PinP function of a screen Sequential Switcher. Moreover, the output of a sensor connects with a input of Sequential Switcher and an electronic music box, and it is used to exchange screen of a child screen and a parent screen, and sound a music box. We can also get to know existence of a bird to sound. The alarm sound of a Sequential Switcher is very greatly jarring, and since it isn't able to cut, the pattern of a mother board was cut.

Charging battery

The surplus electric power of a solar cell is charged in the rechargeable battery. However, if a Fan with LED also turn by night, a battery will completely discharges electricity , and a life is over.

Solar cell panel

Power 9W Voltage 18V Current 500mA(MAX)、Power 4.5W Voltage 18V Current 250mA. Parallel connection of 2panel.

 

Electricity bill

ProDigio    290mA     24h
VB-C50i   MAX25W  06:00-18:00

Motor of feeding machine move on Once for five seconds, greatest six times 30 seconds in total for one day. I ignored it A sensor and a fan are 0 yen by the solar cell. Thermometer and hygrometer are dry battery drive. An electricity bill is about 200 yen in about 9kWh for one month under the treaty of the most general charge system. The food cost is far large (Am I ever at my own pocket).

Hobby

Although each one is a single function, however when each other is connected mutually organically like a CNS( Cranial Nerve System) it is even beautifully and is also convenient. 
This idea is employed efficiently also in the office and serves both as a hobby and useful.