ASCIIBusvProtocol

Status
Not open for further replies.

Desdewit

New Member
Hi Guys

Please see if you can help?
I need to read data from a weighing instrument & display the data on an LCD driven by a pic16f877.
I'm using flowcode but the data I recieve is not the same as displayed on the instrument.
I can send and recieve data from Hyperterminal without any problems so I know my coms are working. Below is the protocol supplied by the manufacturer. Please help in flowcode if possible.

The data format output from the indicator is(7 bit ASCII code is used)
Line Settings:7 Data Bits, 1 Parity bit, Odd Parity, 1 Stop Bit
Baud Rate: 9600
Data Bits: Numerical ASCII characters :0,1,2,3,4,5,6,7,8,9
Other ASCII characters: #,blank/space,+,-,CR,LF
Protocol format is: #AASDDDDDDDDP CR LF
Where:
# = Indicates start of message
AA = Instrument address.ASCII 00 to 99. 00 is default.
S = sign (polarity) (ASCII "+" or "-")
D = Data bits (data for 8 numerals).
P = decimal point position. ASCII 0 to 8.
CR=ASCII carriage return
LF=ASCII line feed.
 
hi,
Are the signal/data voltage levels from the Weigh Indicator swinging +/-V about zero volts or only from +V to 0V.???

Which model of indicator is it.?

EDIT:
The other point I would check are the two RS232 cable connectors, is the pin wiring the same and do they have the same links.??


EDIT2:
Look here to see how to work with 7 bit data.
**broken link removed**
 
Last edited by a moderator:
Hi Eric

I'm sure the connections is right because the right amount of caracters are displayed on the lcd with the right amount of spaces even the start massage character (#) are displayed in the begining.
its just that some of the characters are displayed as garbage.
The model is a Instrotec 5004 indicator.
 
Last edited:
Very modular method:
1> copy entire string to an input buffer: wait for "#" & copy until <LF>
2> convert the sign character to the displayable value, and put to an output buffer
3> convert the decimal point position character, used later in display formatting
4> convert the "data bits", which is more likely a numeric string in ASCII, to an integer

5> if necessary, convert the integer to the units to be displayed. Given string may be in grams, with display to be in ounces
6> convert the integer to its' displayable values, and put to buffer
7> minding any units' conversion, insert the "." into the output buffer. Count to position, copy remaining down 1 character, put "."
8> send buffer to display

Experienced coders may scoff at this approach, but modular allows verifying each block Before coding the next. Going "long hand" will also show ways to collapse it later into shorter/faster. Steps 4->7 beg to be integrated, but resist the temptation until you see how clearly.

I first wrote code in '70 (Fortran!), but still use this approach until I have a Real Good Idea on a unified algorithm. Good Hunting... <<<)))

P.S. as to #3: Are you reading the whole string Then displaying it? You may be getting "overrun" by the scale.
 
Last edited:

As the OlP post asks, are you trying to display each character as its received in the UART, if so this could be the reason that you are getting corrupt data.
Use the '#' character as a sync and store all the data string in a buffer, when you get the CRLF, THEN display the buffer.

I thought from your first post, you were not getting any data on the LCD.
 
Eric

I've isolated the digits that I want to show but if the instrument shows 19994 then it shows someting like 1---4 on my lcd (Where - = some weird characters)
It also look like all numbers from 0 to 4 are displayed correct bv. If I set the instrument to read 12345 my lcd would display everything correct except for the last digit.
 

hi,
I have located the pdf for the Instrotech 5004 indicator, it doesn't give any information for the RS232/UART settings.

Can you recheck the parity, bit length etc.??

EDIT:
How are you compensating in the PIC for the 7bit data byte.????
 
Last edited:
ASCIIBusProtocol

Hi Eric

I think you were right about the 7bit.
If you look at the attatched Character map I can explain.
If I send a 0 I get - on my display & so on.
If the instrument send 0011 0011 for ascii three I see the ascii sign for 1011 0011 on the lcd.
Do you know if there are any way in flowcode to fix this or must I use asm.
I use to do some prog.. in asm before but I'm not realy sure how to compensate in the PIC for the 7bit data byte with asm.
 

Attachments

  • Character map.gif
    153.5 KB · Views: 255

hi,
You could write a software UART subroutine, for the 7 bit data byte.

I dont use flow code, are you able to write in another programming language.??

EDIT:
Look at Nigel's tutorial #7, link near my signature on this post.
Its written for 8bit, but can be modified for 7 bit.
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…