Project status report and question ...
2011-01-04 by Chuck Hackett
Most of my questions on the list over the last year or so have had to do with an ATMega32-based railroad signal controller for ride-on hobby railroads that I am developing. With the help of the list I have: - Finalized the design of the PCB - Made a prototype PCB (using Eagle and isolation milling with the help of pcb-gcode) - Run basic tests on the design and all was well - Sent the design off to Advanced Circuits with an order for 100 boards. Before I placed the order, I studied their pricing structure and made up a spreadsheet showing cost per board .vs. number of boards ordered. It turned out that board #'s 51 -> 100 were almost free. Above 100, the cost per board started going up again - strange, I expected it to go down. The board is 2.750" x 2.375", double-sided, w/solder mask and silk on both sides, no cutouts. Since this was my first experience with a PCB house I was very nervous that I might have messed something up such that I would have 100 "coasters" to give away as Christmas presents. To my relief, the boards came back on-time and looked great with very small (intended), but legible, silkscreen print, etc. I had set it up to "tent" the vias (vias 0.024" drill, mask limit of 0.025") so that the silkscreen print would be uninterrupted but most of the vias were coated (on the ring), some filled in, but few had a flat surface over them. Not as I had expected, but no big deal. I plan on calling Advanced and asking them what I should expect in this area. BTW: My rep at Advanced was very helpful in the whole process and followed up to see if I was happy with the boards - I was. - We stuffed one board and it passed basic tests so we stuffed 29 more while we were at it (mostly SMT). - I am now writing the firmware. My two challenges have been that I am using FreeRTOS for the first time and, due to the recommendations of list members, I bypassed my initial plan (start with RS-485 and switch to CAN later) and went right to CAN. I included an MCP2515 CAN controller (SPI interface) and MCP2551 CAN bus driver on the board. It took me about 4 days to get the MCP2515 to cooperate - mostly due to a dumb (aren't they all?) programming error of course. On the positive side, I have lot of 'instrumentation' in place as a result of the "bug chase". I now have simple test messages (w/o interrupts) going between two controllers (over 5" of wire :-) ). In the process I have gained a basic understanding of how to work with the MCP2515 and I'm about to convert it to interrupt driven. So far I have not discovered any connections (traces) I needed that I did not include in the board design, so, so far, the boards won't have any ugly "cut/reroute" of traces. - Observation: Since the MCP2515 was added after the prototype stage I wasn't sure about how to drive the MCP2515 clock. I ended up adding a "solder jumper" (3 small pads) to the board so that I could use either OC2 (Timer 2 output) or XTAL2 from the ATMega32. It works fine using OC2 but the processor dies when I connect the MCP2515 clock to XTAL2 (14.7456MHz xtal). In re-reading the ATMega32 datasheet just now I realized that I don't have CKOPT programmed. I'll try programming CKOPT later today and see if there is enough drive to connect the MCP2515 so I can free up the OC2 pin for other possibilities and run the MCP2515 at the full 14.7456 MHz (datasheet says that it can go up to 40 MHz). Now a question: I'm currently using AVRStudio W/WinAVR but I would like to find a (Windows based) debugger that has things like stack-traceback (AVRStudio does not, as far as I can tell) and, if possible, is 'extensible' so that I could add code that 'knows' how to display the FreeRTOS stacks, data structures, etc. I evaluated CodeWorks which supports Java extensions and had a nice looking debugger but, unlike tools such as AVRStudio, GDB, etc., they do not support elf/croff2 files, etc., they only support debugging of object files that are generated by their CodeWorks Studio tool chain. I have too much invested in WinAVR code to re-target it all so I have stopped looking at CodeWorks. Plus, I was less than happy with the response I got from CodeWorks support on several 'novice' (to CodeWorks) questions. I'm now looking at using GDB and avr-insight (graphical interface for GDB) ... Any other suggestions for a (preferably) graphical debugger (does not have to be free, just 'hobby' affordable) for use with WinAVR that supports extensions that would allow customization for things like FreeRTOS data structures or other "user" data structures, such as the ability to follow linked lists, etc.? I suppose I could download the stuff required to re-build my own copy of Insight/GDB but, as interesting as that might be, I'd rather spend my time working on my controller code :-) ... sorry to be so long-winded ... anyway, thanks to all for the help getting me this far. Cheers, Chuck Hackett "Good judgment comes from experience, experience comes from bad judgment" 7.5" gauge Union Pacific Northern (4-8-4) 844 http://www.whitetrout.net/Chuck