Show Posts
Pages: [1] 2
1  Using Arduino / Programming Questions / Re: Serial conflict while using both MIDI and DMX libraries on a Mega 2560 on: September 19, 2014, 12:09:04 pm
I wanted to reignite this issue as I am having the same problem.
C:\Users\Austin\AppData\Local\Temp\build493702711025049459.tmp/core.a(HardwareSerial.cpp.o): In function `__vector_36':
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.cpp:109: multiple definition of `__vector_36'
DMXSerial\DMXSerial.cpp.o:C:\Program Files (x86)\Arduino\libraries\DMXSerial/DMXSerial.cpp:353: first defined here
c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/bin/ld.exe: Disabling relaxation: it will not work with multiple definitions
C:\Users\Austin\AppData\Local\Temp\build493702711025049459.tmp/core.a(HardwareSerial.cpp.o): In function `__vector_37':
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.cpp:209: multiple definition of `__vector_37'
DMXSerial\DMXSerial.cpp.o:C:\Program Files (x86)\Arduino\libraries\DMXSerial/DMXSerial.cpp:440: first defined here

I am using the DMXSerial library on a 2560 and if I call any other Serialx.begin, I get the error.  So for OP the issue is not the midi library it is simply that the DMXSerial library somehow occupies all of the serial something (timers?).  The issue has to have something to do with this:
Don't use the Arduino Serial implementation

I have learned to avoid using the standard Serial implementation of the Arduino. There is a problem with it when accessing the hardware base serial interface because the serial kind of parity and stop bit handling is not set at all and the standard values are used.

Instead of using the built-in Serial object that is implemented in the HardwareSerial library this library initializes and controls all the Control Registers by itself.

There was a first approach published on  in 2011 that used the build-in Serial implementation but it turned out that when using the Interrupt features there is a implementation conflict with the interrupt routines needed for DMX and the existing interrupt routines of the standard Serial implementation. The site mentions that the core file has to be modified - but this is not true in Serial is not used at all.

So you have to avoid using the Serial object at all and even don't use it for debugging purpose!
This is getting a little over my head and why I am posting here and hoping someone can provide more incite.
My DMX out is on pin 18 (TX1) but I have things connected to all three other ports but I can't use them.  Soft serial would probably work but I need simultaneous listening.
2  Using Arduino / Programming Questions / Re: SDFAT return file creation date, time, ect...not print! on: September 15, 2014, 12:59:57 pm
Awesome! Thank you!  I had tried searching SD card file date format but that now obviously doesn't make a lot of sense.

Also, I just want to reiterate the answer here:

Date: YYYYYYYMMMMDDDDD (add 1980 to the year)
Time: hhhhhmmmmmmsssss
3  Using Arduino / Programming Questions / SDFAT return file creation date, time, ect...not print! [SOLVED] on: September 15, 2014, 02:09:35 am
So I'm in the process of tearing apart and modifying Nick Gammon's program which allows you to program one arduino from a SD card connected to another arduino.  This program (not library) uses the SdFat library.  I would like to show the file's creation date on my display NOT print them to the serial port.  I can't seem to figure this simple task out.

This is how nick/SdFat does it:
file.printFatDate(&Serial, d.creationDate);
I just want to return the creation date to my lcd print function.
I tried just doing String(d.creationDate) but get some weird int which I can't figure out any way that it represents a date of any kind.

I don't really fully understand everything going on in his program and just try to move/delete things to work it down to the elemets I need.
4  Using Arduino / Project Guidance / Exploding RGB button matrix! on: September 02, 2014, 08:12:53 pm
Ok so lets talk theory here.  I have a matrix of RGB buttons.  Lets say it's 9x6 for 54 buttons.  My concept is that if you press a button it lights up either red, green, or blue (random, cycled, whatever).  50-100ms later the buttons in the 4 main cardinal directions light up that color with the original going back dark.  The 4 lights continue out until shooting "off the edge" of the matrix.  If any off shoots overlap then we get the combined secondary color (easy).  The issue here is that any number of any combination of buttons can be pressed at any time AND a button may be pressed before its previous "off shoots" reach the edge of the matrix.  I can't even begin to write code for this as I'm not sure how to approach keeping track of the lights and where they are going.  I am also trying to reduce the amount of variables needed as this needs to be scalable.

My best idea right now is to have two bytes per button where I use at least 12 bits.  Each of the 12 bits represents a unique combination of direction and color.  Bit 0 is red going left, bit 1 is red+up, bit 4 is green+left, etc.  This means it doesn't matter what space generated the "explosion" of color.  The status bits get updated every delay time and then the LEDs are updated accordingly and if an LED is asked to be green three times it's just fine.

What I don't like about this is that I would need 216 bytes just for this small scale test.  2 bytes per button, 54 buttons, and a copy of it all for previous and new.  I guess that is not a ton compared to the mega's 8k SRAM but there are still a lot of other variables to store.

At this time, I don't see any issues with this setup (thanks for rubber ducking it for me!) but if anyone has a better suggestion, I would love to hear it!
5  Products / Arduino Due / Re: DMX on Arduino DUE (DMXSimple/DMXSerial) on: May 23, 2013, 10:31:36 pm
+1 bump
6  Products / Arduino Due / Re: Due EEPROM alternative? SD? on: February 01, 2013, 07:41:42 am
So the DUE does not have internal EEPROM at all?
7  Products / Arduino Due / Website SPI correction needed. on: January 28, 2013, 01:22:01 am
I'm sorry if this has already been address or discussed.  I just got my Due and have not been following the forums.  I was trying to understand the SPI on the due and noticed some things.  There is no indication on the board of the orientation of the 2x3 SPI header.  I could only find the answer by looking at the pinout post here or testing for the power pins.  There should be some indication on the website and/or silkscreen of pin 1.  Then I noticed the ICSP header and was confused as to the difference until looking at schematic and seeing it is only for the U4.  Maybe I'm unaware that the SAM cannot be ICSPed then?  Either way its header was labeled as "SPI" on the silkscreen but on the SPI page in the connections table it shows the pins labeled as ICSP-x for the Due.  I could see people connecting SPI devices to the U4.
Also, and this is probably answered somewhere else (forgive me please) but why is the SPI header and the two connections by pin 22 5V when nothing on the board can handle 5V?  Is this for mega shields?
8  Using Arduino / Installation & Troubleshooting / Leonardo mouse and keyboard issues on: June 09, 2012, 11:14:05 pm
I just got my Leonardo and was excited to try the mouse and keyboard features.  I have had much trouble with both.  The keyboard seems to only somewhat work.  Sometimes a very press and release of a single key (with a delay) with notepad open doesn't work.  Also the logout example doesn't work.  Ctrl+Alt+Del doesn't seem to work.  I can't really explain exactly what issue I'm having with keyboard other than mostly not working.  I'm running windows vista BTW.

How is the mouse.move suppose to work?  What number do I put for the ints?  I thought it was maybe the number of pixels but that is clearly not the case.  I tried to move -1440, -900 to corner the mouse then move 720, 450 to center it from wherever it was but that just makes it jump around a bit.

Any ideas appreciated, Thanks!
9  Using Arduino / Project Guidance / Re: Digital 12 socket light dimmer. For christmas! on: December 12, 2011, 02:01:22 pm
10  Using Arduino / Project Guidance / Re: Digital 12 socket light dimmer. For christmas! on: December 01, 2011, 08:25:14 pm
Update:  The forums seemed to be down earlier and I had some extra time so I connected to the secondary with a resistor only and voila! perfect zero crossing detector.  I'm sure if there was some sort of inductive or capacitive load on the secondary this would mess things up but it only runs the uC.  I'll try to post a video sometime.  I'm off to write the new code, hope it is as simple as I think it will be.
11  Using Arduino / Project Guidance / Re: Digital 12 socket light dimmer. For christmas! on: November 30, 2011, 11:04:56 pm
Sorry I didn't get back to you.  I used it for Halloween and had it flicker for a "loose wire" simulator.  The digital control works well and I decided to forget the IR for now in place of bluetooth!  I made a socket inside for a RN-42 module I move around to whatever current project I'm working on and I send it commands from my phone with a program designed in AppInventor.  Also works well but I need some emergency help on the dimming.  I absolutely cannot get solid code to work well for dimming.  I have lots of snippets that sort of work under certain conditions (one light, one level, etc) but I'm incredibly frustrated and the Christmas tree is ready.

I really need to fix the phase thing and then dimming should be incredibly easy.  What I would like to know from the community is how a LED (ac optoisolator) will respond to being driven off the secondary of the transformer.  When resistor only driven will the response be in phase with primary mains voltage?  I think it would also be 90 out out of phase so then I can maybe see about RC driving the LED but my voltage may be too low (the capacitor would need to be pretty big).  What do you think?  Your quick responses will be greatly appreciated.


EDIT:  Basically I can only drive from mains with a RC combo (thus causing my problem) and may only be able to use a resistor from the secondary for the opposite reason. I think my secondary is only about 7vac thus needing only about 500 ohms of resistance/reactance.  (a 5uF cap + R100 then)
12  Using Arduino / Project Guidance / Re: Digital 12 socket light dimmer. For christmas! on: September 25, 2011, 05:28:18 pm
After reversing the action of the software and turning on after a delay, things worked just as bad.  I hooked up to a real oscope at school today and found what seems to be the problem.  Now the question is how to fix it.  My zero cross trigger is 90deg out of phase.  It triggers on the peaks and valleys.  I suppose a quick fix would be to delay roughly 4ms extra but I am very puzzled on why it is not performing how I expect it to.  Below I have included a basic schematic of my ZC detector and of the observed waveform.  The black led is part of the opto (blue)--its AC input.  Input resistor is 1k and the cap is somewhere in the .1 to .3uF range (don't remember-its SMD and doesn't say)  My only thought was that the led wasn't turning on until mains was nearing 170V but this would show the output peaking downward not upward (to 5V).  Any ideas?

EDIT BAhhhh I got the same exact results in a simulation as well.  What the heck am I missing?
13  Using Arduino / Project Guidance / Re: Digital 12 socket light dimmer. For christmas! on: September 14, 2011, 06:14:34 pm
Thanks guys for the responses.  I've been delayed by a more time sensitive project but was briefly looking at the code again today.  Some good advice on the set low once thing.  I was thinking a triac had to be of the zero crossing type to shut off at the cross but now that I think of it, I believe ZC or no ZC only applies to the optocoupler and thinking of a single SCR it makes sense that a triac cannot be shut off mid cycle.  I did test a few of the pins with simple high and low and they worked fine.  After I complete my other project, I'll get back to this and invert the theory.

EDIT Just so I'm straight on this--it takes less time to check a value in a boolean array then to simply tell the pin to go low when it already it?
14  Using Arduino / Project Guidance / Digital 12 socket light dimmer. For christmas! on: September 09, 2011, 11:09:56 pm
I am making a digital 12 dimmer light control system for Christmas lights.  I am using a ATmega328 on a custom board with external 16MHz crystal at 5V.  I'm in the US so mains is 120VAC RMS at 60Hz.  I have an AC input, transistor output optocoupler connected to a hardware interrupt to detect zero cross.  The antiparallel leds in the optocoupler are driven using a series capacitor and resistor straight from the mains.  My outputs are Arduino pins 6-17.  These drive DC input, triac output optocouplers which drive triacs.

My theory is to detect a zero cross and then turn on any pin not marked for off.  I then scan an array which contains the percentages for each outlet.  This number is mapped to 0 to 8333 representing the time, in microseconds, after the zero cross to turn the pin back off.  This array then needs to be scanned at least 100 times between each zero cross for 1% resolution.

I set the outlets in 10% increments to showcase the dimming.  Right now I get what appears to fully on down to 30%.  20% flickers and surges badly and 10% strobes/flickers but is consistently dim.  This was tested on a 40w incandescent light bulb.  I believe it to be a software issue and that is why I am here but I have included a basic hardware explanation in case.

I originally had the interrupt function call "on" (which calls dim) but this did not work as the code either still thought it was in an interrupt (crippling timing functions) and/or, because the interrupt pulled the program out of dim, dug a continuously deeper loop until freezing.

#include <IRremote.h>
#include <IRremoteInt.h>

int level[] = {
  0, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10,100,100};//percentage on
//    1   2   3   4   5   6   7   8   9   10  11  12  :sockets-zero is placeholder

//int program = 0;
int x;
int limit = 11;                      //sets the number of sockets used.  set to 12 to use all.
//unsigned long milli = 0;
unsigned long micro = 0;
volatile boolean interruptv = false;

void setup(){
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(13, OUTPUT);
  pinMode(14, OUTPUT);
  pinMode(15, OUTPUT);
  pinMode(16, OUTPUT);
  pinMode(17, OUTPUT);
  pinMode(3, INPUT);
  digitalWrite(3, HIGH);
  attachInterrupt(1, interrupt, FALLING);

void loop(){
  if (interruptv)

void interrupt(){
  interruptv = true;

void on(){
  //delayMicroseconds();          //possibly accounts for time after trigger but
  interruptv = false;             //before zero cross (Vin is below voltage necessary to turn on ZC sensing leds.
  for (x = 1; x <= limit; x++){
    if (level[x] > 0)
      digitalWrite((x+5), HIGH);  //turns on all the plugs not set for off at the ZC

void dim(){
  micro = micros();                //sets time of ZC
  while(!interruptv){              //do until next ZC
    for (x = 1; x <= limit; x++){//continuously look through the set levels to see if any need to be turned off.  This should run at least 100 times every 8ms.
      if( ((map(level[x], 0, 100, 0, 8333)) <= (micros() - micro)) && (level[x] < 100)){ //this should run every (limit * 100) every 8ms
        digitalWrite((x+5), LOW);//turns lights off once their percentage of the 8ms cycle is complete.

I did some calculations and I think I had come up with 900 some clock cycles per percent of dimming.  I would think this is enough but I could be wrong.

Any help would be appreciated.

15  Using Arduino / Storage / SD card variable file name on: September 02, 2011, 11:18:06 pm
I am creating the charges logger for a vending machine rebuilt to use RFID cards.  I would like so after every time the card is removed and replaced a new file is created with the current date.  I am using the SD library so the statement in question is file ="filename.txt", FILE_WRITE); I have an RTC which puts each element of time/date into an int so I have an int minute, int hour, and so on.  I am just starting to try to put minute as the file name but I will need to put pieces together to achieve a full date.  Also, I would need to be able to append a number if there is a duplicate file name as I probably will not use seconds in the file name (or maybe I could).  And finally, I don't how to get the .txt in as I don't want my client to have to modify the file name.  (The txt file gets pasted into excel for processing.)

I know I need some sort of character array but I can't get anything to work.  I am thinking "String - object" may be the right path but that's not working for me either.

Help is always greatly appreciated,

Pages: [1] 2