ASCII Limit

Status
Not open for further replies.

Suraj143

Active Member
I want to send an 8bit value (0 to 255) from PC to PIC UART.

I use VB 6.0 to send that values.I have a decoding problem at PIC UART side.

If I send D'1' then PIC will receive it as D'49'.

What about If I send D'30' what value will I receive from PIC side?

What about If I send D'129' what value will I receive from PIC side?
 
Last edited:
Try sending 0x01 and if that doesn't work then post example Pic and VB code. You're somehow sending the ascii value for 1 which is 0x31 or decimal 49.

Mike.
 

You need to read the helpfile for your assembler/compiler - to check what it sends - but commonly placing quote marks around a figure (like '1') instructs it to send the ASCII character inside the quotes (which is what you appear to be getting).

But D'129' etc. doesn't really make much sense - D is trying to send a decimal numeric value, and the quotes are trying to send an ASCII character.
 
Hi thanks for your info.

This is what I want to do.I have many slaves connected to two wire bus.I'm giving commands through a PC.
Ex: Turn ON relay 4 on slave 2.

The attachment shows the frame I'm using.In simply its a MODBUS frame.

Earlier I planned to use a binary format frame but when PC sends commands the frame data goes to all slaves so it is unable to detect the start & end of a frame.

So I planned to use ASCII format frame.The problem is when using ASCII to show a single byte it needs to send as two ASCII characters so the frame length will be doubled.

Any ideas on my protocol structure?
 

Attachments

  • Frame Sructure.PNG
    5.4 KB · Views: 188
Last edited:
The attachment shows the frame I'm using.In simply its a MODBUS frame.
It doesn't look like a modbus frame. If it was ASCII, it's missing a leading ":" and a trailing linefeed (vbLf). If it's binary/RTU then it has an unwanted trailing 0x0D.

The ASCII modbus and the RTU/binary modbus frames both have the same information content (which includes the device address).

If I send D'1' then PIC will receive it as D'49'.

What about If I send D'30' what value will I receive from PIC side?
It seems you are not sending D'1' but "1" - e.g. The VB6 code should look something like (assuming you're using the MSCOmm control):
Code:
MSComm1.output = chr(1)      'correct: this will send D'1'
and not
Code:
MSComm1.output = "1"     ' WRONG - this will send D'49'
 
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…