Author Topic: Ethernet, USB & CAN - C coding  (Read 3370 times)

0 Members and 1 Guest are viewing this topic.

Offline sidharthTopic starter

  • Newbie
  • Posts: 6
  • Country: 00
Ethernet, USB & CAN - C coding
« on: November 18, 2013, 06:00:17 am »
Hello All,

I mostly work with Microchip micros. I need to learn to add ethernet, USB & CAN to my projects.

I have searched online & there's so much data about these protocols, it's overwhelming! There are also these ready made modules available that can be used that convert from RS232 to whatever... but I'm not satisfied with these. I want to be able to build my own hardware, write my own driver software in C.

My questions are:
1) Where & how do I START to learn about USB, ethernet & CAN  so that I can write some useful code in C that actually works? I'm not too big on theory, I'm more of a hands-on, get your hands dirty kinda guy.
2) Does it make sense to but some of these development kits?

All guidance / suggestions would be much appreciated.


Thanks,
Sid
 

Offline David_AVD

  • Super Contributor
  • ***
  • Posts: 2806
  • Country: au
Re: Ethernet, USB & CAN - C coding
« Reply #1 on: November 18, 2013, 06:04:20 am »
Writing things like that from scratch will be time consuming.  Maybe start with one of the chip vendor's dev kits and their USB / Ethernet / CAN frameworks?
 

Offline Stonent

  • Super Contributor
  • ***
  • Posts: 3824
  • Country: us
Re: Ethernet, USB & CAN - C coding
« Reply #2 on: November 18, 2013, 06:08:27 am »
If you don't fully want to reinvent the wheel you can go with some existing stuff:

ELM327 (PIC18 based)

http://elmelectronics.com/obdic.html

STN1110 (PIC24 Based)

http://www.obdsol.com/stn1110/

For the CAN interface there's the MCP2551 and MCP2515

If you search ELM327 on ebay or AliExpress you'll see a lot of devices that use a PIC18 but a pirated copy of the old ELM327 software.  Some are USB, some are Bluetooth.
The larger the government, the smaller the citizen.
 

Offline lapm

  • Frequent Contributor
  • **
  • Posts: 564
  • Country: fi
Re: Ethernet, USB & CAN - C coding
« Reply #3 on: November 18, 2013, 07:37:15 am »
I would definitely not recommend trying to do these from scratch. Ready made modules and software examples to them gets you started quickly. That way you don't loose interest on what you are trying to do and have known working example if you decide to dig in deeper later.
Electronics, Linux, Programming, Science... im interested all of it...
 

Offline hans

  • Super Contributor
  • ***
  • Posts: 1638
  • Country: nl
Re: Ethernet, USB & CAN - C coding
« Reply #4 on: November 18, 2013, 09:43:20 am »
Implementing USB or Ethernet stacks requires reading documents carefully, going through tons of driver code from demo's and others plus lots of "digital probing" (WireShark, other USB analyzer tools out there) to make it work.
I think it is a good learning experience, but also quite a high learning curve.

Nevertheless, if you want to do anything at all with these peripherals, you need hardware. You can bake your own, it's not that hard (USB: tons of PICS, Ethernet: ENC28J60 or PIC32 + MII ethernet Phy like KSZ8051MLL, CAN: PIC with CAN and MCP2551, or MCP2515+MCP2551). Otherwise, get an evaluation board from Olimex or the other quadruple million vendors out there.

With any hardware in hands, I would search for demo applications so you can verify your hardware setup is working OK (SPI communication OK, crystal's OK, etc.).
If you understand the example application, it's your decision: spend a lot of time to write your own stack or search for a decent open source one and actually implement your application.
 

Offline matkar

  • Regular Contributor
  • *
  • Posts: 153
  • Country: si
  • Sixty percent of the time it works EVERY time.
Re: Ethernet, USB & CAN - C coding
« Reply #5 on: November 18, 2013, 05:54:06 pm »
I mostly work with Microchip PIC18F series of microcontrollers. I use CAN a lot. I have adopted Microchip's CAN library, corrected a few bugs, added some of my stuff and use it regularly in my projects. For the USB I have tried Microchip's CDC example years ago and I haven't found a problem there. Nowadays I mostly use FTDI products (serial and parallel interface) for USB connectivity. I have tried Microchip's TCPIP stack with ENC28J60 and MRF24WB0MA module as well and haven't found any problems there except for the flash consumption.
None of the above is something you will be able to master without a sheer amount of studying the documentation. Using libraries will save you a lot of time but you still have to understand their internals, requirements and be able to configure them.
 

Offline Stonent

  • Super Contributor
  • ***
  • Posts: 3824
  • Country: us
Re: Ethernet, USB & CAN - C coding
« Reply #6 on: November 18, 2013, 09:17:52 pm »
If you're just doing CAN without a vehicle application it might be feasible. But if you want to use it in a vehicle, you've got a lot of  protocols to learn.
The larger the government, the smaller the citizen.
 

Offline sidharthTopic starter

  • Newbie
  • Posts: 6
  • Country: 00
Re: Ethernet, USB & CAN - C coding
« Reply #7 on: November 19, 2013, 04:23:38 am »
The road ahead does not look particularly easy... if I write my own stack / drivers / libraries, but I will.

To save time... I'll have to start with ready made libraries n stuff... for now!

Thank you all for your suggestions. Much appreciated.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf