USB master on Photon

Can the Photon act as USB master?

The STM32F205 does support USB OTG, so the photon can connect to slave devices in principle, although we haven’t implemented or tested this yet.

I’m curious - what kind of devices would you connect?

What is OTG?

I’m interested in controlling an NCE interface for Cab Bus. What the hell is that? It’s a Digital Command and Control (DCC) system for model railroads.

I see what undertone was going thru to control his vacuum and would like to avoid such a setup if possible.

So I was hoping to hook a Particle Photon directly to this:

And issue commands from an IOS app.

Going through USB is probably more trouble than it’s worth. Do you already have that interface? If so, perhaps you can take a nice high quality picture of the top and bottom of the board and we can take a look to see how to interface with it?

Thanks in advance for taking a look. There may be some opto-isolation and some level juggling. Both capacitors are 25V 4.7uF. Not sure what’s on the bottom of the board. I can just make out iNI ||C and 22 04

BTW That’s a USB B connector on the left. And on the right is a RJ plug, not ethernet, for signaling the track.

Do you have a multimeter? If so, can you test the connectivity between the leads marked TX?RX?/RX?TX? and the lead with the dotted RED line? I’m trying to see if they broken the RX/TX out.

Also, plug the device into your computer and check the voltage between V+ POWER and GND?

From TX?RX to RX?TX is 18M ohms. From RX?TX to dotted line is 6.42M ohms.

No power on the breakout. I’m using compass points. The small black device next to the USB with 4 pins has 3.2V on the SW pin and 5V on the NW pin the chip reads 5038.

I think power for the E side of the board is coming from the track and power for the W side of the board is coming from USB. The opto keeps them from killing each other.

There are only 4 traces that cross between sides of the board and all go thru the opto. Three red are on top and the blue is on the bottom:

Ok. Let’s try this again. Looked at the board again. Measure between 9 and 3,4,&5. And then between 10 and 3,4,&5. Also measure between 1&7 and 2&8 and then 2&7 and 1&8.

The first five breakouts go to uP pins 1,20,8,28,27

6 & 7 go nowhere.

So, It looks like the following is true:

Breakout - uC
1 - Vpp
2 - Vdd
3 - Vss
4 - RB7/ICSPDAT/ICDDAT/SEG13
5 - RB6/ICSPCLK/ICDCK/SEG14

That’s unfortunate. I was hoping they’d break out RX/TX. It’s probably for dianostics/programming Do you mind soldering a wire to the uC’s pin 18? That’s your serial TX from USB to the uC

So you think 17 and 18 are Rx and Tx? And then just choose two pins on the Particle? Any idea on the timing or protocol?

And would I be better off powering up the W side of the board and hitting the opto?

Just a note to say I was wrong about OTG on the photon. I didn’t realize there was some missing hardware, such as a 5v source, that would be needed to support OTG.

@mdma Wouldn’t that just mean an external source (not thru mini USB) connected to JP1 pins 11 & 12???

According to the datasheet pins 17 and 18 are TX and RX respectively. If you want go ahead and solder a onto pin 18. Then plug that wire into the Photon’s RX pin. Then solder two wires to breakout 2 and 3 (vdd and vss) and plug into VIN and GND respectively on the Photon.

Power the device up over usb (don’t have the photon plugged into usb) and the photon should power up. If it does power it down and unplug VDD (breakout 2). Now plug both the Photon into USB and the main box into USB. You should be able to program the Photon.

Have it open up serial1 and send everything it recieves to the usb serial (a loop back). Use whatever software came with the device to send some commands (are those commands documented?). If they aren’t documented then you will need to reverse engineer them.

Report on the above and we’ll go from there

@mdma, do you know if OTG for the Photon or Electron is on Particles radar for implementation?

I am wanting to connect a Photon to the Electron and USB is the only serial available.

@wesner0019, you could possibly use I2C master/slave communications between the two.

@peekay123, no, my only external connection is a remote micro USB

My son the model train nut is doing a project with Photon and DCC. He was researching this long-dormant approach and came across this post http://ralf.alfray.com/trains/nce_usb.html where the NCE board has been successfully hacked.