Forum: PC-Programmierung rs 232 kommunikation mit sensor auf c spache


von siewe (Gast)


Lesenswert?

hallo !!
Ich bin anfänger wollte Kommunikation zwischen rs 232 und ein druksensor 
aufbauen mit c/oder c++ leider ist wasneues für mich.
habe folgendes von sensor hersteller bekommen :
salut Mr Bess


je suis debutant et je me retrouve subitement face a une situation dont 
je suis totalement perdu .bref je dois creer une communication entre le 
rs 232 et un capteur qui aura pour but de me donner une valeur de 
pression en mbar, à l,aide du langage c ,jai recu la documentation du 
fabricant alors tout egaré je vous prie de me venir en secours si 
possible ;celui ci me donnera la valeur de la pression en mbar car plus 
tard il sera question de le lier avec un µc serie 430 de texas 
instruments, mais pour l,instant je m,occupe d,abord de la communiction 
rs 232 et le capteur (la pression devrait etre affiche en mbar . voir 
command 44 xx: 08=mbar):
documentation du fabricant
Preample; Start; Addr; Comm; Bcnt; Status; Data; Chk:
  Baud: 1200bit/s: data Bit: 8, parity: Odd, Stops Bit: 1 Flow control: 
RTS

Preamble: -tree or more ff (hex)
Start: - start character short frame 02- master to slave
  82- Slave to master
- start Character long frame 06 –master to slave
86- slave to master

Addr: - short or long address (one byte or five bytes). See examples
Comm: - command HRT.(one byte.
Bcnt: - byte count (one byte). This is the number of bytes which from 
the remainder of this message
Status: - two bytes of bit- coded information (communication errors + 
operational state).
Data: -data (if any)
Chk: checksum (one byte). Exclusive-or off all the bytes which precede 
it in the message, starting with the “start” character

Examples
Command 0 : read identifier (short frame).
Master to slave ff ff ff ff ff ff 02 00 00 00 02 (02 =Chk)
Slave to master ff ff ff ff ff ff 06 00 00 0e 00 00 fe 0d f0 05 01 01 01 
01 00 03 01 02 0e
Undersored characters are long address (unique identifier) of slave.

Command1: read Primary variable
Master to slave:ff ff ff ff ff ff 82 0d f0 03 01 02 01 00 00 7e (7e 
=Chk)
slave to Master: ff ff ff ff ff ff 86 0d f0 03 01 02 01 07 00 00 07 3f 
01 76 54 66

Underscored characters are long address.
Following bytes: 01= number of Command
07= byte count
00 00 = status
07 =unit (bar)
3f 01 76 54 = Presure in bar (IEEE 754 floating point format)
66= Chk

Command34: write Primary variable damping value (output response 0 to 
99, 5 s)
Master to slave : ff ff ff ff ff ff 82 0d f0 03 01 02 22 04 00 00 00 00 
59
Underscored Characters are Long address.
Following bytes: 22 = number of Command
04 = byte count
00 00 00 00 = Damping value
59 = Chk

Slave to master ff ff ff ff ff ff 86 0d f0 03 01 02 22 06 00 40 00 00 00 
00 1f
40 = Configuration Changed (first byte of status).

Command 44: Write primary variable units.
Master to slave ff ff ff ff ff ff 82 0d f0 03 01 02 2c 01 xx yy (yy = 
Chk)
Slave to master ff ff ff ff ff ff 86 0d f0 03 01 02 2c 03 00 40 xx yy

Underscored Characters are long address.
Following bytes:
2c = number of
22 = number of Command
04 = byte count

xx : 04 = mmh20
     06 = psi 0B = Pa
     OD = torr
     08 = mbar (soll in mbar angezeigt werden !!!)
     0C = kpa
     0A = kg/cm^2
     OE = atm
     05 = mmhg

 falls jedman sich auskennt, bitte ich um hilfe wie ich erst umgehen 
soll!!
Danke
siewe

von Stefan B. (stefan) Benutzerseite


Lesenswert?

siewe, bevor du anfängst in C zu programmieren, solltest du die 
Kommunikation mit dem Sensor verstanden haben. Dabei ist nützlich, wenn 
du einfach obige Kommandos zum Sensor schicken kannst und die Reaktion 
darauf siehst.

Ein Weg dafür ist ein gut ausgestattetes RS232-Terminalprogramm zu 
nehmen und etwas rumzuspielen. Ich empfehle dafür das Br@y++ Terminal. 
Es hat Macrotasten und du kannst darauf die obigen Mastersequenzen in 
Hexform ablegen (s. Help) und mit einem Mausklick senden. Es ist 
kostenlos und die Downloadquellen stehen im RS232-Artikel.

Wenn es dann zum Selbstprogrammieren geht, kann ich Codebeispiele von 
http://www.codeproject.com empfehlen. Allerdings eher C++, da gibt es 
mehrere fertige Libraries für serielle Kommunikation.

von Fleischbremse (Gast)


Lesenswert?

Die Beschreibung auch noch auf Französich. Wer befasst sich mit so einer 
Sprache? Weltsprache ist Englisch!

von Cimbom G. (cimbomgs)


Lesenswert?

Fleischbremse wrote:
> Die Beschreibung auch noch auf Französich. Wer befasst sich mit so einer
> Sprache? Weltsprache ist Englisch!

Französisch?! Auf welcher Seite bist du den gelandet?!

von FBI (Gast)


Lesenswert?

> Französisch?! Auf welcher Seite bist du den gelandet?!
Wer suchet der findet :)
Siehe OP zweiter Absatz.

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.