<?xml-stylesheet type="text/xsl" href="https://community.element14.com/cfs-file/__key/system/syndication/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>Project: ferris farm post 13</title><link>/challenges-projects/design-challenges/vertical-farming/b/blog/posts/project-ferris-farm-post-13</link><description>Hand written code here is my basic idea for the code to be run every 5 minutes or so If temp is above x activate fan 1 (relay)if temp is below x deactivate fan 1 if humidity is above x activate fan ...</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Project: ferris farm post 13</title><link>https://community.element14.com/challenges-projects/design-challenges/vertical-farming/b/blog/posts/project-ferris-farm-post-13</link><pubDate>Fri, 11 Sep 2015 01:44:16 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:e45e576c-ffa2-4a41-b97e-2658b9247e86</guid><dc:creator>RWReynolds</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;Ok, let&amp;#39;s see what we can figure out here...&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;First I think the simplest thing to do here is to just put everything in the &amp;quot;big loop&amp;quot; inside your main() function.&lt;/p&gt;&lt;p&gt;You can look at breaking things out into separate functions later if you want to clean the code up.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;You will need, at very least, a system tick timer. You can fins an example of this in the stk3200_blink example code. It would be great to use separate timers and interrupts if you can figure them out. But you can get what you want done with the system tick timer. It&amp;#39;s just not as pretty.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Here&amp;#39;s how this can work...&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;In the example code you will see this line:&lt;/p&gt;&lt;p&gt;&lt;strong&gt; /* Setup SysTick Timer for 1 msec interrupts&amp;nbsp; */&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&amp;nbsp; if (SysTick_Config(CMU_ClockFreqGet(cmuClock_CORE) / 1000)) while (1) ;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;This sets up the system tick timer based on based on the core clock divided by 1000. This will create a millisecond timer.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;This code is the interrupt handler for the tick timer. it will fire every 1ms and increment the global variable msTicks. Now if you capture that var at any given time and then continually compare it to a set value as you cycle through the big loop you can use it as a timer for your motor control, ensor reading, etc...&lt;/p&gt;&lt;p&gt;I have put an exmple of this below the interrupt handler code.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;static volatile uint32_t msTicks; /* counts 1ms timeTicks */ This is just here so you can see how it&amp;#39;s declared. Look at the blink example to&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; understand where it has to be declared.&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;/**************************************************************************//**&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt; * @brief SysTick_Handler&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt; * Interrupt Service Routine for system tick counter&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt; *****************************************************************************/&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;void SysTick_Handler(void)&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&amp;nbsp; msTicks++;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* increment counter necessary in Delay()*/&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;/* My example&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;main()&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint32_t motor_timer = 0; // The motor timer variable. You will need one of these for each timer function you want.&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint32_t motor_timeout = 2160000; // This is 6 hours in ms&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; motor_timer = msTicks; //Set the motor timer to the current system ticks count&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; while(1)&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(msTicks - motor_timer &amp;gt;= motor_timeout) // When the system tick counter. msTick, has counted far enough past the captured value the&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // run_motor() function will be executed.&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run_motor();&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;OK, because I&amp;#39;m not sure exactly where you are as far as the C language and programming methods are concerned, take a look at this and let me know what you think. It&amp;#39;s not the best or prettiest way to do it but until I understand your skill level with C I don&amp;#39;t want to get too deep. So we&amp;#39;ll do this one step at a time.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Also, what sensors do you plan to use and how do you plan to interface all the peripherals? I know that&amp;#39;s a big question but it will obviously determine what you need as far as software. What pins to use. What alternate functions to use, etc... You should be able to do everything from the expansion header on the EZR32WG. They have a nice set of GPIO and alternate function pins broke ou there.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Cheers,&lt;/p&gt;&lt;p&gt;Rick&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=421&amp;AppID=120&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: Project: ferris farm post 13</title><link>https://community.element14.com/challenges-projects/design-challenges/vertical-farming/b/blog/posts/project-ferris-farm-post-13</link><pubDate>Wed, 09 Sep 2015 10:25:35 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:e45e576c-ffa2-4a41-b97e-2658b9247e86</guid><dc:creator>RWReynolds</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;Shane, I&amp;#39;ll take a look at your psuedo code over the next couple of days and see if i can help in getting you started on porting it to C.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Also, you said that the motor control code would only run in one direction. That should serve the purpose for this project. But, I am looking at cutting the new motor control code out of my project so you might be able to use that as well.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Cheers,&lt;/p&gt;&lt;p&gt;Rick&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=421&amp;AppID=120&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: Project: ferris farm post 13</title><link>https://community.element14.com/challenges-projects/design-challenges/vertical-farming/b/blog/posts/project-ferris-farm-post-13</link><pubDate>Mon, 07 Sep 2015 18:09:17 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:e45e576c-ffa2-4a41-b97e-2658b9247e86</guid><dc:creator>DAB</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;Are you planning to synchronize the turning just during daylight hours?&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Or are you using lights to keep the growing cycle 24/7?&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;DAB&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=421&amp;AppID=120&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item></channel></rss>