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

Modbus implementation
Goto page Previous  1, 2, 3, 4, 5, 6
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
scrwld



Joined: 28 Jun 2010
Posts: 3

View user's profile Send private message

PostPosted: Mon Jun 28, 2010 2:29 am     Reply with quote

Hello everyone. I'm new to this forum.

I have the same problem, works with max232 and MAX485 does not work, take an inverter gate I had on hand (74HC14) and now works, no 100 percent.From my experience with modbus have never had to add some additional device to work.

continue to seek the reason for this when have some results I will indicate.

regards

luis lopez



http://www.subirimagenes.com/otros-pic16f877232485-4728280.html
yerpa



Joined: 19 Feb 2004
Posts: 58
Location: Wisconsin

View user's profile Send private message Visit poster's website

PostPosted: Mon Jun 28, 2010 10:25 am     Reply with quote

You could try swapping your two serial data lines (data+ and data-). This should perform an inversion just like your inverter chip, without requiring the inverter chip.
SimpleAsPossible



Joined: 19 Jun 2004
Posts: 21

View user's profile Send private message

Other hardware options
PostPosted: Wed Jun 30, 2010 7:46 am     Reply with quote

It looks like the issues here MIGHT have to do with the software enabling the transmitter, so a change to the hardware might help.

I have successfully used a circuit I found in a Circuit Cellar RS-485 article a few years ago. It uses a 555 timer as a retriggerable one-shot, triggered by the negative edge of TX. The output is used as the enable signal for the 485 driver. Once TX goes high and stays high, the one-shot times out, after approximately one character time. The only connections to the driver circuit are the RX and TX lines -- no enable necessary.

If it turns out that the problem really is that the software is not correctly handling the enable line, this will take care of it. Or at least diagnose it so you can find a solution you like.
scrwld



Joined: 28 Jun 2010
Posts: 3

View user's profile Send private message

PostPosted: Wed Jun 30, 2010 10:54 pm     Reply with quote

yerpa, simpleaspossible thanks for your response.

I change the connection and runs but tends to give errors and lost communication. The correct connection is A-A B-B.

The program has a break of about 3 milliseconds and this is the best value to give me a result, the problem is that after transmission during that time the slave has ability exit and this causes collisions with other slave or master.

Code:

PORTE.2 = 1 '/ / PULL RE2 High to start transmission RS-485 mode and wait stabilizes
PAUSE 3 '/ / this value  work 3ms less no work so many error.
For B0 = 1 To Length 'Send the response to Master
B1 = buffer [B0]
Gosub charout
Next B0
PAUSE 3' / / wwhen finish
PORTE.2 = 0' / / PULL RE2 Low to terminate transmission RS-485 mode


With relation to use a 555, I have on hand a B&B converters working in this way without using a 555. Take one and modify it to use the part that interests me and works great now I'm testing takes approximately 2 hour without errors at 19200 delay between polls 500 ms.

Tomorrow I'll connect to a PLC with a network of 20 modbus nodes and see how it works.

regards

luis lopez


Ver Imagen: http://s2.subirimagenes.com/otros/previo/thump_4743590rs485.jpg
iman_zahari



Joined: 20 Jul 2010
Posts: 15

View user's profile Send private message Yahoo Messenger

PostPosted: Tue Jul 20, 2010 11:44 pm     Reply with quote

Hey guys, in ex_modbus_slave.c , what does these means?

int8 coils = 0b00000101;
int8 inputs = 0b00001001;
int16 hold_regs[] = {0x8800,0x7700,0x6600,0x5500,0x4400,0x3300,0x2200,0x1100};
int16 input_regs[] = {0x1100,0x2200,0x3300,0x4400,0x5500,0x6600,0x7700,0x8800};
int16 event_count = 0;


Does this really implies that the pin b0 and b2 will always be high? If that is so, why is the inputs are already defined as b0 and b3 will always be high, meanwhile b2 will be low? This will cancel of the coils output at b2?

The other thing is, why are the holding registers and input registers are set at 0x8800, 0x7700 etc? Why it doesn't use as only 0x0000, 0x1000 etc?

Thanks.
iman_zahari



Joined: 20 Jul 2010
Posts: 15

View user's profile Send private message Yahoo Messenger

PostPosted: Wed Jul 21, 2010 12:50 am     Reply with quote

I tried using modbusview. When I tried to force coil 01 to go high, the reply is high,

transmit:
[01] [05] [00] [FF] [00] [8C] [3A]

receive:
[01] [05] [00] [FF] [00] [8C] [3A]


So I guess it is correct. But, when I tried to read the value of the coil at 01, the result is like this,

transmit:
[01] [01] [00] [00] [00] [64] [3D] [E1]

receive:
[01] [81] 02] [C1] [91]

Which is an exception value of illegal data address. I am not very sure of what it means, does this mean that I have to write an exact address for this type of coding in the ex_modbus_slave.c file?

I am using the exact code with modbusview set to master with USE_WITH_PC 1. Nothing else changed. Can someone help me?
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Wed Jul 21, 2010 2:24 am     Reply with quote

The data you show are different from the addresses and quantities used in the MODBUS-Master example. The quantity of 100 used in read_coils request is outside the range provided by the slave example. It's correct to throw an execption in this case, check the code.
iman_zahari



Joined: 20 Jul 2010
Posts: 15

View user's profile Send private message Yahoo Messenger

PostPosted: Fri Jul 23, 2010 1:19 am     Reply with quote

The length is the buffer size rite? Sorry but I'm not sure where to locate it.
iman_zahari



Joined: 20 Jul 2010
Posts: 15

View user's profile Send private message Yahoo Messenger

PostPosted: Fri Jul 23, 2010 1:23 am     Reply with quote

All right. I got it. It is 5. I got confused by the buffer size. But if int8 coils = 0b00000101 is the number of length, then what int8 inputs = 0b00001001 is supposed to mean?
iman_zahari



Joined: 20 Jul 2010
Posts: 15

View user's profile Send private message Yahoo Messenger

PostPosted: Sat Jul 24, 2010 2:33 am     Reply with quote

oo ok. i got it all now. tqvm FvM
bbnnbb



Joined: 09 Mar 2012
Posts: 3

View user's profile Send private message

HELP
PostPosted: Fri Mar 09, 2012 5:06 am     Reply with quote

PLEASE SIR I HAVE THE SAME PROJECT AS YOU CAN YOU HELP AND ALSO TEL ME WICH HMI YOU USED;
BEST REGARDS,
_________________
HELLO EVERY BODY!,AM WORKING IN MY FINAL PROJECT IN IMPLEMENTATION OF THE MODBUS AND INTERFACING WITH HMI SO I NEED HELP IN MY PROJECT (I USE LIBRARY MODBUS OF CCS)
bbnnbb



Joined: 09 Mar 2012
Posts: 3

View user's profile Send private message

help on HMI
PostPosted: Sun Mar 18, 2012 7:20 am     Reply with quote

please sir can you advise me with which HMI you choose cause i did the same work as you except the analog output (not yet problems with MCP4921) and now i need an HMI software.
_________________
HELLO EVERY BODY!,AM WORKING IN MY FINAL PROJECT IN IMPLEMENTATION OF THE MODBUS AND INTERFACING WITH HMI SO I NEED HELP IN MY PROJECT (I USE LIBRARY MODBUS OF CCS)
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 Previous  1, 2, 3, 4, 5, 6
Page 6 of 6

 
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