Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

help - Win Interface to setup a device throw RS232

Status
Not open for further replies.

ajsik

Newbie level 3
Joined
Aug 13, 2004
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Ostrava, Czech Republic
Activity points
47
wininterface

I am working on some project, measuring termocouples. The device itself doesn't have any buttons or display. And there are a lot of values to be setuped. So i need to do some GUI in Windows (98 or higher) which will be used to setup the device.

The HW of device has a rs232 line and I work in Ansi C on 8051 and on PC side in Delphi 5.0 + Comport library (by winsoft.sk).

I need it, to be stable, crc enhanced , line fault detection, etc...

I do some rountines but it is not stable and do many errors when you work like "normal user" (no comm closing, cable unplug without comm closing etc... you know :? ).

If you have any experiencies, please give me some advice, about this. Any protocol, or way how to manage the communication ... I ll do rountines but i dont have any imagination how to manage comm ... thanks
 

Pinczakko

Full Member level 2
Joined
Jul 29, 2004
Messages
136
Helped
13
Reputation
26
Reaction score
0
Trophy points
1,296
Location
Taka Bonerate National Park, Indonesia
Activity points
1,592
Unfortunately, I've only been working on the serial port by using MSCOMM32 control (an activeX control) from within visual basic. But, I'm sure you can use the activeX control from delphi too. It has the majority of the feature you are asking for, such as parity control, bitrate control, etc.
As for the stability issue, it depends a lot in your application design. I've made an application (using VB) that do serial port interfacing into a vehicle weighting system. The data from the vehicle weighting system is sent to the serial port all the time (streaming). But in my application, I only open the port when the user pushes certain button in the application in the PC. Then it grabs the "streaming bytes" from the wighting system twice the length of the "data" bytes. It is needed since I need to get "one complete data bytes" and discard the "uncomplete data bytes".
Since you are using thermocouple. Perhaps, you only need to do temperatur "sampling" in a timely basis. You don't need the user to close or open the communication port manually. Just open the port and grab the data as needed then close it again in a timely basis using a timer .
 

ajsik

Newbie level 3
Joined
Aug 13, 2004
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Ostrava, Czech Republic
Activity points
47
The device is a conveter ... on the input is termocouples (J,K,S,B) and outpup is 0-20mA , 4-20mA , 0-10V and user defined (between 0-22mA and 0-11V). There is an option to measure with "cold end" or with "box temperature" to prevent exact temperature of enviroment temperature. And some other options to be setuped.

And I need to do GUI that will be able to setup these options and send it to the Converter and retreive it back.

Here is a sample of GUI ... www.volny.cz/ajsik/preview_fisrt_alpha.JPG

It looks simply and on the table it works fine, once you get it to the end-users they will find every weakness (You know it has to be "idiot-proove")

Is it better to do it in binary mode or ANSI (like modem comm) ? There is about 100Bytes to send and retreive (not real time sampling).

The CRC is problem itself, on PC there are libraries, but on microchip you have only 9Bits data register, 8Bits flag register and one interrupt (that interrupts on incomming char). So I have to solve CRC by myself and send it as an additional chars in stream.

How to detect line fault (cable un-pluged) ? I have only 3 wires connected (Rx, Tx and GND).

thanks for future hints ...
 

Pinczakko

Full Member level 2
Joined
Jul 29, 2004
Messages
136
Helped
13
Reputation
26
Reaction score
0
Trophy points
1,296
Location
Taka Bonerate National Park, Indonesia
Activity points
1,592
Is it better to do it in binary mode or ANSI (like modem comm) ? There is about 100Bytes to send and retreive (not real time sampling).
For this I think it's better to use ANSI, since most of the libraries available in PC only capable of detecting "this kind of connection". And as far as I know this is the "inofficial standard" (or perhaps it's already standard ? I don't know for sure).

How to detect line fault (cable un-pluged) ? I have only 3 wires connected (Rx, Tx and GND).
For this, I haven't know yet. Perhaps you can send a "dummy signal" from PC that will be replied with a "connection" signal from the thermocouple system in a timely basis. Since you said that the system is "non-realtime", you can handle the "dummy signal" in the thermocouple system by using interrupt handler routine.

That's all I can think of :).
 

ajsik

Newbie level 3
Joined
Aug 13, 2004
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Ostrava, Czech Republic
Activity points
47
thaks a lot ... i will do it in ANSI mode and line error by dummy signal ... on monday I will start :) ... I have to relax ... 8)
 

Big Boy

Full Member level 4
Joined
Jan 19, 2004
Messages
235
Helped
21
Reputation
42
Reaction score
11
Trophy points
1,298
Activity points
4,723
You could encode with a special start character, and a checksum, ended with a CR/LF

(All values in hexadecimal)
- Start with a special character (ex, a column)
- Send the command (register number, +80 for read, ex: 01 = write register 1, 81 = read register 1)
- Send the length
- if a write, send the value to write (in hex for example)
- Finally, substract all the bytes sent, and send this, as a checksum.

Ex: To set value of register 1 to 5, set register 2 to '55 FF 02', and retrieve register 3.

:010105F9
:020355FF02A5
:82017D

Description of first line above:
:010105F9
':' is the start of line
'01' is a write to register 1
'01' is the length (1 byte)
'05' is the value
'F9' is 0 - '01' - '01' - '05'
CR/LF

Second line:
:020355FF02A5
':' is the start of line
'02' is a write to register 2
'03' is the length (3 bytes)
'55FF02' is the value (the 3 bytes 55 FF 02)
'A5' is 0 - '02' - '03' - '55' - 'FF' - '02' (equal A5, truncated to 1 byte)
CR/LF

Idem for the other lines. When reading back a value, something similar could be used for the device->PC reply.

So, this way, the device will know when a line start (with a column), it will know when it end (CR/LF) and will also know if the data is valid (check to see if it received 'length' bytes plus one byte for the command, one byte for the length and one byte for the checksum. Plus, by *adding* all the bytes it receive together, it will know that this is valid if and only if the sum equal zero.

When you receive a column, reset the checsum to zero, and start over. When you receive a CR, check the result.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top