LED state logging and servo sequence

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
mrglasspoole
 
Posts: 7
Joined: Tue Jan 03, 2012 8:45 pm

LED state logging and servo sequence

Post by mrglasspoole »

Hi,

i'm new to the micro-controller stuff and have now an Arduino Mega 2560, a Arduino Ethernet Shield and an Adafruit MicroSD card breakout.
I have a lot of stuff in my head i want to do :)
Also got some books and bin through some tuts and examples.

One thing i want to do is a logger for our central heating. The heating has an LED for everything. So the idea was to just log if the LED is on or off.
But the LDR way is not really a good way. So i want to connect the Arduino parallel to the LED's. How can i do that? With an transistor?

The next problem i have is, how can i play a sequence i recorded to move servos?
I thought there is something like Brookshire's VSA out there that works with Arduinos.
There are all kinds of examples how to trigger servos, but nothing about how to record a sequence and play it back.
Is there really everybody using servo controllers from Parallax or Pololu and DMX and doing it with the PC?
DMX is dying and the Mega 2560 can controller a lot of servos and other stuff and is good for embedded systems.
So i wonder that there is nothing like VSA out there for Arduino.

I found out how to control the servos via my Xbox controller and also to use putty to log the positions.
But just putting the output of the log into the sketch

Code: Select all

void loop()
{
myservo.write(0);
myservo.write(0);
myservo.write(0);
myservo.write(59);
myservo.write(64);
myservo.write(71);
myservo.write(78);
myservo.write(85);
myservo.write(91);
myservo.write(95);
myservo.write(99);
myservo.write(103);
myservo.write(109);
myservo.write(115);
myservo.write(121);
myservo.write(129);
myservo.write(140);
myservo.write(153);
myservo.write(162);
myservo.write(166);
myservo.write(169);
myservo.write(174);
myservo.write(179);
myservo.write(179);
myservo.write(179);
myservo.write(179);
myservo.write(179);
myservo.write(179);
myservo.write(179);
myservo.write(160);
myservo.write(149);
myservo.write(145);
myservo.write(141);
myservo.write(139);
myservo.write(137);
myservo.write(137); 
 delay(15);
}
does not work...

And sure, that would be to much. There needs to be something that says "5s in this position, 2ms and this position" and so on...

User avatar
jasonwebb
 
Posts: 111
Joined: Sat Sep 10, 2011 2:15 pm

Re: LED state logging and servo sequence

Post by jasonwebb »

Not really sure what you mean by "the heating has an LED for everything". Do you mean that each 'function' of the heating unit has an LED that turns on whenever that function is being performed? If you want to detect whether an LED in another circuit is on or off, and you don't have the option of integrating your electronics directly to that other circuit, an LDR is actually a good idea. Simply place the LDR directly onto the LED you want to sense, then cover it all up in black tape so that the LDR will only receive like from that LED.

If you really want to crack open your heating unit and solder wires in there, you risk damaging the unit or making it difficult to maintain in the future. However, you may be able to accomplish this if you're really determined by simply using an alligator clip wire to connect to the anode of the LED you want to sense, and another alligator clip wire to connect to the heating unit's ground. Your Arduino must share ground with the heating unit if you want to do this method, which doesn't sound fun to me.

I have no idea what "Brookshire's VSA" is, but it should be a very trivial matter to play 'sequences' of servo movements. IIRC, one can control servos easily using various libraries, several of which keep track of the servo's position. Simply create an array of values you'd like your servo to reach, then loop through that array, moving from position to position at the speed you want.

Something like this (pseudo-code):

Code: Select all

int positions[] = {2,5,100,5,28,82,3,85};
int currentPosition = 0;

void setup() {
   for(int i=0; i<{length of array}; i++) {
      if( positions[i] > currentPosition ) {
            // make servo go forward
            currentPosition++;
       } else {
           // make servo go backwards
           currentPosition--;
     }
  }
}

User avatar
adafruit_support_bill
 
Posts: 88091
Joined: Sat Feb 07, 2009 10:11 am

Re: LED state logging and servo sequence

Post by adafruit_support_bill »

Simply create an array of values you'd like your servo to reach, then loop through that array, moving from position to position at the speed you want.
Or, to take it a step further, create a table with columns for: servo, position and time. This can be created in any spreadsheet program. Save it to a file on the SD card, the read the file and perform the scheduled actions on the Arduino.

User avatar
mrglasspoole
 
Posts: 7
Joined: Tue Jan 03, 2012 8:45 pm

Re: LED state logging and servo sequence

Post by mrglasspoole »

Do you mean that each 'function' of the heating unit has an LED that turns on whenever that function is being performed?
Yes that is what i mean :-)
And i know now that Opto-isolator's is what i need to do it.
Already got it running on the breadboard with some buttons that simulate the heating unit led's and some 4N35 Opto-isolator's.

I look later into the servo stuff cause i got only one Arduino and need to make one thing after the other :)

User avatar
philba
 
Posts: 387
Joined: Mon Dec 19, 2011 6:59 pm

Re: LED state logging and servo sequence

Post by philba »

I had a project to do something kind of similar though I wound up moving and never carried it through.

I would highly recommend you NOT open up the existing equipment. It's easy enough to sense whether an LED is lit. Don't use LDRs but rather phototransistors. One of the issues I had was being able to see if the LED was on (visually) so I didn't want to obscure it. A PT next to it works pretty well but you will need to compensate for ambient light. There are several ways to do this. I did some experiments with the pull up value and found one that worked in my environment. Another approach is to have two PTs: one as the LED sensor and one as an ambient light sensor and use an opamp to reject common inputs. I had sort of designed (i.e. in my head) a simple pcb with a PT on each side, pullups, opamp, Schmidt trigger and a 3 pin connector (pwd, gnd, signal). It would go to a collector board. The pcb would be placed next to the LED. That's my ideal approach.

Locked
Please be positive and constructive with your questions and comments.

Return to “General Project help”