hi,
i'm facing a problem that can't be solved at least for me
i receive serial input from weight meter head
the input in the form shown in this image ASCII Characters
this picture shows the input from weight meter at the left
and the lcd output for the code attached
it's 2 kilogram but the lcd shows 20 and sometimes it shows 00000000 values instead since it store values randomly without index or char to start from
Name:  serialp.jpg
Views: 546
Size:  247.5 KB
--
the problem is that i need to read the values after "=" equal ascii character
i need a way to store array of ascii's input let's say 10 input's until it reaches the charachter "=" so that i can use DIG to extract the values and display it in 7 segment display instead of lcd.


note: the data sheet of the weight meter head shows that the input is
decimal,<ASCII> i don't now what this is suppose to mean !!
but when i tried another code it gives me reversed values on the lcd if i tried to store values as string of 10 char
and then used dig to extract them and displayed them at lcd with DEC before each char extracted
i.e
it shows
decimal 35 for ascii 5
decimal 84 for ascii 0
but when i put weight more than 9 it shown only the values coresspondes to the right part of the number
so if the weight was 10 it shows 84
another thing to say is that 84 is the reverse of dec equavelent for ascii 0
--
the code i'm using


'************************************************* ***************
'* Name : 7SEG-MULTIPLEXING.BAS *
'* Author : [ Eng. Mohammad Aqel ] *
'* Date : 11/9/2007 *
'************************************************* ***************
DEFINE OSC 20


' Set LCD Data port
DEFINE LCD_DREG PORTD
' Set starting Data bit (0 or 4) if 4-bit bus
DEFINE LCD_DBIT 4
' Set LCD Register Select port
DEFINE LCD_RSREG PORTD
' Set LCD Register Select bit
DEFINE LCD_RSBIT 0
' Set LCD Enable port
DEFINE LCD_EREG PORTD
' Set LCD Enable bit
DEFINE LCD_EBIT 1
' Set LCD bus size (4 or 8 bits)
DEFINE LCD_BITS 4
' Set number of lines on LCD
DEFINE LCD_LINES 2
' Set command delay time in us
DEFINE LCD_COMMANDUS 2000
' Set data delay time in us
DEFINE LCD_DATAUS 50


INCLUDE "modedefs.bas"




' Set baud rate
DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
DEFINE HSER_TXSTA 20h ' Enable transmit, BRGH = 0
DEFINE HSER_SPBRG 129 ' 2400 Baud @ 0.17%
DEFINE HSER_CLROERR 1 ' Clear overflow automatically


datain var byte


SerialData var byte

COUNTER VAR WORD
COUNTER1 VAR BYTE
COUNTER2 VAR BYTE
ASCII VAR BYTE








Ser var byte[20]
A var byte[5]
B var byte[5]
i var byte
j var byte




ADCON1 = 6 'PORTA AND e DIGITAL
TRISC = %10000000 ' PORTC.7 is the RX input
' PORTC.6 is the TX output
TRISB=0
TRISD=0
TRISA=0
PORTD=$FF
PORTB=0
A0 var word
A1 var word
A2 var word
A3 var word
A4 var word
A5 var word
A6 var word
A7 var word
A8 var word
A9 var word
A10 var word
b0 var byte
num var byte




Hex_input var byte
A_D_A VAR BYTE [20]


MAIN:


'hserin [DEC3 ser] ' Receive string of 10 characters


For i = 0 to 19
HSERIN [DEC3 ser(i)]
Next i

'for j=0 to 19
'if ser.0[i] = "=" then
'LCDOUT $fe,$80,dec j
'endif
'pause 100
'next j

A0=Ser dig 0
A1=Ser dig 1
A2=Ser dig 2
A3=Ser dig 3
A4=Ser dig 4
A5=Ser dig 5
A6=Ser dig 6
A7=Ser dig 7
A8=Ser dig 8
A9=Ser dig 9
A10=Ser dig 10
LCDOUT $fe,$80, # a0, # A1, # A2, # A3, # A4, # A5, # A6, # A7, # A8, # A9, # A10









'goto MAIN


eND