Jump to content

Need help debugging Arduino Command Station


CaptOblivious

Recommended Posts

CaptOblivious

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
CaptOblivious

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
CaptOblivious

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

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

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...