Gadget Renesas

Linking Ideas and Electronics

がじぇるね工房

Using the function on GR-KURUMI, Ethernet vol.

GR-KURUMIの機能を使う Ethernet編

####

Ethernet with GR-KURUMI

image01 image01

We can use sketch reference on GR-KURUMI even though it appears as if it’s “editing”.

Standard is WIZ550io including Wiznet W5500 as controller chip instead of Arduino Ether Shield.
Though it’s not so popular yet.
http://www.wiznet.co.kr/product-item/wiz550io/

Controller chip W5500 is a grand-successor of W5100 used for Ether Shield, with enhancement of the function, hardware bag has been fixed or the number of socket has been increased.

Let’s try out W5500.

Isn’t this WIZ550io?
The picture shows an originally designed board, called WalNet. It’s not so different from WIZ550io.

Now let’s operate WalNet, please refer to the examples for Arduino、customize for WalNet.
https://www.arduino.cc/en/Tutorial/WebClient

Here is the code for your reference.

image03

Found “ the document has been transferred here” in the response.
it seems that the program works and connect to Google by HTTP without fail.


How comfortable! Both DHCP and DNS are working.

image04

On trying out WalNet, amendment is required for the part of library.
gr_common/RLduino78/libraries/Ethernet/utility
w5100.h WIZ550io_WITH_MACADDRESS
Disables by commenting out or defining under another name.


While WIZ550io has EEPROM storing MAC Address on board, WalNet doesn’t have.

####

Working out for Internet radio

image05

Using MP3 decoder IC to play music with SD card.
Please refer to SD Card vol.
There are many music distribution service sites on internet.
They are called internet radio.

Let’s combine WalNet network function and WalSound board for SD card. Then access the internet radio station to play music.


We might say this is a kind of IOT, since these are the internet-connected things.

####

How to access internet radio?

image06
image07

The application “Winamp” on PC help search internet radio station, so listeners can take the music distribution service easily. However, this is not GR-KURUMI’s case. Since there is no search engine on it, we have to search internet radio station by ourselves.

To specify the radio station in advance, please refer to this site for radio station information.

http://www.shoutcast.com

Opening the site, you can see the chart showing the Bit Rate, audio compression technology form such as MP3, AAC etc. by genre.
Click on the icon for download sign, then you can choose the application among Winamp, M3U, XSPF.
This time, choose Winamp.
Once download, the file with extension of “.PLS” shows up.
Open this with appropriate text editor.

[playlist]
numberofentries=1
File1=http://167.114.131.90:5344/stream
Title1=(#1 - 0/1000) ebrandradio
Length1=-1
Version=2

Global IP address of server for music distribution service:167.114.131.90
The port number of the server:5344
File name:stream

※Sometimes the file shows the domain name instead of global IP address.

Sending HTTP sentence to get file to the address as well as port number, you can get a lot of music data, MP3 form in this case, then tear them to pieces and throw into MP3 decoder IC.

Rather than MP3, VS1063A support AAC form as well, corresponding to almost all distribution services.

※For more information, please refer to the document about VS1063A.

####

Enhancement of bit rate

image08

SD Card case, there seems to be no problem to play music even with 192kbps.
Internet radio case, we can listen to a tune up to 32kbps.

There seems to be a problem with efficiency by internet side.

Identify the issue with packet monitor on network.

Please refer to PacMon by Layer.
http://www.layer.co.jp

Supporting Japanese language, very convenient.

Blue inverted sign shows the packet data from server.
Found the data is divided into 1,024byte,
interval diverge up to 170ms.

image09

On TCP, transmission Control Protocol, flow control which adjust the size of sending data would work in accordance with the amount of empty capacity of the receiving buffer.


Seeing the contents of the packet data from EalNet Just before the server transmit the data, we can see how flow control work.



The blue Inverted “Window” shows 2,048byte.
confirmed that the server hesitate to send the big size of data, considering the window size.

What shall we do?

Recommend to extend the buffer size at receiving side.

image10

Controller chip W5500 can have 8 piece of sockets,
the buffer for receiving/sending used at each socket would be divided by several patterns among 32kbyte of RAM.



Rather than the application of using several sockets at the same time, only a socket will cover the usage like this.


Set 32kbyte into transmission part and receiving part with each 16kbyte.


Suggested that this change be executed in w5500.cpp under gr_common/RLduino78/libraries/Ethernet/utility


In reset function init, the buffer size of each socket has been set at 2kbyte across the board,reset 16 for socket 0, reset 0 for others.

image11

Operating the program after compile, confirmed the empty space has been 16kbyte for receiving buffer on WalNet.

image12

The data size sending from server remarkably has increased.

####

Notice on sending HTTP sentence

image13

Just in case, this is the brief note just on sending HTTP sentence.



Please see the screen on the packet monitor,
found a large amount of packet data by 1byte has been sent out from WalNet on sending HTTP sentence.


Since HTTP sentence has 96 characters, the packet data is suppose to be sent 96 times more than we need.

As a matter of course, one time transmission is enough.

This is caused by
client.print
which is the character function for serial, assumed to be sent the packet data by 1 byte unit,
Client.print do so in Ethernet as well.


Ethernet can proceed the data by block, sending by 1 byte unit cause traffic jam on network to no avail.


Please don’t say IOT.


The counter measure is done at one time with
client.write


We will never know unless we check the packet data running in LAN cable in the packet monitor.

For your reference, here is the code.

MVP information

@chobichan

General hard engineer.. submitting his writing for technical magazine occasionally.
twitter account:
https://twitter.com/chobichan

Chobichan avatar

Follow him

All articles from @chobichan

share