LM35 thermometer? Answered

I want to make a theromoter with pic16f88 and LM35 sensor and show the results on a 16x2 lcd plzzz  help me out

Question by robot1398 7 years ago  |  last reply 7 years ago


LM35 Sensor? Answered

I wanted to know how to convert the readings from a LM35 sensor to Celsius and Fahrenheit.I need them for a thermometer application. I would also like to have the arduino code to serial print the values 

Question by Bot1398 7 years ago  |  last reply 7 years ago


LM35 circuit design

Hi, any advice on putting an LM35 into a circuit to control a small (120w max) DC immersion heater element so that it maintains water temperature around 38C ? Thanks

Topic by RionZion 1 year ago  |  last reply 1 year ago


what is the c code for temperature indicator using lm35 pic18f uC for range o to 100 degree celcius?

I need a c code for temperature indicator using lm35 pic18f uC for range o to 100 degree Celsius..... As lm35 is for -55 to 150 degree Celsius.....how to configure or code it for 0 to 100 degree Celsius.......?

Question by Riakjanu 2 years ago  |  last reply 2 years ago


microcontroller using Nuvoton and lm35

Hello, anyone here know how to use Nuvoton NUC 140 VE3CN? I get some trouble on connecting the pin and using what kind of library to activate the pin. We already success in compose the main.c but the data can not show in the LCD. I got text like this: warning: unknown conversion type character 0x20 in format [-Wformat=] Thank you in advance

Topic by diah ajengS1 3 years ago


What's Wrong With My Code or My Sensors?

Hey gotta question! So I made an i'ble on how to make your own mini temperature sensor, and it worked great for a while, but after time, the temperature settings started getting more off and off. So what's wrong? I have the right conversion factors! If you go look at the Lm35's data sheet, I have all the conversion factors to convert the analog out from the LM35 to a degrees. Every time I use the LM35 with my arduino, it seems to work OK at first, the slowly slip and get worse. Now on the LM35's data sheet there are 2 schematics for wiring the sensor, should I use the schematic with the resistor for more accurate readings? Thanks!

Topic by HavocRC 4 years ago  |  last reply 4 years ago


1 Arduino + 3 or 4 LM35s?

I am a total beginner, having logged about one hour here (the last hour). Does this sound OK for a first Arduino project? I want to sample and log the temperature outside at the surface and at depth for a total of 4 readings to a depth of around 50cm (20"). The reason is to consider if I should provide my daughter's pet rabbits with an underground burrow as relief against the next heat wave. It seems a nicer option than running a swamp cooler all day. Though I suppose I could use an Arduino + LM35 to turn on and off the swamp cooler :) It looks like I can do it with 4 x LM35s, an Arduino One, some sort of data storage, a 9v battery and a bread board. Any recommendations for if I should use WiFi or an SD card for storage? My guess is the SD card is simpler to programme and maybe less of a battery drain. It seems I just need to hook up the data out of the LM35s to the analogue ports, then loop over the inputs and write the outputs to a file somewhere. And calibration too. Any pointers on how to turn the LM35s into probes that can be buried in the ground? I was thinking I could bind all the probes onto a dowel, dig a hole and bury it. How to extend the LM35 pin outs? Thanks in advance for any suggestions.

Question by FargingIcehole 2 years ago  |  last reply 2 years ago


ICL7107 and LM35 based 7-segment thermometer

I'm trying to create a digital centigrade thermometer based on an ICL7107 3 1/2 digit 7-segment driver/ADC and an LM35 linear centigrade temperature sensor but I'm having a few problems. There doesn't seem to be much online about using the ICL7107 with a LM35 and most of the schematics available are for volt meters, but that's not a massive problem as the LM35 gives 10mV/C linearly. I'm just trying to go based on the few schematics I have found but I'm wondering about the supporting components for the LM35 which seem a little too simple. The first schematic I found was from a Hungarian electronics forum and seems to depict a diode and amplifier being used for the temperature sensing which seems like a bad idea to me. The second seems more like what I'm trying to do. The other few things are the negative voltage source, the first schematic shows an inverter being used as does the datasheet, but the second schematic shows an LMC7660 voltage converter which seems like a better option to me. The second one does also show three diodes in series used to drop the voltage for the LED displays which doesn't seem like the best idea, but I can't think of a better way to do it without attaching resistors to each one as the number of lit segments will be variable. The supporting components for the ICL7107 seem pretty consistent between the two and the schematic so I'm confident those are correct, but I'm looking for some advice on how to connect the LM35 in a way that will give me an accurate readout. Thanks!

Topic by andy70707 5 years ago  |  last reply 1 year ago


Sensor Help with Arduino

Hi all! I need help with trying to figure out datasheets. I was digging through my electronics when I found and LM35 sensor. So I looked up the datasheet but I couldn't find out how to convert the analog output to a temperature. I found an i'ble on how to do it but I want to know how to find that information in the datasheet so that next time I get something I'll be able to do it myself. I looked at all the curves and none of them seemed to be temperature vs. voltage. I also looked through the whole first part and couldn't find the multiplier. Also does that multiplier change with the amount of voltage you supply the LM35 with? Say I use 5 volts. Will it give a different reading over 4.5 volts? There's so much technical and complicated data that I don't know what to look for. Here is the link to the datasheet http://www.ti.com/lit/ds/symlink/lm35.pdf Thanks!

Topic by HavocRC 5 years ago  |  last reply 5 years ago


any one provide me complete code and docs to post temperature on to thing speak using lm35, arduino uno and esp8266

Any one pls male me project on posting sensor data on to thing speak

Topic by iottrainingacpl 1 year ago


Is arduino nano can power many sensors and IC?

Is 5V in arduino nano is enough to power up two IC555, DS1307 RTC, LM35, DHT11, 74HC595N and 74LS14 IC's. 20 x 4 LCD at the same time without affecting LCD brightness and contrast?

Question by Rajkumar2506 1 year ago  |  last reply 1 year ago


temperature controller

I have a code that can increase the duty cycle of the pmw output to control the brightness of my bulb and i have lm35 conneted next to the bulb to sense the temperature and now my problem is i have to add two more additional switches for my gain and make the other two the setpoint of my temp,and i de an attachment of my code

Topic by PapaneE 3 years ago  |  last reply 3 years ago


small 12v heater element control

Hi, looking for a bit of advice from electronically literate folks... I'm planning a low-temp water heating device that will keep a water/yeast/sugar solution at around 38C to produce optimum levels of CO2. so far what i have in mind is using a cheap 12v car immersion heater (the type used for making hot drinks on the go), powered by 4 x 3.7v lithium batteries in series (giving me roughly the right voltage range). The part i'm now trying to figure out is regulating the heating of the solution. I'm considering using an LM35 component to monitor the temperature via contact on the outside of the vessel. What i'm stuck on is what other components would i need in the circuit to take the  voltage output of the LM35 and use it to control the 12v immersion heater to maintain a temperature of around 35 degrees? Any advice would be much appreciated, thanks!

Topic by RionZion 1 year ago  |  last reply 1 year ago


Can anyone write me code for arduino wheather station with 433mhz TX and RX? Answered

I need code for arduino wheater station, which uses sensors: LM35, BMP180, Reed switch ( wind speedmeter) and a potentiometer for wind direction. I use 433mhz TX and RX I will need and code for the RX but to use serial to read the data.  P.S. with Manchester. h Thank you !!! 

Question by Konstantin Dimitrov 3 years ago  |  last reply 3 years ago


Is it ok to post it?

Hey Instructables! So a couple of weeks ago I finished a year long project, automating my room. The project is completly modular so if any piece burns out or fails you can quickly switch it, the project includes automatic lighting controlled via a PIR sensor, an LM35 controlled fan, a miniature green house controlled by another LM35 and it displays the info about humidity and temp, through a 16x2 lcd and DHT11, a combination lock for my door via a keypad, a infrared control that can turn on or of my desk lamp, alarm clock, room lights, solder station and has the function to turn the whole system on or off, it also includes a modified Sony alarm clock, that has a TDA2040 amplifier with aux in and its connected to some speakers around my room. I have all the eagle files and ready to print pdf´s. Everything is controlled by 2 DIY arduinos. I made most of the modules for the sensor array but a couple of the controll modules were made using already existing files on fritzing, and the DIY-Duino https://www.instructables.com/id/DIY-Arduino-or-The-DIY-Duino/ Should I redesign this modules and controller board before uploading, or will crediting the authors of this parts will do?

Topic by GG_Beta 5 years ago  |  last reply 5 years ago


Storing Simple Analog Data

Hey guys! I just got this cool little temperature (LM35) and I had a small problem. I want to upload this sketch to my ATtiny45 and put it on my plane so I could get the temperature from above. Only problem is I have no way of seeing it. So is there a simple, easy solution to storing a couple of numbers? I though I could just set the temperature every 3 minutes to a variable, but if I turned the board off, the data would be lost. So I don't need to store tons of memory just a couple numbers! Thanks!

Topic by HavocRC 5 years ago  |  last reply 5 years ago


How to Embed Youtube Video

Not sure what I am doing wrong. I have embedded videos before but I posted a few new Instructables today and can't seem to get Youtube videos to embed. I tried the techniques on this page. https://www.instructables.com/id/How-to-embed-a-video-into-Instructables/?&sort;=NEWEST&limit;=40 I also tried clicking the embed video icon and pasting the Youtube embed code into the box. It shows a flash box but when previewed (and published) there is no embedded video. For example, this step should have a video embedded. https://www.instructables.com/id/PWM-Fan-Controller/step2/PWM-Fan-Controller-LM35-Sensor-Overview/ I am sure I am missing something simple, I am just not sure what it is...

Topic by abbtech 8 years ago


741 Signal amplifier Answered

How would I go about creating an amplifier using an LM741 to amplify a 0mv-400mv signal to a 0v-4v signal? All the circuits from google or textbooks don't work, or produce strange oscillations. The only way I can get it to work is in inverting mode, where I can get -4v-0v out, which isn't very useful. My specific application for this is for a digital thermometer. I intend to amplify the 0-400mv analogue signal from an LM35 linear temperature sensor, then somehow sample that without using loads of logic or transistors and convert it to decimal or binary, then drive a dual 7-segment display to show the temperature. I have a prototype made using 20 comparators and 10 xor gates, and countless diodes, so if anyone could advise me on an easier way to do that, that would be great. And no PICs/AVRs, I know how to use them and have programmers, but I prefer to do "real" electronics using CMOS chips.

Question by andy70707 8 years ago  |  last reply 8 years ago


Arduino Compatible Component Basic Element Starter Kit

- Great Arduino kit for  beginners. Makes a great basis for a robotics or electronics Instructable. Perfect for kids who want to catch the electronics bug.  - Package includes: 1 x Arduino duamilanove - 1 x Development expansion board - 1 x Mini breadboard - 1 x Breadboard - 1 x Acrylic plate - 1 x LED emitter kit (red / green / yellow; each 5pcs) - 2 x Buzzer - 4 x Push button switch - 2 x Seven segments display - 2 x Mercury switch - 3 x Light dependent resistor - 1 x Adjustable resistor - 1 x Flame sensor - 1 x Infrared receiver - 1 x Resistor kit (200ohm / 1K ohm / 10K ohm; each 10pcs) - 1 x LM35 temperature sensor - 1 x USB cable (48cm) - 65 x Breadboard cable (8~22cm) - 1 x 9V battery - 1 x Battery slot - 1 x Remote control (1 x LR1130 / included) - 2 x Storage case (1-large / 1-small) - 1 x Software CD http://dx.com/p/arduino-compatible-component-basic-element-pack-starter-kit-132807

Topic by GadgetNut 6 years ago  |  last reply 6 years ago


Temperature LED lights for motorcycle

Hi I would like to build a temperature sensing leds for my rid to work on my motor cycle to check for black ice!. I want have this circuit as small as possible (fit in a bike light so can mount on handle bars of my motor bike) I have been able to do this via a Arduino board but when I convert this to work on a Attiny85 it will not read the same results. I think this could be due to the way the Attiny85 converts the elec signal. I use a 4.5 volt battery (3 * 1.5) could this be the problem? Here is the code I have used for both the Arduino (which works great) and also the Attiny85 (not working as should) /* temp lights using Uno & LM35 Arduino */ const int tempPin = A0; const int Temperature= 0; // declare the led pins  const int led01 = 9;   const int led02 = 10;   const int led03 = 11;  //declare the variable for the temp int temp=0;//changed to = 0? int AjustTheTemp= 0; //Declare the leds as outputs void setup() {    Serial.begin(9600);      pinMode (led01, OUTPUT);   pinMode (led02, OUTPUT);   pinMode (led03, OUTPUT); }     // Main Program     void loop() {         // read the voltage from the temp sensor     // and change it to celsius     int reading = analogRead(Temperature); float voltage = reading *5; voltage /= 10; float TemperatureC = (voltage - 0.5) ; //show temp in monitor so can make changes        Serial.print("TEMPRATURE = ");   Serial.print(TemperatureC );   Serial.print("*C");   Serial.println();     delay (1000);//delays the print to monitor                // by 1 sec   if (TemperatureC<(1-AjustTheTemp)) {   digitalWrite(led01, HIGH);   digitalWrite(led02, LOW);   digitalWrite(led03, LOW);   } else if(TemperatureC<(4-AjustTheTemp)){   digitalWrite(led01, LOW);   digitalWrite(led02, LOW);   digitalWrite(led03, HIGH);  }    else if(TemperatureC<(10-AjustTheTemp)){   digitalWrite(led01, LOW);   digitalWrite(led02, HIGH);   digitalWrite(led03, LOW);      }      } /* temp lights using Attiny & LM35 */ //const int tempPin = 0; const int Temperature= 3; // declare the led pins (attiny) const int led01 = 2;   const int led02 = 1;   const int led03 = 4;  //declare the variable for the temp int temp=0;//changed to = 0? int AjustTheTemp= 0; //Declare the leds as outputs void setup() { //  Serial.begin(9600);      pinMode (led01, OUTPUT);   pinMode (led02, OUTPUT);   pinMode (led03, OUTPUT);   pinMode (Temperature, INPUT); }     // Main Program     void loop() {         // read the voltage from the temp sensor     // and change it to celsius     // temp = analogRead(Temperature);     // temp = temp * 0.48828125;        int reading = analogRead(Temperature); float voltage = reading *5; voltage /= 10; float TemperatureC = (voltage - 0.5) ; //show temp in monitor so can make changes        // Serial.print("TEMPRATURE = ");   //Serial.print(TemperatureC );   // Serial.print("*C");   // Serial.println();     //delay (1000);//delays the print to monitor                // by 1 sec   if (TemperatureC<(27-AjustTheTemp)) {   digitalWrite(led01, LOW);   digitalWrite(led02, HIGH);   digitalWrite(led03, LOW);   } else if(TemperatureC<(29-AjustTheTemp)){   digitalWrite(led01, LOW);   digitalWrite(led02, LOW);   digitalWrite(led03, HIGH);  }    else if(TemperatureC<(31-AjustTheTemp)){   digitalWrite(led01, LOW);   digitalWrite(led02, HIGH);   digitalWrite(led03, LOW);      }      }

Topic by minimadmalc 4 years ago  |  last reply 4 years ago


How to show 3 different temperatures using 3 LEDs connected to a ATtiny85?

Hi people I am trying to build a temperature sensor using 3 LEDs. The aim is to have them come on at specific temperatures. This is for my motorcycle ride to work this coming winter. I want to know when the temp goes below 8c down to 5c from 5c down to 0c then below. I have managed to do this via a arduino board & a LM35 sensor and 3 LEDs. But I cant get this to work on the ATtiny85 chip. Below is the code I wrote for this on the arduino. Any help or different program would be of great. *my first attempt at a temp warning light need it to come on when temp lower than 5deg celsius */ int tempPin = A1; int led01 = 8; int led02 = 9; int led03 = 10; int tempMax = 28; int tempMid = 27; int tempMin = 5; int temp; void setup() {   Serial.begin(9600);     pinMode (led01, OUTPUT);   pinMode (led02, OUTPUT);   pinMode (led03, OUTPUT);   pinMode (tempPin, INPUT); }     void loop() {      temp = analogRead(tempPin);      temp = temp * 0.48828125;     Serial.print("TEMPRATURE = ");   Serial.print(temp);   Serial.print("*C");   Serial.println();   delay(1000);   if (temp > tempMax){   digitalWrite(led01, HIGH);   digitalWrite(led02, LOW);   digitalWrite(led02, LOW);   } if (temp < tempMid){   digitalWrite(led01, LOW);   digitalWrite(led02, HIGH);   digitalWrite(led02, LOW);   } if (temp < tempMin){   digitalWrite(led01, LOW);   digitalWrite(led02, LOW);   digitalWrite(led02, LOW); }}

Question by minimadmalc 4 years ago  |  last reply 4 years ago


Arduino Run at the same time?

Hi ,  i got problem with my code which is can't run at the same time. for the Heat is great but the ultrasonic didn't trigger the buzzer which is more than 30cm away. btw here is my code , which part should i change ? Thanks #include #define trigPin 6    //trigPin #define echoPin 7    //echoPin LiquidCrystal lcd(12,11,5,4,3,2); int tempPin = A1;   // the output pin of LM35 int fan = 10;       // the pin where fan is int led = 9;        // led pin int temp; int tempMin = 35;   // the temperature to start the fan int tempMax = 70;   // the maximum temperature when fan is at 100% int fanSpeed; int fanLCD; int duration, distance; int buzzer = LOW; void setup() {   Serial.begin (9600);        //Baud rate   pinMode (trigPin, OUTPUT);  //trig pin as output   pinMode (echoPin, INPUT);   //echo pin as input   pinMode (13, OUTPUT);       //Buzzer pin as output   pinMode(fan, OUTPUT);   pinMode(led, OUTPUT);   pinMode(tempPin, INPUT);   lcd.begin(16,2);   } void ultrasonic() {   digitalWrite (trigPin, HIGH);   delayMicroseconds (1000);   digitalWrite (trigPin, LOW);   duration = pulseIn (echoPin, HIGH);   distance = (duration/2) / 29.1;   if (distance > 30)   {     Serial.print(distance);     Serial.println(" cm");     digitalWrite (13, HIGH);   }   else   {     Serial.println (distance);     Serial.println ( "cm");     digitalWrite (13, LOW);   } } void heat() {   temp = readTemp();     // get the temperature   if(temp < tempMin) {   // if temp is lower than minimum temp     fanSpeed = 0;      // fan is not spinning     digitalWrite(fan, LOW);         }   if((temp >= tempMin) && (temp <= tempMax)) {  // if temperature is higher than minimum temp     fanSpeed = map(temp, tempMin, tempMax, 32, 255); // the actual speed of fan     fanLCD = map(temp, tempMin, tempMax, 0, 100);  // speed of fan to display on LCD     analogWrite(fan, fanSpeed);  // spin the fan at the fanSpeed speed   }   if(temp > tempMax) {        // if temp is higher than tempMax     digitalWrite(led, HIGH);  // turn on led   }   else {                    // else turn of led     digitalWrite(led, LOW);   }   lcd.print("TEMP: ");   lcd.print(temp);      // display the temperature   lcd.print("C ");   lcd.setCursor(0,1);   // move cursor to next line   lcd.print("FANS: ");   lcd.print(fanLCD);    // display the fan speed   lcd.print("%");   delay(200);   lcd.clear();   } float readTemp() {  // get the temperature and convert it to celsius   temp = analogRead(tempPin);   return temp * 0.48828125; } void loop() {    ultrasonic();   heat(); }

Question by Melromeo 5 years ago  |  last reply 5 years ago


Arduino | Run 2 Function at the same time.

Hi , i wanna ask about 2 function which is Ultrasonic and Heat that run at the same time  , For me , i just got Heat running as i want but the Ultrasonic doesn't trigger the buzzer if object (Laptop) 30cm away from the ultrasonic. I've been trying since last week but the result is still the same ;'( Btw here is the code , i've seperate it to 2 function which is Ultrasonic and Heat.  i hope u guys can guide me which part should i change or Add. Thanks in advance ;) //*********************************** #include #define trigPin 6    //trigPin #define echoPin 7    //echoPin LiquidCrystal lcd(12,11,5,4,3,2); int tempPin = A1;   // the output pin of LM35 int fan = 10;       // the pin where fan is int led = 9;        // led pin int temp; int tempMin = 35;   // the temperature to start the fan int tempMax = 70;   // the maximum temperature when fan is at 100% int fanSpeed; int fanLCD; int duration, distance; int buzzer = LOW; void setup() {   Serial.begin (9600);        //Baud rate   pinMode (trigPin, OUTPUT);  //trig pin as output   pinMode (echoPin, INPUT);   //echo pin as input   pinMode (13, OUTPUT);       //Buzzer pin as output   pinMode(fan, OUTPUT);   pinMode(led, OUTPUT);   pinMode(tempPin, INPUT);   lcd.begin(16,2);   } void ultrasonic() {   digitalWrite (trigPin, HIGH);   delayMicroseconds (1000);   digitalWrite (trigPin, LOW);   duration = pulseIn (echoPin, HIGH);   distance = (duration/2) / 29.1;   if (distance > 30)   {     Serial.print(distance);     Serial.println(" cm");     digitalWrite (13, HIGH);   }   else   {     Serial.println (distance);     Serial.println ( "cm");     digitalWrite (13, LOW);   } } void heat() {   temp = readTemp();     // get the temperature   if(temp < tempMin) {   // if temp is lower than minimum temp     fanSpeed = 0;      // fan is not spinning     digitalWrite(fan, LOW);         }   if((temp >= tempMin) && (temp <= tempMax)) {  // if temperature is higher than minimum temp     fanSpeed = map(temp, tempMin, tempMax, 32, 255); // the actual speed of fan     fanLCD = map(temp, tempMin, tempMax, 0, 100);  // speed of fan to display on LCD     analogWrite(fan, fanSpeed);  // spin the fan at the fanSpeed speed   }   if(temp > tempMax) {        // if temp is higher than tempMax     digitalWrite(led, HIGH);  // turn on led   }   else {                    // else turn of led     digitalWrite(led, LOW);   }   lcd.print("TEMP: ");   lcd.print(temp);      // display the temperature   lcd.print("C ");   lcd.setCursor(0,1);   // move cursor to next line   lcd.print("FANS: ");   lcd.print(fanLCD);    // display the fan speed   lcd.print("%");   delay(200);   lcd.clear();   } float readTemp() {  // get the temperature and convert it to celsius   temp = analogRead(tempPin);   return temp * 0.48828125; } void loop() {    ultrasonic();   heat(); } //***********************************

Topic by Melromeo 5 years ago  |  last reply 2 years ago


500W electric scooter control and instrumentation with Arduino mega

1. Introduction DC 500W motor control with an Arduino mega to limit starting current and to vary the speed of the scooter. The battery is in 24V, 10A.h. The following table summarizes their characteristics: https://i58.servimg.com/u/f58/17/56/35/17/a014.jpg https://i58.servimg.com/u/f58/17/56/35/17/a111.jpg 2. Bibliography: Link download : sketch_escooter_feed_back_reel_V1.ino https://drive.google.com/file/d/0B_fB3GAsM02FSlRTWHdyRkhuUW8/view?usp=sharing escooter_ampli_SIMULINK.mdl https://drive.google.com/file/d/0B_fB3GAsM02FOW9OdmlhdDhJZGc/view?usp=sharing escooter feed back ISIS.DSN https://drive.google.com/file/d/0B_fB3GAsM02FOXdRWFN5OWRMQkE/view?usp=sharing youtube  :  "study trotinette electric e-scooter 100W et 350W, wiring"  youtube https://www.youtube.com/watch?v=QqJ2-YiE8Tg&index;=75&list;=PLfZunVn_gcq7EOurXuWU2sRFmh6CbiUiL Article: «Study of electric scooters 100W and 500W (Arduino), Revue 3EI 2017» Pdf? Book «I realize my electric vehicle» at DUNOD 3. Open loop program To test the programming, we simulate the program in ISIS, as can be seen in the following figure. In addition, we have an LCD display to display data (duty cycle corresponding to the PWM at 32Khz, motor current, motor voltage, action on the pushbuttons, 4 push buttons are used. BP1 to manually increment the duty cycle, BP2 decrement it. BP3 set the duty cycle to 0, corresponding to the brake contact. The speed of the motor is practically proportional to the duty cycle https://i58.servimg.com/u/f58/17/56/35/17/a211.jpg We made our own current amplifier called a step-down chopper but it is possible to buy a shield There are many cards for Arduino to control DC motors especially of low powers and also of great powers as can be observed on the following links.http://www.robotpower.com/products/MegaMotoPlus_info.html http://www.robotshop.com/en/dc-motor-driver-2-15a.html https://www.pololu.com/file/0J51/vnh3sp30.pdf https://i58.servimg.com/u/f58/17/56/35/17/a310.jpg But all these chopper shields measure the current internally but there is no current limitation. In order to have a current limitation, an analog current loop is required using specialized AOP or IC or a fast digital current loop. But what should be the value of the limitation current? The choice of the current value is normally for the 1-hour operation service in order to be able to carry out relatively long climbs without reaching the critical temperature of the engine. In our case, the limitation current must be Limiting motor = Power / Upper battery = 500W / 24V = 20A In addition, the power transistor of the chopper can only support 50A in our case. But in open loop, it has no current regulation, so as not to exceed the maximum current, a ramp of the duty cycle will be used. A 0.1 second interruption routine will be used to measure the voltage of the current (sample measurement, sample). This sampling time is arbitrary but does not allow to be faster than the rise time of the current because the electric time constant of the motor is L / R = 1.5 ms. Open loop operation with a 25.5s (8bit) ramp and 0.1s interrupt routine provides a good understanding of the operation of a DC motor drive. The display will only be done every 0.2s to have a stability of the digits on the screen. In addition, a digital filtering will be done on the current and the voltage on 4 values therefore on 0.4s. [b] Algo open loop [/b] Interrupt Routine All 0.1S Read voltage and current Loop loop (push button scan) If BP1 = 1 then increment PWM If BP2 = 1 then decrement PWM If BP3 = 1 then PWM = 0 Displaying variables every 0.2s Code: [Select] // include the library code: #include #include #include #define SERIAL_PORT_LOG_ENABLE 1 #define Led     13       // 13 for the yellow led on the map #define BP1     30       // 30 BP1 #define BP2     31       // 31 BP2           #define BP3     32       // 32 BP3 #define LEDV    33       // 33 led #define LEDJ    34       // 34 led #define LEDR    35       // 35 led #define relay   36       // 36 relay #define PWM10    10      //11   timer2    LiquidCrystal lcd(27, 28, 25, 24, 23, 22); // RS=12, Enable=11, D4=5, D5=4, D6= 3, D7=2, BPpoussoir=26 // Configuring variables unsigned   int UmoteurF = 0;  // variable to store the value coming from the sensor unsigned   int Umoteur = 0; unsigned   int Umoteur2 = 0; unsigned   int Umoteur3 = 0; unsigned   int Umoteur4 = 0; unsigned   int ImoteurF = 0;  unsigned   int Imoteur = 0; unsigned   int Imoteur2 = 0; unsigned   int Imoteur3 = 0; unsigned   int Imoteur4 = 0;            byte Rcy=0 ;    // 8bit duty cycle unsigned    int temps; // the setup function runs once when you press reset or power the board void setup() {   pinMode(Led, OUTPUT);   // Arduino card   pinMode(LEDV, OUTPUT);   pinMode(LEDR, OUTPUT);   pinMode(LEDJ, OUTPUT);   pinMode (PWM10,OUTPUT);     // Pin (10) output timer2   //  digitalWrite(LEDV,LOW);   Timer1.initialize(100000);         // initialize timer1, and set a 0,1 second period =>  100 000   Timer1.attachInterrupt(callback);  // attaches callback() as a timer overflow interrupt   lcd.begin(20, 4);    Serial1.begin(9600);   TCCR2B = (TCCR2B & 0b11111000) | 0x01;         //pin 10  32khz    http://playground.arduino.cc/Main/TimerPWMCheatsheet                                                   //http://www.pobot.org/Modifier-la-frequence-d-un-PWM.html   //   analogWriteResolution(bits)      https://www.arduino.cc/en/Reference/AnalogWriteResolution lcd.setCursor(0,1); lcd.print("Rcy"); lcd.setCursor(10,1); lcd.print("Um"); lcd.setCursor(5,1); lcd.print("Im"); lcd.setCursor(10,1); lcd.print("Um"); lcd.setCursor(20,1); // 4 lines display * 20 characters lcd.print("BP1+"); lcd.setCursor(25,1); lcd.print("BP2-"); lcd.setCursor(29,1); lcd.print("BP3=0"); } // Interruptions  tous les 0.1s void callback()  { temps++; //toogle state ledv for check   if ( digitalRead(LEDV)== 1 ) {digitalWrite(LEDV,LOW);}     else {digitalWrite(LEDV,HIGH);}     analogWrite(PWM10,Rcy);   // frequency Umoteur=analogRead(A0); Imoteur=analogRead(A1); Imoteur2=Imoteur; Imoteur3=Imoteur2; Imoteur4=Imoteur3; ImoteurF=(Imoteur4+Imoteur3+Imoteur2+Imoteur)/4 ; Umoteur2=Umoteur; Umoteur3=Umoteur2; Umoteur4=Umoteur3; UmoteurF=(Umoteur4+Umoteur3+Umoteur2+Umoteur)/4 ;   }// End routine // Loop corresponding to main function void loop() {    // BP + LED   if ((digitalRead(BP1))==1) {     lcd.setCursor(20,0);      // Column line     lcd.print("BP1");     digitalWrite(LEDR, LOW);        digitalWrite(LEDJ, LOW);     Rcy++;                        // PWM incrementation     if ( Rcy>254)  {Rcy=254;}     delay(100);               //8bits * 100ms = 25S increment 25ssecond slope     }        if ((digitalRead(BP2))==1) {     lcd.setCursor(20,0);     lcd.print("BP2");             Rcy--;      if ( Rcy<2)  {Rcy=2;}  // PWM almost at 0, engine stop         delay(100);      digitalWrite(LEDR, HIGH);     digitalWrite(LEDJ, HIGH);     }   if ((digitalRead(BP3))==1) {     lcd.setCursor(20,0);     lcd.print("BP3");      Rcy=2;               // PWM almost at 0, engine stop     } if (temps>=2)  { lcd.setCursor(0,0); lcd.print("                "); // Erase line lcd.setCursor(0,0);     lcd.print(Rcy); lcd.setCursor(5,0); ImoteurF=(ImoteurF)/20;     //resistance (5/1024)*(10/0.25ohm) si ACS712 66mV/A                            // For resistance 1ohm (ImoteurF) / 20; Simulation 5/25 lcd.print(ImoteurF); lcd.setCursor(10,0); UmoteurF=UmoteurF*10/38;                              //10/38   10/30 simula if (Umoteur>ImoteurF){UmoteurF=UmoteurF-ImoteurF;  }  //U-R*I lcd.print(UmoteurF); temps=0; }// End if time    } // End loop https://i58.servimg.com/u/f58/17/56/35/17/dsc_0614.jpg Since there is a limit of 9000 characters in the forum below Open loop program feature previous The interrupt routine lasts only 250 microseconds, the loop of the main program which scans the action of push buttons is 13micros and the display time of all data is 11ms. Thus, it is possible to improve the sampling period and thus the speed of the regulation of the current. The Arduino makes it possible to make the instrumentation of the scooter so to know the power, the consumption in Ah and Wh, to measure the speed, to know the consumption according to Wh / km, to measure the temperature of the engine, Have a safe operation. But for now we will see how to limit the current 4. Closed loop program, limited current control The sampling period will increase to 0.01 seconds (interrupt routine) If the current is less than the desired value, then the duty cycle can be increased or decreased to the desired value which is the setpoint. On the other hand, if the motor current is greater than the limiting value, there is a rapid decrease in the duty cycle. So as not to exceed the value of the duty cycle if it is saturated to 254 maximum and to the minimum value 6. Code: [Select] if (Imoteur<4000)                    // No current limitation at (20A * 10) * 20 = 4000   {if (consigne>Rcy)   {Rcy=Rcy+1;}   // Pwm ramp + 1 * 0.01second pure integrator    if (consigne    if ( Rcy>254)  {Rcy=254;}           // Limitation of duty cycle    analogWrite(PWM10,Rcy);   // Frequency 32kHz timer2}         } if (Imoteur>4000)  { Rcy=Rcy-5;              // No current filtering, to be faster                     if ( Rcy<6)  {Rcy=5;}       // Rcy is not signed, nor the PWM therefore Rcy minimum must not be less than 6                   analogWrite(PWM10,Rcy);   // Frequency 32kHz timer2}                        } 5. Closed Loop Program, Limited Current Control with Acceleration Handle An acceleration handle provides a 0.8V voltage when not operated and a 4.5V voltage when the handle is fully engaged. Instead of using pushbuttons to increase or decrease the speed setpoint, an acceleration handle will be used Code: [Select] Upoignee=analogRead(A3); // The relation in Upoign and the setpoint which corresponds to the duty cycle corresponds to if (Upoignee>100) { consigne=(Upoignee/2);     //0=a*200+b    et 255=a*800+b                      consigne= consigne-100;                   }                            else { consigne=0;   }               if (Upoignee<100) { consigne=0;  }     // redundancy     6. Temperature and safety program of the motor with the current measurement The outdoor temperature measurement can be easily performed by the LM35 component which charges 0.01V by degrees Celsius Code: [Select] temperature=analogRead(A2); //lm35 0.01V/°C temperature=temperature/2;       // Temperature coefficient lcd.setCursor(5,2); lcd.print("      "); lcd.setCursor(5,2); lcd.print(temperature);   // Display in ° C lcd.setCursor(9,2);      // Erasing secu display lcd.print("     ");   if (temperature>80 ) {lcd.setCursor(9,2);         // If motor external temperature is above 80 ° C                      lcd.print("secuT");                       Rcy=0;} In addition, thermal safety by measuring the motor current will be added. If the limitation current is greater than 10s then the motor will no longer be powered for 30s. A "secu" display will appear on the LCD display. This safety makes it possible to cut the motor on slope too high and when blocking the engine but it would be necessary to add the measurement of the speed in the latter case Code: [Select] if (timesecurite>=10000 ) {flagarret=1;      // If limitation current for a current of more than 10s                               timerepos=0;                               consigne=0;                               Rcy=0;                                 timesecurite=0;}       //   Then stop engine during a downtime    if (flagarret==1 ) {lcd.setCursor(9,2);         // If limiting current for a current of more than 20s                      lcd.print("secU");  }     //   Then stopping the motor for a stop time and display                                                     if (timerepos>=30000 &&  flagarret==1) {flagarret=0;                                           lcd.setCursor(9,2);      // After a rest time here of 30s                                            lcd.print("       ");   }   The display can be observed if the temperature is above 80 ° C https://i58.servimg.com/u/f58/17/56/35/17/a017.jpg Thermal safety by measuring the motor current (digital thermal relay) which allows to know the image of the internal temperature of the engine would be ideal. But for this, it is necessary to know well the thermal modeling of the motor. 7. Measurement of the energy capacity of the battery The energy capacity of a battery is in A.H, we will display the value in mA.H to have a high accuracy. The capacity will be in A.Second in the following equation. So to have in mA.H, it will be divided by capacity by3600. Capacity (A.s) n = I * Te + Cn-1 with Te = 0.01s and I multiplied by 10 So in the interrupt routine Code: [Select] capacity=ImoteurF+capacity ; And in the display Code: [Select] lcd.setCursor(0,3); // Display of energy capacity lcd.print("C mA.h="); capacity1=capacity/(18000);   //18000=3600*5  5=> Current measurement coefficient lcd.print(capacity1); To check a current of 10A with an adjustable resistor and after 30s, the capacity must be 83mA.H 8. Power and modeling with SIMULINK Modeling helps to understand the vehicle and its control. In addition, it is possible to compile the control part directly into the Arduino program from simulation under Simulink. But it will not be possible to simulate the instrumentation with the LCD display. In the following figure, we can observe the simulation of the programming of the chopper with the current limitation with Simulink. In the following figure, the green box shows the duty cycle control to vary the speed and the red border the current limitation. The controller of the control is here a simple integrator but it is possible to carry out a multitude of control. https://i58.servimg.com/u/f58/17/56/35/17/azub_c15.jpg In the previous figure, it can be observed that the current is well limited to 25A from 2s to 9.5s. Then, the current reaches 10.8A under established speed regime at 22.5km / h. The dynamics are similar to the tests carried out. With a slope of 5%, the cyclic ratio reaches only 100% as can be seen in the following figure. The speed will reach painfully 19km / h with a current of 24A and a motor power of 580W. See article: Study of electric scooters 100W and 500W (Arduino), 9. First conclusion It is easy to control a 500W DC motor with an Arduino and some components So repair many scooters that are in DC motors. But it takes some knowledge (automatic, engine) to know how to properly manage the engine and limit its current so as not to damage it The display of the speed, the distance, the operating time to know the Watt.km / km can also be realized with a menu 2. The .ino program as an attached file, But it is not possible to put an attached file in ISIS electronic labcenter? What is this forum? It would be desirable that the compiler could generate the.cof to debug in Isis and test the program line by line .... Arduino still has to make a lot of effort to be on the same level as other microcontrollers 10. speed measurement (tachometer) Velocity measurement is carried out using a hall effect sensor SS495 or A1324 which counts each revolution of the wheel. It is enough to enter the perimeter of the wheel of the scooter (130mm of radius therefore 0.816m in the case To have the speed, it is enough just to divide the number of turn of wheel on an arbitrary time of 1s to have a minimum speed of 0.81m / s therefore of 2.93 km / h. In addition, an average filter with 3 values will be used to display the speed. At 25km / h, there will be 8.5 laps. To count the turns, an external interrupt routine will be used on input INT0 21 of the mega card. http://www.locoduino.org/spip.php?article64 To simulate the speed, a pulse on input 21 will be used with a duty cycle of 10%. https://i58.servimg.com/u/f58/17/56/35/17/a018.jpg Code: [Select] void INT0b21() {   Tspeed++;   // External interruption to count the number of turns } // In the set up declare the interrupt routine when the 5V edge of the magnet detection is done   attachInterrupt(digitalPinToInterrupt(21), INT0b21, RISING );  // External interruption // In loop if (temps09>=5)  {        // 1 second loop lcd.setCursor(13,2);      // Erasing speed lcd.print("kph     "); lcd.setCursor(16,2); speed1=Tspeed*2937;      //1tour*816*3.6/1s=2.937km/h speed2=speed1;           //Tspeed (rate/seconde) speed3=speed2; speedF=(speed1+speed2+speed3)/3000;   // To put in kph lcd.print(speedF,1);    // Display to the nearest tenth Tspeed=0;   // Reset counter temps09=0;  //reset time } To improve the accuracy of the velocity measurement, it is possible that the sampling time of the velocity measurement is dependent on the velocity. For example: For speeds less than 10km / h sample at 1second, but above 10km / h sample at 2 seconds. 11. Distance measurement for autonomy The distance corresponds to the total number of turns of the wheel multiplied by the perimeter of the wheel. So do not set the number of turns to 0 for each sample. On the other hand, the reset of the distance will be done when pressing the reset of the Arduino Mega. The distance display will be displayed to the nearest second. At 32km / h, it will take 2 minutes to do 1km as can be seen in the following figure: https://i58.servimg.com/u/f58/17/56/35/17/a019.jpg Code: [Select] void INT0b21() {   Tspeed++;   // External interruption to count speed   nbrRate++; } lcd.setCursor(13,4);      lcd.print("km      ");  // distance=(nbrRate*816)/1000;  //distance m distance=distance/1000;  //distance km lcd.setCursor(15,4);      lcd.print(distance,1);  You can observe the electrical installation with the chopper, the arduino, and the display when the program is set up https://i58.servimg.com/u/f58/17/56/35/17/dsc_0613.jpg 12. Synthesis The RAM space is used only at 4% and ROM space at 3%, for an Arduino mega. So we could take an arduino a little smaller. But, there are 8 Lipo cells to make the 24V power supply to power the engine via the chopper. Therefore, the voltage measurement of each element will be on the Arduino with a JST connector. This measurement makes it possible to know if a cell with an internal resistance which begins to pose a problem and to know if the balancing of each cell has indeed been carried out. It is possible to switch to 36V with 12 cells also with the arduino mega without using an external shield that multiplex 24 analog inputs on input A0 It is possible to send all data to a smartphone via Bluetooth HC06 via pins 20, 21, RX1 and TX1. But the application under android realized under JAVA Studio can not be shared on this forum. This part will not be explained. After having made the instrumentation of this scooter, a study should be carried out on the precision of the measurements, it is possible to read "Instrumentation of a low-power electrical motor vehicle" eco marathon "type Revue 3EI N ° 81, July 2015 http://www.fichier-pdf.fr/2015/09/07/instrumentation-vehicule-faible-consommation-eco-marathon/

Topic by Iutgeiisoissons 2 years ago