I am currently trying to get my DCC train controller to work. I had it working before using an arduino nano and an L298N. Problem was that my last remaining HC-05 bluetooth module gave up the ghost (something to do with short-circuit).
Thankfully I had an Itead Mboard lying around, complete with a bluetooth Bee in the socket. Such is ideal for this project. The Mboard has an atmega32u4 uController.
I have the BT working, and the communication runs well, yet no train aint moving.
I still have an analog oscilloscope (happen to got it got free) and the track signals look okay, but it is hard to tell if the timing is actually correct, though I suspect it is.
The Mboard makes some hearable and irritating HF noise, when I enable track power. (it sounds almost the exact same as my train controller is short-circuiting). Even when there is no closed circuit. And the scope tells me that the track voltage is just 3V instead of 15V. But here I do not really trust that scope tbh. I only have no other means to measure the voltage correctly. I tried both motor connections but it remains the same.
The Mboard has been collecting dust for quite some years, and the last time I used it, my robot car was still driving. I suspect the hardware is not entirely working as I want it to. I am also not using it on a conventional way. Instead of PWM'ing the enable pin, I am PWM'ing both direction pins. For all I know it may be some capacitors creating short circuit.
What I wanted to ask here. Are the timer settings for an 32u4 the same as for a 328P?
void initDCC() { // initialize the timer
bitSet(TCCR1A,WGM10);
bitSet(TCCR1A,WGM11);
bitSet(TCCR1B,WGM12);
bitSet(TCCR1B,WGM13);
bitSet(TCCR1A,COM1B1);
bitSet(TCCR1A,COM1B0);
bitClear(TCCR1B,CS12); // set prescale on 1
bitClear(TCCR1B,CS11);
bitSet(TCCR1B,CS10);
OCR1A=DCC_ONE_BIT; }// on/off time?