DCC / Model Railroad
#1
Posted 07 December 2012 - 04:44 PM
#2
Posted 08 December 2012 - 04:37 AM
#3
Posted 08 December 2012 - 11:40 AM
Thanks - good idea -I tested it and....This could help:
http://highfieldtale...r-for-netduino/
Cheers
because of frequency i need at least two SPI-bytes to generate a 58us pulse. As between two SPI Bytes there is short "1" pulse, it is not possible to generate a constant value of "0" for 58us.
May be i try a timer....
#4
Posted 08 December 2012 - 12:49 PM
#5
Posted 09 December 2012 - 10:53 AM
#6
Posted 09 December 2012 - 10:57 AM
#7
Posted 09 December 2012 - 03:23 PM
Right - Timers don't work, bit SPI does not work too.
I set the SPI to 500kHz. Between two Bytes in SPI there is a gap of 2.2us (measuring Clock-Pulses). During this gap the Data Port is high. So it is not possible to keep the SPI data for two bytes low.
Seems to be, that I have to step back to an external Microcontroller.
Chris
You are right: there's a spike between every byte pair. That's the way I used a low-pass filter to cut them off.
Have a look at the schematic: there is a resistor (1.5k) and a capacitor (1n), followed by a logic gate (better if Schmitt-trigger).
As for me, a simple R-C filter is dramatically easier than adding a second MCU.
http://highfieldtale...r-for-netduino/
By the way, I believe the spikes have not any influence in the railroad system. It is very narrow compared to the pulses duration.
Hope it helps.
Cheers
#8
Posted 06 July 2014 - 03:08 PM
#9
Posted 06 July 2014 - 04:31 PM
Nice post, i'm following your suggestions Mario to do my DCC controller.One question. In the image you can see in blue the clock signal in yellow the data signal...Why the signal rises before the clock signal begins?thanks
Clunis, a piece of your code would help, as well as kind yet firmware version of the Netduino.
I've experienced a lot of different behaviors around SPI upon Netduino MCU and firmware version.
Ciao
#10
Posted 06 July 2014 - 05:10 PM
I found the code googling in the net... I followed some intresting web pages
for example this one
http://www.tinyclr.i...-velocità-.aspx
here the code.
my firmware version is the last one downloaded from Chris post
Version: 4.2.0 Update 1 (version 4.2.0.1) Netduino Plus 1
Ciao,
grazie!
#11
Posted 07 July 2014 - 03:36 AM
The Atmel-based Netduino, that is the first edition, had not troubles on SPI. However, yes, I remember there's this strange behavior about the MOSI signal off the pulsed pattern: it stays high. Also stays high between a byte and the next one, so that I inserted a small R-C lowpass filter to cut those spikes.
Despite this glitch, the waveform and its timing is correct. If you drive any SPI-enabled logic, you shouldn't have any issue.
Even in a non-classic usage as the IR transmitter, the spikes are not a problem. The receiver embeds a good bandpass filter which cuts anything falls off the expected message pattern.
Ciao
#12
Posted 07 July 2014 - 11:08 AM
I'm not driving a SPI-enable logic device, but i'm thinking how to use the "enable pin" to cut off the signal before data, for example drive a transistor?
#13
Posted 07 July 2014 - 11:53 AM
Uh? well, you can do it, but...what's the goal?
Just formulate the question better: what is the expected waveform?
#14
Posted 07 July 2014 - 12:26 PM
I want to cut the blue part of the yellow channel.
The expected waveform is the yellow trace between the blue.
#15
Posted 07 July 2014 - 01:06 PM
Since you have a scope, I'd suggest to display the "enable" signal aside to the two other traces. Furthermore, we may discuss on how cut the undesired sections.
Riciao
#16
Posted 07 July 2014 - 01:11 PM
there is another way of doing this, with a marklin modell train. You can use one of the .net microfamework harware boards to use the CAN bus signal, followed by some minor electronics for buffering (isolator and optocoupler). Have to dig up the schematics, pretty simple stuff. I did it on a breadboard. Then connect it to the second train controller box coming pretty much with every digital started pack and can be bought seperately as well.
Use some software in .net to write the CAN bus messages. And off you go, I succeeded in doing this even with an LCD touch connected to the NetMF HW and control the trains speed, extras, the train's track switches, pretty much anything connected and using the rails as means of communication. The CAN protocoll from Marklin can be found on the Marklin web site.
One can even think of connecting a BLE or Wifi receiver unit to the .net board and be able to control your train from your mobile device. If you extend the controlling software with some nice UDP stuff UPNP is even in the game .... so your trainset will even be noticable on the network ....
#17
Posted 10 July 2014 - 08:26 PM
#18
Posted 11 July 2014 - 03:47 AM
Hi guys, some good news!!!I abandoned the SPI solution and decided to try with normal Serial signal.With this simple code (http://pastebin.com/8J3bCJc7) I'm able to write on serial port the entire "Idle Packet" (I started my work analyzing this one). The random high and low bits are not really random they are "start" and "stop" bits... The trick is use these to form our packet!!!According with this document http://www.nmra.org/...-91-2004-07.pdf i can stretch the zero symbol when i need to write three or more consecutive zero signals . So it's almost simple get a correct waveform.See you soon!
That's a good news indeed, but I wonder why the SPI wasn't suitable for the desired waveform. With the SPI you can compose an "arbitrary" waveform, as long -yesy- there are some limitations.
Ciao
#19
Posted 17 July 2014 - 08:00 PM
Thanks
#20
Posted 18 July 2014 - 03:47 AM
A simple NPN transistor...
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users