Hi everyone! I am new to embedded linux systems and the beaglebone black. I 
have had some interest lately in creating a DCC model railroad controller 
for a while now, and while I have seen examples out there for Arduino and 
the RPi, not much is out there in the way of handling something like this 
on the beaglebone. The DCC signal is sent to the locomotives through the 
track via square-waveform AC in the voltage range of +-8v to +-22 v. A 
binary 0 is represented by a 100 microsecond +v, and a 100 microsecond -v, 
and a 1 is 58 microseconds +, -. My plan was to use an H-bridge setup to 
provide the +15v to the tracks, and use a GPIO pin on the board to control 
the h-bridge. One example I saw in Python for the RPi used a for loop to 
write the binary information in a similar fashion to this (c-type code 
below):

string bit_pattern = "111111111100100101";             // example string

for (int i = 0; i < bit_pattern.length(); i++) {

     if (bit_pattern[i] == '1') {

          writePin (WHICHEVER_GPIO, PIN_HIGH);
          usleep (binary_one_delay);                                       
        // delay for ~58 microseconds
          writePin (WHICHEVER_GPIO, PIN_LOW);                      // turn 
the pin back off
          usleep (binary_one_delay);                                       
        // and delay again to represent 1
     }

     else if (bit_pattern[i] == '0') {

          // same as above, using different delay pattern
     }
}

// the DCC spec says there must be a delay here, I think it was 20 
microseconds minimum?
usleep(packet_space_delay);


I'm not sure that the usleep function (or nanosleep) can provide the 
microsecond resolution I need here. The DCC spec also says that the packet 
should be resent several times to ensure packet delivery, so would it be 
possible to get this to work using the usleep() or nanosleep() timer and 
GPIO pins with this kind of accuracy if I am resending the packets, say, 10 
times? I am currently reading through Derek Molloy's book on the beaglebone 
so if I have to do something like use the PRUs I will do so, but I am 
really new to all of this and the amount of information out there is just 
overwhelming! Advice on how to proceed is of course greatly appreciated. 
Thanks!

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to