Computer Controlled Window Blinds

kd5crs

Senior Member
Here's a link to the video of the blinds in action. I could not have done it without the help from the members of this forum, you all rock!

http://www.instructables.com/id/Computer-Controlled-Window-Blinds/

Here's the code, first the 28x2 on the control board:
Code:
'28x2 program for computer interface and blind control
'by Brian (kd5crs)
'12/3/09
'version 10 adds U to the start of each transmission. v9 works great.

symbol transmit = c.2
symbol receive  = c.3
symbol TVonoroff = 0
symbol green_led = b.6
symbol p08m28talk = a.1

symbol wloc = b0
symbol wcom = b1
symbol TVadc  = b3
symbol counter = w7
symbol coro = b6
symbol LDR1d = b7
symbol LDR2d = b8
symbol Tempd = b9
symbol Blank1 = b10
symbol Blank2 = b11
symbol TVison = b12

symbol LDR1dHund = b30
symbol LDR1dTens = b31
symbol LDR1dOnes = b32

symbol LDR2dHund = b33
symbol LDR2dTens = b34
symbol LDR2dOnes = b35

symbol TempdHund = b36
symbol TempdTens = b37
symbol TempdOnes = b38

symbol trycount = b42

symbol tossit = b25

high green_led
pause 200
low green_led
pause 200
high green_led
pause 200
low green_led
pause 200
high green_led
pause 200
low green_led


Blank1 = 0
Blank2 = 0
'pause 10
'sertxd("Cube interface is online",13,10)
adcsetup = 1
disconnect
gosub NOACK



HOLDINGPATTERN:
	trycount = 0
	serrxd [5000,TVCHECK],("CI"),wloc,wcom
	sertxd("W")
	pause 5
	sertxd("OK",#0,13,10)
	pause 100
	goto MAIN
	

MAIN:
	pause 10
	serout transmit,N1200_8,(0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55) ' preamble to lock link the tx/rx
	pause 5 ' lock link and preamble solution by wolfgang ;0) cheers
	serout transmit,N1200_8,("GG",$FF,wloc,$FF,wcom,$00,$00)
	pause 5
	pause 10
	high p08m28talk
	'pause 100
	high green_led
	serin receive,N1200_8,("GG"),tossit,wloc,tossit,coro,tossit,LDR1d,tossit,LDR2d,tossit,Tempd,tossit
	low p08m28talk
	pause 100
	low green_led
	gosub ACK
	goto HOLDINGPATTERN


ACK:
	'if TVison > 2 then BADDATA
	'if wloc > 18 then BADDATA
	'if coro > 2 then BADDATA
	'if Blank1 > 1 then BADDATA
	'if Blank2 > 1 then BADDATA
	
	bintoascii LDR1d,LDR1dHund,LDR1dTens,LDR1dOnes
	bintoascii LDR2d,LDR2dHund,LDR2dTens,LDR2dOnes
	bintoascii Tempd,TempdHund,TempdTens,TempdOnes
	
	'23 bytes
	sertxd("-",#TVison,"-",wloc,"-",#coro,"-",LDR1dHund,LDR1dTens,LDR1dOnes,"-",LDR2dHund,LDR2dTens,LDR2dOnes,"-",TempdHund,TempdTens,TempdOnes,"-",#Blank1,"-",#Blank2,13,10)
	low green_led
	'sertxd("Command successful",13,10)
	pause 10
	'hsersetup B2400_8,%111	
	return

NOACK:
	low green_led
	sertxd("0000000000000000NOACK",13,10)
	'sertxd(#TVison,32,#wloc,32,#coro,32,#LDR1d,32,#LDR2d,32,#Tempd,32,#Blank1,32,#Blank2,13,10)
	pause 10
	high green_led
	pause 100
	low green_led
	pause 100
	high green_led
	pause 100
	low green_led
	pause 100
	high green_led
	pause 100
	low green_led
	pause 10
	return

TVCHECK:
	readadc10 TVonoroff,TVadc
	pause 10
	if TVadc > 35 then 
		gosub TVON
	else 
		gosub TVOFF
	endif
	sertxd("W")
	pause 5
	sertxd("TV",#TVison,13,10)
	goto HOLDINGPATTERN

TVON:	
	'sertxd("TV is on",13,10)
	TVison = 1
	pause 10
	return

TVOFF:	
	'sertxd("TV is off",13,10)
	TVison = 2
	pause 10
	return

BADDATA:
	sertxd("The data is bad. 0000",13,10)
	goto HOLDINGPATTERN
Next the 08m on the control board:

Code:
'v2 Change from 5 to 2.5 seconds

symbol p28reset = 4
symbol p08m28talk = pin3
symbol p08mLED = 2

high p28reset

MAIN:
	high p08mLED
	pause 100
	low p08mLED
	pause 100
	high p08mLED
	pause 100
	low p08mLED
	pause 100
	high p08mLED
	pause 100
	low p08mLED
	do while p08m28talk = 0
	loop
	high p08mLED
	pause 2500
		if p08m28talk = 1 then 
			goto RESET28
		elseif p08m28talk = 0 then
			goto MAIN
		endif
	goto MAIN
	
RESET28:
	low p28reset
	pause 5
	high p28reset
	low p08mLED
	goto MAIN
Third, the 14m on the window unit. Each unit is given a unique letter as an identifier, so window 1 is "A", window 2 is "B", etc.

Code:
'14m program for blinds/sensor board
'version 9, adds U to start of transmissions
'by Brian (kd5crs)
'12/3/09

symbol transmit = 5
symbol receive  = 2
symbol green_led = 4
symbol wloc = b0
symbol wcom = b1
symbol ack  = b2
symbol coro = b6
symbol LDR1d = b7
symbol LDR2d = b8
symbol Tempd = b9
symbol open1 = "A"
symbol open2 = "L"
symbol open3 = "M"
symbol open4 = "N"
symbol close1 = "B"
symbol status1 ="C"
symbol servo_pin = 3
symbol temp_pin = 1
symbol LDR1 = 0
symbol LDR2 = 4
symbol WindowName = b3
symbol switchpin = pin3
symbol lastposition = b4
symbol servoposition = b5
symbol tossit = b10

'This section defines the window name
WindowName = "A"

'high green_led
'pause 500
'low green_led

read 0,lastposition

if switchpin = 1 then BSWITCH
	
goto BSTATUS

HOLDINGPATTERN:
	high green_led
	serin receive,N1200_4,("GG"),tossit,wloc,tossit,wcom,tossit
	low green_led
' WindowName is individual window, X is both living room windows, U is all windows
	if wloc = WindowName or wloc = "U" or wloc = "X" then MAIN
'	if wloc = WindowName then 
'		goto MAIN
'	elseif wloc = "U" then
'		goto MAIN
'	elseif wloc = "X" then 
'		goto MAIN
'	endif
	goto HOLDINGPATTERN
	
	

MAIN:
	high green_led
	pause 500
	low green_led
'	pause 100
'	high green_led
'	pause 100
'	low green_led
'	if wcom = open1  then BOPEN
	if wcom = close1  then BCLOSE
	if wcom = status1 then BSTATUS
	select case wcom
	case open1
		servoposition = 210
		coro = 1
		goto BOPEN
	case open2
		servoposition = 105
		coro = 2
		goto BOPEN
	case open3
		servoposition = 95
		coro = 3
		goto BOPEN
	case open4
		servoposition = 85
		coro = 4
		goto BOPEN
	endselect
		
	goto MAIN
	
BOPEN: 
'	coro = 1
	write 0,1
	'if wloc = "U" or wloc = "X" then goto HOLDINGPATTERN
	gosub SENDIT
	servo servo_pin,servoposition
	pause 2000
	low servo_pin
	goto HOLDINGPATTERN
	
BCLOSE: 
	coro = 5
	write 0,2
	'if wloc = "U" or wloc = "X" then goto HOLDINGPATTERN
	gosub SENDIT
	servo servo_pin,75
	pause 2000
	low servo_pin
	goto HOLDINGPATTERN
	
BSTATUS:
	readadc LDR1,LDR1d
	readadc LDR2,LDR2d
	readtemp temp_pin, Tempd
	gosub SENDIT
	goto HOLDINGPATTERN
	
'BCHECK:
'	if coro = 1 then 
'		goto BOPEN
'	elseif coro = 2 then 
'		goto BCLOSE
'	endif
'	goto HOLDINGPATTERN

SENDIT:
	serout transmit,N1200_4,(0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55) ' preamble to lock link the tx/rx
	pause 5 ' lock link and preamble solution by wolfgang 
	serout transmit,N1200_4,("GG","U",wloc,"U",coro,"U",LDR1d,"U",LDR2d,"U",Tempd,"U")
	pause 5
	return
	
BSWITCH:
select case lastposition
case 1 
	goto BCLOSE
case 2 
	servoposition = 210
	goto BOPEN
endselect
goto BCLOSE
And last, the 08m on the window boards, used to add a local push button for control.

Code:
'p08m button chip for window blinds
'by Brian (kd5crs)

symbol pinfor14 = 0
symbol pin14power = 1
symbol pushbutton = pin4

high pin14power

pause 2000	' if power outage, 14 will ignore. if button, 14 will execute

high pinfor14

MAIN:
if pushbutton = 1 then PB
goto MAIN

PB:
low pin14power
pause 10
high pin14power
goto MAIN
I hope this helps anyone attempting something similar, or as a reference for getting good results from the Sparkfun 434 mhz pairs.

Now I just need to make one correction on the PCB (notice the white tape covering the ripped up trace?) and then I can buy the boards for my other windows.

Feel free to ask any questions, and I'll do my best to answer.

Brian
 

kd5crs

Senior Member
Oh one thing, how did you attach the socket to the servo? (looks really useful)
I took one of the plastic servo horns and sanded it down until it fit in the square 1/4" drive of the socket. With regular servos you have to use a 3/8" adapter due to the diameter of the servo gear, but the 9g servos will fit a 1/4" directly.

It will work any time you want a servo to turn a hexagonal rod, as you can just use the appropriate sized socket.

Finally, the socket I used has a little detent on the drive side, so the servos snap on very securely.

Brian
 

ocwo92

New Member
Hope the original author is still reading this.

I've been thinking of a similar project, but I wasn't sure whether small servos would deliver enough power to turn the blinds rod. It looks like even the small servo you're showing in the video can turn the blinds without the use of gears. Is this true, or did I miss something?
 

garylcamp

New Member
Hi ocwo92,
Looks like KdScrs is not on the air any more here. I was wondering the same thing. I have one of the 9g Servos and just made it move with a 08M last week. I have wanted to have controlled blinds for years but it looked to expensive and difficult. I have some of the blinds, quite old now, and they are quite difficult to turn. I dont see how the 9g servo can manage that, though seeing is believing, to some extent. I expect the life of the controlled blinds will be much shorter than my manual ones. Still, worth looking at. Possibly getting a slightly bigger servo and some better quality blinds may just work out.

Wish the video was made with more light and a slower hand. I would like to see more of the hardware.
 

kd5crs

Senior Member
Hope the original author is still reading this.

I've been thinking of a similar project, but I wasn't sure whether small servos would deliver enough power to turn the blinds rod. It looks like even the small servo you're showing in the video can turn the blinds without the use of gears. Is this true, or did I miss something?
Howdy! Sorry, I thought I'd set this board up to email me when I got a new reply.

The trick is to remove the manual open-close rod and associated gear system. Then a servo can turn the blinds rod.

With regards to my automated blinds, one of the three blinds still uses the little 9g servo shown in the video. It has been working multiple times a day for 2 years now with no problems. The other two, however, I changed out with a bigger servo (the standard model airplane size, so 44g I think?). Sometimes the blinds would get pushed juuuuust wrong and the little servo couldn't do it. Plus, with the 2-inch blinds, the larger servo fits perfectly into the top piece, eliminating the need for the wooden legs.

Hope that helps!
 

garylcamp

New Member
Thank you so much. It does help. The encouragement helps. If I can ever get ito the new house I will be very happy if I can get some controlled blinds. We designed it so as to have 7 windows on south side and only 1 on the north. But in the desert sun the summers will be rough. I am trying to think of a way to make ultra cheap shades and overhangs (I am on SS income) and as much automation (spelled Pic and Axe) as I can cobble together. I got some 5 in. computer case fans (12v, 200ma) that I think I can use in the attic vents instead of full house fans. Much cheaper, smaller, lower power and more controllable than one big fan. Can not think of a smart (read cheap and easy) way to put "blinds" to shut the air flow in the winter (or at night). Pretty tricky to make them out of Styrofoam sheets, especially if I want to automate them. In work.

Anyway, thanks for the info. I think I will look at the larger 44g servos and better quality blinds for the house. When you say remove the open-close gear do you mead take the gears and mechanisms completely out or just remove the handles? I wonder if putting graphite "key" lube would help. It is non-sticky dry lube.
 
Top