1. Do not share user accounts! Any account that is shared by another person will be blocked and closed. This means: we will close not only the account that is shared, but also the main account of the user who uses another person's account. We have the ability to detect account sharing, so please do not try to cheat the system. This action will take place on 04/18/2023. Read all forum rules.
    Dismiss Notice
  2. For downloading SimTools plugins you need a Download Package. Get it with virtual coins that you receive for forum activity or Buy Download Package - We have a zero Spam tolerance so read our forum rules first.

    Buy Now a Download Plan!
  3. Do not try to cheat our system and do not post an unnecessary amount of useless posts only to earn credits here. We have a zero spam tolerance policy and this will cause a ban of your user account. Otherwise we wish you a pleasant stay here! Read the forum rules
  4. We have a few rules which you need to read and accept before posting anything here! Following these rules will keep the forum clean and your stay pleasant. Do not follow these rules can lead to permanent exclusion from this website: Read the forum rules.
    Are you a company? Read our company rules

Contrling AirCore Gauge with AVR

Discussion in 'DIY Motion Simulator Building Q&A / FAQ' started by stowaway, Mar 3, 2012.

  1. stowaway

    stowaway New Member

    Joined:
    Mar 16, 2009
    Messages:
    213
    Location:
    Gold Coast - Australia
    Balance:
    1Coins
    Ratings:
    +0 / 0 / -0
    I am trying to control a aircore guage I took out of a Volvo Prime Mover with a ATMEGA16L Chip.

    I have tried using FAST PWM and Phase Correct PWM.. with teh below method, and it just causes the pins to go haywire, no sense in them at all.

    for example if I pass the value .5 the pin just goes back and forth.. Does anyone understand how these gauges work?

    Code:
    void setMeterPosition(float pos){
    
    
      // Calculate the voltage on the PWM pins based on the angle we want
      float sinCoilValue = maxAnalogRes*sin(pos);
      float cosCoilValue = maxAnalogRes*cos(pos);
      
      // change the polarity of the coil depending on the sign of the voltage level
      if (cosCoilValue<=0) {  
    	PORTD |= (1 << PD5);  
    		        
      } else {  
    	PORTD ^= ~(1 << PD5);
    	}
    	
      if (sinCoilValue<=0) {
    
    PORTD |= (1 << PD4); 	    
      } else {
    PORTD ^= ~(1 << PD4);      	
      }
    
      // take the absolute value because analogWrite doesn't take negatives
      sinCoilValue = abs(sinCoilValue);
      cosCoilValue = abs(cosCoilValue);
    
      SetPWMOutput(sinCoilValue);
      SetPWMOutput2(cosCoilValue);
     
    
    }
  2. stowaway

    stowaway New Member

    Joined:
    Mar 16, 2009
    Messages:
    213
    Location:
    Gold Coast - Australia
    Balance:
    1Coins
    Ratings:
    +0 / 0 / -0
  3. stowaway

    stowaway New Member

    Joined:
    Mar 16, 2009
    Messages:
    213
    Location:
    Gold Coast - Australia
    Balance:
    1Coins
    Ratings:
    +0 / 0 / -0
    G'day Guys!! HUGE progress today!

    My Guages ending up being Stepper Gauges and NOT Air-core guages.. so once i figured that out, making them move was simply..

    heres a video, ive got it to go faster and less noise too (changed the delay)

    http://www.youtube.com/watch?v=Bn0byV5v ... e=youtu.be