Show Posts
Pages: 1 ... 5 6 [7] 8 9 ... 20
91  Using Arduino / Interfacing w/ Software on the Computer / Re: arduino Eclipse MAC and Windows on: July 07, 2013, 09:17:33 pm
I am not exactly sure what you are trying to do but...

If you want to run Eclipse to compile Arduino code then there is no better way of doing that than the newest V2.1.0.4 version of the Arduino Eclipse plugin:
http://iloapp.baeyens.it/blog/blog?

I've written some installation instructions:
http://trippylighting.com/teensy-arduino-ect/arduino-eclipse-plugin-installation/
92  Using Arduino / Networking, Protocols, and Devices / Re: Wire.h error working with Eclipse on: June 28, 2013, 05:43:37 am
If you are using the Arduino Eclipse Plugin there are provisions made to import a complete library not just a particular file out of the library.
Highlight your project and select "import". That will present you with a selfexplanatory selection to either " import a folder containing source code ...." Or "import Arduino libraries...".
When selecting the latter it will present a list of all the libraries that come with the Arduino IDE and all the libraries in your personal libraries folder.
93  Using Arduino / LEDs and Multiplexing / Re: How to vary brightness of high-powered LED with arduino on: June 16, 2013, 04:42:32 pm
No! What you're paying for is a fully developed integrated system that is aimed at a very specific low-volume market. It likely comes well packaged with documentation, and is probably backed by a support and business infrastructure. THAT is what you are paying for! Reducing this to pure hardware cost only is a bit naive.

@OP
http://www.ledengin.com/products/emitters#LZ4 LedEngin makes some High Power specialty LEDs two versions of UV LEDs are amongst them. Then you need a power supply and a constant current LED driver.
This one http://ledsee.com/index.php/new-products/arduino-6-channel-led-shield-035-07-1a-detail for example should work and plugs right on top of an Arduino.
94  Using Arduino / LEDs and Multiplexing / Re: Connecting RGB LED Anode on: June 12, 2013, 07:41:47 pm
http://www.adafruit.com/blog/2012/11/30/tutorial-arduino-lesson-3-rgb-leds-arduino/
95  Using Arduino / Networking, Protocols, and Devices / Re: Wifi Dongle on: May 30, 2013, 07:13:56 pm
He's going to plug that into a USB power supply. Yes, you should be able to connect that to an Ethernet shield. You should be able to connect most WiFi routers to the Ethernet Card. A TP-Link TL WR 703n works fine here for example.
96  General Category / General Discussion / Re: The arduino Yun; cool, but what are some examples of how to leverage it? on: May 22, 2013, 05:48:26 pm
I think the ability to wirelessly program an Arduino board could be a killer feature. The Yún uses the same WiFi chipset as a TP-Link TL WN703n  http://wiki.openwrt.org/toh/tp-link/tl-wr703n/ar9331_pinout.
Something somewhat hacked but working has been done before http://www.cse.dmu.ac.uk/~sexton/ENGD2003/openwrt/arduino%20teensy%20openwrt.html. Would be interesting to see what interface is used on the Yún to communicate with the Atheros.
97  Using Arduino / LEDs and Multiplexing / Re: PWM dithering explanation on: May 20, 2013, 08:30:07 pm
Very interesting. Never thought of that.

Little correction on the article. The flicker frequency " for lack of better words" of 30 is too low. For a TV that's ok as usually pixels are not turned from full on to full off etc.
However PWM dimming does just that so the min frequency that will not be noticed by most people is 100Hz.
98  Using Arduino / LEDs and Multiplexing / Re: Controlling 8 stepper motors from one Arduino 328 on: May 14, 2013, 05:25:49 am
I am sure you could write some software and build some electronics to accomplish the task, however, here is a solution that will allow you to use servos without a headache. It has 16 servo channels and a small well written library.

http://www.adafruit.com/products/815
99  Using Arduino / LEDs and Multiplexing / Re: blink-without-delay slowing things by factor 10 ? on: May 08, 2013, 05:22:37 pm
@tmd,

Thanks! You are absolutely correct and your bullet points explained it very clearly. It pains me that the value of 256 ms really stared me in the face and I still did not get it. I got the same explanation on the Teensy forum using a lot less words :-)
100  Using Arduino / LEDs and Multiplexing / Re: blink-without-delay slowing things by factor 10 ? on: May 07, 2013, 06:45:15 pm
The measurement values I provided in the starting post are for a complete fade using the ledOne(0,0,0,255,255,25) 256 times to cross the color cube from all-off to all-on. So I have not measured the speed of the routine directly e.g. by switching a digital pin on-off and using my oscilloscope but for comparative purposes its good enough.

The three lines you marked as "not needed" do just that.

However, I believe that really does not answer the question why eliminating/out-commenting that one line of code:
Code:
previousMillis = currentMillis;
Speeds up the code by several factors.

Even more puzzling is that I use this same code in the rgbFade Method and it does not seem to have the same effect there. the only difference is that I don't use it within the if(){} structure.
101  Using Arduino / LEDs and Multiplexing / Re: blink-without-delay slowing things by factor 10 ? on: May 07, 2013, 05:22:56 am
Well..I did intend to use micros() at some point just to see if it would make any difference, but it did not, so I have changed it back already.

What does however seem to be slowing down the process is this line:

Code:
previousMillis = currentMillis;

There seem to be two reasons for that.
1. Both are of a different type "unsigned long" and "long"
2. They are 32 bit values

Changing the unsigned long to a long - while not the end solution - already showed improved execution time. My idea is to use pointers instead of copying bytes. I yet have to try that out.
102  Using Arduino / LEDs and Multiplexing / blink-without-delay slowing things by factor 10 ? on: May 06, 2013, 06:50:49 pm
The code below works in conjunction with my High Power RGB LED shield http://ledshield.wordpress.com. The shield is connected to the Arduino compatible Teensy3 per I2C bus.
The core routine is an adapted 3D Bresenham algorithm to with the three coordinates being red, green, blue. each time through the main loop the algorithm advances one pixel in 3D RGB space (I guess in that case it's really a voxel ). I apologize for the lack of commention/documenting. This is still under heavy development.

When out-commenting the blink-without-delay code marked as such in the main loop (at the very end) the fading algorithm runs substantially faster than with it enabled (the value for "interval" is set to 0). The rough measurement for an 8-bit fade from r,g,b 0,0,0 --> 255,255,255 appears to be dependent on which frequency I am running the I2C bus with. Going from 100kHz to 2.4MHz results in a 10x increase. When the blink-without-delay code is enabled there is no increase in execution speed beyond 4ookHz.

Is there an alternative method to mills() or am I using this incorrectly or inefficiently ?

Without blink-without-delay code

100 kHz --> 337 ms
400 kHz --> 97 ms
600 kHz --> 75 ms
800 kHz --> 58 ms
1000 kHz --> 53 ms
1200 kHz --> 47 ms
1500 kHz --> 42 ms
2000 kHz --> 36 ms
2400 kHz --> 33 ms

with blink-without-delay

100kHz --> 337 ms
400kHz --> 256 ms
600kHz --> 256 ms
800kHz --> 256 ms
1000kHz --> 256 ms
1200kHz --> 256 ms
1500kHz --> 256 ms
2000kHz --> 256 ms
2400kHz --> 256 ms

Code:
#include "i2c_t3.h"
#include "HPRGB2.h"

long interval = 0;
long previousMillis = 0;
long previousMillisTimer = 0;
int current;

class RGBFader:
public HPRGB {
public:
  RGBFader (uint8_t mcp4728ID = 0x00, uint8_t pca9685ID = 0x00);
  void randomLineInit(void);
  void randomLine(void);
  void rgbFade(uint8_t x1, uint8_t y1, uint8_t z1,uint8_t x2,uint8_t y2,uint8_t z2);
 
private:
  int16_t  xd, yd, zd;
  uint8_t  x, y, z;
  uint16_t ax, ay, az;
  int8_t   sx, sy, sz;
  int16_t  dx, dy, dz;
  uint8_t  x1, y1, z1;
  uint8_t  x2, y2, z2;
  uint8_t  r, g, b;
  boolean newLine;
  boolean (RGBFader::*pLine)();
  uint16_t MAX(uint16_t a, uint16_t b);
  uint16_t ABS(int16_t a);
  int8_t ZSGN(int16_t a);
  boolean lineXdominant(void);
  boolean lineYdominant(void);
  boolean lineZdominant(void);
};

RGBFader::RGBFader(uint8_t mcp4728ID, uint8_t pca9685ID)
{
  _mcp4728ID = mcp4728ID;
  _mcp4728_address = (MCP4728_BASE_ADDR | _mcp4728ID);
  _pca9685ID = pca9685ID;
  _pca9685_address = (PCA9685_BASE_ADDR | _pca9685ID);
}

/* find maximum of a and b */
inline uint16_t RGBFader::MAX(uint16_t a, uint16_t b) {
  return (a > b) ? a : b;
}

/* absolute value of a */
inline uint16_t RGBFader::ABS(int16_t a) {
  return (a < 0) ? -a : a;
}

/* take sign of a, either -1, 0, or 1 */
inline int8_t RGBFader::ZSGN(int16_t a) {
  return (a < 0) ? -1 : a > 0 ? 1 : 0;
}

void RGBFader::randomLineInit(void){

    uint8_t rand;
    rand = random (1, 4);
   
    x1 = 0;
    y1 = 0;
    z1 = 0;
   
    if (rand==1) { x2=255; } else { x2= random(0, 256); };
    if (rand==2) { y2=255; } else { y2= random(0, 256); };
    if (rand==3) { z2=255; } else { z2= random(0, 256); };

    x = x1;
    y = y1;
    z = z1;
   
    dx = x2 - x1;
    dy = y2 - y1;
    dz = z2 - z1;
     
    ax = ABS(dx) << 1;
    ay = ABS(dy) << 1;
    az = ABS(dz) << 1;

    sx = ZSGN(dx);
    sy = ZSGN(dy);
    sz = ZSGN(dz);

    if (ax >= MAX(ay, az)){                 /* x dominant */
      yd = ay - (ax >> 1);
      zd = az - (ax >> 1);
      pLine = &RGBFader::lineXdominant;
    }
    else if (ay >= MAX(ax, az)){            /* y dominant */
      xd = ax - (ay >> 1);
      zd = az - (ay >> 1);
      pLine = &RGBFader::lineYdominant;
    }
    else if (az >= MAX(ax, ay)){            /* z dominant */
      xd = ax - (az >> 1);
      yd = ay - (az >> 1);
      pLine = &RGBFader::lineZdominant;
    }
}

void RGBFader::rgbFade(uint8_t x1, uint8_t y1, uint8_t z1, uint8_t x2, uint8_t y2, uint8_t z2){
    newLine = (this->*pLine) ();
    if (newLine){
     
    unsigned long currentMillis = micros();           
    Serial.println(currentMillis-previousMillisTimer);
    previousMillisTimer = currentMillis;
   
    x = x1;
    y = y1;
    z = z1;

    dx = x2 - x1;
    dy = y2 - y1;
    dz = z2 - z1;

    ax = ABS(dx) << 1;
    ay = ABS(dy) << 1;
    az = ABS(dz) << 1;

    sx = ZSGN(dx);
    sy = ZSGN(dy);
    sz = ZSGN(dz);

    if (ax >= MAX(ay, az)){                 /* x dominant */
      yd = ay - (ax >> 1);
      zd = az - (ax >> 1);
      pLine = &RGBFader::lineXdominant;
    }
    else if (ay >= MAX(ax, az)){            /* y dominant */
      xd = ax - (ay >> 1);
      zd = az - (ay >> 1);
      pLine = &RGBFader::lineYdominant;
    }
    else if (az >= MAX(ax, ay)){            /* z dominant */
      xd = ax - (az >> 1);
      yd = ay - (az >> 1);
      pLine = &RGBFader::lineZdominant;
    }
  }
}

void RGBFader::randomLine(void){
  newLine = (this->*pLine) ();   
 
    if (newLine){
    int rand;
    rand = random (1, 4);
   
    x1 = x2;
    y1 = y2;
    z1 = z2;
   
    if (rand==1) { x2=0; } else { x2= random(0, 256); };
    if (rand==2) { y2=0; } else { y2= random(0, 256); };
    if (rand==3) { z2=0; } else { z2= random(0, 256); };

    x = x1;
    y = y1;
    z = z1;

    dx = x2 - x1;
    dy = y2 - y1;
    dz = z2 - z1;

    ax = ABS(dx) << 1;
    ay = ABS(dy) << 1;
    az = ABS(dz) << 1;

    sx = ZSGN(dx);
    sy = ZSGN(dy);
    sz = ZSGN(dz);

    if (ax >= MAX(ay, az)){                 /* x dominant */
      yd = ay - (ax >> 1);
      zd = az - (ax >> 1);
      pLine = &RGBFader::lineXdominant;
    }
    else if (ay >= MAX(ax, az)){            /* y dominant */
      xd = ax - (ay >> 1);
      zd = az - (ay >> 1);
      pLine = &RGBFader::lineYdominant;
    }
    else if (az >= MAX(ax, ay)){            /* z dominant */
      xd = ax - (az >> 1);
      yd = ay - (az >> 1);
      pLine = &RGBFader::lineZdominant;
    }
  }
}

boolean RGBFader::lineXdominant(void){
 
  goToRGB(x, y, z);
  if (x == x2)
  {
    return 1;
  }
  if (yd >= 0)
  {
    y += sy;
    yd -= ax;
  }
  if (zd >= 0)
  {
    z += sz;
    zd -= ax;
  }
  x += sx;
  yd += ay;
  zd += az;
  return 0;
}


boolean RGBFader::lineYdominant(void){
   
  goToRGB(x, y, z);
  if (y == y2){
    return true;
  }
  if (xd >= 0){
    x += sx;
    xd -= ay;
  }
  if (zd >= 0){
    z += sz;
    zd -= ay;
  }
  y += sy;
  xd += ax;
  zd += az;
  return false;
 
}

boolean RGBFader::lineZdominant(void){
   
  goToRGB(x, y, z);
  if (z == z2)
  {
    return true;
  }
  if (xd >= 0)
  {
    x += sx;
    xd -= az;
  }
  if (yd >= 0)
  {
    y += sy;
    yd -= az;
  }
  z += sz;
  xd += ax;
  yd += ay;
  return false;

}

RGBFader ledOne;// default mcp4728 id(0) and default PCA9685 id(0)

void setup()
{
  Serial.begin(115200);
   
  ledOne.begin();
  ledOne.setCurrent(100,100,100); // set maximum current for channel 1-3 (mA)
  ledOne.setFreq(330);            // operation frequency of the LED driver (KHz)
  ledOne.setPWMFrequency(120);
  ledOne.eepromWrite();           // write current settings to EEPROM
  delay(100);                     // wait for EEPROM writing
 
 
//test current-settings read function 
  Serial.print("Max current - channel one   :");
  Serial.println(ledOne.getCurrent(1));
  Serial.print("Max current - channel two   :");
  Serial.println(ledOne.getCurrent(2));
  Serial.print("Max current - channel three :");
  Serial.println(ledOne.getCurrent(3));
 
//test current-switch-frequency read function
  Serial.print("Operating Frequency :");
  Serial.println(ledOne.getFreq());
}

void loop()
{
  unsigned long currentMillis = millis();            // if out commented
  if(currentMillis - previousMillis > interval) {    // code runs
    previousMillis = currentMillis;                     // substantially 
    ledOne.rgbFade(0,0,0,255,255,255);
  }                                                             // faster
}
103  Using Arduino / LEDs and Multiplexing / Re: 3W Dimmable LED Driver DC 7-30V 700mA on: May 06, 2013, 06:44:46 pm
The LED driver board I posted is available throug ebay and costs 3,50 not including shipping.

@OP,

No I did not operate that LED driver board from a 9V battery I had three of these to operate a 700mA RGB LED. I would not attempt to do that with a 9V battery ;-)

However, If you initial Driver worked from a 9V battery there is no reason the Driver I suggested should not be able to do that. It uses the same IC.
104  Using Arduino / LEDs and Multiplexing / Re: 3W Dimmable LED Driver DC 7-30V 700mA on: May 06, 2013, 04:35:44 pm
Perhaps you post a little schematic of what is connected how. From your description I cannot gather what a schematic would look like.
105  Using Arduino / Networking, Protocols, and Devices / Re: I2C or USB PCAP touch sensor output - help! on: April 29, 2013, 05:47:42 am
A link to the data sheet for the capacitive touch sensor would help ;-)
Pages: 1 ... 5 6 [7] 8 9 ... 20