Shop OBEX P1 Docs P2 Docs Learn Events
WOW, This is a Noob Question...but — Parallax Forums

WOW, This is a Noob Question...but

gr8_big_geekgr8_big_geek Posts: 34
edited 2012-04-11 15:37 in BASIC Stamp
Alright All,

I've been working on this far too long I think. I've finished writing my own voice recognition program and that part is working great. I'm just now pulling out my old Parallax bread board and microcontroller so I can automate things in my lab. So here comes the "noob" moment. I'm doing a simple light on/off and I'm messing around with this servo and for the life of me I cannot remember how I solved this back in the day.

<enough of the back story; down to the problem />

Okay, the program goes like so:

{$STAMP BS2}
counter VAR word
FOR counter = 1 TO 150
PULSOUT 10, 1200
PAUSE 20
NEXT

Now that's fine because it flips the light to the correct position on the dimmer but when the program is done...lights out! The darn thing returns to the starting position (which is off). ARRG! How can I get the servo to flip to a position and just stay there until I run another command through the microcontroller?

I know I solved this issue like 3 years ago when I was playing with these before but I cannot find the old HDD that had all of those old programs on there.

Any and/or all help would be great.

Thanks in advance all!

your random Geek~

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2012-04-10 11:26
    How about a listing of your real program? What you've showed is a simple fragment that moves a servo from its initial position to one extreme (2.4ms pulse width), then (after about 3 seconds) stops doing anything (and the servo turns off its motor which then stops holding its position).

    What's the pulse width for a starting position? What's the pulse width for an ending position? Each FOR / NEXT loop (like what you've got) essentially commands the servo to move to some position for the amount of time consumed by the PAUSE x # FOR loops.
  • gr8_big_geekgr8_big_geek Posts: 34
    edited 2012-04-10 11:29
    Actually, that was the whole program. All I need to do is move the servo to that position and then hold there. When I need the dimmer to be moved to another position I will have another program for that command.

    The light is tied into a voice recognition program so when I speak, "lights at 50 percent" the lights will adjust to 50%. The servo is tied into my voice rec. program; so really all I need the servo to do is just hold right there and not move indefinitely.

    PULSOUT 10, 1200 = lights at 100%
    PULSOUT 10, 250 = lights at 0%

    When I speak for the lights to be at any % between 100 and 0 I have a different .bs2 script which runs through my voice rec. program. I simply need the servo to hold where I need it. I'm thinking of a DO...LOOP but I cannot remember the syntax.

    I'm reading through a bunch of Parallax PDF's now trying to remember how to get the servo to hold. I know you have to send pulses to it every so many ms' but I cannot remember how to set up that loop.
  • xanaduxanadu Posts: 3,347
    edited 2012-04-10 11:45
    You're missing
    '{$PBASIC 2.5} 
    
    '



    So you're saying running that code makes the servo move to the switch's on position, and then back? Check you batteries or something. That code moves the servo by adding 1 to your initial 1200 per for loop. That's pushing it past the servos limit as mentioned earlier but shouldn't cause it to reverse direction unless you have some other problem going on there.
  • gr8_big_geekgr8_big_geek Posts: 34
    edited 2012-04-10 11:51
    ' {$STAMP BS2}
    ' {$PBASIC 2.5} 'thank you for this also Jon!
    counter VAR word
    DO
    FOR counter = 1 TO 200
    PULSOUT 10, 1159
    PAUSE 20
    NEXT
    LOOP

    Got it! Sheesh, too much coffee and not enough sleep. It's working fine now. I speak the command and the lights go to the level I need for as long as I need them.

    Thank you everyone for being there! Sometimes, you just need to type it out and then read back through what the heck you are thinking!

    *mad scientist laugh* MUAHAHAHHAAHHAHA

    Now my office is almost completely automated!!!! YAY, I'm almost an official Geek!
  • xanaduxanadu Posts: 3,347
    edited 2012-04-10 12:02
    You're welcome and there's no such thing as a noob question! Your post left me really confused because what you have now doesn't seem much different, and doesn't do anything but hold it in one place. So I'm assuming that in your real program it's not just one DO loop and uses different subroutines triggered by some kind of input listening to your voice recognition hardware. It sounds really cool you should post the whole thing when it's done. I'd like to automate some lights round here myself :) but I'm more interested in the voice recognition part. Good stuff :)
  • gr8_big_geekgr8_big_geek Posts: 34
    edited 2012-04-10 12:16
    Ah, yes...I actually wrote my voice recognition program using C#. It currently holds up to 32 million commands and works surprisingly well. I actually wrote it b/c I was getting frustrated with all of the things I figured should be automated in a home. I'm just now pulling out all of my old microcontrollers to begin automating things throughout the house. My wife is only letting me do it in my lab though (but that's okay the theory would still hold up in a home regardless).

    The Basic Stamp is just to control the little servos and switches that will turn things on and off based on the voice commands of the user. I'm working to expand the way in which the program takes in the information also. I figured by using the accelerometer in an android device I could have the program recognize where in the dwelling you are (based on quadrants. eg: quadrant 1-A is the master bathroom, etc). Then the voice rec. program would turn the devices relevant to your location on.

    It's been a lot of fun I think! :)

    Thanks again for all of your help!
  • StephenMooreStephenMoore Posts: 188
    edited 2012-04-10 14:41
    Impressive sir.

    Here is another voice that would love to get a look see at your command interpreter.

    I have Microsoft Studio and can load C#. The real world interfaces do not do much with out control input and vice versa.

    Regards,

    SM
  • xanaduxanadu Posts: 3,347
    edited 2012-04-11 13:38
    Stephen,

    Here is an interesting article on it, http://www.devx.com/dotnet/Article/30866/1954 and it uses Basic Stamp and has the code to boot!
  • mindrobotsmindrobots Posts: 6,506
    edited 2012-04-11 15:37
    32 million commands!!! I'm having trouble coming up with 32 useful verbs to use for commands!
Sign In or Register to comment.