CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

PIC18F4550 and RS485 link

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
neo19



Joined: 14 Aug 2012
Posts: 30
Location: France

View user's profile Send private message

PIC18F4550 and RS485 link
PostPosted: Tue Apr 04, 2023 8:50 am     Reply with quote

Hello,

I need some advice about RS232 connection.

I use :
- PCWH compiler 5.050
- PIC 18F4550
- baud=115200

My PIC (Slave) communicates with a microprocessor board and It's working well.

The microprocessor board can read Voltage values from the PIC but it's slow when I use lots of slave PIC. Character frames are around 34 characters.

The PIC send directly the values with :
Code:

for (i=0;i<=6;i++)
      printf("%04.1f ",M_V[i]);
putc('\r');


I would like to optimise the speed of my RS232 connection and send only an 2 hexadecimal value instead of 5 Characters. So the Character frames will be reduce by 4 so around 14 characters. Smile

I use this code :
Code:

     for (i=0;i<=6;i++)
      {
      VLCAN=M_V_int[i] & 0b11111111;
      VHCAN=(M_V_int[i] & 0b111100000000)/16;
      printf("%c%",VHCAN, VLCAN);
      }
     putc('\r');


with VHCAN and VLCAN are bytes


It's working well except if the value are less than 20 !!
In this case, I have strange behaviors.

Is there something I can do to solve this?

Thanks a lot for your help.


Last edited by neo19 on Wed Apr 05, 2023 7:48 am; edited 1 time in total
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Tue Apr 04, 2023 9:28 am     Reply with quote

I think you have a misconception regarding RS232, since this type of cable communication only admits 2 devices
connected to each other, a DTE and a DCE. For the purposes of the RS-232 standard, a connection is defined by a
cable from one device to another, that is, between 2 devices.
neo19wrote:
Quote:
The microprocessor board can read Voltage values from the PIC but it's slow when I use lots of slave PIC.

To achieve this you must implement a connection with RS485 protocol that supports various devices connected to
the network, which makes it possible for multiple nodes.
_________________
Humberto
neo19



Joined: 14 Aug 2012
Posts: 30
Location: France

View user's profile Send private message

PostPosted: Wed Apr 05, 2023 7:50 am     Reply with quote

Hello Humberto,

You are right, I missed Something in my first message :

Of course I'm working with a RS485 connection and protocol. Else it could not work.
gaugeguy



Joined: 05 Apr 2011
Posts: 288

View user's profile Send private message

PostPosted: Wed Apr 05, 2023 8:53 am     Reply with quote

It appears you are trying to mix ASCII characters and binary values together in one message. This will take some very special parsing to get to work as you found out binary values below 20 are ASCII control characters.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group