Tying in more speeds
Hi, I may not explain this right, but I am trying to finish up my final of making a fan run at say· ontime 8000ms high pause· offtime8000 ms low then pause then loop.·However I cant seem to add on· 2 more different speeds· 10000 ms and 500 ms·to· show changing of speeds. I start with do and end with loop. But every time I type in command I cant make it work.Where could I look to or what can I type in for my program to work. Ideas are welcome. My actual program is similar to p138 in process control guide. I am a real novice on this. Thanks.
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
········
·'···· ·····[noparse][[/noparse] declarations ]
·fan····· · pin···· 2········· ' fan driver· I/O
·ontime···con····8000····· ' time to leave fan on
·offtime·· con··· 8000····· ' time to leave fan off
·'·········[noparse][[/noparse] main routine]
·do
···· high fan·················· ' energize fan
···· pause ontime··········· ' pause while running
···· low fan··················· ' de-energize fan
···· pause offtime··········· ' pause while off
loop
····
·· just need to know how to write/incorporate 2 or more speeds in this program to show class of changes in speeds...thanks Russ (novice!!!)
It's an assignment, hope I've started you thinking.
Then look at the editor Help file under "DO". There is a modified version where you can LOOP UNTIL (something occurs). That event can be a switch closure, a counter value, etc. That will let you get out of the loop and go to the second speed loop or readjust the on/off times or whatever you want to do.
It goes without saying that physically drawing a flow chart on paper is the fastest way to understand what your program has to do.
Cheers,
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tom Sisk
http://www.siskconsult.com
·
···· [noparse][[/noparse]declarations]
·fan pin 2 ' fan driver I/O
·on time Con·50 ' time to leave fan on····· (program 1)
·offtime· Con 50 ' time to leave fan off····
·ontime Con 400 ' time to leave fan on····· (program 2)······ (these 3 programs are in actual seperate form
·offtime Con 400 ' time to leave fan off··························· (from each other but still Iam lost)
·ontime Con 10000 'time to leave fan on··· (program 3)
·offtime Con 10000 ' time to leave fan off
·[noparse][[/noparse] main routine]
·do
·high fan ' energize fan
·pause ontime 'pause while running
·low fan 'de-energize fan
·pause offtime 'pause while off
loop
· how should this program read?·· I am correct oneverything hardware wise. Russ
···
Basically, you have three sets of 50% duty cycle which means the motor theoretically is going to run at approximately the same speed. As an exercise, start out by letting the total of ontime + offtime be a constant, say 300. To go slow ontime = 50, offtime = 250, medium speed might be ontime = 150, offtime = 150 and high speed might be ontime=250 and offtime = 50. Note that in your program you have the motor on for 50 mS, off for 50 mS; then on for 400 mS then off for 400 mS; then on for 10 Sec and off for 10 Sec. Not a very smooth running fan!
As mentioned earlier you might use the LOOP UNTIL construct rather than the same do - loop you had way back in the beginning.
For instance, suppose you connected a switches to pin 3 and pin 4. ( I don't know if this is available in your case).
[noparse][[/noparse]declarations]
fan pin 2 ' fan driver I/O
switch pin 3
switch2 pin 4
ontime Con 50 ' time to leave fan on (program 1)
offtime Con 250 ' time to leave fan off
ontime2 Con 150 ' time to leave fan on (program 2) (these 3 programs are in actual seperate form
offtime2 Con 150 ' time to leave fan off (from each other but still Iam lost)
ontime3 Con 250 'time to leave fan on (program 3)
offtime3 Con 50' time to leave fan off
[noparse][[/noparse] main routine]
main:
do
high fan ' energize fan
pause ontime 'pause while running
low fan 'de-energize fan
pause offtime 'pause while off
loop until switch = 1
do
high fan ' energize fan
pause ontime2 'pause while running
low fan 'de-energize fan
pause offtime2 'pause while off
loop until switch2 = 1
goto main
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tom Sisk
http://www.siskconsult.com
·
Hit PBASIC Help, look·up FOR...NEXT, change up your on and off values.