element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum Programming my CNC/fan to move based on temperature
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Not Answered
  • Replies 2 replies
  • Subscribers 391 subscribers
  • Views 127 views
  • Users 0 members are here
Related

Programming my CNC/fan to move based on temperature

Former Member
Former Member over 10 years ago

I'm using a Fireball Probotix cnc and attaching a fan to it.  The fan will be cooling a non-uniformly heated bar that has LM34 temperature sensors attached to it.  I need the fan/cnc to move toward the hottest temperature at all times.  Anyways, I'm having troubles writing the code for this.  Does anyone have any experience with anything similar to this and can help me with a flow chart or something?

  • Sign in to reply
  • Cancel
Parents
  • Robert Peter Oakes
    0 Robert Peter Oakes over 10 years ago

    Well knowing the position of each sensor is a must of course so a table with sensor ID, X, Y co-ordinate and its current reading

    reading all sensors into the table (Memory), then locating the one with the highest reading

    move servos/steppers to that X, Y co-ordinate, that should be a simple matter of emmiting Gcode or step and direction if your directly controlling the steppers. GCode is easier if the CNC is already wired to accept it

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Reply
  • Robert Peter Oakes
    0 Robert Peter Oakes over 10 years ago

    Well knowing the position of each sensor is a must of course so a table with sensor ID, X, Y co-ordinate and its current reading

    reading all sensors into the table (Memory), then locating the one with the highest reading

    move servos/steppers to that X, Y co-ordinate, that should be a simple matter of emmiting Gcode or step and direction if your directly controlling the steppers. GCode is easier if the CNC is already wired to accept it

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Children
  • Former Member
    0 Former Member over 10 years ago in reply to Robert Peter Oakes

    Right now I'm using the step and direction/ the tone function. The problem I'm having is getting the cnc to stop moving once it reaches the temperature sensor with the highest temperature.  For now, I'm just using 3 sensors horizontally spaced a few inches apart and the fan is attached to the cnc.

     

    I was thinking of coding it in such a way where when one of the temperatures start to decrease (by the fan) a few degrees, then it would stop (noTone).  But I have no idea how to do that.  Any idea?!

     

     

    Heres the code i'm using to test this out

     

    int tempOutput0=A0; //Defines analog pin 0 as integer tempoutput0

    int tempOutput1=A1; //Defines analog pin 1 as integer tempoutput1

    int tempOutput2=A2; //Defines analog pin 2 as integer tempoutput2

    int fanPower=10; //Defines pin 10 as integer fanPower

    int YDirection=2; //Defines pin 2 as integer YDirection

    int YStep=3; //Defines pin 3 as integer YStep

     

     

    void setup()

    {

    Serial.begin(9600);  //Directs to Serial library and defines baud rate

    pinMode(fanPower, OUTPUT); //Defines the fan's power output

    pinMode(YStep, OUTPUT); //Defines YStep as an OUTPUT (step of the motor)

    pinMode(YDirection, OUTPUT); //Defines YDirection as an OUTPUT (motor direction)

     

     

    }

     

     

    void loop()

    {

       digitalWrite(fanPower, HIGH);

    int rawvoltage0=analogRead(tempOutput0);

    float millivolts0= (rawvoltage0/1024.0) * 5000;

    float fahrenheit0= millivolts0/10;

    Serial.print(fahrenheit0);

    Serial.println(" degrees Fahrenheit1, ");

    delay(1000);

     

     

    int rawvoltage1=analogRead(tempOutput1);

    float millivolts1= (rawvoltage1/1024.0) * 5000;

    float fahrenheit1= millivolts1/10;

    Serial.print(fahrenheit1);

    Serial.println(" degrees Fahrenheit2, ");

    delay(1000);

     

     

     

     

    if (fahrenheit0 > fahrenheit1)

    {

    digitalWrite(YDirection, HIGH); //set the motor direction

    tone(YStep,400);

    }

    else 

    {

    digitalWrite(YDirection, LOW); //set the motor direction

    tone(YStep,400);

     

     

    //if fahrenheit0 or fahrenheit1 starts to decrease then stop

    }

    }

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube