Page 12 of 23 FirstFirst ... 2789101112131415161722 ... LastLast
Results 111 to 120 of 225

Thread: Project: Tempest SXR

  1. #111
    Resident 100HP water-cannon operator SXRguyinMA's Avatar
    Join Date
    Jun 2008
    Location
    MA
    Posts
    5,865

    Default Re: Project: Tempest SXR

    Alright crenn I need you lol. I hooked it up to test it...and the servo spins the wrong way! I can't flip it as there's not enough room. It is possible to make the servo spin the opposite way? I tried reversing the settings in the code (from 5,175 to 175, 5 for servo position) and it didn't change anything. Any ideas?

  2. #112
    Resident 100HP water-cannon operator SXRguyinMA's Avatar
    Join Date
    Jun 2008
    Location
    MA
    Posts
    5,865

    Default Re: Project: Tempest SXR

    ok I figured it out. I set the computer off (no voltage to pin 7) setting to 180 instead of 50 (other end of servo). Then I placed the servo arm in it's correct position so the louvers will be closed when the servo is at this position. I then swapped the map=val figures to make the servo spin the other way and set the range of motion for the servo. These readings will need to be adjusted more once I get the system up and running, so I can set the ROM for the actual temps the case sees, not just ambient or in my mouth lol

    Current code:
    Code:
    // Controlling a servo position using a temperature sensor
    // by Michal Rinott <http://people.interaction-ivrea.it/m.rinott>
    // edited 5-12-2010 by Will Lyon to include base setting for servo if voltage not detected on pin 7
    // edited again 7-4-2010 by crenn to simplify the code a little
    // edited yet again 7-5-2010 by crenn to add features
    // edited again 7-21-2010 by Will Lyon - recalibrated servo positions
    
    #include <Servo.h>
    
    Servo myservo;  // create servo object to control a servo
    
    //Constants
    const unsigned char CONTROL = 7;	// digital pin used to detect if the system is on or off
    const unsigned char temps = 0;		// analog pin used to connect the temp sensor
    const unsigned char MAX_VAL = 10;
    
    //Main global varibles
    char trigger = 0;			// varible used to store the control pin value
    unsigned int val;			// variable to read the value from the analog pin
    
    unsigned int updateAvgtemp(){
    	static int history[MAX_VAL]={0};
    	static unsigned char lastHist=0;
    	static unsigned char numHist=0;
    	unsigned int temp=0;
    	unsigned char counter=0;
    	unsigned char arcount=0;
    	history[lastHist] = analogRead(temps);
    	if(numHist<MAX_VAL)
    		++numHist;
    	arcount=lastHist;
    	++lastHist;
    	if(lastHist>=MAX_VAL)
    		lastHist=0;
    	temp=0;
    	counter=0;
    	do{
    		temp+=history[arcount];
    		arcount--;
    		if(arcount>MAX_VAL)
    			arcount=(MAX_VAL-1);
    		counter++;
    	}while(counter < numHist);
    	return (temp/numHist);
    }
    
    void setup()
    {
      pinMode (CONTROL, INPUT);		// sets the control pin to input
      myservo.attach(9);			// attaches the servo on pin 9 to the servo object
      digitalWrite(CONTROL, LOW);		// ensure internal pullup resistor is disabled.
    }
    void loop()
    {
      trigger = digitalRead(CONTROL);	// read input of pin CONTROL  and store it
      if (trigger == HIGH){			// reads if pin CONTROL, if true, do this:
        val = updateAvgtemp();		// read the value of the temp sensor (value with range of 1024)
        val = map(val, 350, 700, 160, 80);	// scale it to use it with the servo (value between 160 and 80)
        myservo.write(val);			// sets the servo position according to the scaled value
      }
      else {
        myservo.write(180);			// sets servo position to 180 if above statment is false
      }
      delay(125);								// wait 25ms for the servo to move to it's new position and also 100ms until it gets the new value
    }
    I was going to get some vid, but during the servo removal process I accidentally broke one of the servo mounts, so I had to re-glue it and it's setting now. Hopefully later tonight or tomorrow I can get it all back together and get a vid of it working!

  3. #113
    Resident 100HP water-cannon operator SXRguyinMA's Avatar
    Join Date
    Jun 2008
    Location
    MA
    Posts
    5,865

    Default Re: Project: Tempest SXR

    Johnny Five Alive!!!

    Ok well not Johnny Five, but my louvers are alive

    After a little messing with the servo arm mounting, grinding down one of the servo mounts to clear the first louver, messing with the coding and a little silicone spray on the hinges, I'm happy to report it works!!!

    Enjoy


  4. #114
    Will YOU be ready when the zombies rise? x88x's Avatar
    Join Date
    Oct 2008
    Location
    MD, USA
    Posts
    6,334

    Default Re: Project: Tempest SXR

    Nice. Very smooth movement.
    That we enjoy great advantages from the inventions of others, we should be glad of an opportunity to serve others by any invention of ours, and this we should do freely and generously.
    --Benjamin Franklin
    TBCS 5TB Club :: coilgun :: bench PSU :: mightyMite :: Zeus :: E15 Magna EV

  5. #115
    A.B. normal msmrx57's Avatar
    Join Date
    Jan 2008
    Location
    Western Wisconsin
    Posts
    1,602

    Default Re: Project: Tempest SXR

    WHOO HOOOO!!!!! That is kewl as all get out man! rep too
    Quote Originally Posted by SXRguyinMA View Post
    Now, off to the basement to do some fiddling with the rods and such.
    so far left of center i'm in right field

  6. #116
    Stupidity feeds my children blueonblack's Avatar
    Join Date
    Feb 2008
    Posts
    2,616

    Default Re: Project: Tempest SXR

    Awesome!
    “Do not trust people like me. I will take you to museums, and parks, and monuments, and kiss you in every beautiful place, so that you can never go back to them without tasting me like blood in your mouth. I will destroy you in the most beautiful way possible, and when I leave you will finally understand why storms are named after people.”

  7. #117
    rawrnomnom diluzio91's Avatar
    Join Date
    Jan 2010
    Posts
    2,471

    Default Re: Project: Tempest SXR

    okay... that deserves a massive + rep for pure awesomeness
    Not dead yet

  8. #118
    Fox Furry crenn's Avatar
    Join Date
    Apr 2005
    Location
    In the shadows behind you
    Posts
    4,067

    Default Re: Project: Tempest SXR

    Looking good! The easiest way to change the servo direction is this line when you're writing to the servo.

    Code:
    myservo.write(180-val);
    It does a small amount of maths before it writes it, but not too much. But your solution works fine as well.
    Antec Sonata II | Pioneer DVR-212
    Good news! You can follow my website or follow me on twitter!

  9. #119
    If you can't hack it, you don't own it! Oneslowz28's Avatar
    Join Date
    Mar 2007
    Location
    Aiken, Sc
    Posts
    5,084

    Default Re: Project: Tempest SXR

    Looking Good!

  10. #120
    Resident 100HP water-cannon operator SXRguyinMA's Avatar
    Join Date
    Jun 2008
    Location
    MA
    Posts
    5,865

    Default Re: Project: Tempest SXR

    Quote Originally Posted by x88x View Post
    Nice. Very smooth movement.
    Thanks! and thank crenn for the smooth movement!

    Quote Originally Posted by msmrx57 View Post
    WHOO HOOOO!!!!! That is kewl as all get out man! rep too
    Thanks!

    Quote Originally Posted by blueonblack View Post
    Awesome!
    thanks

    Quote Originally Posted by diluzio91 View Post
    okay... that deserves a massive + rep for pure awesomeness
    thank you sir!

    Quote Originally Posted by crenn View Post
    Looking good! The easiest way to change the servo direction is this line when you're writing to the servo.

    Code:
    myservo.write(180-val);
    It does a small amount of maths before it writes it, but not too much. But your solution works fine as well.
    Thanks for the heads up

    Quote Originally Posted by Oneslowz28 View Post
    Looking Good!
    thanks CJ!

    and once again a HUGE thanks to crenn. without his help sorting out the coding it wouldn't be nearly what it is now

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •