2012年11月18日星期日

Help! with programming Pololu Maestro 12

Hi all, I'm new to this site and a first time user of a servo controller. I had experience with servos, but that was in RC car applications with a radio and a receiver, but never an automated controller such as pololu so this is very new to me and pretty exciting to see something you programmed come to life. My problem, however, is not to do with servos, but and LED aquarium light I am trying to control.

A member on my local forum posted a write up on how he used the same controller to control his aquarium light. I liked the idea and made a light similar to his original design. He posted his script as well which I adapted and modified it to suit my application. I understand what the script does and how it flows, but to get it to do exactly what i have imagine is what I'm having a little problem with. Here is the script.


CODE: SELECT ALL EXPAND

 What I have is an LED light with 6 channels. 2 white (servo 0 and 1), 2 royal blue (servo 2 and 3) and 2 blue (servo 4 and 5) channels. I have a timer that turns on the whole system at a certain time and the controller will control when and which led to turn on or off. here is my thought process:

-Once the system is turned off, I want all channels to be off
-The royal blue LED will turn on first, starting off at its minimum value and slowly ramping up to its maximum value in 30 mins
-The blue LED will turn on after the royal blue is at maximum power, slowly ramping up from its minimum value to a certain point (~85% of maximum) in 30 mins.
-The white LED will turn on after the blue LED is finish, slowly ramping from its minimum value to a certain point (~70% of maximum) in 1 hour.
-All LEDs will stay at their current position for 6 hours
-The White LED will slowly dim from its current value to minimum and turn off in 1 hour
-The blue LED will slowly dim from its current value to minimum and turn off in 30 mins
-The royal blue LED will slowly dim from its maximum value to minimum and off in 30 mins.
-The controller will not move for another 10 mins, just incase the timer doesnt match up completely with the controller and stays on when the script is finished.

I have ran the script for 2 days now and so far I noticed the time commands I have set in the program doesnt match up with what I had in mind. The first day it was an hour off so I messed with the script (just trial and error) the second day it was 15 mins off. Which im beginning to wonder if there are something wrong with my script. So my question is, are my time commands inline to what i want to do? how do i fix this?


------------------------------------------------
 Re: Help with programming Pololu Maestro 12
by DavidEGrayson

Hello.

I don't see anything wrong with your script, but please keep in mind that the Maestro's internal clock is not as accurate as a watch. The crystal itself has a 0.1% tolerance, so it could lose or gain as much as 86 seconds every day. Also, the Maestro has many tasks to take care of concurrently, so the execution of time of the script can sometimes be hard to predict.

I see you have a lot of arbitrary numbers in your code that affect how long it will take. Have you calculated how long each part of the code should take and made sure that it adds up to 24 hours?

In order to prevent noticeable drift over the months, I would power the Maestro from a wall power adapter that is in turn powered by some sort of standard AC outlet timer. I would expect these timers to be much more accurate than the Maestro. The timer should turn the Maestro off for some time every night in order to reset the Maestro's clock and the state of your script. Then you don't actually have to worry about doing the calculations to make sure that your loop takes exactly 24 hours to execute.

--David


没有评论:

发表评论