News:

;) This forum is the property of Proton software developers

Main Menu

Ethernet Communication Interface

Started by Fred, Feb 26, 2021, 04:16 PM

Previous topic - Next topic

Fred

I am newbie here and this my first post.

I want to make a communication between the PIC to notebook throught the ethernet, can someone here provide me a sample and simple code.

Thanks.
Fred

TimB


What serial to ethernet module do you have?

Gamboa

Hi Fred,
I am using Xport from Lantronix. It is a very expensive but very effective solution. It is a gateway from Usart to Ethernet. The PIC works as a serial port and the XPORT translates your serial frame to Ethernet protocol. It works very well.
On the other hand there are cheaper things in Wiznet, but I have not tried them.

Regards,
Gamboa
Long live for you

John Drew

Hi Fred,
I have used the Wiznet solution successfully.
Here is a write up of my experiments.
http://www.vk5dj.com/internet.html
Cheers
John
VK5DJ

Fred

Quote from: TimB on Feb 26, 2021, 06:30 PMWhat serial to ethernet module do you have?

TimB,
I still no have an ethernet module, I will buy once I have any information and suggestion  from here.

Fred

Fred

Quote from: Gamboa on Feb 27, 2021, 05:59 AMHi Fred,
I am using Xport from Lantronix. It is a very expensive but very effective solution. It is a gateway from Usart to Ethernet. The PIC works as a serial port and the XPORT translates your serial frame to Ethernet protocol. It works very well.
On the other hand there are cheaper things in Wiznet, but I have not tried them.

Regards,
Gamboa

Gamboa,
Thanks for info, I will look and search the product.

Do you have a sample code in proton side, example to control a led (on and off).

Fred.

Fred

Quote from: John Drew on Feb 27, 2021, 07:59 AMHi Fred,
I have used the Wiznet solution successfully.
Here is a write up of my experiments.
http://www.vk5dj.com/internet.html
Cheers
John
VK5DJ

John,
Thanks for a link.
Seems like the board you are using under RS232.

Any information for a sample code John in Proton.

Fred.

John Drew

Hi Fred,
It is very simple from the PIC side. All you need do is use HRSIN and HRSOUT.
The WIZnet is just a transparent RS232 interface. You feed RS232 in at the remote end and that is what comes out of the WIZnet device.
The complicated part is putting your data out of your remote computer where you have to understand how to set up an interface. I wrote a program in Delphi to achieve this for a special purpose and would be of no use to you. You could make use of a simple comms program like TeraTerm to do simple keyboard stuff.

Here are the essentials for receiving and transmitting from a PIC to WIZnet. The setting up of WIZnet can be done using the supplied program. There is information on my website as to some of the settings.

'set up the hardware serial port
Declare Hserial_Baud = 9600                      ' Set baud rate to 9600
Declare Hserial_RCSTA = %10010000                ' Enable serial port and continuous receive
Declare Hserial_TXSTA = %00100000                ' Enable transmit and asynchronous mode
Declare Hserial_Clear = On                       ' Optionally clear the buffer before receiving

'Send data out
HRSOut Dec2 AntennaEL 'output the antenna setting
While TXSTA.1 = 0: Wend                          'wait until TX buffer empty

'Bring data in
HRSIn {250, TIMEDOUT3}, Dec WaitChr 'wait for input or timeout 
 

top204

#8
That's what i have always found the complex part of ethernet coms John. i.e. The setting up on the PC side. :-)

I have not bothered with the low-level parts of ethernet coms because I always found them extremely boring, and far too over engineered etc... It is a 30 year old protocol that is just like DNA in that it has so many parts in it that are simply not required anymore, but are left in place for compatability, and if not manipulated correctly can cause problems for little reason!

I've used Delphi and C++ to setup and open sockets etc so it is just like opening a COM port, but operating systems keep changing their low level functionality for ethernet or Wi-Fi coms, so you can never tell whether it is the OS or yourself that is causing problems. Especially with Windows and Android that change dramatically from version to version for very little reason, if any!

The microcontroller part of the setup is relatively straightforward, but you have to be careful of the firewall in the router and sometimes it simply will not let anything through, and if experiments keep up that are not quite right, it can screw up the firwall altogether and block things that should not be blocked and vice-versa. Way too over-engineered and clumsy! If it was made leaner, speeds would increase dramatically, even with standard equipment of today.



John Drew

Agreed Les,
I was very pleased with myself when I got it to work on the PC by using a Delphi library. My little interface enabled me to control the rotation and reading of position of antennas by remote control. Hohum for experts but not bad for a radio ham.
Router settings were critical to success.
John

OG

How do they do this without making settings like routing.
How two devices communicate directly, even if there is a modem in between.
For example, whatsapp app and so on.
How do mobile devices jump off the modem and meet.

John Drew

One of the world's mysteries :)
Well beyond this old fella.
John

top204

#12
That type of ethernet/WiFi coms is named "Ad Hoc". But it is now being dropped by operating systems because of its vulnerabilities, and because big corporates cannot see what is being transferred between devices so they cannot spy on people as much and steal data. LOL

It was a good system and operated just like a password protected serial coms using the IP of the master/slave and a joint password, and windows used to support it as standard, but Windows 10 dropped it and it had to be enabled at low-level. However, it never worked very well with Windows 10 and coms used to drop for no reason, even when the units were only a few feet apart and not sending/receiving much data. But that's Mico$oft for you. :-)