Teensy 3 Octows2811 pov Speed problems

Status
Not open for further replies.

Quwat

Active member
Hello world
I am making my first pov project with the epic T3 and octo library, but I have run into a problem.

I am at the stage where I'm trying to get all the basics up and running before I can do something cool with it. I have got a very crude pov running, but I'm having problems controlling it. I'm sure there is only some small thing I have missed, but I just can't seam to find it.

What should happen

I'm using an old fan with some home brew slip rings, the motor spins at about 2000 rpm all that works well. It has a magnetic sensor hooked up to.

At this stage I only have a strip 5 leds long only using one data line, but I plan to use 150 in the end with all 8.

So with the communication speed it takes 3*10-5 sec to update each led, so 5 of them should take only 1.5*10-4.
With the rpm of 2000 the period is 1/(2000/60) = 0.03
So I should be able to get 0.03 / 1.5*10-4 = 200 points of time resolution.

with the full 150 I will be able to get 53 points of time resolution, I want to use it for a bar music visualizer so that's ideal.

What really happens
With the five leds adapting the example code, I have an interrupt that changes a bool to trigger a colour wipe without any delays in the main loop. I expect a stable wedge that makes up 1/200 of the circle, but I get a jumpy 1/7 !?!?!

Here is a video showing that result; https://docs.google.com/file/d/0B-UwY1-6XVBreGtCcTZnTTNHbEU/edit?usp=sharing

Knowing that something was wrong, I timed how long it actually took for the colour wipe method to run. I found that it took 7970 miroSec = 7.97 milliseconds? This must be wrong, is that because the library interferes with the clock?

What I think it could be

Some how in a very oblivious way I have missed something in the code side, because I adapted it from the example code that has a setting I missed?

Yes I have it set to power only 5 leds, but is that a problem because its not a multiple of 2?

The reed switch triggers twice at each side, I have two magnets to keep it in balance (their a bit to big) and as they pass the reed switch they switch it on and off twice each. But I did account for that by making that second hit disable the led lighting rather than enabling it again, stopping a halving of the resolution.

Here is the code shown running in the video, it also has the time testing commented out in it ( wasn't made to share);

/* OctoWS2811 BasicTest.ino - Basic RGB LED Test
http://www.pjrc.com/teensy/td_libs_OctoWS2811.html
Copyright (c) 2013 Paul Stoffregen, PJRC.COM, LLC

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

Required Connections
--------------------
pin 2: LED Strip #1 OctoWS2811 drives 8 LED Strips.
pin 14: LED strip #2 All 8 are the same length.
pin 7: LED strip #3
pin 8: LED strip #4 A 100 ohm resistor should used
pin 6: LED strip #5 between each Teensy pin and the
pin 20: LED strip #6 wire to the LED strip, to minimize
pin 21: LED strip #7 high frequency ringining & noise.
pin 5: LED strip #8
pin 15 & 16 - Connect together, but do not use
pin 4 - Do not use
pin 3 - Do not use as PWM. Normal use is ok.

This test is useful for checking if your LED strips work, and which
color config (WS2811_RGB, WS2811_GRB, etc) they require.

*******modified by Shaun Tocher for POV testing 22/4/13********

*/

#include <OctoWS2811.h>

const int ledsPerStrip = 5;

int pin = 11;// interupt pin
boolean interupt = false;


DMAMEM int displayMemory[ledsPerStrip*6];
int drawingMemory[ledsPerStrip*6];

const int config = WS2811_GRB | WS2811_800kHz;

OctoWS2811 leds(ledsPerStrip, displayMemory, drawingMemory, config);

void setup() {

pinMode(pin,INPUT);
attachInterrupt(pin, checkPoint, RISING);
leds.begin();
leds.show();
//Serial.begin(9600);
}

#define RED 0xFF0000
#define GREEN 0x00FF00
#define BLUE 0x0000FF
#define YELLOW 0xFFFF00
#define PINK 0xFF1088
#define ORANGE 0xE05800
#define WHITE 0xFFFFFF
#define OFF 0x000000


void checkPoint()
{
if(interupt==false)
{
interupt=true;
}
else
{
interupt=false;
}
}

//unsigned long timeOld;

void loop() {

noInterrupts();
if(interupt==true)
{

//timeOld = micros();

colorWipe(BLUE,0);

//Serial.println(micros()-timeOld);
//delay(4);

colorWipe(OFF,0);

// to find the rpm of the motor
// int val = (1000/(millis()-timeOld))*60;
// if(val > 100 && val < 10000)
// {
// Serial.println(val);
// delay(1);
// }
//counting timeOld = millis();


interupt=false;
}

interrupts();
}


void colorWipe(int color, int wait)
{
for (int i=0; i < leds.numPixels(); i++) {
leds.setPixel(i, color);
leds.show();
delayMicroseconds(wait);
}
}

Please help, all comments welcome
 
Status
Not open for further replies.
Back
Top