|
|||||||||||||
Charon 2 DB peripherals demo firmwareEnglish version Czech version Charon 2 pages: # Main page # Development Kit # Demo Applicat. # Charon 2 OnLine Charon 2 DB Peripheral demo firmware is default embedded application for the Charon 2 modules. It's using the peripherals on the Charon 2 Development Board. This application and it's source code is well documented in this article..Main Features
Download
Setup the IP address At first you have to assign unique IP address to the Ethernet device. We are not supporting the DHCP because of some troubles and uncompatibilities with previous versions, we prefferes easy serial terminal setup.Run any RS-232 terminal program (Hercules or Tera Term for example) with port parameters: 9600Bd, no parity, 8 data bits, 1 stop bit (9600 8N1). Switch the handshake control off (Flow : NONE). After power up with shorted the “SETUP jumper”, the first page of the serial setup should be displayed in the opened serial terminal. RS-232 Setup is intended for use in setting Charon 2 network parameters. Before you connect the Charon 2 Development Kit into the network, the parameters should be set to the correct values for proper operation on the network (accessing the Charon 2 Development board from network). You can see this page on the picture, follow the instructions and “Press any key to enter RS232 setup“. The actual configuration is printed, and can be seen in the easy menu allowing change of basic network parameters. When the Charon 2 DB peripherals demo firmware is loaded into the microcontroller, these network parameters are set to default values:
Just press “I” or “i” (non case sensitive) to assign an
IP address for the device. There is automatic mode inserting "." (dot separators) if the number in the IP address is 3 characters long. There is ENTER automaticly inserted if the last number has 3 characters. You can't use backspace key in editing..
When all paramethers are OK, remove the “SETUP jumper” and press “R”
for “R: Reboot (exit setup)”. Accessing to the module with using the HTTPThe user can access this Charon 2 DB peripherals demo HTML page by an internet browser. Simply write the current Charon 2 IP address into the browser and the following page appears. The default IP address =192.168.1.100 , in browser: http://192.168.1.100.There is a ‘welcome’ HTML page and from this page the user can enter to other pages (links on page): On NutOs status HTML pages we can see some important NutOs operating system information. The main purpose of the implemented application on Charon 2 is peripheral control. Therefore the most important link is Peripheral control to show the following HTML page : Charon 2 DB peripherals demoLCD display control![]() On the webpage is an edit box to control displayed text on the external
LCD display connected to the Development Board. This edit box has dimensions
of 2x16 chars - the same as the connected LCD display to ensure similar
visualisation. LED diodes - output pins control![]() LED diodes present on the Development Board (as LED-bar graph) are controlled with 8 checkboxes. Each checkbox has a corresponding picture which shows the required (or present) LED state. Checkbox state represents the bit value of the output shift register - if it is checked then given bit/pin is in log.1 state and if unchecked then given bit/pin is in log.0 state. Because LED diodes are connected to VCC then LED states are opposite the checkboxe states. But the pictures display the real LED states. Output shift register port state is displayed in one edit box as a
decimal value. DIP switches - input pins reading![]() DIP switches present on the Development Board are monitored within 8 checkboxes and 8 corresponding pictures. Each checkbox has a corresponding picture, which shows the present DIP switch state. The checkbox state represents the bit value of the input shift register - if it is checked then the given bit/pin is in log.1 state and if it is unchecked then the given bit/pin is in log.0 state. Because the DIP switch is connected to GND (when it is switched on the input pin is connected to GND) then DIP switch states are negated checkbox states. But picture displays are the real DIP switch states. Input shift register port state is displayed in one textfield as a decimal
value. RS232 data outputThe user can send some data (text) from this HTML page to the RS232 port located on the Development Board. The user writes the required text in the edit box and in the next update the text is transmitted to the RS232 (at baud rate given in RS232 baud rate box setting). Because this RS232 data is sent to Charon 2 with the GET method and
Ethernut supports a maximum of 256 bytes received by the GET or POST
methods, length of this RS232 data output is limited to cca 70 bytes
(because the whole 256 byte GET message also includes other settings:
LED, DIP switch). RS232 data inputWhen Charon 2 receives some data from RS232 the user can display this
data (text) on the HTML page in the supplied textfield. This data is
updated with every refresh or update of the HTML page. Charon 2 buffers
a maximum of 255 bytes of received chars. If no data was received from
the last refresh/update then the previously received data remains displayed. RS232 baudrate controlCharon 2 RS232 line baudrate is controlled through the given edit
box on the HTML page. When we transmitsome data from the HTML page to
RS232 line, data is transmitted at the given baudrate. After refresh/update
of the HTML page this box displays the current baud rate (therefore
speed may be slightly different as required due to limited step in Charon 2 UART baud rate setting). Thermometer(s) readingThe Charon 2 Development Board has a connector for connecting 1-wire thermometers. The Charon 2 measures temperature from all thermometers every 1 second. The number of connected thermometers is automatically detected. The user can read the thermometers values on the HTML page. The values are displayed in the edit box on the HTML page - in the case of multiple connected thermometers, the temperatures are displayed on multiple lines. In the present firmware, the maximum number of thermometers that can
be connected is 5 (but may be set to different value in Charon 2 firmware). RS232 to TCP port 23 (telnet) linkOn the HTML page is displayed information that Charon 2 works also
as a converter between the RS232 line and TCP (port 23 = telnet). This
converter works independently from controlling other peripherals (except
baud rate of RS232 whos changes are reflected immediately). Update and refresh values on HTML pageAll required values are sent to the Charon 2 Development Boards peripherals
by the Update/Refresh values button. Then the required data is
submitted by the GET method to the Charon 2 which works as a server.
The Charon 2 sets required values, collects required information and
displays the modified HTML page with current peripheral values. Additional pictures and links![]() The HTML page shows 2 pictures - logos of the main firmware/software developer companies. These pictures are links to their homepages where the user can obtain more information about embedded Ethernet (products, examples, solutions, .. ). On the top left corner of the page is a link to the original Ethernut project (www.Ethernut.de) Use this link to see additional information
about Ethernut & NutOs current operating system state.. On the top right corner is a link to the HW group (www.HW-group.com) company homepage, authors of the Charon modules and another Ethernet devices. Description of RS232-telnet converterRS232 to TCP port 23 (telnet) linkCharon 2 DB peripherals demo firmware works in the background as RS232 to telnet (TCP port 23) converter. To display functionality of this converter simply run telnet on a computer on the network and connect to a given IP address (default IP=192.168.1.100). Then connect a computer with a running RS232 terminal to the Charon 2 Development Board serial port (default serial port parameters are 9600,8,N,1 , but the baud rate can be changed from the HTML page). After this action the telnet client is connected with the terminal program through the network. The user can write something into the terminal and Charon 2 sends this data to the telnet client (data appears in telnet window). This also works in reverse (from telnet to RS232).Description of firmwareBasic principle of firmware is to perform some actions as a result of user requirements and some background services. The background is running in threads:
When firmware starts it firstly opens the network and UART device. It initializes UART to default speed 9600 baudrate and loads network parameters from EEPROM. Then the Setup jumper is checked and if present runs RS232 setup. Starts Receiver thread to receiving data from RS232 line and starts Thermo thread reads temperatures from thermosensors. Initializes
network to parameters stored in EEPROM. Then register CGI samples to
display web pages (NutOs status pages and Charon 2 DB peripherals
demo page). Next the 4 threads are created for processing server
HTTP responses (threads are named httpd1, httpd2, httpd3, httpd4). The
LCD display is then initialized to default value: startup text is displayed.
At the end of main routine is endless loop for processing TCP to RS232
transfer (this can be made in independent thread, but in this case the
main program routine will have nothing to do). LCD display controlOutput to LCD display is performed during HTML page response in ShowForm routine. Required text to LCD is sent as parameter "LCDtext" from HTML page. The string value of this parameter is firstly filtered by the ReplaceHTMLStr routine to correct conversions to true text chars. Then actions for "intelligent" separation of given text to 2 lines on the LCD display is performed. Finally initialization of LCD display (LCD_Init function) and writing required text to this LCD (LCD_Puts function) takes place. Initialization is necessary because in the case of the LCD being removed, no firmware restart is required.LED diodes - output pins controlLED diode (in bargraph) control is performed during HTML page response in ShowForm routine. Required values of the LEDs is sent as parameter "ShiftLEDOut" from HTML page. According to this parameter, value simply sets the states of LED diodes with function DevBoardShiftLedOut (because LEDs are connected to outputs of shift register on Development Board).DIP switches - input pins readingDIP switch state is captured during HTML page response in ShowForm routine. Capture is performed by function DevBoardShiftByteIn because DIP switches are connected to inputs of the shift register on the Development Board. State is finally inserted into HTML page.RS232 data output Sending data to the RS232 line is performed during
HTML page response in ShowForm routine. Required data is sent
as parameter "RS232DataOut" from HTML page. These parameter
values are firstly filtered by function ReplaceHTMLStr and then
sent to Charon 2 UART (_write function). RS232 data outputSending data to RS232 line is performed during HTML page response in ShowForm routine. Required data are sent as parameter "RS232DataOut" from HTML page. This parameter values are firstly filtered by function ReplaceHTMLStr and then sent to Charon 2 UART (_write function).
RS232 receiving is processed in the background in thread Receiver.
This thread simply reads data from RS232 line and if something is received,
sends received data to TCP port (if client is connected) and also stores
data to buffer. This buffer rxbuff can be read by user into HTML
page response. Buffer rxbuff has limited size - 255 bytes.
|
...
ShiftLEDOut ="<#ShiftLEDOut> ";
ShiftLEDIn ="<#ShiftLEDIn> ";
LCDText ="<#LCDText> ";
RS232DataOut ="<#RS232DataOut>";
RS232Speed ="<#RS232Speed> ";
RS232DataIn ="<#RS232DataIn> ";
Thermometer ="<#Thermometer> ";
//not remove next line - this char is mark for Charon insert data command
//@
if ((ShiftLEDOut =="<#ShiftLEDOut> ")||(ShiftLEDOut==null))
ShiftLEDOut = 0xAA;
if ((ShiftLEDIn =="<#ShiftLEDIn> ")||(ShiftLEDIn==null))
ShiftLEDIn = 0x55;
if ((LCDText =="<#LCDText> ")||(LCDText==null))
LCDText = " LCD Text"+"\n"+ "Ethernut project";
if ((RS232DataOut=="<#RS232DataOut>")||(RS232DataOut==null))
RS232DataOut = "RS232 Data Out" + "\n" + "0123456789";
if ((RS232Speed =="<#RS232Speed>")||(RS232Speed==null))
RS232Speed = 9600;
if ((RS232DataIn =="<#RS232DataIn> ")||(RS232DataIn ==null))
RS232DataIn = "RS232 Data In" +"\n" + "0123456789";
if ((Thermometer =="<#Thermometer> ")||(Thermometer==null))
Thermometer = 0.0001 + "\n" + 0.0002 + "\n" + 0.0003;;
...
|
... |
...
ShiftLEDOut ="<#ShiftLEDOut> ";
ShiftLEDIn ="<#ShiftLEDIn> ";
LCDText ="<#LCDText> ";
RS232DataOut ="<#RS232DataOut>";
RS232Speed ="<#RS232Speed> ";
RS232DataIn ="<#RS232DataIn> ";
Thermometer ="<#Thermometer> ";
//not remove next line - this char is mark for Charon insert data command
//
ShiftLEDOut= 254;
ShiftLEDIn = 8;
LCDText=unescape("%20%43%68%61%72%6f%6e%20%49%49%20%64%65%6d%6f%20%0a
%45%74%68%65%72%6e%75%74%20%50%72%6f%6a%65%63%74");
RS232DataOut =unescape("%44%61%74%61%20%74%6f%20%52%53%32%33%32");
RS232Speed =9601;
RS232DataIn =unescape("");
Thermometer = 26.6250 ;
;
if ((ShiftLEDOut =="<#ShiftLEDOut>")||(ShiftLEDOut==null))
ShiftLEDOut = 0xAA;
if ((ShiftLEDIn =="<#ShiftLEDIn> ")||(ShiftLEDIn ==null))
ShiftLEDIn = 0x55;
if ((LCDText =="<#LCDText> ")||(LCDText ==null))
LCDText = " LCD Text"+"\n"+"Ethernut project";
if ((RS232DataOut=="<#RS232DataOut>")||(RS232DataOut==null))
RS232DataOut= "RS232 Data Out" + "\n" + "0123456789";
if ((RS232Speed =="<#RS232Speed> ")||(RS232Speed ==null))
RS232Speed= 9600;
if ((RS232DataIn =="<#RS232DataIn> ")||(RS232DataIn ==null))
RS232DataIn= "RS232 Data In" +"\n" + "0123456789";
if ((Thermometer =="<#Thermometer> ")||(Thermometer ==null))
Thermometer= 0.0001 + "\n" + 0.0002 + "\n" + 0.0003;
...
|
Project files must be located in directory \ethernut\nut\app\<ProjectDirectory> to ensure correct inclusion of some headers.
Project was created by Ing. Igor Cesko for for the HW-group
company. Additional routines for LCD display control, shift registers
control, 1-wire thermometers reading, threads processing, UART control,
TCP control was collected from www.HW-group.com
resources and examples included in NutOS operating system
www.ethetnut.de.
You can test this demo online on our public IP address : 80.250.3.195 in our Prague office.
We have a minimum of 20 pcs in stock at all times. It can be shipped via FedEx next day all over the world. We accept payement by Credit Cards or Wire Transfer, check our prices in the PriceList .
Or try to contact your nearest distributor of our products - International Distributors .
Charon 2 Development Kit included
![]()
- The Charon 2 module with MAC address and serial number on the label.
- The Charon I&II Development Board (Shortly Development Board only).
- An HW STK-500 compatible programming adapter for serial RS-232 port.
- A LapLink serial communication cable with a DB-9 female socket on both ends.
- The DS1822 1-Wire thermometer sensor
- A LCD display 2x16
- CD with all necessary software in the /Charon2/ directory
| Main page | Products | Support & Download | Pricelist | Contacts | SiteMap |