|
|
View previous topic :: View next topic |
Author |
Message |
Tony Stark
Joined: 20 Aug 2021 Posts: 5
|
EX_RS232_485.C FILE of PIC CCS |
Posted: Sun Aug 22, 2021 11:37 am |
|
|
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: 9271 Location: Greensville,Ontario
|
|
Posted: Sun Aug 22, 2021 1:48 pm |
|
|
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
|
|
Posted: Sun Aug 22, 2021 8:27 pm |
|
|
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: 9271 Location: Greensville,Ontario
|
|
Posted: Mon Aug 23, 2021 4:33 am |
|
|
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: 19591
|
|
Posted: Mon Aug 23, 2021 7:08 am |
|
|
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. |
|
|
|
|
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
|