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 CCS Technical Support

1 o
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
vortexe9000



Joined: 07 Jun 2010
Posts: 50
Location: Banned - spammer

View user's profile Send private message

1 o
PostPosted: Thu May 05, 2011 12:04 am     Reply with quote

sdfg
_________________
Banned for spamming his own posts


Last edited by vortexe9000 on Sun Feb 19, 2012 7:48 am; edited 4 times in total
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Thu May 05, 2011 5:46 am     Reply with quote

It looks like you have a pretty good example right in your post. What problem did you find in it?
_________________
The search for better is endless. Instead simply find very good and get the job done.
temtronic



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

View user's profile Send private message

PostPosted: Thu May 05, 2011 5:54 am     Reply with quote

As for software, CCS supplies some RS-485 examples in the 'examples' folder.Probably a good place to start. Be aware that ISIS,like all simulators will NOT perform like the PICs in the Real World.They are full of bugs and quirks....stick with real code in real PICs in the real world.
vortexe9000



Joined: 07 Jun 2010
Posts: 50
Location: Banned - spammer

View user's profile Send private message

please Help me ...
PostPosted: Thu May 05, 2011 7:36 am     Reply with quote

hjk
_________________
Banned for spamming his own posts


Last edited by vortexe9000 on Sun Feb 19, 2012 7:37 am; edited 1 time in total
vortexe9000



Joined: 07 Jun 2010
Posts: 50
Location: Banned - spammer

View user's profile Send private message

Thanks
PostPosted: Thu May 05, 2011 4:08 pm     Reply with quote

please a simple code in CCS for numerical DATA and message

Idea
_________________
Banned for spamming his own posts
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Thu May 05, 2011 6:35 pm     Reply with quote

Hi,

I have a remote relay project that utilizes multiple 'nodes', and a single 'master' in a 1/2 duplex arrangement. I have defined my own 'protocol' as follows:

Code:

// Here we have the Node command set.

// #N00:Q<CR>         <----- Query Command     - Response is !N00:Q0,0:00000<CR>
// #N00:R<CR>         <----- Reset Command     - No Response
// #N00:S0,0<CR>      <----- Set Command       - Response is !N00:S0,0<CR> - basically an echo
// #N00:V<CR>         <----- Version Command   - Response is !N00:VX,Y


Each node has two relay outputs, and the 'Set' command is used to control them. The #N is just a pre-amble. The 00 is the desired node address (eg. 01, 02, or 03). Q, R, S, and V are the various command types I have defined. Everything else is data, such a 0,0 which turns both relays OFF with the Set command.

The 'node' module uses a serial interrupt to fill a receive buffer with incoming data. Each command always starts with a '#' character, and ends with a <CR> (carriage return), so it's easy to know when a complete command string has been received. Once the valid command string has been received, I first validate the address (the 2nd and 3rd characters of the command with each node having a unique address set by DIP switches) , and then act on the command type (determined by the 6th character). Here is a snippet from the Switch construct that processes the incoming commands after address validation:

Code:


               case 'S':   // here we have the Set command
                  
                  if (gethexbyte(RxBuffer[6]) == 0)
                  {
                     Output_low(Relay1_Output);
                     If (Relay1_Status == 1)               // only write to EEPROM for changes...                     
                     {   
                        Relay1_Status = 0;
                        //Write_EEPROM(0, Relay1_Status);
                     }   
                  }



So, using my example, your node firmware must do the following:

1. Look for a '#' character, and start buffering incoming characters until a <CR> is received, and set a 'valid command' flag.
2. If we have a valid command, look at the address character(s) and compare to the node address.
3. If address match is found, process the command.
4. Loop back to step 1.

Hope this gives you a start!

John
vortexe9000



Joined: 07 Jun 2010
Posts: 50
Location: Banned - spammer

View user's profile Send private message

dfzerf
PostPosted: Fri May 06, 2011 3:57 am     Reply with quote

gghnb
_________________
Banned for spamming his own posts


Last edited by vortexe9000 on Sun Feb 19, 2012 7:47 am; edited 3 times in total
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Fri May 06, 2011 6:23 am     Reply with quote

First, you should not post the CCS example code on this forum. I think it is a copyright violation somewhere in the fine print.

Next, you should have current limiting resistors for those 3 LEDs called Relay 1, 2, 3.

Third, tell us just what problem you are having. It looks like you have a reasonable start. Most (or at least many) of us don't use simulators so we can't help you with simulation problems. What code have you tried? What did it do or not do that you don't want or want?
_________________
The search for better is endless. Instead simply find very good and get the job done.
vortexe9000



Joined: 07 Jun 2010
Posts: 50
Location: Banned - spammer

View user's profile Send private message

PostPosted: Fri May 06, 2011 7:16 am     Reply with quote

vgb
_________________
Banned for spamming his own posts


Last edited by vortexe9000 on Sun Feb 19, 2012 7:30 am; edited 1 time in total
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Fri May 06, 2011 7:58 am     Reply with quote

Hi,

RS-485 communications is one of those areas where you are going to learn next to nothing by simulating the problem alone. You may get it to "work" on your PC, but it very unlikely that it ever work in the "real world". If your simulator doesn't care about LED current limiting resistors, what else doesn't it care about?

IMHO, the CCS-provide 'RS485.c' code is much more than you need for a simple project like this. It's bloated with lots of conditional code that allows it to work with a wide range of PIC's, and a number of different configurations. For a simple job like you have, it's WAY more trouble than it's worth. If you understand the code intimately, you can clean it up and make it functional, but I don't think you are at that point?

I presented a example of a simple network protocol that would do exactly what you want. I've done lots of similar networks for remote relay control, and environmental sensing, and it works. If you REALLY want to learn something here, I'd recommend scrapping the CCS approach, and creating your own code. It will be simpler, and most important, you will understand it!

As far as your hardware goes, the MAX485 chips all need to have pin 2 and pin 3 connected together. This connection is then wired to a pin on the PIC and will control the direction of data on the network. The compiler will automatically handle control of this connection if you specify an 'Enable=' in your #use rs232 directive.

I know that there is lots of code available on the internet, and elsewhere, but you aren't going to learn a whole lot but simply cutting and pasting and then asking "My code doesn't work, why......?"

Good Luck!

John
vortexe9000



Joined: 07 Jun 2010
Posts: 50
Location: Banned - spammer

View user's profile Send private message

PostPosted: Fri May 06, 2011 9:28 am     Reply with quote

cvbhjk
_________________
Banned for spamming his own posts


Last edited by vortexe9000 on Sun Feb 19, 2012 7:31 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: Fri May 06, 2011 12:38 pm     Reply with quote

You had been very well guided regarding this point. I want to reinforce the previous comment. For a begginer it is not
easy to take control of the whole RS485 hardware/software system like this. I strongly suggest to do it in real world,
not by simulation, you should start with the minimum hardware (2 PIC + 2 RS485 transceivers) talking in both way,
one each time. You can define your own protocol and control packets and let your basic system to grow including new
nodes and controls.
In this way you will get a `solid' hardware and software as a starting development plataform. Take it easy.
The simulation are good, but for a begginer you loose the feeling of the real world, I mean, if you do not connect a real
resistor between the PIC pin and the LED, for sure you will say "good bye" to the PIC. In the real world, things burn
and die, and this CANT be ignored in your learning stage.
Looking around, you will find many codes that could do what you want, but the best code in this stage is the one that
you can understand and manage. THEN you would learn how to do it solid and efficient.
Write and post your own code. There are many people looking at, and for sure you will receive many helps, more than
if you copy and paste code from somebody.
My 2 cents contribution. Good luck.

Humberto
temtronic



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

View user's profile Send private message

PostPosted: Fri May 06, 2011 2:21 pm     Reply with quote

The 'simulator' you're using , doesn't care if you have correctly wired the PIC for a crystal and caps, power supply pins or current limiting resistors.
ANY of those NOT done in the real world will spell disaster. It even doen't warn you that the xmt/rcv pins are wired wrong to the DE-9 connector !
After 40 years of designing with micros(25 with PICs) there isn't ONE simulator that I'd use let alone have any faith in. NONE simulate the real world.Your circuit can have over 40 flaws in it that the 'simulator' will NOT warn you about. Then again you get what you pay for. ISIS/Proteus is free and frankly you couldn't pay me to use it.
Do yourself a HUGE favour. Get rid of it, buy a couple of 'white solderless breadboards', a handful of parts and learn by doing. You'll be much further ahead from dealing with true 'hands on' work. You'll remember the 'little details (xtal caps, pin #s, proper fuse options, etc.) that simulators NEVER care about BUT must be correct for projects to work in the real world!
vortexe9000



Joined: 07 Jun 2010
Posts: 50
Location: Banned - spammer

View user's profile Send private message

Hi friends ...
PostPosted: Sat May 07, 2011 4:58 am     Reply with quote

drtze
_________________
Banned for spamming his own posts


Last edited by vortexe9000 on Sun Feb 19, 2012 7:31 am; edited 1 time in total
vortexe9000



Joined: 07 Jun 2010
Posts: 50
Location: Banned - spammer

View user's profile Send private message

PostPosted: Sat May 07, 2011 11:28 pm     Reply with quote

eeferty
_________________
Banned for spamming his own posts


Last edited by vortexe9000 on Sun Feb 19, 2012 7:32 am; edited 1 time in total
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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