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

EX_RS232_485.C FILE of PIC CCS

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



Joined: 20 Aug 2021
Posts: 5

View user's profile Send private message

EX_RS232_485.C FILE of PIC CCS
PostPosted: Sun Aug 22, 2021 11:37 am     Reply with quote

I want to simulate the circuit from ex_rs232-485.c file to see how it works but I wonder what the devices in it include, is it like I am drawing like in the picture?

https://drive.google.com/file/d/136M5FzTJOgVgUO4s_XBjgxWGxnPXHYXx/view?usp=sharing

Code:

/////////////////////////////////////////////////////////////////////////
////                             EX_RS232_485.C                      ////
////                                                                 ////
////     Converts RS485 data and puts it onto RS232 data line.       ////
////                                                                 ////
////  Jumpers:                                                       ////
////     PCM,PCH    pin B2 to RS232 RX, pin B1 to RS232 TX           ////
////                                                                 ////
////                                                                 ////
////  The following conditional compilation lines are used to        ////
////  include a valid device for each compiler.  Change the device,  ////
////  clock and RS232 pins for your hardware if needed.              ////
/////////////////////////////////////////////////////////////////////////
////        (C) Copyright 1996,2003 Custom Computer Services         ////
//// This source code may only be used by licensed users of the CCS  ////
//// C compiler.  This source code may only be distributed to other  ////
//// licensed users of the CCS C compiler.  No other use,            ////
//// reproduction or distribution is permitted without written       ////
//// permission.  Derivative programs created using this software    ////
//// in object code form are not restricted in any way.              ////
/////////////////////////////////////////////////////////////////////////

#include <16F627A.h>
#device *=16
#fuses HS, NOWDT, NOLVP, NOBROWNOUT, NOPROTECT, PUT
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_B2, rcv=PIN_B1, stream=PC)


++++++++++++++++++++
Code mostly removed.
Reason: Forum rule #10

10. Don't post the CCS example code or drivers, or ask for such code and drivers.

Forum rules:
http://www.ccsinfo.com/forum/viewtopic.php?t=26245

- Forum Moderator
++++++++++++++++++++
temtronic



Joined: 01 Jul 2010
Posts: 9106
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Aug 22, 2021 1:48 pm     Reply with quote

From a quick look...
1) you only need 1 set of resistors.....

2) the PC will need to control /RE and DE

3) PIC can have /RE and DE tied together, controlled using 1 I/O pin

4) depending on how you 'simulate' the devices, it may not work. Proteus ,for example , doesn't not 'simulate' PICs very well.
Tony Stark



Joined: 20 Aug 2021
Posts: 5

View user's profile Send private message

PostPosted: Sun Aug 22, 2021 8:27 pm     Reply with quote

How many PICs do I need to make it?
what will the pic connect to, i connect like in the picture(on post) is there anything wrong?, and how do i post picture on this forum?
temtronic



Joined: 01 Jul 2010
Posts: 9106
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Aug 23, 2021 4:33 am     Reply with quote

1 as you posted,
in addition to my previous post
you need to add xtal/2csp to the PIC
/MCLR needs to be tied high
VDD and GND from PSU are required
VDD and GND to the MAX487 device
bypass caps on both
gnd from PC RS232 connector to PIC
pullup for MAX487 needs to be tied to VDD, NOT gnd ( you show TWO different symbols for GND)
'scope' not connected to RXD of PC
TXD of PC not needed as you disabled the PC MAX487 from transmitting
Ttelmah



Joined: 11 Mar 2010
Posts: 19221

View user's profile Send private message

PostPosted: Mon Aug 23, 2021 7:08 am     Reply with quote

I think you need to understand what this software involves.
It is a set of routines to support sending messages between similar devices
on an RS485 bus.
Each device can send messages to other numbered devices on the bus,
and receive messages from other devices on the bus.
Now, you could 'watch' this traffic on a PC, but unless the PC has similar
code in it, the PC will not have an ID, and will not identify 'messages'. To have
the PC do this, you would need a PIC running the same code as an interface
to the PC (so with two serial ports, one RS485, talking to the bus, and
one simple RS232 talking to the PC), and have the code in this send
the messages that it sees 'on' to the PC, and have stuff received from the
PC sent on as messages,.
There needs to be a minimum of two devices running this code, but the
maximum depends on how many devices you want.
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