Marklin Motorola, L298 shield, and Ardurail

Hi everyone,

I just recently bought myself a Marklin train set from Aldi here in town, and after having a bit of fun with it, my mind turned to how I would go about hacking it to run with an Arduino and JMRI on my Orange Pi.

I found Ardurail ( which looks to be my leading contender for controlling the mfx decoder onboard my little shunting loco in these tests. If you note the Hardware Options section, it reads:

one digital pin for the digital signal (default pin 6) (optional) one digital pin for the shortcut detection of the booster (optional) one digital pin for go signalisation for the booster (optional) four analog pins (default A0-A3, can be changed in Ardurail.h) for S88 usage.

However, to generate the AC voltage at around 18V or so, I'm going to need more than one pin I suspect!

Feasibility study here - how hard would it be to attach the "digital signal out" pin to the DIRA on the L298 and use the INA as a sort of "enable" so when the Arduino is transmitting a packet, it signals to power on the motor (INA) and then to form the AC waveform to make the packet, it uses DIRA. I'm pretty certain I could write the code to make the "enable" routine, whats got me worried is, would the L298 hold up to that rapid a switching of the direction voltage? Certainly, its silicon, not a relay, so its infinitely faster, but does it have a saturation point of frequency where the pulses of pseudo-AC just turn into a mess?

Many thanks!