CaptOblivious Posted December 11, 2010 Share Posted December 11, 2010 I wonder if anyone else here has an Arduino and a spare DCC booster and would be willing to help me out a bit? I've got some preliminary code for generating DCC waveforms on my Arduino, but it isn't working and I can't tell why. The waveform itself looks correct, and as near as I can tell, it's transmitting legal packets, but my loco isn't moving and I can't tell why. Could someone have a look and perhaps help me see where I've gone wrong? http://devices.artificial-science.org/2010/12/10/dcc-waveform-generation-arduino-sketch-v-1/ Link to comment
inobu Posted December 11, 2010 Share Posted December 11, 2010 Don, Your best bet is to get a DCC packet sniffer so you can see and interpret the data. http://www.opendcc.de/elektronik/dcc_sniffer/sniffer_sw_e.html NCE has one you can buy. Trying to translate HEX is going to be a challenge. Inobu Link to comment
CaptOblivious Posted December 12, 2010 Author Share Posted December 12, 2010 Inobu, Thanks, I'd thought about bgetting one of those, but they're a bit more than I can afford right now. I am getting a 16-channel logic probe for Christmas that would work as well: I'm quite comfortable staring at raw binary or hex (I don't even see the code any more. All I see is: F7 here, DD51 there...). I just didn't want to have to wait that long, esp if the solution is obvious to someone else ;) Link to comment
Martijn Meerts Posted December 12, 2010 Share Posted December 12, 2010 I'm so used to Objective-C by now, that the code you've got seems totally weird =) Link to comment
CaptOblivious Posted December 13, 2010 Author Share Posted December 13, 2010 A fellow on the OpenLCB mailing list found the bug for me; it was a pretty silly mistake, as I expected. Fresh, working code will be posted to my blog later today. Link to comment
stevenh Posted December 13, 2010 Share Posted December 13, 2010 Don't leave us hanging :) What was the reason? Meanwhile, I've wanted to tinker with DCC and the Arduino for a while (I even have decoders floating around my proto-layout), but I just haven't found the motivation to hack up another locomotive... all my DCC-enabled jobs are back in another part of the country. Link to comment
CaptOblivious Posted December 13, 2010 Author Share Posted December 13, 2010 The error was this: Because the two halves of a zero-bit can be of different lengths (to enable "stretched-zero" DC operation), I check to see if, first, the interrupt was called for the /first/ half of the bit, and if the bit is currently a zero; in which case I switch the zero counter. I had only intended to do any other processing during the /second/ half of the bit, but because of the structure of the conditional statement, I was doing all other processing twice over, once at the first half (but only if the current bit is a '1'), and once at the second half. Which meant that every other '1' bit was effectively disappearing into the void, instead of appearing on the rails. D'oh! Working up a full-fledged command station Arduino library now; I hope to have a preliminary working version up by week's end. Link to comment
stevenh Posted December 14, 2010 Share Posted December 14, 2010 Is the Arduino to have a myriad of inputs/buttons/switches/rotary-switches/potentiometers/LCDs/force-feedback/realistic-throttle-handles or will a computer program/RS232 control it? Link to comment
CaptOblivious Posted December 14, 2010 Author Share Posted December 14, 2010 Steven, None of the above. I might have a pot and a couple of buttons, maybe, just for testing. But the code I'm writing is supposed to only generate the DCC signal from commands received—where those commands come from is immaterial. So you could use this library to build a Zephyr-alike, a computer interface, or whatever. I intend to take it in the direction of working with OpenLCB, as the OpenLCB project doesn't have a command station yet. Or a cab<->CS protocol. Link to comment
CaptOblivious Posted December 18, 2010 Author Share Posted December 18, 2010 Update, looking for folks interested in contributing to my new software project: https://github.com/Railstars/CmdrArduino http://devices.artificial-science.org/2010/12/18/introducing-cmdrarduino-a-library-for-building-dcc-command-stations-with-arduino/ Link to comment
CaptOblivious Posted December 27, 2010 Author Share Posted December 27, 2010 The software is alive! I just drove my EF65 back and forth and worked its headlights using only my Arduino and a booster. I've put up a new page to track progress on the library: http://devices.artificial-science.org/cmdrarduino/ 1 Link to comment
KenS Posted December 28, 2010 Share Posted December 28, 2010 Now that's an accomplishment. Congratulations. 1 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now