<?xml version="1.0" encoding="UTF-8"?>        <rss version="2.0"
             xmlns:atom="http://www.w3.org/2005/Atom"
             xmlns:dc="http://purl.org/dc/elements/1.1/"
             xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
             xmlns:admin="http://webns.net/mvcb/"
             xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
             xmlns:content="http://purl.org/rss/1.0/modules/content/">
        <channel>
            <title>
									BLDC motor using arduino - Arduino				            </title>
            <link>https://www.tweaking4all.com/forum/arduino/bldc-motor-using-arduino/</link>
            <description>Tweaking4All.com Discussion Board</description>
            <language>en-US</language>
            <lastBuildDate>Sun, 10 May 2026 01:54:57 +0000</lastBuildDate>
            <generator>wpForo</generator>
            <ttl>60</ttl>
							                    <item>
                        <title>RE: BLDC motor using arduino</title>
                        <link>https://www.tweaking4all.com/forum/arduino/bldc-motor-using-arduino/#post-3383</link>
                        <pubDate>Sun, 25 Apr 2021 11:17:38 +0000</pubDate>
                        <description><![CDATA[I have no experience with motors, so I&#039;m just guessing ...
I do see that your code is reading the potentiometer and stores the value in Delay (this would not be a great variable name as it ...]]></description>
                        <content:encoded><![CDATA[<p>I have no experience with motors, so I'm just guessing ...</p>
<p>I do see that your code is reading the potentiometer and stores the value in <strong>Delay</strong> (this would not be a great variable name as it can be confused with the <strong>delay</strong> function) ... should this be <strong>delayTime</strong> instead?</p>
<pre contenteditable="false">int t = analogRead(IN); //From the potentiometer

// Should this be "Delay" or "delayTime" ???
Delay = map(t, 0, 1024, 1, 1000); //we obtain the delay speed using the potentiometer
//we map the values from 1 to 1000 microseaconds

//MAIN CODE FOR LCD VOLTAGE DISPLAY
voltReading = analogRead(battPin);
volts = (voltReading / 1203) * 100;
if (volts == 100) {
  lcd.setCursor(12, 0);
  lcd.print(volts);
  lcd.print("%");
  delay(delayTime);
  lcd.clear();

  Serial.print(volts);
  Serial.print("%");
  delay(delayTime);
} else {
  lcd.setCursor(14, 0);
  lcd.print(volts);
  lcd.print("%");
  delay(delayTime);
  lcd.clear();

  Serial.print(volts);
  Serial.print("%");
  delay(delayTime);
}</pre>]]></content:encoded>
						                            <category domain="https://www.tweaking4all.com/forum/arduino/">Arduino</category>                        <dc:creator>Hans</dc:creator>
                        <guid isPermaLink="true">https://www.tweaking4all.com/forum/arduino/bldc-motor-using-arduino/#post-3383</guid>
                    </item>
				                    <item>
                        <title>BLDC motor using arduino</title>
                        <link>https://www.tweaking4all.com/forum/arduino/bldc-motor-using-arduino/#post-3376</link>
                        <pubDate>Fri, 23 Apr 2021 17:32:02 +0000</pubDate>
                        <description><![CDATA[Hey guys, I just started working with Arduino and Idk what the issue with my code is. The motor is running but on one speed only. I need the pot to increase/decrease the motor speed. This co...]]></description>
                        <content:encoded><![CDATA[<p>Hey guys, I just started working with Arduino and Idk what the issue with my code is. The motor is running but on one speed only. I need the pot to increase/decrease the motor speed. This code is to try the lcd to show battery percentage too. Please, would appreciate any help anyone can give.</p>
<p> </p>
<p>#include &lt;LiquidCrystal.h&gt;</p>
<p>//BLDC CONTROLLER PIN DECLARATION<br />int AA1=3;<br />int AA2=5;<br />int BB1=11;<br />int BB2=10;<br />int CC1=9;<br />int CC2=6;</p>
<p>int enable=2; //This is not used for now, The ESC is always enabled<br />int emfA=A0;<br />int emfB=A1;<br />int emfC=A2;</p>
<p>int fase=1;<br />int deltaA=0;<br />int emA=0;<br />int sum=0;</p>
<p>int IN=A3; //pin A3<br />int Delay=4000;</p>
<p>int it=0;<br />int it2=1;</p>
<p><br />static int delta= 0;<br />static int Lastdelta= -1;</p>
<p>unsigned long previousMillis = 0;</p>
<p>//LCD PIN DECLARATION FOR BATTERY DISPLAY</p>
<p>LiquidCrystal lcd(13,12,8,7,4,1);</p>
<p>int battPin = A4;<br />int delayTime = 1000;<br />int voltReading;<br />int volts;</p>
<p> </p>
<p>void setup() {<br />//SETUP CODE FOR BLDC CONTROLLER</p>
<p>Serial.begin(250000);<br />pinMode(AA1,OUTPUT);<br />pinMode(AA2,OUTPUT);<br />pinMode(BB1,OUTPUT);<br />pinMode(BB2,OUTPUT);<br />pinMode(CC1,OUTPUT);<br />pinMode(CC2,OUTPUT);</p>
<p>pinMode(enable,OUTPUT);</p>
<p>pinMode(IN,INPUT);<br />pinMode(emfA,INPUT);<br />pinMode(emfB,INPUT);<br />pinMode(emfC,INPUT);<br /><br />digitalWrite(enable,HIGH);<br />previousMillis = micros();</p>
<p>//SETUP CODE FOR LCD VOLTAGE DISPLAY<br />lcd.begin(16,2);<br />pinMode(battPin, INPUT);<br />Serial.begin(9600);</p>
<p><br /><br />}</p>
<p>void loop() {</p>
<p>//MAIN CODE FOR BLDC CONTROLER <br />int emA = analogRead(emfA);<br />int emB = analogRead(emfB);<br />int emC = analogRead(emfC);<br />int sum = (emA+emB+emC)/3;</p>
<p>unsigned long currentMillis = micros(); //count time<br /><br /><br />if(currentMillis - previousMillis &gt;= Delay)<br />{<br /><br />previousMillis += Delay;<br /><br />//Phase1 C-B<br />switch(fase){<br />case 1:<br />digitalWrite(AA1,LOW);<br />digitalWrite(AA2,LOW);<br />digitalWrite(BB1,LOW);<br />digitalWrite(CC2,LOW);<br />digitalWrite(BB2,HIGH);<br />digitalWrite(CC1,HIGH);<br />delta = emA-sum;<br /><br />break;</p>
<p>//Phase2 A-B<br />case 2:<br />digitalWrite(AA2,LOW);<br />digitalWrite(BB1,LOW);<br />digitalWrite(CC1,LOW);<br />digitalWrite(CC2,LOW);<br />digitalWrite(AA1,HIGH);<br />digitalWrite(BB2,HIGH);<br />delta = emC-sum;<br />break;</p>
<p>//Phase3 A-C<br />case 3: <br />digitalWrite(AA2,LOW);<br />digitalWrite(BB1,LOW);<br />digitalWrite(BB2,LOW);<br />digitalWrite(CC1,LOW);<br />digitalWrite(CC2,HIGH);<br />digitalWrite(AA1,HIGH);<br />delta = emB-sum;<br />break; <br /><br />//Phase4 B-C<br />case 4:<br />digitalWrite(AA1,LOW);<br />digitalWrite(AA2,LOW);<br />digitalWrite(BB2,LOW);<br />digitalWrite(CC1,LOW);<br />digitalWrite(BB1,HIGH);<br />digitalWrite(CC2,HIGH);<br />delta = emA-sum;<br />break;</p>
<p>//Phase5 B-A <br />case 5:<br />digitalWrite(AA1,LOW);<br />digitalWrite(BB2,LOW);<br />digitalWrite(CC1,LOW);<br />digitalWrite(CC2,LOW);<br />digitalWrite(AA2,HIGH);<br />digitalWrite(BB1,HIGH);<br />delta = emC-sum;<br />break;</p>
<p>//Phase6 C-A<br />case 6:<br />digitalWrite(AA1,LOW);<br />digitalWrite(BB1,LOW);<br />digitalWrite(BB2,LOW);<br />digitalWrite(CC2,LOW);<br />digitalWrite(CC1,HIGH);<br />digitalWrite(AA2,HIGH);<br />delta = emB-sum;<br />break;<br />}</p>
<p>if (Lastdelta &lt; 0){<br />if (delta &gt; 0)<br />{<br />Lastdelta=delta; //save the last delta<br />fase= fase + 1;<br />if (fase &gt; 6) <br />{<br />fase = 1;<br />}<br />}<br />}//Zero cross from - to +</p>
<p>if (Lastdelta &gt; 0){<br />if (delta &lt; 0)<br />{<br />Lastdelta=delta;<br />fase= fase + 1;<br />if (fase &gt; 6) {<br />fase = 1;<br />}<br />}<br />}//Zero cross from + to - <br /><br />}//Case ends</p>
<p> </p>
<p>int t =analogRead(IN); //From the potentiometer<br />Delay=map(t,0,1024,1,1000); //we obtain the delay speed using the potentiometer<br />//we map the values from 1 to 1000 microseaconds</p>
<p>//MAIN CODE FOR LCD VOLTAGE DISPLAY<br />voltReading = analogRead(battPin);<br />volts = (voltReading/1203)*100;<br />if (volts == 100)<br />{<br />lcd.setCursor(12,0);<br />lcd.print(volts);<br />lcd.print("%");<br />delay(delayTime);<br />lcd.clear();</p>
<p>Serial.print(volts);<br />Serial.print("%");<br />delay(delayTime);<br />}<br />else<br />{<br />lcd.setCursor(14,0);<br />lcd.print(volts);<br />lcd.print("%");<br />delay(delayTime);<br />lcd.clear();</p>
<p>Serial.print(volts);<br />Serial.print("%");<br />delay(delayTime); <br />}</p>
<p><br /><br />} //loop ends</p>
<p> </p>
<p> </p>]]></content:encoded>
						                            <category domain="https://www.tweaking4all.com/forum/arduino/">Arduino</category>                        <dc:creator>vaneeza</dc:creator>
                        <guid isPermaLink="true">https://www.tweaking4all.com/forum/arduino/bldc-motor-using-arduino/#post-3376</guid>
                    </item>
							        </channel>
        </rss>
		