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
Shift it! Warehouse Automation Design Challenge
  • Challenges & Projects
  • Design Challenges
  • Shift it! Warehouse Automation Design Challenge
  • More
  • Cancel
Shift it! Warehouse Automation Design Challenge
Forum System software for checking motor temperature and for giving appropriate sound indication
  • News
  • Forum
  • Projects
  • Leaderboard
  • Files
  • Members
  • Mentions
  • More
  • Cancel
  • New
Join Shift it! Warehouse Automation Design Challenge to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 30 replies
  • Subscribers 42 subscribers
  • Views 1251 views
  • Users 0 members are here
  • design challenge
  • shift it
Related

System software for checking motor temperature and for giving appropriate sound indication

manojroy123
manojroy123 4 months ago

Flowchart for detecting motor temperature and giving sound indiction.

image

In the above flowchart you can see how the system software works. First it checks for motor temperature and gives proper indication about it. Bellow is the working video of the system.

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

Arduino code

First we read sensor value from ADC.

 // Read sensor value
         int newValue = analogRead(A1);

Than we filter those value using median filter. Median Filter function code is given bellow. There were many software filter available like SMA(Simple mean average), LMA(Logarithmic mean average), median filter. SMA was still giving lots of error, so we have used median filter for processing sensor data. it was still giving some error. We are looking for more better software filter for processing sensor values.

/*Median Filter */
// Median filter function
int median(int *array, int size) {
  int sorted[size];
  // Copy array
  for (int i = 0; i < size; i++) {
    sorted[i] = array[i];
  }

  // Simple bubble sort
  for (int i = 0; i < size - 1; i++) {
    for (int j = 0; j < size - i - 1; j++) {
      if (sorted[j] > sorted[j + 1]) {
        int temp = sorted[j];
        sorted[j] = sorted[j + 1];
        sorted[j + 1] = temp;
      }
    }
  }
  

After filtering the Raw ADC sensor data using median filter. We convert the filtered value to voltage. Code for which is given bellow.

 int rawValue = filteredValue;
  float voltage = rawValue * 0.00323 ;  // Convert to voltage
  const float Rref = 992.0; //1K ohm referance resistor
 
  // Calculate sensor resistance from voltage divider formula
  float Rt =  Rref*( voltage / (3.307 - voltage));

After converting to voltage. We convert the voltage value to temperature using "Invert Callendar-Van Dusen" technique which has some constant in it. bellow is the code for it.

// Callendar-Van Dusen coefficients for standard PT1000 (α = 0.00385)
const float A = 3.9083e-3;
const float B = -5.775e-7; 
const float R0 = 1000.0;  // PT1000 resistance at 0°C

//Function for voltage to temperature convertion
float calculateTemperature(float Rt) {
  float temp = -A + sqrt(A * A - 4 * B * (1 - Rt / R0));
  temp = temp / (2 * B);
  return temp;
}

After doing all the required processes we simply print this value in serial terminal and give appropriate buzzer indication based on algorithm shown in flowchart. bellow is the code for it.

// the loop function runs over and over again forever
void loop() {
    digitalWrite(LED_BUILTIN, HIGH);
       delay(10);
      /*Median Filter Local Varibales*/
      // Read sensor value
         int newValue = analogRead(A1);
         int filteredValue;
      // Store new value in buffer
          readings[index1] = newValue;
          index1 = (index1 + 1) % windowSize;

      // Check if buffer is full
          if (index1 == 0) bufferFilled = true;


      // Apply median filter only when buffer is filled
  if (bufferFilled) {
    filteredValue = median(readings, windowSize);
    Serial.print("Raw: ");
    Serial.print(newValue);
    Serial.print("  Filtered: ");
    Serial.println(filteredValue);
  } else {
    Serial.print("Raw: ");
    Serial.print(newValue);
    Serial.println("  (Warming up)");
  }
         
       //Serial Read Write
     
       int rawValue = filteredValue;
  float voltage = rawValue * 0.00323 ;  // Convert to voltage
  const float Rref = 992.0; //1K ohm referance resistor
  float Res = (Rref*voltage)/(3.3-voltage);
 



// Calculate sensor resistance from voltage divider formula
  float Rt =  Rref*( voltage / (3.307 - voltage));

  // Invert Callendar-Van Dusen to get temperature (for T ≥ 0°C)
  float temp = calculateTemperature(Rt-20.0);

  Serial.print("Raw ADC Value: ");
  Serial.print(rawValue);
  Serial.print(" => Voltage: ");
  Serial.print(voltage, 3);  // 3 decimal places
  Serial.println(" V");
  Serial.println(" Resistance");
  Serial.println(Rt-20.0);
  Serial.println(" Temperature");
  Serial.println(temp);

//Buzzer program
  if(Rt > 1174 and Rt < 1194){
        digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
         delay(100);                       // wait for a 100 milisecond
           for(int a = 0; a<5; a++){
                            digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
                            delay(100);
                            digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
                            delay(100);  
                            }
        }
   else if(Rt >= 1194){
                         digitalWrite(LED_BUILTIN, LOW);   // turn the LED off (Low is the voltage level)
                         delay(1000);      
                      }
    

}

  • Sign in to reply
  • Cancel

Top Replies

  • Jan Cumps
    Jan Cumps 4 months ago in reply to manojroy123 +2
    Your code does not do that: if(Rt > 1174 and Rt < 1194){ // ... 48, 49 } else if(Rt > 1194){ // 51, 52... } 50° is unsafe according to your comment above (it's above 45°, but not above 50°). But…
  • Jan Cumps
    Jan Cumps 4 months ago +1
    delay(100); // wait for a second This will not do what you expect. See the delay() documentation: Description Pauses the program for the amount of time (in milliseconds) specified as parameter…
  • michaelkellett
    michaelkellett 4 months ago in reply to manojroy123 +1
    I have told you, in another thread, that you can't decide on a better filter without looking at the noise signals you want to get rid of and comparing them with the signal you want to keep. From what…
Parents
  • shabaz
    shabaz 4 months ago

    Just out of curiosity I copy-pasted your code and tweaked slightly into a file that can be built on any PC: https://gist.github.com/shabaz123/6af531f3ef202713dcf5b3dbd8153bad

    I think your ADC is 10-bit. The code just provides some example ADC values and calculates the output.

    If you run it, you'll see this:

    PS C:\development> g++ test11.c
    PS C:\development> .\a.exe
    adcVal: 550 temperature: 33.801365
    adcVal: 552 temperature: 36.150436
    adcVal: 554 temperature: 38.520874
    adcVal: 556 temperature: 40.913486
    adcVal: 558 temperature: 43.328476
    adcVal: 560 temperature: 45.765839
    adcVal: 562 temperature: 48.226185
    adcVal: 564 temperature: 50.709911
    adcVal: 566 temperature: 53.217026
    adcVal: 568 temperature: 55.748127
    adcVal: 570 temperature: 58.303619
    

    The question is, why didn't you look at the voltages that were coming out of your circuit (e.g. with a multimeter, or a 'scope), and then what did you expect the ADC values to be? It doesn't make sense to fly blind, which is what you're doing. 

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • manojroy123
    manojroy123 4 months ago in reply to shabaz

    I have checked the ADC values and than adjusted it on calculation. Standard ADC value per bit for that ic was 0.00305 but it wasn't accepting it so I adjusted it's value to 0.00323 than I started getting accurate result including temperature of ice without setting it's temperature. I guess there is not fault in that setting.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Reply
  • manojroy123
    manojroy123 4 months ago in reply to shabaz

    I have checked the ADC values and than adjusted it on calculation. Standard ADC value per bit for that ic was 0.00305 but it wasn't accepting it so I adjusted it's value to 0.00323 than I started getting accurate result including temperature of ice without setting it's temperature. I guess there is not fault in that setting.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Children
  • shabaz
    shabaz 4 months ago in reply to manojroy123

    "getting accurate result"

    How do you figure that? What ADC value would represent (say) 50 degrees? What ADC value would represent 50.5 degrees? What about 51 degrees?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • 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