Page 1 of 8
New USB-Loconet interface
Posted: 28.01.2012, 20:24
these days I've made the first successful tests with a self-made "native USB" loconet-PC interface.
Native because I've build my interface around a PIC 18F4550 (with integrated USB interface).
For the USB communication I'm using the Microchip's USB stack found in the "Device - CDC - Serial Emulator" from the Microchip Application Library
(the PICDEMFS part). From the same library originate also the Windows host drives (linux ones are already in kernel).
The project is in an early (alpha) development phase, I still need to implement some of the errors handling included in the Loconet Personal Edition, but the basic functionality (passing the messages between Loconet & USB) in a light layout (tested only with a Profi-Boss connected to a Rocrail PC under Windows XP & Linux) looks good.
If someone is interested in testing/developing new functionality, please let me now and I'll post the schematic (I need to drawn it, I have just a test board) and the hex/code (makes less sense to post them if nobody is interested).
LE I've drown the schematic and I've added the hex file & the windows driver.
Posted: 04.02.2012, 13:06
Because I have no more time to work on this interface, I'm quite happy with its functionality *) and because I've succeed to clean a little the code (I'm a bad coder, but I think my code can be read), I'll stop the development of this interface.
I'm attaching to this post the last state of the code. It should work in mplab (I have mplab 8.14) or mplabx (I've tested it a little under linux), and it should compile with C18 compiler. The mplab configuration files are pointing to the c:\ln2usb (decompressing the annexed .zip to c:\ is enough to receive a working project).
In Rocrail the interface works as locobuffer and the he communication parameters (in Rocrail) are quite relaxed and are not fixed in code - I've tested it with 57600 & 115200 baud (no flow control).
*) I have a small layout, so the communication errors/conflicts are not a problem. For that reason, I haven't implemented all checks in Loconetpersonaedition.pdf.
I hope it will helps someone to play with loconet development.
PS I think some comments are in Romanian language. If someone needs to understand them, simply ask.
LE I think I forgot to specify: all the files are released in a GPL sense - free to be used in any purposes as long as any changes/improvement are made public.
Posted: 14.06.2012, 15:06
Some thoughts about this interface:
- as I said in the first post, it is based on the CDC Serial Interface Emulator found in Microchip's usb stack. That means with small changes (I've hard-codded the Loconet pins, but they are only three) the code should functions for any PIC microcontroller supported in the stack.
- I've written/tested it with 18F4550 because I've had it in my drawers, but I "prepared" the code for 18F2550, the smaller brother of the series (in my version, a signal should be rerouted from RD2 to RB2, but the project can be easily changed to use the same pin for both controllers).
- when costs constraints are important, I suppose the best option is the 18F14K50, which is also supported by microchip's stack (Low Pin Count USB Development Kit), because it is cheaper (2.25 E compared with 4.45 E for 18F2550 at my supplier) and it is smaller (smaller and cheaper PCB). The only test that should be done is to see if my program fits in the memory which is half the memory of 18F2550/4550). Unfortunately, since I've thrown away some "useless" code from the stack, my program doesn't compiles directly, but (once again) I think the "reconstitution" of the original shouldn't be so hard (just copying the changed/new files to the original USB stack should do the job).
Posted: 14.06.2012, 20:10
Attached is a project who compiles also for 18F14K50. I don't have such a controller to test it.
The pins used for the loconet communication are defined in the controlLn.h file.
Edit: as I see, this version still being downloaded. It is OK for me, but I recommend the download of the version in the next post. It is complete (for more devices) and is the version I'm updating when I fix problems/bugs.
Posted: 12.08.2012, 22:59
today I was trying to "speak" with a MGV50 module and, using my interface, I couldn't.
Because meantime I succeed to fix this problem (the OPC_PEER_XFER command seems to be different than the other ones), I'm updating the sources I've posted here (the "full" package).
Edit on 31.08.2012.
The fix in the previous version was a quick work-around. Because meantime I succeed to fins the right fix, I'm replacing the "quick" version with the better one.
Speaking about better version, I'm trying (for another application - a little bit chaged mgv50) to implement the loconet communication using the USART module of a PIC. If it will work (and there are big chances) and I'll find the necessary time, I'll try "update" this interface also.
Posted: 03.10.2012, 14:50
As already mentioned in the post above, I was working to implement the Loconet communication using the hardware USART module of PICs microcontrollers.
Attached are the schematic and the firmware for an usb-loconet interface using the hard USART & USB modules of a PIC18F4550.
The tests I've done were quite limited and because I don't have a real board for it (I've tested it just on a breadboard), I'll stick with the old version (soft usart) and I can't test this one any further.
However, I've used the same communication functions in other projects and there they behave as expected.
If someone decide to give it a try and has problems, just post them here.
If someone decide to give it a try and succeed, just post here.
PS For the firmware, just remove the .txt extension.
LE I've made some corrections/updates on the text.
Posted: 03.10.2012, 15:09
maybe Peter (GCA Hardware) is interested to make a board; Just write him.
Posted: 03.10.2012, 15:30
I've already changed some PMs with Peter.
He knows he can use my designs as basis for new products (I believe my designs are not really "production ready").
More than that I have no idea what can I tell him (but I'll answer with pleasure if he has questions/requests).
PS I just want to congratulate you for your job with Rocrail.
Posted: 03.10.2012, 16:01
I am sorry I did not get back to you about the USB Interface, because there were sooo many other items to take care of.
But slowly I am getting to a point that I wll be able to start this issue.
If all goes well, I like to use this design as a replacement for GCA85.
I will get you updated as sonn as something is cooked.
Posted: 03.10.2012, 16:18
As I already told you, feel free to use what you need/like from my designs. Just tell me if you need anything else.
PS You don't have anything to sorry about, I don't expect anything special and you shouldn't change your schedules just because of me.
Take your time!
New USB-Loconet interface
Posted: 07.12.2012, 14:53
I am working on a definitive version of your LN2USB interface.
Once it is all settled, I promise you to send you a complete unit after PC-Board production .
I am looking for the right driver for Windows/Linux/Mac.
For windows I found usbser,sys.
But that does not seem to be working, because I can not make contact.
Trying to use Linux fails because I do not know what driver to use.
Linux recognses unit as Microchip Technoligy CDC RS232 Emulation demo.
But that is far as I can go.
Posted: 07.12.2012, 18:23
which version are you implementing, the one with soft com-port or the one using the hardware USART?
Which micro-controller are you planning to use?
In any case, for the windows I'm using the microchip's CDC-Driver I've posted in the first post of this topic.
For the linux I was thinking it uses the libusb driver/library (included in the kernel). As long I was using the openSuse 10.3, I could connect to the interface using the /dev/ttyACM0 port it created at connection.
Recently I've installed the openSuse 12.2 and... I should made some more tests, because it detect my interface as FTDI USB-serial converter (creates 2 /dev/ttyUSBx ports) and doesn't work as expected.
I can't test anything for Mac.
However, under both systems (windows and linux) the Rocrail settings are the same - LocoBuffer, COMx//dev/ttyUSBx, NO CTS, any baud rate.
Edit: After a reboot I could use the interface in Linux as expected - it created a serial port under /dev/ttyACM0. Using this port, I can communicate with the Loconet devices.
Attached is a screen-shot with the (linux) configuration.
PS Like any other serial-USB convertor, you need, of course, write permissions for /dev/ttyACM0.
Posted: 08.12.2012, 14:17
So far, I used 18F2550 because that was 'on my shelf'.
I can see some communication now, in Win7 from Rocail to LN2USB.
Using the comport simulation.
But it seems not to be able to communicate yet, both with IB and GCA50.
Still trying to figure out what is going wrong.
All other hardware
Posted: 08.12.2012, 14:25
Also here, there is picture of testboard.
Posted: 08.12.2012, 18:30
the test board is looking great. Congratulations!
Regarding the firmware you used, have you compiled the project for 18F2550? Has it worked OK, or had you to change something?
Regarding the communication problems, I'm not sure why you have them.
Your schematic is a little bit different from mine, but yours looks/seems to be better (mine is supplied directly from the USB port of my computer...)
Reacts the LED2 as expected (off when the interface is powered and connected to loconet, steady on when powered and disconnected from loconet and pulsing during loconet communication)?
Which is the value of the R10 resistor? Do you see any improvements if you short-circuit it (just to be sure the low level still be reached).
Can you bypass the T2 transistor + one of the resistors R14 or R7 to recreate the original schematic (found in the LocoBuffer) with only one transistor (just to see if the second transistor introduces some extra delays/makes the slew-rate to slow)?
PS I suppose you can see the interface (as a COM port) in the device manager in the windows and you use this port in the Rocrail.