Using Hserin

SAborn

Senior Member
When using Hserin with a 18m2 i am a little miffed to the values that are received and was wondering if someone can explain how the values relate to the data sent.

Example:- i send a "R" via serial and the value received with serrxd is 82 or R as expected, now using Hserin reading the same "R" it gives a value of 43 or ascii + why the 43???

Sending the same "R" through serial using a VB program gives a value of 171 using Hserin.

The results are always the same and i can make no sense of why, i do realize with Hserin it stores raw data but what format is this raw data.
 

inglewoodpete

Senior Member
baud rate, clock speed, true/inverted, stop bit, parity bits and finally, VB encoding selection all affect what you send and receive.

I use SerialPort.Encoding = System.Text.Encoding.GetEncoding(28591) for encoding: it provides for simple byte values 0-255 rather than multibyte "characters" that are often used by windows applications.

Put an oscilloscope on the wires to see if the error is on the send or receive end.

And, before eclectic asks: "More information, please." :)
 
Last edited:

SAborn

Senior Member
And, before eclectic asks: "More information, please."
What more is there to tell? its a direct com port connection to PC, 4800 baud, 4 mhz clock, and for initial test using PE 5.50 terminal window to send data. (R gives a Hserin value of 43)
Only using/sending 1 byte

Here is a little test program that i used to send "R" via the output buffer and read the value back.

Code:
#picaxe 18m2

disconnect
hsersetup B4800_4, %0

MAIN:
	


	b0 = 0 
	hserin b0

	sertxd (b0,"   ", #b0, 13,10)	
	pause 1000
	
	goto main
 

inglewoodpete

Senior Member
'fraid I don't have a spare M2-series PICAXE to test on, so it's over to others with 18M2s or experience with hSerial on them.
 

hippy

Ex-Staff (retired)
What more is there to tell? its a direct com port connection to PC, 4800 baud, 4 mhz clock, and for initial test using PE 5.50 terminal window to send data. (R gives a Hserin value of 43)
What cable are you using and what is its output polarity ?

The HSERSETUP command indicates you expect Txxxx polarity but download cables to the PICAXE will give Nxxxx polarity.
 

SAborn

Senior Member
The HSERSETUP command indicates you expect Txxxx polarity but download cables to the PICAXE will give Nxxxx polarity.
Perhaps you can explain how that is changed in the HSERSETUP, because be buggered if i can see or make sense of where that is in the manual.
I found the manual very poor in this section, as it chops and changes from X2 parts to M2 parts without making clear what features carry through from each part, and the examples given dont help either.

The cable is a 3 wire direct to physical com port1.
 
Top