My Hobby Room

If I don't keep track of my software/hardware created in some way, I'll be in a lot of trouble when I try to repair or fix it later.
This is because I would forget. I often have a hard time understanding why I did it at that time, because it is unexpectedly difficult to understand.
Especially in  programming, I have a hard time understanding why I used this program code and no use for programs?
When I find code that is smarter and more beautiful than past,  I often regret why I did it this way. I must kepp the circuit and planning.
I've been forgetting things a lot lately.
 


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.

The LED fan rotates in the daytime because of the supply from the solar battery and rechargeable battery, but at night no rotate and no light up because of the suspend.

Close up

 

T&D Pro Digito Development set(Archives)

I bought it at the well-known Akizuki Electronics Trading Company.

I purchased it at better-known Akizuki electronic. 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 biggest common drawback is that only the person who logged in by administrator authority and root authority can do control of apparatus.
It is difficult for the 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 gaved, the settings have been changed and there is also the danger that the system may be damaged, which makes it very difficult to manage.
 

This is where ProDigio comes in. This module has HTTP server function, we can make it operating as cgi and ssi  protocol by description of a script. This is a very wonderful function. External inputs and outputs unit include IO terminal, USB memory connector, com port, and CF card. It's just filling a bowl. If you access these via your browser, you can control the peripherals equipment

I can control thermometer & hygrometer ,fan with led , motor of feeding machine, battery charger and a live camera server. If I use a mechanical relay, we will become controllable electrical goods with large power consumption, such as a cleaner and an electric light.

This script resembles C programming language 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

 

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, this system is operating under 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 are a lot of  small parts that I have to do the soldering iron by myself. The person who is weak in a soldering iron can get a half finished product, but it is expensive. I made myself in order to make it because of "MOTTAINAI". When I changed a circuit of internal mother board in a LapTop PC, I was tense for remodeling , this task 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 through mail order. I decomposed immediately and remodeled. Since the supply container of food is transparent, this in a good point that the check of residual quantity is easy.

However, the motor gear component is quite cheap, and it is often unstable that a gear was not engaged. I bought it for 10,000 yen for the list price of 18,000 yen.
I think this product  of around 2000 yen total of 500 yen for the control base, 500 yen for the drive part, and 1000 yen for the plastic body.

 I can get a better quality made in Japan drive unit at Tsukumo Robot Kingdom for 1000 yen, so I'm planning to make a second one soon.

A stand is made of Hinoki wood from Hinohara village. It has a very nice fragrance.

Voice reception

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

I'm thrilled to hear the surprisingly good sounds of Japanese bush warbler, also pick up the sound of cars on the 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, this have 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 safety.

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 to 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 (Of course 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.