電子工作60 – 太陽光追跡式ソーラーパネルの製作

 

概要

前述の電子工作29で、既製品の小型のソーラーバッテリーチャージャー(モデルNo.ES885、秋月で1000円で購入)を使って室内でモデル実験を行った。今回は実際の太陽を東から西方向に追跡することが出来る実用に近い装置を組み立てて動作させてみた。

 

今回製作にあたって考えていたこと

1)     2,3年前に買って置いたソーラーパネル(ETM500,直径10cm、出力2V)ものを3枚使う。

2)     パネルを東から西に回転させるためにDCギヤードモータを使う。

3)     勿論 PICBasic Proと16F819を使う。

4)     出来るだけ簡単にする。

 

回路図

  下に回路図を示す。1本の中空シャフトに3枚のソーラーパネルを平面に貼った板を取り付ける。それをモーターで正/逆方向(東から西方向)に約100度回転させる。回転の両端にはマイクロスイッチが装着してあり回転の起点や終点になる。モーターの回転はドライバ(TA7267BP)に16F819より送られてくる2本の信号によって制御される。シャフトの回転速度の調節はVR500Wで行う。3枚のソーラーパネルは直列につないであり最大6V強の出力が得られる。その1枚からの出力(1−2V程度)を太陽光の強度を示すセンサー信号として16F819に取込んで利用する。十分明くるくなった時の出力約1.5V以上でシステムは起動する。暗くなって出力が約1.5V以下になると定位置(東端マイクロスイッチより少し西方向に少し離れた地点)で停止し、翌日また明るくなるのを待つ。PICやモータの電源は出力DC5VのACアダプタを使用した。電流を50mA程度消費するモータはパネルを動かす時だけ動作する。例えば1サイクル(15分間パネルを太陽に暴露)毎に約1分間通電される。したがって全体の電流消費は最大でも100mA以下でである。Sun exp. SWを設けてパネルの動きを検討する時に使うTest run と実際の太陽への暴露集電 Sun expos (例えば15分間)を選べるようにした。

 

Photo 1

ソーラーパネルの全体図で最上部に3枚のパネル、その下がDCギヤードモータ、一番下が制御基板

 

Photo 2

長屋の窓側の手すりに実際に設置し動作中の様子。回転音は殆んどしない。

 

Photo 3

制御基板: 真中に16F819、左上にモータドライバ、青い部品はVRである。ヒューズは

モータを保護するために設置した。左上端に追加したSun exp SWが見える (2011.11.6)。

 

Photo 4

左の写真はソーラーパネルのシャフトとギヤードモータとの接続部を示している。外径8mmのパネルシャフトと外径6mmのモータ軸を長さ4cmの

強化芯入りのプラスチックチューブ(外径10mm、内径6mm)で結び、レギュラーバンドで締め付けてある。 パネルシャフトが何らかの理由で動か

なくなった場合、モータ軸はプラスチックチューブの中で空転しモータの破損を防いでいる。右の写真は回転の両端に使われていうマイクロスイッチ

で、パネルシャフトに固定した外径3mmのアルミワイヤ(手で曲げられる)が回転の両端でマイクロスイッチをON/OFFさせる。

 

                                

 

結果&コメント

1)     まだ完全ではないがほぼ正しく太陽を追い続ける。

2)     初期設定でOSCCONをOSCCON=%0110000としてしまった。これはOSCCON=%00110000を意味し、Internal clockで500KHzをセットしたことになり、そのままプログラムを作成してしまった。これでPauseの設定時間がすごく遅い理由が分かった。4MHzに比べ500KHzだと4/0.5=8倍だけ処理速度が遅い訳である。とにかく不具合も無いので今回はこれで行くことにした。(Later found 2011.11.7)

3)     RA4にSun exp. SWを設けたので、このピンをanalogからdigitalにするためADCON1の設定を一部変えた(DADAA (RA4-RA0))(2011.11.7)。 

4)     DCモータの制御は回転方向と回転時間で行っている。停止位置など必ずしも正確ではない。中古のGeared step motor を使ってみたいが秋葉原でなかなか見つからない。

5)     3枚パネルからの最大出力は晴天の日で6.8Vほどであった。

6)     パネルの回転角が最大で100度位になるようにVRでモータの回転調整を行う。その場合Sun exp. SWのTest runを使う。

7)     この時点で充電池への充電は試みていない。

8)     複数個(例えば8個)のCdSセンサなどを曲面に設置して太陽に向け位置情報を得るのも一つの方法だ。

9)     ソフト面でまだまだ改良の余地あり。

10)     何らかの原因でDCモータが回り続けた場合の対策が必要: PICをもう1個加え、RB1とRB2のレベル変化をモニタする方法が使えるかもしれない。ドライバからモータへの出力波形はユニークなようで    利用出来るかどうか分からない。

11)     LimitSWwは現在のところダンパーの役しかしていない。

12)     ACアダプタに毎日セットした時間にON/OFFするタイマ(例えばAutomatic Timer AT120 by anx)を装着しておけば、システムの起動時に自動的にリセットがかかって便利だろう。

13)     15−min太陽暴露モードで回転が時々LSWeで停止してしまう問題発生。ソフトを一部変えたが完全には解決していない(as of 2011.11.9)'SolarSCAN2Prac6.bas―>'SolarSCAN2Prac7.bas

14)     ネジ止めコネクタのケーブルが良く破損する(これまで2回経験)。破損するとパネルが定位置で止まらなくなる

 

 

プログラム

太陽が東から昇り、次第に高度を上げて西の方向に進み、最大高度に達した後で高度を次第に下げながら移動し、やがて西に沈むという流れをソーラーパネルが追跡するようにプログラムを組む必要がある。動作原理はこうだ。(1)3枚のうちの1枚のパネルの出力電圧を読込んで回りが十分明るいかどうか(1.5V以上で明るいとする)を判断、もしそうなら先ずパネルを回転させて最東端に到達させる{マイクロスイッチを使う}。(2)パネルを一定間隔づつ西方向へ移動(回転)させながら1枚のパネルの出力電圧データを合計8個集める。(3)そしてその中の最大値を計算する。(4)次にパネルを再び回転させて最東端に移動させた後、得られた最大値の位置情報“I”を使ってその位置まで移動させる。(5)その位置で太陽にパネルを一定時間暴露させて電気を集める。(6)終了したらまた前の(1)に戻って同じ操作を繰り返す。DCモータを制御して回転速度や移動距離(回転角度)を決めるので、各設定値はトライアル&エラー手法で求めた。なお、システムは500KHzのIntenal clockで動作している(4MHzではない)。したがってPauseの時間設定には注意が必要である。 下図はプログラムのフローチャートを示す。

                                         

 

'**********************************************

'SolarSCAN2Prac7.bas - a new simplified version updated from SolarSCAN2Prac3.bas (2011.11.6->11.9-> 11.14)

'Sun exposure/test SW added. Found that the system had been working at a clock speed of 500 KHz. works OK!

'******* Pin connection ********

'Pin 14 - Vdd (+5V)

'Pin 5 - Vss (GND)

'Pin 4 - /MCLR for reset

'Pin 18 - RA1/AN1 - voltage input from one of Solar panels (max 2V)

'Pin 12 - RB6 - H/L input from limit SW (East), pulled up with 10K

'Pin 13 - RB7 - H/L input from limit SW (West), pulled up with 10K

'Pin 7 - RB1 - H/L output to Pin 1 of motor driver (Toshiba's TA7267BP)

'Pin 8 - RB2 - H/L output to Pin 2 of motor driver

'Pin 11 - RB3 - Output to LED(Y) indicating that solar panels are being exposed Sun

'Pin 10 - RB4 - Output to LED(G) indicating that system is STOP mode

'Pin 3 - RA4 - H/L input from Sun exp SW for Sun Exposure/Test-run selection

 

'****** Main program ******

'---- Setting ----

Define ADC_BITS 10       '10-bit ADC used

Define ADC_CLOCK 3      'Internal clock used

Define ADC_SAMPLEUS 50  'Sample timing

 

OSCCON=%00110000  'Internal 500KHz

ADCON1=%10000100  'Right justified, ADCS2=0, DADAA (RA4-RA0)

   

TRISA=%00110010  'RA1, RA4 and RA5=inputs

TRISB=%11000000  'RB6-7=inputs

 

A var WORD [8]    'Declair an Array for 8 16-bit data - very important

Max1 var word     'Note: "MAX" and "MIN" (parameters in PBP) cannot be used (Max1).

Maxvalue var word  'Maximum value found

Vspanel var word   'Vspanel is voltage from one solar panel used as sensor and a 16-bit data

n var BYTE        'Counter

l var BYTE         'Counter

I var byte          'Counter

t var word          'Counter (t>256)

m var Byte         'Counter

 

Motorp1 var PORTB.1    'Motor driver pin1

Motorp2 var PORTB.2    'Motor driver pin2

LimSWe Var PORTB.6    'West-end Limit Switch

LimSWw Var PORTB.7    'East-end Limit Switch

LEDsunexp var PORTB.3  'LED (Y) indicating that solar panels are being exposed to Sun

LEDstop var PORTB.4    'LED (G) indicating that system is STOP mode

SunExpTestSW var PORTA.4  'Sun Exposure/Test-run selection SW (H/L)

 

Start:

Vspanel=0  'These are important!

Motorp1=0

Motorp2=0

SunExpTestSW=0  '11.6

n=0

l=0

I=0

t=0

M=0

 

LEDsunexp=0

LEDstop=0

A(0)=0  'These are very important! No these settings cause an erroneous operation.

A(1)=0

A(2)=0

A(3)=0

A(4)=0

A(5)=0

A(6)=0

A(7)=0

 

'---- Wake-up routine - Outside brightness check ---- 周囲の明るさを判断して起動または待機する部分

SPanelinloop:      

Gosub Vspanelread

if (Vspanel>307) then  'equivalent to about 307 (Vspanel=1.5V)/brightness.

Pause 500

Goto Jump0

Else

oto SPanelinloop

Endif

 

'---- Moving Motor to LSWe then toward West ----パネルを東端に寄せる

Jump0:

Motorp1=0

Motorp2=0

 

LSWeLoop:        'LSWe contact check

Gosub ToEast      'Move motor toward East

If LimSWe=0 then   'Contacted to LimSWe?

Gosub Motorstop

Gosub ToWest

Pause 100         'Return a little bit

Gosub Motorstop

Goto Jump1        'If contacted, go to Jump1

Else

Goto LSWeLoop

Endif

 

'---- Collection of Vspanel data at designated points ----パネル1枚からの出力を8つの位置で合計8個集める

Jump1:

Gosub ToEast      'Move motor toward East

if LimSWe=0 then   'Check again if a continuous contact to LSWe is occurring

Gosub Motorstop

Goto Jump1a

Else

Goto Jump1

Endif

 

Jump1a:

n=0

For n=0 To 7          'Read and collect 8 data

ADCON0=%10001101   'Read Vspanel from ch1

ADCIN 1, A(n)         'Store them in A(n) array

Pause 50

Pause 100   'May take a certain period of time for S. panel to generate full power

Gosub ToWest        'Move to West for 0.3 sec (adjustable)

Pause 300   '0.3 sec

Gosub Motorstop

Next n

 

Pause 200  'from 2000 '10.25

 

'---- Seeking Maxvalue among the collected A(n) array data ----集めた8個のデータの最大値を求める

Max1=0

l=0

Maxvalue=0

 

Max1=A(0)              'First data A(0) assumed to be Max1

For l=1 To 7

  IF Max1 < A(l) Then    'Comparing Max1 with 2nd data

  Max1=A(l)            'If Max1>A(l), Max1 remains as it is after ENDIF

  Endif

Pause 20  '10.25

Next l

Maxvalue=Max1         'Max1 is the maximum value found.

 

'---- Return the solar panel to LSWe ----パネルを東端に寄せる

LSWeLoop1:        'LSWe contact check

Gosub ToEast       'Move motor toward East

If LimSWe=0 then

Gosub Motorstop

Gosub ToWest

Pause 150    'was 100   11.9

Gosub Motorstop

Goto Jump2        'If contacted, go to Jump2

Else

Goto LSWeLoop1

Endif

 

'---- Seeking "I" value corresponding to Maxvalue ----得られた最大値の位置情報“I”を使ってパネルをその位置まで移動させる

Jump2:

If Maxvalue=A(0) then Goto I0   'A(0)-A(7) data are stored in an array A

If Maxvalue=A(1) then Goto I1

If Maxvalue=A(2) then Goto I2

If Maxvalue=A(3) then Goto I3

If Maxvalue=A(4) then Goto I4

If Maxvalue=A(5) then Goto I5

If Maxvalue=A(6) then Goto I6

If Maxvalue=A(7) then goto I7

 

I0: I=0: Goto Jump3     'Jump3 to expose the solar panel to Sun

I1: I=1: Goto JumpX     'If I=1, go to jumpX.

I2: I=2: Goto JumpX

I3: I=3: Goto JumpX

I4: I=4: Goto JumpX

I5: I=5: Goto JumpX

I6: I=6: Goto JumpX

I7: I=7: Goto JumpX

 

JumpX:       'Move the solar panel to West by I

For m=0 to I

Gosub ToWest

Pause 300  'from 600

Gosub Motorstop

Next m

Pause 200 'from 2000 '10.23

 

'---- Expososure to Sun for 15 min ----パネルを太陽に暴露して集電する

Jump3:

If SunExpTestSW=1 Then

High LEDsunexp

t=0

For t=1 to 300  '15 min timer (=900 sec) 15分タイマ

Pause 366  '=about 3 sec

Next t

Low LEDsunexp

Goto Jump4

Else

High LEDsunexp

Pause 732   'equivalent to about 6 sec for Test run テスト用6秒タイマ

Low LEDsunexp 

Goto Jump4

Endif

 

'---- Return the solar panel to LSWe ----パネルを東端に寄せる

Jump4:

LSWeLoop2:         'LSWe contact check

Gosub ToEast       'Move motor toward East

If LimSWe=0 then    'Contacted to LimSWe?

Gosub Motorstop

Goto Jump5        'If contacted, go to Jump5

Else

Goto LSWeLoop2

Endif

 

Jump5:

Gosub ToWest      'Move motor toward West to protect the lever of LSWe

Pause 500         '500 msec

Gosub Motorstop

Goto Start       'Go to Start again またStartへ戻る

 

'****** Subroutines ******サブルーチン類 

Vspanelread:

ADCON0=%10001101   'Read Vspanel from ch1

ADCIN 1, Vspanel

Pause 50

Return

 

ToEast:    'Move motor toward East

Motorp1=0

Motorp2=1

Return

 

ToWest:    'Move motor toward West

Motorp1=1

Motorp2=0

Return

 

Motorstop:   'Stop motor

Motorp1=0

Motorp2=0

Return

'****** End of program -------

 

'Note:

  'melabs U2 Programmer's configurations 16F688

  'Oscillator - INTOSC; WDTE - Disable; Power-up Timer - Enable!

  'MCLRpin - Reset; BODEN - Disable; L.V.Programming - Disable,

  'CCP Mult. wirh – RB2, F.P.M. Wrire Enable - all, CD - Not Protected; Data EPPROM - Not Protected

  'CCP Mult. wirh – RB3, F.P.M. Wrire Enable – all, CD – Not Protected; Data EPPROM - Not Protected

 

(一部改良 2011.11.19)

  上記のシステムで単3ニッケル水素2本への充電を試みた。途中でソーラーパネルが想定される正しい位置に停止しなくなる問題が発生した。これは直列につないである3枚のパネルの内の1枚を太陽光の強さを検知するセンサとして使っているために何らかの干渉がRA1/AN1ピン入力へ起きるためだと考えた。そこで太陽光の強さの検知を独立したもう1枚のソーラーパネルで行うように改良した。下の写真の最上部の四角パネルがそれである。3枚のパネルと同じ軸に固定されているので、回転するとそれらと常に同じ方向を向く。サイズは68x80x4mmで、1.5Vで250mAの出力がある。

 

 したがって回路も以下に示すように一部変更した。3枚のパネルからの出力は充電専用になり、PICとはGNDを共有しない。

 

プログラムも一個所変更した。これまでは3枚のパネルの内の1枚のパネル最大出力は2.0Vであったが、新しいパネルでは最大出力は1.5VなのでWake−up部分の設定を以下のように変えた。

If (Vspanel>307) Then  'equivalent to about Vspanel=1.5V è If (Vspanel>204) Then  'equivalent to about Vspanel=1.0V (201.11.19)

  明るさに対する新しいパネルの出力は小さいからである。新しいパネルの出力が約1.0Vを超えるとシステムは動作を開始する。

 

 

Sun Tracking Solar Charger (English version of the above Electronics Project 60 in Japanese)

  In this project, a 3-panel solar charger and a sensor solar cell are driven by a motor so that they can roughly track the East-to-West movement of the sun (one-dimensional). A 16F819 (PIC) controls the rotation of a shaft to which the 3-panel solar charger, the sensor solar cell and the motor are connected. When the sun rises in the morning and its light becomes sufficiently bright, the sensor solar cell (electrically-independent from the solar charger) installed on the top end of the shaft senses the sunlight and generates a certain voltage, sending it to PIC. If the voltage is higher than 1.0V, the sun tracking operation starts. If not, however, the system waits. Using the Limit SW (East, micro switch) as the starting point, the solar charger is turned a certain angle by the motor, stops to collect a voltage data via Port RA1 and store it in A (0). The similar operation while gradually increasing the angle is repeated step by step, collecting a total of 8 data in A (0)-A (7) at different angles. In the final step, the solar charger is supposed to be in the westmost position. The speed of the motor needs to be adjusted by VR 500W in such a way that one scan (a movement from East-end to West-end) is just able to cover the entire designated rotary angle of about 100 degrees (using Test run mode of Sun exp SW). The maximum value, the highest voltage obtained at a given angular location [I], is calculated among the collected 8 data. Then, the solar charger is turned from the East-end to the angular location [I] of the maximum value where the solar power is collected by the solar charger for 15 minutes. The solar charger spends about 1 minute for each sun tracking operation and 15 minutes for solar power collection. Photo 1Photo 4 shown in the above Japanese section indicate the details of each part of the initial-version solar charger. Photo 5 shown below is its slightly modified version, newly added with a square sensor solar cell that is exclusively used for sensing the strength of sunlight.

 

Details of the main components used:

a)       16F819 – using its internal clock at 500KHz

b)       Solar panel (round, ETM500 2V, 500mA) x 3 – total output >6.5V (bright sunny day – over 30,000 lux) when connected in series; capable of charging 2 or 4 AA/AAA NiMH batteries

c)      Solar panel (cell) (square, ETMP250-1.5V, 250mA) x 1 – used as voltage sensor to find the sunlight direction

d)      Geared motor (second hand, RB-35GM-CA35-12, 12V 32rpm) – works well with a supply voltage of DC 5V and its power consumption about 50mA

e)      Power source – AC adapter (DC 5V 1A) – used for PIC and driving the motor

 

Comments and what have been found:

a)      This solar charger is designed to stop at 8 different angular locations for solar power collection. It first scans the sunlight levels (as voltage levels) of 8 different angular locations, and then it moves to an angular location where the highest sunlight level was recorded, and collects the solar power into NiMH batteries for 15 minutes.

b)      In wintertime, the solar charger operates for about 8 hours. Therefore, it collects the solar power for (8h x 60m)/(15m + 1m)=480/16=30 times 15m x 30=450 minutes.

c)      Near the sunset time, when the sunlight becomes weaker than the designated level, the solar charger stops at a location slightly away from the East-end (Limit SW) and waits there until the sun rises again in the following morning and the sunlight becomes stronger than the designated level.

d)      In the test run, a 24-hour dial preset timer was connected to an AC adapter that supplies DC5V to PIC and the motor. The timer was set to supply the power to the AC adapter only from 7:00 to 18::00, saving the electricity during nighttime.

e)      It was found through 3-day trial run that this prototype solar charger could reasonably well track the sun.

 

Photo 5 Upper section of Sun Tracking Solar Charger

 

 

Program

'SolarSCAN2Prac7.bas - a new simplified version updated from SolarSCAN2Prac3.bas (2011.11.6, 11.9, 11.14, 11.19)

'Sun exposure/test SW added. Found that the system had been working at a clock speed of 500 KHz. works OK!

'Because 500KHz internal clock is used, Pause xxx is different from that when 4MHz internal clock is used.

'Independent solar panel (ETMP250-1.5V, 250mA Aki) was added to precisely measure the intensity of solar power 11.19.

'PicBASIC Pro 2.50A used for compiling

'******* Pin connection ********

'Pin 14 - Vdd (+5V)

'Pin 5 - Vss (GND)

'Pin 4 - /MCLR for reset

'Pin 18 - RA1/AN1 - voltage input from one of Solar panels (max 2V)

'Pin 12 - RB6 - H/L input from limit SW (East), pulled up with 10K

'Pin 13 - RB7 - H/L input from limit SW (West), pulled up with 10K

'Pin 7 - RB1 - H/L output to Pin 1 of motor driver (Toshiba's TA7267BP)

'Pin 8 - RB2 - H/L output to Pin 2 of motor driver

'Pin 11 - RB3 - Output to LED(Y) indicating that solar panels are being exposed Sun

'Pin 3 - RA4 - H/L input from Sun exp SW; Test run or Sun exposure

 

'****** Main program ******

'---- Setting ----

Define ADC_BITS 10     '10-bit ADC used

Define ADC_CLOCK 3     'Internal clock used

Define ADC_SAMPLEUS 50 'Sample timing

 

OSCCON=%00110000  'Internal 500KHz

ADCON1=%10000100 'Right justified, ADCS2=0, DADAA (RA4-RA0)

   

TRISA=%00110010  'RA1, RA4 and RA5=inputs

TRISB=%11000000  'RB6-7=inputs

 

A var WORD [8]    'Declair an Array for 8 16-bit data - very important

Max1 var word     'Note: "MAX" and "MIN" (parameters in PBP) cannot be used (Max1).

Maxvalue var word 'Maximum value found

Vspanel var word  'Vspanel is voltage from one solar panel used as sensor and a 16-bit data

n var BYTE        'Counter

l var BYTE        'Counter

I var byte        'Counter

t var word        'Counter (t>256)

m var Byte        'Counter

 

Motorp1 var PORTB.1    'Motor driver pin1

Motorp2 var PORTB.2    'Motor driver pin2

LimSWe Var PORTB.6     'West-end Limit Switch

LimSWw Var PORTB.7     'East-end Limit Switch

LEDsunexp var PORTB.3  'LED (Y) indicating that solar panels are being exposed to Sun

SunExpTestSW var PORTA.4  'Sun Exposure/Test-run selection SW (H/L)

 

Start:

Vspanel=0  'These are important!

Motorp1=0

Motorp2=0

SunExpTestSW=0  '11.6

n=0

l=0

I=0

t=0

M=0

 

LEDsunexp=0

LEDstop=0

A(0)=0  'These are very important! No these settings cause an erroneous operation.

A(1)=0

A(2)=0

A(3)=0

A(4)=0

A(5)=0

A(6)=0

A(7)=0

 

'---- Wake-up routine - Outside brightness check ----

SPanelinloop:      

Gosub Vspanelread

If (Vspanel>204) then 'equivalent to about Vspanel=1.0V (307 - Vspanel=1.5V)/brightness. changed 11.19

Pause 500

Goto Jump0

Else

Goto SPanelinloop

Endif

 

'---- Moving Motor to LSWe then toward West ----

Jump0:

Motorp1=0

Motorp2=0

 

LSWeLoop:         'LSWe contact check

Gosub ToEast      'Move motor toward East

If LimSWe=0 then  'Contacted to LimSWe?

Gosub Motorstop

Gosub ToWest

Pause 100    'Return a little bit

Gosub Motorstop

Goto Jump1        'If contacted, go to Jump1

Else

Goto LSWeLoop

Endif

 

'---- Collection of Vspanel data at designated points ----

Jump1:

Gosub ToEast      'Move motor toward East

If LimSWe=0 then  'Check again if a continuous contact to LSWe is occurring (10.30 inserted)

Gosub Motorstop

Goto Jump1a

Else

Goto Jump1

Endif

 

Jump1a:

n=0

For n=0 To 7       'Read and collect 8 data

ADCON0=%10001101   'Read Vspanel from ch1

ADCIN 1, A(n)      'Store them in A(n) array

Pause 50

Pause 100   'May take a certain period of time for S. panel to generate full power

Gosub ToWest       'Move to West for 0.3 sec (adjustable)

Pause 300   '0.3 sec

Gosub Motorstop

Next n

 

Pause 200  'from 2000 '10.25

 

'---- Seeking Maxvalue among the collected A(n) array data ----

Max1=0

l=0

Maxvalue=0

 

Max1=A(0)               'First data A(0) assumed to be Max1

For l=1 To 7            'from 8 ?          

  IF Max1 < A(l) Then   'Comparing Max1 with 2nd data

  Max1=A(l)             'If Max1>A(l), Max1 remains as it is after ENDIF

  Endif

Pause 20  '10.25

Next l

Maxvalue=Max1           'Max1 is the maximum value found.

 

'---- Return the solar panel to LSWe ----

LSWeLoop1:        'LSWe contact check

Gosub ToEast      'Move motor toward East

If LimSWe=0 then

Gosub Motorstop

Gosub ToWest

Pause 150   '200 was OK, from 100 11.9 delicate; 100 is too small to cause a stoppage at LSWe

Gosub Motorstop

Goto Jump2        'If contacted, go to Jump2

Else

Goto LSWeLoop1

Endif

 

'---- Seeking "I" value corresponding to Maxvalue ----

Jump2:

If Maxvalue=A(0) then Goto I0   'A(0)-A(7) data are stored in an array A

If Maxvalue=A(1) then Goto I1

If Maxvalue=A(2) then Goto I2

If Maxvalue=A(3) then Goto I3

If Maxvalue=A(4) then Goto I4

If Maxvalue=A(5) then Goto I5

If Maxvalue=A(6) then Goto I6

If Maxvalue=A(7) then goto I7

 

I0: I=0: Goto Jump3     'Jump3 to expose the solar panel to Sun

I1: I=1: Goto JumpX     'If I=1, go to jumpX.

I2: I=2: Goto JumpX

I3: I=3: Goto JumpX

I4: I=4: Goto JumpX

I5: I=5: Goto JumpX

I6: I=6: Goto JumpX

I7: I=7: Goto JumpX

 

JumpX:       'Move the solar panel to West by I

For m=0 to I

Gosub ToWest

Pause 300  'from 600

Gosub Motorstop

Next m

Pause 200 'from 2000 '10.23

 

'---- Expososure to Sun for 15 min ----

Jump3:

If SunExpTestSW=1 then

high LEDsunexp

t=0

For t=1 to 300  '15 min timer (=900 sec)

Pause 732  '=about 6 sec 11.14

Next t

Low LEDsunexp

Goto Jump4

Else

High LEDsunexp

Pause 366

Low LEDsunexp 

Goto Jump4

Endif

 

'---- Return the solar panel to LSWe ----

Jump4:

LSWeLoop2:         'LSWe contact check

Gosub ToEast      'Move motor toward East

If LimSWe=0 then  'Contacted to LimSWe?

Gosub Motorstop

Goto Jump5        'If contacted, go to Jump5

Else

Goto LSWeLoop2

Endif

 

Jump5:

Gosub ToWest      'Move motor toward West to protect the lever of LSWe

Pause 500         '500 msec

Gosub Motorstop

Goto Start

 

'****** Subroutines ******

Vspanelread:

ADCON0=%10001101   'Read Vspanel from ch1

ADCIN 1, Vspanel

Pause 50

Return

 

ToEast:

Motorp1=0

Motorp2=1

Return

 

ToWest:

Motorp1=1

Motorp2=0

Return

 

Motorstop:

Motorp1=0

Motorp2=0

Return

'****** End of program -------

 

'Note:

  'melabs U2 Programmer's configurations 16F688

  'Oscillator - INTOSC; WDTE - Disable; Power-up Timer - Enable!

  'MCLRpin - Reset; BODEN - Disable; L.V.Programming - Disable,

  'CCP Mult. wirh - RB3, F.P.M. Wrire Enable - all, CD - Not Protected; Data EPPROM - Not Protected

 

Menu Pageへ戻る

Topへ戻る