Triggering oscilloscope

SteveP May 16, 2021

  1. SteveP

    SteveP New Member

    8
    4
    3
    Hi,
    Am building a DCC++EX command station and am trying to analyze the signal output pin
    of the Arduino used to trigger the motorboard. Want to use an external trigger (another Arduino pin)
    to trigger on the beginning of the preamble.

    Is there a point in the code that I could do a digitalWrite(triggerPin) that would do the trick?

    Any other suggestions for catching 1 packet, software or hardware based?

    SteveP
     
  2. Ash

    Ash TrainBoard Member

    106
    67
    8
  3. SteveP

    SteveP New Member

    8
    4
    3
    Ash,
    Thanx,. I ordered an ARD-DCCSHIELD, should be useful.
    But I still want to sync my scope to the signal. Shouldn't be that hard...

    SteveP
     
  4. FlightRisk

    FlightRisk TrainBoard Member

    548
    237
    14
    We put a pin in the old version a while back, let me see where we would put that now.
     
  5. SteveP

    SteveP New Member

    8
    4
    3
    I'm using mega pin10 at the moment - my problem is where to trigger it in the code.
    Currently doing that in DCC::setFunctionInternal(), based on a specific pattern. It works - kinda.
    It does get me a nice trace of the specific function I am interested in seeing, ignoring all the others.
    But it is a pain to use. I may add a command to select the packet of interest, instead of having to rebuild
    and reload the program each time...

    I purchased an ARD-DCCSHIELD, which is working well. I may not even need to pursue the oscilloscope
    method further. I may also play around with mods to the ARD program to allow it to trigger the scope.

    Steve
     
  6. BigJake

    BigJake TrainBoard Member

    3,299
    6,339
    70
    Now, there's an interesting product!

    "There's a shield for that!"
     
  7. FlightRisk

    FlightRisk TrainBoard Member

    548
    237
    14
    Yes, I have that listed on our website, mostly to use as a decoder or sniffer. Maybe you should look at this page since we have used an $8 packet analyzer and worked with a person named "littleyoda" to build a DCC filter to plugin to the free sigrok pulseview and also made a sketch for Arduinos or ESP32s to do packet sniffing.

    https://dcc-ex.com/reference/tools/diagnostic-tools.html

    So to sniff packets, you just need an inexpensive microcontroller and our sketch, that's it. Connect the signal pin directly to the arduino signal pin. If you want to connect to the track, you just need the very simple circuit in figure 5 on that page. To analyze packets, which also lets you see the waveform, you need the little $8 logic analyzer, Pulseview, some better probes, and a cheap microcontroller.

    The links to everything are on the website.
     
    Last edited: May 21, 2021
    Mark Ricci and BigJake like this.
  8. FlightRisk

    FlightRisk TrainBoard Member

    548
    237
    14
    Here is a Nano on a breadboard running DCCInspector-EX software the code is available in the software downloads menu
     

    Attached Files:

    Mark Ricci likes this.
  9. wvgca

    wvgca TrainBoard Member

    499
    305
    21
    just throw a line in just before where you want to trigger on in the .ino. the line should reference an unused pin on the mega using write to change the state of that pin.
    the 'scope should be hooked up to that pin as a trigger
     
  10. FlightRisk

    FlightRisk TrainBoard Member

    548
    237
    14
    Actually, it would have to be in the interrupt handler in another .cpp file and triggered on the end of the preamble. But the sniffer or analyzer does almost everything a scope can do for our purposes.

    Another option would be to trigger on a command. We could use our "user function override" feature by creating a myFilter file, putting in the couple of lines of example code (a callback function) and adding your code in there to look for what command to turn it on and what to turn it off. We can intercept any or all DCC++ commands going to the parser so that when you enter a say a throttle command (if opcode== `t`), it calls back to your routine telling you what command it got and you turn on a gpio port yourself. You could then check for another command to turn it off, like the <s> command or anything you want.
     

Share This Page