MPCM mode, send data from slave to master ?

Go To Last Post
43 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hello,

i have a question about the MCPM mode.

1x master atmega 2560 

2x slave atmega 16

 

i can alredy send data from the master to each of te slave's, but i have now send data from the slave to the master.

i read a lot of documentation, but i can't find anything about this case.

maybe someone can help me with this ?

 

thank you.

This topic has a solution.
Last Edited: Thu. Apr 16, 2020 - 08:17 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The idea is that the Master addresses the slave, and then that slave - and only that slave - is allowed to reply

 

So the Slave's reply is just a normal UART transmission

 

EDIT

 

You might want to take a look at this thread:

 

http://www.8052mcu.com/forum/read/183501

 

read the whole thread.

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Fri. Apr 3, 2020 - 07:38 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

thank you, i'm gonna read it.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You may also want to look at using serial S.N.A.P protocol to use in M/S mode instead of the MSCP as it uses normal serial comms.

You can find info on S.N.A.P here: http://www.hth.com/snap/

Arduino lib here: https://github.com/PHaroZ/arduin...

Enjoy

 

Jim

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

Last Edited: Fri. Apr 3, 2020 - 08:51 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

no,... the communication between the master and the slaves is verry little and easy. 

for that i don't need a protocol.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 2

But as soon  as you talk about slaves returning values you need some kind of call/response protocol?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Indeed.

 

And you also need some "special" hardware support; you can't just short all the Slaves' transmitters (outputs)  together - they have to be specifically designed (or modified) to allow that ...

 

EDIT: AVRs do have such "special hardware support" - see Brian's reply below.

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Thu. Apr 9, 2020 - 11:38 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:

And you also need some "special" hardware support; you can't just short all the Slaves' transmitters (outputs)  together - they have to be specifically designed (or modified) to allow that ...

 

Actually, you can just short them together. If you disable the transmitters in the slaves, and only enable them when there is a reply to send back to the master, you can just wire them all together. If TXEN is cleared then there is no longer any override of the TX pin port direction so it'll revert to the default which is an ordinary input.

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#2 Hardware Problem? Read AVR042.

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ah - I was being over-general, having just come from this thread: https://www.avrfreaks.net/forum/can-single-uart-send-data-multiple-device

 

Sorry about that. I've updated the post.

 

Brian Fairchild wrote:
If you disable the transmitters in the slaves

That counts as "some 'special' hardware support":

 

I wrote:
they have to be specifically designed (or modified) to allow that

ie, they have to have some way to disable the transmitter, or have a "bussable" output; eg, open-drain.

 

But this thread is specifically about AVRs - so,as you say, they do have the enable/disable transmitter facility.

 

But PC COM Ports (whether real or via USB) generally do not.

 

Also, if the AVR is being connected via some sort of driver (eg, RS232) you have to ensure that has the enable/disable transmitter facility

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Thu. Apr 9, 2020 - 11:39 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

trixo wrote:
i don't need a protocol

Yes, you do!

 

It may be a very simple protocol - but it is still a protocol!

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Y'all seem to be concentrating on the AVR. If OP has a multi-drop setup as mentioned, then are there transceivers in play?  RS-485 or RS-422?  Then I have many apps with MPCM where the AVR's TXEN is never changed, but rather the '485 driver is tickled.

 

If direct connect, or other driver style -- indeed trickier.

 

I had a couple apps where there was a "quiet time" between rounds of polls, and a slave could beg for attention.  Kind of a poor-man's Ethernet.  Certainly there would be other ways of using that principle, or token passing, or TDM, or other.

 

All that said, what situation is OP trying to solve?  Continuous polling of each slave would be, say, a millisecond apart.  Are you really going to get faster response in another way?

 

 

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

Last Edited: Thu. Apr 9, 2020 - 01:05 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

theusch wrote:
Y'all seem to be concentrating on the AVR

That's because the OP is specifically talking about AVRs:

 

In #1, trixo wrote:
1x master atmega 2560 

2x slave atmega 16

 

I forgot this in #7, and Brian called me up on that in #8

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Thu. Apr 9, 2020 - 01:39 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hello,

 

sorry, i forget to say the i'm ussing RS485 (max485).

 

the situation is that the slaves first only receive a litle bit of data, 

and that they,... lets say 30 sec. later send data to the master. 

 

so there is no mixing from  receiving & transmiting in a short time.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:

Y'all seem to be concentrating on the AVR

 

That's because the OP is specifically talking about AVRs:

 

Sheesh.  Did you bother to read the rest of my opus, or did you stop after a handful of words to dash off your "correction"?  If you reread my post, do you see the point that if you have an external gating device such as RS485 transceiver it doesn't matter whether the AVR has a TXEN bit or not?  Or is that so far-fetched?

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

trixo wrote:
sorry, i forget to say the i'm ussing RS485 (max485).

 

You left out a really important piece of information.......  Not nice.

 

JIm

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

i didn't realized that was important information blush

sorry for that.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

trixo wrote:

i didn't realized that was important information blush

sorry for that.

 

 

Seriously?  Were you not reading the others coming up with alternative ideas of 'hardware support' based on your OP?

 

When you re asking for help include EVERYTHING.  No matter how trivial you may think it is.

 

JIm

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

trixo wrote:

sorry, i forget to say the i'm ussing RS485 (max485).

 

MPCM will still work. You will, as theusch says, need to control the transmit buffer on your slaves.

 

trixo wrote:

the situation is that the slaves first only receive a litle bit of data, and that they,... lets say 30 sec. later send data to the master. so there is no mixing from  receiving & transmiting in a short time.

 

OK, so whether you like it or not, you will need some sort of protocol.

 

Question, can any slave reply to the master's message after 30 seconds or only a slave who has been sent that message?

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#2 Hardware Problem? Read AVR042.

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

MPCM will still work.

Have used it with Motorola HC11, HC05, PIC (shivers.... ) AVR and maybe others for a long time.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

in my start post i said i have 2 slaves, and that is what i have now.

but it can be later on extended to 12 slaves.

 

it start with:

master to slave 1 -> start your job

master to slave 2 -> start your job

.

.

.

.

.

master to slave 12 -> start your job

 

after 30 sec.

master ask slave 1 please send me your data.

master ask slave 2 please send me your data.

.

.

.

.

master ask slave 12 please send me your data.

Last Edited: Fri. Apr 10, 2020 - 06:34 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

js wrote:
maybe others for a long time.

I think it originated with the 8051 ?

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

trixo wrote:

...for that i don't need a protocol.

 

trixo wrote:

in my start post i said i have 2 slaves, and that is what i have now. but it can be later on extended to 12 slaves.

...

master ask slave 12 please send me your data.

 

Whether you realise it or not, that is a protocol.

 

With the information you have now posted it should become clear to you how to write your code. You need two types of message from the mater to the slave...

 

[start_of_message] [slave_address] [start_your_job]

 

...and...

 

[start_of_message] [slave_address] [send_your_result]

 

No need for MPCM at all as you can encode the slave address right in the message. Each of those messages could be as small as 3 bytes but you might want to append a CRC onto each one.

 

The slaves reply could be something like...

 

[start_of_message] [ slave_address] [length_of_data] [data_1] ... [data_n]

 

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#2 Hardware Problem? Read AVR042.

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Brian Fairchild wrote:
No need for MPCM

Sure, but what MPCM gives you is a way for the UART to automatically recognise the address/start-of-message - with no software overhead.

 

I'm not sure if the AVR does it, but the 8052 could also do the address matching in hardware - with no software overhead.

 

Thus, when not addressed, the MCU would be totally oblivious to any & all traffic on the line. It could sleep, if it were a low-power application.

 

 

EDIT

 

"could" rather than "would"

 

EDIT 2

 

This probably not so much of a Big Deal nowadays - with improvements in microcontroller performance, memory capacity, etc

 

Possibly a more significant issue nowadays would be using standard stuff - not relying upon proprietary hardware features like this ... ?

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Fri. Apr 10, 2020 - 08:49 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

what i already said in my first post, is that i already can send a "start your job" code to each of the slaves.

now i need data back from the slaves, so i:

master side

1e - pin 2&3 from max485 --> "1"  // put in transmit mode

2e - make TXB80 = "1" // ninth bit

3e - send adress slave

4e - send data // who's tell the slave: send me your data

5e - send stop code

6e - pin 2&3 from max485 --> "0"  // put inreceive mode   I'M NOT SURE THIS IS CORECT ?

 

slave side

from when i received the data who's tell the slave: send me yourdata

1e - pin 2&3 from max485 --> "1"  // put in transmit mode  I'M NOT SURE THIS IS CORECT ?

from here i don't no what to do ??????????????????????????????

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

and, as I said in the first reply, there is really nothing special about doing the reply!

 

In #2, I wrote:
So the Slave's reply is just a normal UART transmission

 

The only thing you need to take care of is to ensure that all the slaves which are not addressed have their transmitters disabled (or hi-Z, or whatever)

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

sorry but my english is not that good that i always understand the reply's correctly.

 

what you say goes automatically correct i think, because i used a MAX845 (by each slave and the master). 

 

the data sheet, give's a lot of information over sending from the master to the slave. but nothing about the other way around.

Last Edited: Fri. Apr 10, 2020 - 08:38 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

trixo wrote:
but nothing about the other way around.

Because, again, there is nothing special about that - MPCM is irrelevant to that part.

 

MPCM is really just about providing an addressing mechanism from Master to slave. Nothing more.

 

As noted in the link I gave, you might choose to make further use of the 9th bit for your own purposes in your own protocol - but that's entirely up to you.

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

thanks for your patience yes

 

Quote:

MPCM is really just about providing an addressing mechanism from Master to slave. Nothing more.

 

this open my eyes, a little bit more.

 

Last Edited: Fri. Apr 10, 2020 - 08:57 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


Let me give you a clue. Note: I will not answer any questions about this code, it is up to you to figure it out. This is from a real life unit, currently installed in over 500 locations worldwide, which has a master controller and can support multiple slaves.

 

 

#define TX_ON PORTD.2=1;
#define TX_OFF PORTD.2=0;


void putchar(char c)
{

    while (g_tx_counter == TX_BUFFER_SIZE);

    #asm("cli")
    if (g_tx_counter || ((UCSRA & DATA_REGISTER_EMPTY)==0)) {
        // tx register is not empty so put in buffer
        g_tx_buffer[g_tx_wr_index]=c;
        if (++g_tx_wr_index == TX_BUFFER_SIZE) {
            g_tx_wr_index=0;
        }
        ++g_tx_counter;
    } else {
        // tx register is empty so turn on line driver and go
        TX_ON;
        UDR=c;
    }
    #asm("sei")
}

interrupt [USART_TXC] void usart_tx_isr(void)
{

    if (g_tx_counter) {
    // more data in buffer so output it
        --g_tx_counter;
        UDR=g_tx_buffer[g_tx_rd_index];

        if (++g_tx_rd_index == TX_BUFFER_SIZE) {
            g_tx_rd_index=0;
        }
    } else {
        // no more data in buffer so turn off line driver
        TX_OFF;
    }
}

 

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#2 Hardware Problem? Read AVR042.

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Brian Fairchild wrote:

The slaves reply could be something like...

 

[start_of_message] [ slave_address] [length_of_data] [data_1] ... [data_n]

For multi-slave setups, you'd need an extra field:

 

[start_of_message] [ slave_address] [this_is_a_slave_reply] [length_of_data] [data_1] ... [data_n]

 

Otherwise, other slaves might try to interpret the [length_of_data] field as a packet-type field.

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This is the MPCM packet format I have been using for years. It's an adaptation of my early understanding of MPCM.

The protocol for the RS485 buss is as follows:
It is a 9 bit comms protocol with bit 8 used for address or data marker. 1=Address, 0=Data

 

PKD_ADR    1  ; Destination address (0x01-0xff, 0 not used) bit 8=1
PKO_ADR    1  ; Origin address (0x01-0xff, 0 not used) bit 8=0 from now on
PK_N_BYT   1  ; Number of bytes in packet (0x00-0xff, 0 is used for data request)
PKIO_DATA  PKIO_DATA_SIZE       ;Space for data
PK_CRC     2  ; 16 Bit CRC   MSB,lsb

 

CRC must be initialized to $FFFF, polynomial 0xA001

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

Last Edited: Fri. Apr 10, 2020 - 09:36 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hello,

i am a little bit further, when a connect a logic analyzer on the connection between the atmega 16 and the 

max485, i can see that the slave puts the data on the bus (0b10101010) but i don't get it in to the master.

i'm gonna post the part of code from the master who's have the job to do this.

i hope some one can tell me, whats go wrong.

firts you see in the code the request: "send me your data"

and then :"receive data from TSOP" (who is the slave).

i really appreciate your help,...thanks.


 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

trixo wrote:

...when a connect a logic analyzer on the connection between the atmega 16 and the max485, i can see that the slave puts the data on the bus (0b10101010) but i don't get it in to the master.

 

Is that when you look on the input pin to the MAX or on the RS-485 data lines themselves? ie Have you proved that you MAX chip is working correctly?

 

And, likewise, at the master end, have you checked that you get the right data out of the MAX chip and into the mega2560 with a scope/logic analyser?

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#2 Hardware Problem? Read AVR042.

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
between the atmega 16 and the max485

so that is be on the input from the MAX485 on the slave.

i didn't check it on the master between MAX485 and the atmega 2560,.......good point

 

i checked and it was not OK.

for some or other reason the TX from the slave passed not the MAX 485.

working on it now.

Last Edited: Sun. Apr 12, 2020 - 02:36 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


It'll be worth checking at all 4 possible points where the MAX chips connect to the AVRs.

 

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#2 Hardware Problem? Read AVR042.

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Might want to make sure you have your control inputs set properly too

Jim

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

i checked and it was not OK.

for some or other reason the TX from the slave passed not the MAX 485.

working on it now.

 

yes i think it has something to do whit the RE & DE on the MAX 845.

 

the other hardware connections where OK

 

 

Last Edited: Sun. Apr 12, 2020 - 04:33 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just remembered.....put a 10k pull-up resistor on RO.

It's important.
Jim

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hello,

i have make some steps, the fault i made was that on the master and the slave the DE pin from the max485 was "1".

of course there can only 1 max 485 have his DE pin high.

 

so i changed that in the code, and now i see the pulstrain (10101010) on the RX pin from the master.

but it looks that i don't get the pulse train in to the UDR0 register.

i have a line in the code where the programm don't passes.

 

while ((UCSR0A & (1 << RXC0)) == 0) {};   // Do nothing until data have been received and is ready to be read from UDR
receivedbyte = UDR0;                                 // Fetch the received byte value into the variable "ReceivedByte"

 

 so i have a pulse trein on the RX pin (pinE0), but the interrupt which says: hello there is unreaded data in the register  whil not be excecuted ?

 

Last Edited: Thu. Apr 16, 2020 - 07:04 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

trixo wrote:
but the interrupt which says: hello there is unreaded data in the register  whil not be excecuted ?
 What does this line mean? I don't think it translates well.

 

With the max485 chips - the bus is connected pin 7-7,6-6? If you swap them, then you'll have problems.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

it was may be not correct english smiley but the program wil not passes the:

 

while ((UCSR0A & (1 << RXC0)) == 0) {};   // Do nothing until data have been received and is ready to be read from UDR
receivedbyte = UDR0;                                 // Fetch the received byte value into the variable "ReceivedByte"

 

the RXCO pin stays "0" while there is a pulse train on the RX pin.

 

no 7-7 6-6 who is A & B is correct connected. i can send comando's master -> slave.

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

update:  it works corectly now. when i received data in the master, i have to make the MPCM bit in the UCSR0 byte low........of course.

thanks for your help yes

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

trixo wrote:
it works corectly now.

So please mark the solution - see Tip #5 in my signature, below.

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...