SerOut

Probleme beim senden

  • 1
  • 2
  • Page 1 of 2
Test123
 
Avatar
 
Subject:

SerOut

 · 
Posted: 12.12.2011 - 09:57  ·  #1
Hallo,
ich arbeite gerade mit einem Drehzahlmessmodul, dass seine Messwerte (rpm, °C) über die RS232 ausgibt.

Ich habe einen ATMEGA8 und ein kleines Display. Die gemessenen Daten kann ich auch empfangen. Soweit so gut.

Das Modul kann die verschiedenen Drehzahlen für 4, 6, 8, 12 Zylinder messen. Der Standardwert ist auf 4 Zylinder eingestellt. Um eine andere Zylinderzahl messen zu können, muss ich einen Befehl per Schnittstelle übertragen.

Der Befehl lautet #CY06<CR>, wobei 06 für einen 6 Zylinder steht (08 für einen 8 Zylinder).

Ich dachte, dass ich mit dem Befehl write (SerOut, 'CY06'+#13) den Befehl übertragen kann, aber beim Messmodul kommt nichts verwertbares an.

Wie gesagt, ich kann die Daten empfangen, nur das Senden macht mir Schwierigkeiten.
Habe ich bei dem Befehl einen Gedankenfehler? Vielleicht kann mir ja jemand einen Hinweis geben,

Im Voraus schon mal Danke.
Merlin
Administrator
Avatar
Gender:
Age: 24
Posts: 1373
Registered: 03 / 2005
Subject:

Re: SerOut

 · 
Posted: 12.12.2011 - 10:31  ·  #2
The # in #CY06 normally implies a number. Is #CY06 perhaps an ENUM (maps to a numeric value) the command must be sent?
Test123
 
Avatar
 
Subject:

Re: SerOut

 · 
Posted: 12.12.2011 - 10:42  ·  #3
According to the datasheet of the rpm-modul:
The format of the command is
# Start of command
XX two char command - here CY for cylinder
{P} command parameters - here 02 for two cylinder, 04 for 4 cylinder, 06 for 6 cylinder etc.
<CR> carriage return

I also tried
write (SerOut, #35+'CY06'+#13)
Merlin
Administrator
Avatar
Gender:
Age: 24
Posts: 1373
Registered: 03 / 2005
Subject:

Re: SerOut

 · 
Posted: 12.12.2011 - 11:26  ·  #4
Did you try (SerOut, '#CY06'+#13)?
Test123
 
Avatar
 
Subject:

Re: SerOut

 · 
Posted: 12.12.2011 - 11:44  ·  #5
Yes, no reaction.

The modul gives the following error code back:
! NACK, problem with the command
xx two char command.

If I send( SerOut, '#CY06'+#13) or (SerOut, #35+'CY06'+#13) then I always get this error message:
! x1x2 - where x1 = A3h = 163d and x2 = 5Eh = 94d

For some reason the command is sent but not understood by the modul. And instead of the C for cylinder it reads the charactor of A3h (£).
rh
Administrator
Avatar
Gender:
Location: Germany
Age: 24
Homepage: e-lab.de
Posts: 5558
Registered: 03 / 2002
Subject:

Re: SerOut

 · 
Posted: 12.12.2011 - 12:58  ·  #6
Hello Test123,

maybe it is a baudrate problem?

rolf
Test123
 
Avatar
 
Subject:

Re: SerOut

 · 
Posted: 12.12.2011 - 13:49  ·  #7
Hello Rolf,
the baudrate is set to 9600 according to the datasheet of the rpm-modul.
If I use a different baudrate then it does not work at all.
Merlin
Administrator
Avatar
Gender:
Age: 24
Posts: 1373
Registered: 03 / 2005
Subject:

Re: SerOut

 · 
Posted: 12.12.2011 - 13:57  ·  #8
Or parity/stop bits?

$A3 is $23 or $80 so '#' with even parity becomes $A3.

Merlin
  • 1
  • 2
  • Page 1 of 2
Selected quotes for multi-quoting:   0

Registered users in this topic

Currently no registered users in this section

The statistic shows who was online during the last 5 minutes. Updated every 90 seconds.
MySQL Queries: 15 · Cache Hits: 14   134   148 · Page-Gen-Time: 0.02159s · Memory Usage: 2 MB · GZIP: on · Viewport: SMXL-HiDPI