Shop OBEX P1 Docs P2 Docs Learn Events
Tying in more speeds — Parallax Forums

Tying in more speeds

redalnredaln Posts: 11
edited 2009-11-19 02:53 in BASIC Stamp
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

  • FranklinFranklin Posts: 4,747
    edited 2009-11-17 04:13
    Attach your actual program to your next post so we can look at it. Also draw a sketch of how you have things connected.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • redalnredaln Posts: 11
    edited 2009-11-17 04:51
    Thanks I will have these items Tuesday.
  • redalnredaln Posts: 11
    edited 2009-11-17 12:10
    ········ Here is program that does work with our fan. Due to amperage of fan we had to upgrade our resistors and use a·TIP31. and reconfigure·original schematic, for safety reasons.·Our instructor okd this part but left us to figure out command part. I have typed in several things and just cant seem to get correct combo.. I will try to send a schematic soon.·· However·Port/pin··2· tied in with fan is being used in this program and works on the following command:
    ········
    ·'···· ·····[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!!!)
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2009-11-17 13:05
    So, you have an "infinite"·DO...LOOP --·you're trapped.· You need to break out of it.· With a button push?· After·some number of iterations?· How?

    It's an assignment, hope I've started you thinking.
  • redalnredaln Posts: 11
    edited 2009-11-17 15:21
    Yep! If i could get correct info for Fri show and tell at college., it would be great. I will keep plugging away, but any help it would be appreciated. Our class doesnt care how we got info, as teacher directed me to this forum, but he wants us to understand how basic works. So if someone could help breakingout of this loop??? I could explain it to the class in my presentation with a program that has 2 or 3 different speeds in a same loop.. Thanks Russ
  • stamptrolstamptrol Posts: 1,731
    edited 2009-11-17 15:57
    First, make sure your program is set to use the editor software ver 2.5 (click the "Directive" button at the top of the editor page.)

    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
    ·
  • redalnredaln Posts: 11
    edited 2009-11-17 16:34
    Thanks! I do have 2.5 ver and will try WED when next class/lab. I appreciate any more info if needed as I learn more about Basic Stamp and its uses. It seems to be awesome, even for a rookie! Again Thanks and keep info coming. Russ
  • redalnredaln Posts: 11
    edited 2009-11-18 21:45
    · Here are my 3 programs and still dont understand how to incorporate all3 together. I have tried ,next ,goto if then, end, loop etc·and several dozens of remedies. No go. My 3 speeds work great by itself, but someone show me what to edit in my program to make all 3 speeds work in one program?· All 3 are 2.5 versions.


    ···· [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

    ···
  • stamptrolstamptrol Posts: 1,731
    edited 2009-11-19 00:25
    As a prof of mine used to say "...you've got a conceptual hangup here!"

    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
    ·
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2009-11-19 00:52
    "Free your mind and your *** will surely follow."· --Anon--

    Hit PBASIC Help, look·up FOR...NEXT, change up your on and off values.
  • redalnredaln Posts: 11
    edited 2009-11-19 01:12
    ·I get the· grasp of changeup of variables and can see where 50% duty cycle is wrong when you showed me!!! Example 300ms total. I guess when we was doing play for a purpose we lost that in translation on my teams part. I can do that very easy however as for multiple pinouts or ports we are not that advanced yet to do this, so I just have 1 port, ·port 2, is this still possible to run?. So I·my next question at the end of program is what do I type loop, next etc.to incorporate this or is it there in black and white and not comprehending what has been giving to me?·I have looked at basic commands and being a rookie it is still foreign to me. That is I can say.·Again I really appreciate your valuable help. We have put my project on hold until I can communicate to my team correct thoughts. Again thanks to all!! Russ
  • redalnredaln Posts: 11
    edited 2009-11-19 01:22
    If 1 port only port 2 is used, can I put loop until in each offtime and do I put a pause also in between cycle times? I am looking at book and pbasic as of now Tom and PJ. Thanks again russ
  • redalnredaln Posts: 11
    edited 2009-11-19 01:25
    Never mind about pause command I see it now. I will keep on trying!!!!!!
  • redalnredaln Posts: 11
    edited 2009-11-19 01:31
    Never mind on loop either/ go to main is command I see now also! I will be in class Friday to tweak and learn and do the best I can on this. The only thing I am unsure is using only 1 port part if this can go on my part. It works seperately on each program as I said before.. Thanks again! Russ.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2009-11-19 02:42
    Well, that was a bust.
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    a  VAR  Word
    speeds:
      FOR a = 0 TO 500   ' hi
        HIGH 0
        PAUSE 9
        LOW 0
        PAUSE 1
        NEXT
      FOR a = 0 TO 500   'med
        HIGH 0
        PAUSE 5
        LOW 0
        PAUSE 5
        NEXT
      FOR a = 0 TO 500   ' lo
        HIGH 0
        PAUSE 2
        LOW 0
        PAUSE 8
        NEXT
    PAUSE 5000          ' nothing
     
    alternate:
      PWM 0, 255, 5000  ' hi
      PWM 0, 128, 5000  ' med
      PWM 0,  64, 5000  ' lo
    PAUSE 5000
     
    GOTO speeds
    
  • redalnredaln Posts: 11
    edited 2009-11-19 02:53
    No it wasnt /isnt a bust> I will try all including this one. Thanks PJ counsel of despair. Appreciate it! Russ
Sign In or Register to comment.