<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>how to give if condition in c in 8051</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/31700/how-to-give-if-condition-in-c-in-8051</link><description> 
Actually i m using adc0804 as input to port 1 and and i want to
drive motor to another port according to adc input. But the problem
is how to give condition in c 
Suppose that i have adc output 11001100, and i want to rotate motor
to particular angle</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: how to give if condition in c in 8051</title><link>https://community.arm.com/thread/61855?ContentTypeID=1</link><pubDate>Thu, 22 Aug 2013 09:55:53 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:cca31162-7acc-42ca-8b2a-3a0ef8f2ab12</guid><dc:creator>surendar sekar</dc:creator><description>&lt;p&gt;&lt;p&gt;
there is no matter behind this....this is simple&lt;/p&gt;

&lt;p&gt;
if(P1==0XCC)&lt;br /&gt;
{ P2^0=1;//POSITIVE TERMINAL OF MOTOR&lt;br /&gt;
P2^1=0;//NEGATIVE TERMINAL OF MOTOR&lt;br /&gt;
}&lt;/p&gt;

&lt;p&gt;
plz check your infinite loop.....&lt;/p&gt;

&lt;p&gt;
That&amp;#39;s all................&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to give if condition in c in 8051</title><link>https://community.arm.com/thread/107020?ContentTypeID=1</link><pubDate>Fri, 12 Apr 2013 01:08:00 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:ca996de3-8ffc-477a-88e1-68323349652c</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;pre&gt;
if( P1 == 0xCC )
&lt;/pre&gt;

&lt;p&gt;
As far as &amp;#39;C&amp;#39; language syntax goes, it is perfectly valid.&lt;/p&gt;

&lt;p&gt;
Whether it correctly implements what you&amp;#39;re trying to achieve is
an entirely different matter!&lt;/p&gt;

&lt;p&gt;
You haven&amp;#39;t said what specific ship you&amp;#39;re using.&lt;/p&gt;

&lt;p&gt;
You haven&amp;#39;t shown your definition of P1.&lt;/p&gt;

&lt;p&gt;
You haven&amp;#39;t said what the &amp;quot;magic number&amp;quot; 0xCC is supposed to
represent.&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;&amp;quot;suppose i am getting adc output 11001100&amp;quot;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
Why &amp;quot;suppose&amp;quot; it? Is it actually happening??&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to give if condition in c in 8051</title><link>https://community.arm.com/thread/81144?ContentTypeID=1</link><pubDate>Fri, 12 Apr 2013 00:24:01 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:52536002-29fd-406e-8c47-f13874c06890</guid><dc:creator>Ankit Bhatt</dc:creator><description>&lt;p&gt;&lt;p&gt;
No program for motor is fine and adc output which is input for
port 1 is also giving right output. But when i am giving condition
then the motor is not rotating.&lt;br /&gt;
suppose i am getting adc output 11001100 which is input to port1 of
8051 microcontroller.&lt;br /&gt;
I am using the following condition :&lt;/p&gt;

&lt;pre&gt;
 if(P1==0xCC)
&lt;/pre&gt;

&lt;p&gt;
&lt;b&gt;Is this condition is valid&lt;/b&gt;&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to give if condition in c in 8051</title><link>https://community.arm.com/thread/81142?ContentTypeID=1</link><pubDate>Fri, 12 Apr 2013 00:21:39 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:869dc6fc-7259-41ec-ba8f-cb7f451e5f3e</guid><dc:creator>Ankit Bhatt</dc:creator><description>&lt;p&gt;&lt;p&gt;
No program for motor is fine and adc output which is input for
port 1 is also giving right output. But when i am giving condition
then the motor is not rotating.&lt;br /&gt;
suppose i am getting adc output 11001100 which is input to port1 of
8051 microcontroller.&lt;br /&gt;
I am using the following condition :&lt;/p&gt;

&lt;pre&gt;
 if(P1==0xCC)
&lt;/pre&gt;

&lt;p&gt;
&lt;b&gt;Is this condition is valid&lt;/b&gt;&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to give if condition in c in 8051</title><link>https://community.arm.com/thread/68214?ContentTypeID=1</link><pubDate>Thu, 11 Apr 2013 13:17:15 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:d761eac8-450c-425f-b666-bf5873336c3f</guid><dc:creator>ImPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
It ain&amp;#39;t that easy.&lt;/p&gt;

&lt;p&gt;
You have to open the books and do some studying.&lt;/p&gt;

&lt;p&gt;
The motor isn&amp;#39;t magically going to &amp;quot;jump&amp;quot; to a new angle. If it&amp;#39;s
a stepper motor, you would normally have to generate a lot of steps
to change it from say 10 degrees to 27 degrees. And you need to keep
track of time length of these pulses etc.&lt;/p&gt;

&lt;p&gt;
So you must figure out which direction to rotate. And how long to
rotate. And what steps are needed to get that motor to do such length
of rotation. And at what speed it can do that. And during that time,
you may still have to look at your input sensor and maybe get a new
direction to go.&lt;/p&gt;

&lt;p&gt;
Good luck.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to give if condition in c in 8051</title><link>https://community.arm.com/thread/61851?ContentTypeID=1</link><pubDate>Thu, 11 Apr 2013 13:15:07 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:a8416092-3628-4ff9-836d-8fc9ad0479b4</guid><dc:creator>Westonsupermare Pier</dc:creator><description>&lt;p&gt;&lt;p&gt;
Maybe if the ADC is supposed to represent the angle to be moved
too, this is the wrong way to achieve it?&lt;/p&gt;

&lt;p&gt;
Perhaps you want to use some math to scale the value on the ADC
(based on it&amp;#39;s range, etc), to an angle (0..359, whatever)&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>