PDA

View Full Version : interactive menu with hyperterminal



jamied
- 2nd January 2009, 15:07
I'm making a menu driven datalogger and am having trouble with hyperterminal not showing all my menu items. If there are only a few lines, everything displays with no problems. but if certain additional menu items show up then the last line of my menu only shows some characters or not at all.
if the "MEMORY CONTAINS DATA" OR "TURBINE IS DE-ACTIVATED" gets displayed then the last line shows:

HOLD (A) while LOGGING re

instead of

HOLD (A) while LOGGING returns to this menu

I know with hyperterminal and realterm I have 20 lines by 80 characters so I can't figure out why my menu doesn't fully display.... I cant add any more menu items as they simply dissapear. I'm under the 500 character buffer limit so It's not that.

I start be sending 27,91,50,74 ' this is the ansi esc[2J to clear the buffer
This clears the buffer and screen, then I send 8 lines to hyperterminal for my menu items ( around 400 characters but below the 500 char buffer) each line is terminated with ,13,10
if I try adding more menu items hyperterminal simply wont display them. The text only fills the first 1/4 of hyperterminals windows so lots of room for more.

Thanks for any insight!!

Jamie

the serial speed is 38400N81 pic 16f877a and 20mhz xtal
otherwise the transfer is rock solid.

Jerson
- 2nd January 2009, 16:27
First of all, the information given by you is not sufficient to fully describe your problem.

My impression is that your speed is unnecessarily high. Do you really need the 38400 baud speed? If not, drop it to 9600 and see if that helps improve things for you. Another thing you may try is to 'pace' the output from the PIC using the define meant for that.


define CHAR_PACING 1000
' define the character pacing in microseconds

jamied
- 2nd January 2009, 17:01
Yes I need 38400 because it dumps 131k of data when downloading logs.
here is the menu code. the last line "HOLD (A) while LOGGING returns to this menu" wont display fully if I add any other menu items.
As I sais the serial connection is rock solid with no problems whatsoever. I can download the data, interact with the menu all with no trouble, It just wont let me add any other menu items without partially or fully deleting the lower lines such as the "HOLD (A) while LOGGING returns to this menu"

Thanks



Serout2 SO,6,[" ITCV2.0 Turbine Controller (SW - V1.0) System Voltage is ",Dec SYSVolts," Volts", 10,13]
Serout2 SO,6,[" < ",HEX2 RTCHr,":",HEX2 RTCMin,":",HEX2 RTCSec," ",HEX2 RTCMonth,"/",HEX2 RTCDate,"/",HEX2 RTCYear," Sample time = ",Dec SamTime," Sec >",10,10,13]
If DirtyMem <> 255 Then
Serout2 SO,6,[27,91,53,109," MEMORY Contains DATA!",27,91,48,109,10,10,13] ' flash the text
EndIf
If TurStatus <> 255 Then
Serout2 SO,6,[27,91,53,102," TURBINE IS DE-ACTIVATED!",27,91,48,109,10,10,13] ' flash the text
EndIf
Serout2 SO,6,[ " (1) Turbine Setup Menu (2) Download Memory Banks",13,10]
Serout2 SO,6,[ " (3) Erase Memory Banks (4) Set the sample time",13,10]
Serout2 SO,6,[ " (5) Set the Clock (6) Log Data ("]
If LogData = 1 Then
Serout2 SO,6,[ "ON)",13,10]
Else
Serout2 SO,6,[ "OFF)",13,10,13,10]
EndIf

Serout2 SO,6,[ " (C) CLEAR THE SCREEN",10,13]
Serout2 SO,6,[ "HOLD (A) while LOGGING returns to this menu",13,10]
SerIn2 SI,6,[PCCommand]
If PCCommand = 49 Then TurbineSetup
If PCCommand = 51 Then ClrMem
If PCCommand = 53 Then SetClock
If PCCommand = 52 Then SampleTime
If PCCommand = 67 Or PCCommand = 99 Then Menu
If PCCommand = 54 Then
If LogData = 0 Then LogData = 1:GoTo Menu
If LogData = 1 Then LogData = 0:GoTo Menu
EndIf
If PCCommand = 50 Then
Serout2 SO,6,[ 13,10]
ADDR = 0
Cont = Bank0A
GoTo DumpMem
EndIf

Darrel Taylor
- 2nd January 2009, 22:33
HyperTerminal allows you to set certain areas of the screen to scroll independently of the rest of the screen. And that mode is saved with the .ht file, so it stays there until reset. A 1-line scrolling area can cause things to not show up because it immediately scrolls out of the 1-line area after every [13,10].

When playing around with ANSI codes, it's easy to trigger the mode without even realizing it.

Try adding this to the top of the program, which should reset it if it's in that mode.
Serout2 SO,6,[27,"[r"]

Creating a New Connection would also reset it, if it's the cause.

hth,

Jerson
- 3rd January 2009, 02:21
Did you try the character pacing define mentioned in my earlier post?

jamied
- 3rd January 2009, 05:42
I tried character pacing and it had no effect on the way the menu displays. just mad it slower. I also tried making a new hyperterminal window also with no change. the menu displays the same on realterm and teraterm so the 1 line scrolling in hyperterminal was also not the problem.

Thank you for trying

jamie

Darrel Taylor
- 4th January 2009, 02:40
I've run the routine you supplied, well ... had to add some stuff cause it was just a snippet, and my crystal was different.

It ended up looking like this ...
DEFINE OSC 10

SO VAR PORTC.6
SI VAR PORTC.7

Bank0A CON 0 ; No idea

RTCHr VAR BYTE : RTCHr = $17
RTCMin VAR BYTE : RTCMin = $44
RTCSec VAR BYTE : RTCSec = $28
RTCMonth VAR BYTE : RTCMonth = 1
RTCDate VAR BYTE : RTCDate = 3
RTCYear VAR BYTE : RTCYear = 9
SamTime VAR BYTE : SamTime = 12
SYSVolts VAR BYTE : SYSVolts = 5
DirtyMem VAR BIT : DirtyMem = 1
TurStatus VAR BIT : TurStatus = 1
LogData VAR BIT : LogData = 1

PCCommand VAR BYTE : PCCommand = 0
ADDR VAR BYTE : ADDR = 0
Cont VAR BYTE : Cont = 0

Serout2 SO,32,[" ITCV2.0 Turbine Controller (SW - V1.0) System Voltage is ",Dec SYSVolts," Volts", 10,13]
Serout2 SO,32,[" < ",HEX2 RTCHr,":",HEX2 RTCMin,":",HEX2 RTCSec," ",HEX2 RTCMonth,"/",HEX2 RTCDate,"/",HEX2 RTCYear," Sample time = ",Dec SamTime," Sec >",10,10,13]
If DirtyMem <> 255 Then
Serout2 SO,32,[27,91,53,109," MEMORY Contains DATA!",27,91,48,109,10,10,13] ' flash the text
EndIf
If TurStatus <> 255 Then
Serout2 SO,32,[27,91,53,102," TURBINE IS DE-ACTIVATED!",27,91,48,109,10,10,13] ' flash the text
EndIf
Serout2 SO,32,[ " (1) Turbine Setup Menu (2) Download Memory Banks",13,10]
Serout2 SO,32,[ " (3) Erase Memory Banks (4) Set the sample time",13,10]
Serout2 SO,32,[ " (5) Set the Clock (6) Log Data ("]
If LogData = 1 Then
Serout2 SO,32,[ "ON)",13,10]
Else
Serout2 SO,32,[ "OFF)",13,10,13,10]
EndIf

Serout2 SO,32,[ " (C) CLEAR THE SCREEN",10,13]
Serout2 SO,32,[ "HOLD (A) while LOGGING returns to this menu",13,10]
SerIn2 SI,32,[PCCommand]
If PCCommand = 49 Then TurbineSetup
If PCCommand = 51 Then ClrMem
If PCCommand = 53 Then SetClock
If PCCommand = 52 Then SampleTime
If PCCommand = 67 Or PCCommand = 99 Then Menu
If PCCommand = 54 Then
If LogData = 0 Then LogData = 1:GoTo Menu
If LogData = 1 Then LogData = 0:GoTo Menu
EndIf
If PCCommand = 50 Then
Serout2 SO,32,[ 13,10]
ADDR = 0
Cont = Bank0A
GoTo DumpMem
EndIf

TurbineSetup:
ClrMem:
SetClock:
SampleTime:
Menu:
DumpMem:


And here is what it displayed ...

<img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=3092" /><!-- 3092 -->

The problem doesn't seem to be in that routine.
Maybe somewhere else in the code?

Need more Input.
<br>

jamied
- 4th January 2009, 04:38
Darrel, Thats exactly as it's supposed to look. Thank you for verifying the code. I wonder if you hit 'C' and clear the screen a bunch of times does it screw up the display for you?

I will keep searching. That routine is was screws up on my end. if I try adding menu items (7) and (8) ect it really messes up.

I will look at it much closer

Thanks for taking the time Darrel

Jamie

Darrel Taylor
- 4th January 2009, 06:28
I wonder if you hit 'C' and clear the screen a bunch of times does it screw up the display for you?
The location MENU: (result of "C" PCCommand = 67) wasn't included in the snippet.
Can I assume it's the routine shown?

Happy to test any portions provided.
<br>

jamied
- 4th January 2009, 14:26
I just realized the menu: lablel was missing from the top of the text
That whole routine is called menu so when you hit 'C' it just repaints it while clearing the screen
I added the routine Clearscreen: a few weeks ago to try and solve my problem but it never helped.

here it is


DEFINE OSC 10

SO VAR PORTC.6
SI VAR PORTC.7


RTCHr VAR BYTE : RTCHr = $17
RTCMin VAR BYTE : RTCMin = $44
RTCSec VAR BYTE : RTCSec = $28
RTCMonth VAR BYTE : RTCMonth = 1
RTCDate VAR BYTE : RTCDate = 3
RTCYear VAR BYTE : RTCYear = 9
SamTime VAR BYTE : SamTime = 12
SYSVolts VAR BYTE : SYSVolts = 5
DirtyMem VAR BIT : DirtyMem = 1
TurStatus VAR BIT : TurStatus = 1
LogData VAR BIT : LogData = 1

PCCommand VAR BYTE : PCCommand = 0
ADDR VAR BYTE : ADDR = 0
Cont VAR BYTE : Cont = 0


Menu:

Serout2 SO,32,[27,91,48,109]
GoSub ClearScreen:Serout2 SO,32,[27,91,48,109]

Serout2 SO,32,[" ITCV2.0 Turbine Controller (SW - V1.0) System Voltage is ",Dec SYSVolts," Volts", 10,13]
Serout2 SO,32,[" < ",HEX2 RTCHr,":",HEX2 RTCMin,":",HEX2 RTCSec," ",HEX2 RTCMonth,"/",HEX2 RTCDate,"/",HEX2 RTCYear," Sample time = ",Dec SamTime," Sec >",10,10,13]
If DirtyMem <> 255 Then
Serout2 SO,32,[27,91,53,109," MEMORY Contains DATA!",27,91,48,109,10,10,13] ' flash the text
EndIf
If TurStatus <> 255 Then
Serout2 SO,32,[27,91,53,102," TURBINE IS DE-ACTIVATED!",27,91,48,109,10,10,13] ' flash the text
EndIf
Serout2 SO,32,[ " (1) Turbine Setup Menu (2) Download Memory Banks",13,10]
Serout2 SO,32,[ " (3) Erase Memory Banks (4) Set the sample time",13,10]
Serout2 SO,32,[ " (5) Set the Clock (6) Log Data ("]
If LogData = 1 Then
Serout2 SO,32,[ "ON)",13,10]
Else
Serout2 SO,32,[ "OFF)",13,10,13,10]
EndIf

Serout2 SO,32,[ " (C) CLEAR THE SCREEN",10,13]
Serout2 SO,32,[ "HOLD (A) while LOGGING returns to this menu",13,10]
SerIn2 SI,32,[PCCommand]
If PCCommand = 49 Then TurbineSetup
If PCCommand = 51 Then ClrMem
If PCCommand = 53 Then SetClock
If PCCommand = 52 Then SampleTime
If PCCommand = 67 Or PCCommand = 99 Then Menu
If PCCommand = 54 Then
If LogData = 0 Then LogData = 1:GoTo Menu
If LogData = 1 Then LogData = 0:GoTo Menu
EndIf
If PCCommand = 50 Then
Serout2 SO,32,[ 13,10]
ADDR = 0
Cont = Bank0A
GoTo DumpMem
EndIf


ClearScreen:
serout2 SO,32,[27,91,50,74]
Return



TurbineSetup:
ClrMem:
SetClock:
SampleTime:
Menu:
DumpMem:

Darrel Taylor
- 4th January 2009, 23:21
Still no problems Jamie.

I get the same screen, and when pressing C it redraws the screen.

Doesn't matter how many times or how fast I press C, it always comes up correct. I can press C fast enough that it misses some of them, but that's to be expected with SERIN2.

Do you have any other ANSI sequences in your program?
<br>

jamied
- 5th January 2009, 05:02
No, thats the whole routine. I'm going to reinstall hyper terminal. This glitch never made any sense to me. Thank you for all your help!!!!
I know its not the code now. I'll update when I get it squared away.. has to me my pc.

Jamie

HenrikOlsson
- 5th January 2009, 11:13
Hi,
Jumping in late here with a quick thought....
Are you by any chance using a USB<->RS232 dongle? I've never had a problem with those myself but I've read about some weird behaviour. I know you said that the transfer was rock solid "otherwise" which may point away from said dongle - but then it would point away from the PC and terminal softwaret too.

Anyway, just a thought.

/Henrik.