Show Posts
Pages: [1] 2 3 ... 11
1  Using Arduino / Programming Questions / Re: Trying to make a standalone signal system... on: June 05, 2014, 07:37:51 am
Regarding the MRRwA libraries, it looks to me like the LocoLinx, LocoNetEtherBuffer and LocoNetMonitor examples are used to control DCC controls using a PC and/or an ethernet shield. The NmraDcc example is used to control DCC accessories and signal aspect packets. This looks like what you're trying to achive. I haven't checked into it, but I'm sure there are DCC signal accessories you can purchase. From what I've read about DCC so far, it looks like the best way to go. You can have multiple engines running on the same track(s) and a good control unit can take care of the switching and signaling for you. It can even control lighting on the train itself and scenery lighting too. I'm starting to get interested in DCC myself now! [I wonder what this is gonna cost me?] smiley-roll

2  Using Arduino / Programming Questions / Re: Trying to make a standalone signal system... on: June 04, 2014, 07:00:23 pm
I just took a glance at the examples and it looks like one of them controls signaling based on the state of turnouts. It doesn't appear to control the route taken. Perhaps the other examples do. From the examples, it looks like the model railroad is controlled via DCC and LocoNet. This may be just what you want.

3  Using Arduino / Programming Questions / Re: Trying to make a standalone signal system... on: June 04, 2014, 06:32:55 pm
I know this is a little off topic, but I was searching for model railroad programs after reading this thread and I came across Model Railroading with Arduino at There's a zip file with a couple libraries for arduino with examples. I have attached the zip to this post. I haven't looked through it yet, so I don't know if there is anything to do with signals. I just thought you might find it useful anyway. Maybe you can look at the library and example files to get a feel for coding your project. Like others have stated earlier, don't try to take in too much at once. Just study one small piece at a time until you understand how each piece of code works, one at a time. If it all seems confusing right now, put it aside for now and stick with your project. You can always study it later.

Hope this helps somehow,
4  Using Arduino / Programming Questions / Re: A question about Pin Change ISR. on: May 31, 2014, 07:05:23 am
You are correct. However, it's not the RTC I'm concerned with. The reasoning for my question in the OP was more about a way to have a pin change ISR in a library that could later, if needed, be expanded to use additional pins. The concept could be applied to any library that may need to share a pin change interrupt in the future, regardless of the particular hardware involved.

I like learning and this was more of a coding challange to see if I could do something that I wasn't sure was possible. Once in a while I'll post questions like the one in this thread just for feedback. So people  here on this forum, that know more than I, can give me hints, tips, feasability, etc. Or even tell me if what I want to do isn't possible so I don't waste my time trying to do the impossible. Anyway, if anyone knows of a better way to accomplish what I wanted to do, or even just a different to do it (just to learn)...

PS. I thought about making a pin change interrupt library, as I know others have attempted to do. I believe it can be done, but due to the way one ISR can be triggered by multiple pins, it's just too complicated for me at this time.

Thanks again for the replies,
5  Using Arduino / Programming Questions / Re: A question about Pin Change ISR. on: May 31, 2014, 02:41:26 am
Sorry for the late reply, I posted late last night and went to sleep.

The RTC is set to interrupt at 1 second intervals to update the time on a display. Not neccesary, I know. But then I didn't have to continuously read the time from RTC to see if I needed to update the display, I just polled a flag. It seemed to me to be easier to code this way. I'm sure others will disagree, but that's the way I did it and it works.

Anyway, I made the libraries for any future use of the hardware in other projects. Perhaps the trackball and some device(s) other than an RTC. The libraries work, but I'm always thinking of future uses for things, as well as improving my coding skills and technique. I was just asking if this sort of thing was possible.

After reading my OP, it occurred to me, my question aswered itself.
Is it possible to conditionally substitute the Pin Change ISR.
#if defined USE_DEFAULT_ISR
/* ISR code here */
If I want to use a different ISR just comment out the #define. If there's a better method I like to learn.

6  Using Arduino / Programming Questions / A question about Pin Change ISR. on: May 30, 2014, 04:34:53 am
I have a project to control the heater and pump for my swimming pool. I have already had a PCB fabricated and all the hardware works as expected. The code I have so far works also. Currently I'm trying to encapsulate parts of my code related to hardware devices into libraries for future use. I'm using a DS3232 RTC to time heater and pump on and off times and a Blackberry microTrackballer breakout board (from SparkFun) for menu navigation. I have the library for the RTC and the trackballer done and working [separately].

The thing is the trackballer uses PCINT0 and the RTC also uses PCINT0, pins 53 and 52 respectively (on the mega). In the original code the ISR was global and written to check which pin had changed and handle it accordingly. Since the RTC uses 1 interrupt and the trackballer uses 5 interrupts (1 for each direction and 1 for the button press) I have put the ISRs in the new trackball library. I know it would be far simpler to put the RTC on it's own PCINT. However, I've already fab'd the PCB. As it is now with the original code it's not a problem. It's only a problem with the trackball library if I want to use interrupt pins that share the same pin change interrupt. So, my question is:

Is it possible to conditionally substitute the Pin Change ISR in the trackball library. Or better yet, insert (when needed) the extra code to check the additional pin(s) used by other hardware?
7  Using Arduino / Programming Questions / Re: Strange error message on: April 19, 2014, 09:13:33 am
It doesn't matter to me at this point. I have created my own alpha-numeric font that is 15x23 in size and is bigger than Arial_bold_14. It replaces the Numeric15x23 font and Arial_bold_font in the sketch. All works fine now. I may come back to the issue later just to satisfy my curiosity. For now, I'm continuing on with the project. After looking at the avrlibc manuals' progmem reference,

These functions are an attempt to provide some compatibility with header files that come with IAR C, to make porting applications between different compilers easier. This is not 100% compatibility though (GCC does not have full support for multiple address spaces yet).
If you are working with strings which are completely based in ram, use the standard string functions described in <string.h>: Strings.
If possible, put your constant tables in the lower 64 KB and use pgm_read_byte_near() or pgm_read_word_near() instead of pgm_read_byte_far() or pgm_read_word_far() since it is more efficient that way, and you can still use the upper 64K for executable code. All functions that are suffixed with a _P require their arguments to be in the lower 64 KB of the flash ROM, as they do not use ELPM instructions. This is normally not a big concern as the linker setup arranges any program space constants declared using the macros from this header file so they are placed right after the interrupt vectors, and in front of any executable code. However, it can become a problem if there are too many of these constants, or for bootloaders on devices with more than 64 KB of ROM. All these functions will not work in that situation.

8  Using Arduino / Programming Questions / Re: Strange error message on: April 19, 2014, 08:44:01 am

Did you read the readme.txt file? You have to change the font used in the showSetDate() function (Display.h tab) from System5x7 to Arial_bold_14. That is when I get the error. The sketch as I uploaded it compiles for me too.

9  Using Arduino / Programming Questions / Re: Strange error message on: April 17, 2014, 06:57:15 am
Oops. smiley-roll I saw 4096 and my mind converted that to 4K and skipped the k that was there. Great, will attach.
10  Using Arduino / Programming Questions / Re: Strange error message on: April 17, 2014, 05:39:43 am

Sorry for not getting back sooner. Something came up and I couldn't get to this until now. I haven't commented the files as well as I'd like to have. Included in the attached folder are two zips and a readme.
Obviously, read the readme. If you have more questions, you can PM me or reply here. This topic will notify me by email. Good luck. smiley-eek

Hold on, The folder is 2MB and apparently an attachment can't be larger than 4K. So, if you're still interested I can email it to you, or if you have another method of getting the files, I'll do that. Let me know.

nevermind PS, it is attached to my next post.

Thanks for your time and help,
11  Using Arduino / Programming Questions / Re: Strange error message on: April 15, 2014, 10:32:46 pm
OK. It looks like you're in Australia. It's 8PM here in California and I'm about to have dinner. I'll try to post tonight, but no promises. If not, it'll be there in the early morning (around noon to you). I'm glad I'm not the only one driven by the need for resolve.  smiley-razz

Thanks for the added effort pYro. Maybe we'll all learn something. I think there's a 60% chance the cause will be something unexpected. But then again, I've only been coding C/C++ for 4-5 years or so. smiley-roll

12  Using Arduino / Programming Questions / Re: Strange error message on: April 15, 2014, 02:21:08 pm
I've made the changes you suggested below. I used both 9 and 10 with the same result.


void isrUp(void)__attribute__ ((section (".text")));
void isrDown(void)__attribute__ ((section (".text")));
void isrLeft(void)__attribute__ ((section (".text")));
void isrRight(void)__attribute__ ((section (".text")));

extern "C"{
  __attribute__ ((section (".text"))) void __vector_10(); // PCINT0 is vector 10 in the data sheet

Same error message.  smiley-confuse smiley-sad

As I was digging through all of the libraries and relavant core files I noticed something odd I hadn't noticed before. You even asked me early on if I was using Timer2. Nowhere in my code or related libraries do I use interrupt vector 15. So, at this point I'm going to try the progmem far memory thing, as the extra instruction cycle overhead won't be a problem.

As I stated at the start of this thread, If anyone is curious about what is going on here, I'll take the time to zip up the sketch files and all the related libraries (at least the ones I've modified [I'm sure none of them are related to this problem]) and post it. It's a small chore to gather it all up, place better comments everywhere (I use my own short hand before I share), zip it all up and then post. So, if no one wants to try and figure it out just for the challenge, I won't bother. Personally, I'd like to know what's using the timer interrupt. As far as I can tell nothing should be. It's things like this that will make me revisit the issue someday, just to know why.

I hope putting the fonts and strings in far memory fixes the problem. If not, I'll stick with the smaller font as that compiles fine for now. I'll just have to squint when I'm further away. (further or farther?) I'll post back and let you know if far memory does the trick.  smiley-wink

Again thanks for the help,
13  Using Arduino / Programming Questions / Re: Strange error message on: April 15, 2014, 12:34:26 pm
I was just about to ask you, what if I place prototypes for my ISR's in the code you gave. You answered before I could post. I will give this a try and let you know.

This might take a short amount of time. I need to modify my sketch so I get the error again, then make the change you suggest. I'll be back! smiley-cool
14  Using Arduino / Programming Questions / Re: Strange error message on: April 15, 2014, 12:23:30 pm
Sorry, I was in the middle of writing and posted before I saw your new post. So I'm a little lost about what your referring to. Try what on the offending ISR? Also, what is the output you're showing/what does it mean?
15  Using Arduino / Programming Questions / Re: Strange error message on: April 15, 2014, 12:18:50 pm
OK, I've read the AVR Libc user manual sections; Memory Areas and Using malloc() and Memory Sections. This is all stuff I've never done before, but that doesn't mean I'm not going to try. However, it does mean I'm going to have more questions (you probably saw that coming  smiley-razz).

I've copied the code you posted and it compiles fine. Now, if I place this code before setup() in my sketch, where do I place my ISR's (in the code you provided) to insure they are close enough to the vector table? I'm guessing right before the while loop after the USB stuff. Correct? 
Pages: [1] 2 3 ... 11