GithubHelp home page GithubHelp logo

elcojacobs / shiftpwm Goto Github PK

View Code? Open in Web Editor NEW
176.0 176.0 86.0 6.79 MB

Arduino Library for software PWM with shift registers

License: MIT License

C++ 47.61% Processing 5.14% C 24.10% Objective-C 23.15%

shiftpwm's People

Contributors

elcojacobs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

shiftpwm's Issues

Teensy 3.0

Hello,

I have spent some time making this work with teensy 3.0, but my efforts were mostly specific to my application, so I pretty much implemented only what I needed.

There are however some pointers I can give you from what I found.

It looks to me like what you do with pins_arduino_compile_time.h is already accomplished with the teensy 3.0, but I am not sure, so in my implementation I simply used digitalWrite for the latch pin. The clock speed is so much higher on the teensy 3.0 I don't think it matters much.

The most important part is of course the interrupt handler, which is mostly identical other than the add_one_pin_to_byte macro, which is as follows.

#define add_one_pin_to_byte(sendInt, thres, ptr) { \
    unsigned char val = *ptr; \
    asm volatile("cmp %0, %1" :: "r" (thres), "r" (val) :); \
    asm volatile("rrx %0, %1" : "=r" (sendInt) : "r" (sendInt) :); \
}

the ARM RRX function works on a 32bit register, so you must pass it an unsigned int for sendInt, and then shift it right 24bits after you add all the bits to send.

for the interrupt timer you use IntervalTimer

m_timer = new IntervalTimer();
period = 1000000.0 / (ledFrequency * maxBrightness);
m_timer.begin(myHandlerFunction, period);

with 3 registers at 100hz pwm frequency with 255 maximum brightness, these are my results.

Load of interrupt: 0.3640691
Clock cycles per interrupt: 685.31
Interrupt frequency: 25500.00 Hz
PWM frequency: 99.61 Hz

This is without the chips actually connected (by boards are being fabricated now), so I suspect much of that is waiting for SPI to timeout in the read loop?

If I don't actually send the values over SPI it drops to Load of interrupt: 0.1692283

If you would like to see my code I will gladly post it somewhere, but it is teensy 3.0 specific.

Latch Pin don't work with Digital Pin 12

I'm trying to change the latch pin to digital pin 12 on arduino uno. It doesn't work. I tried use default 8, also 9, 10. They all worked. Just pin 12 doesn't work. Do you know why? Thanks.

const int ShiftPWM_latchPin=12;

Porting to the attiny85

Hi, i would like to know if its possible to get this library to work with the attiny.
Someone tried before, but it doesn't work and they cannot maintain it anymore.
I would think it is possible , but the code that takes care of serial communications needs to be replaced as the attiny doesn't have hardware serial.

this are the errors that i get when trying to compile :

In file included from \arduino-1.0.6\libraries\ShiftPWM-master/ShiftPWM.h:25,
                 from ShiftPWM_RGB_Example.ino:35:

/pins_arduino_compile_time.h:318: error: 'PORTC' was not declared in this scope

pins_arduino_compile_time.h:319: error: 'PORTD' was not declared in this scope

In file included from ShiftPWM_RGB_Example.ino:35:

ShiftPWM.h:57: error: 'MOSI' was not declared in this scope

ShiftPWM.h:57: error: 'SCK' was not declared in this scope

ShiftPWM.h: In function 'void ShiftPWM_handleInterrupt()':

ShiftPWM.h:131: error: 'SPDR' was not declared in this scope

ShiftPWM.h:147: error: 'SPSR' was not declared in this scope

ShiftPWM.h:147: error: 'SPIF' was not declared in this scope

ShiftPWM.h:153: error: 'SPSR' was not declared in this scope

ShiftPWM.h:153: error: 'SPIF' was not declared in this scope

matrix functionality! :-)

would be really great to get matrix functionality ported here or have the matrix version updated.. really lookinf for a non-blocking version of matrix

Not really a issue ,rather more compatibility

HI , I am trying to really micronise RGB led circuits ,
Using the the new tiny zero , for >>>> led jewelry ,
Tried compiling sketch for tiny zero , but no luck , any chance if this being compatible with new tiny zero : ? )
USing smd 74HC595 plus smd resistor , got a good magnifying Glass light :)
I am hoping to add/combine my-sensors gesture Sensor to turn leds on and off ,
With a small 433mz transmitter for switching RF unit on/off two

Flickering regardless of set frequency on Arduino UNO R3(actually it's Nhduino but it doesn't matter)

I have 3 74HC595s controlling SIX(yes six, because I don't like to use the one pin on the other side of the chip)common cathode RGB LEDs with frequency set to 240(anything lower was just flickering so much I could not look at the LEDs)... First two registers flicker the LEDs at about 15Hz and the third one is fine fading the green but not blue and red(I will upload image of my PCB in Fritzing later)... Using timer2 just makes it worse or not working at all, using balance load slows the flicker to about 3/4 of the speed.

32 bit shift register HV5523

Thanks for making this great library.

What would I need to do to make it work with the HV5523 which has 32 outputs; i.e. needs 32 bit data shifted out?

Thanks for any advice.

Software Serial

Hi,
there seems to have incompatibility between Software serial communcation and ShiftPWM. I can't receive anything from the serial software if this line (and of course all the rest needed for ShiftPWM) is there: ShiftPWM.Start(pwmFrequency,maxBrightness);.
Any solution ? I really need both of them.

Thanks
William

Take a look at my library!

My library is a very useful timing library that can time multiple steps (or sequence code). It is also my first library. Can you guys take a look at it and give me some feedback?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.