i2c master >> i2cslave need help

jyb

Senior Member
hi all
i am trying to make my own radiocommand system and for this as i have several subsysems which need speed i thought (with hippy's help) to use 3 picaxes. the master 28x2 which runs the main tasks and also drive 8 servo and and some other devices
and two 20x2 picaxe .the first one is the"communications driver" ,it drive an xbeepro
the other one, drives a 3d gyro and 3d accelero (its data flow runs at 115200bds)
at this time ,what i can't reach is i2c communication beetwen master 28x2 and slave "communication driver"
the "communication driver" exchange data at 115200bds with the xbee ,using background interrupt (this part runs correctly)
and when it receives data to transmit to the picaxe 28x2 ,transmit is done via the i2c bus : 20x2 send data to the 28x2's scratchpad
this part of program does not work as my attempt
i joined 2 progs (the sound command are just here for tracing)
some help will be welcome
jyb

[/ATTACH]
 

Attachments

inglewoodpete

Senior Member
It is difficult for me to understand exactly what you are trying to do.

I see that the 40x2 starts off as an i2c mater but then changes to an i2c slave. Also, you have the 20x2 starting as an i2c slave and, after receiving the first i2c message, it becomes an i2c master.

Your arrangement is most unusual and very difficult to manage. Usually, the chosen controlling PICAXE is permanently configured as the master and all others are configured as slaves. The master can write to all slaves. The master can also read from all slaves.

In the usual configuration, the master would need to regularly read from each slave. If a slave has data to send to the master, it would put the data into specific scratchpad locations for the master to read.
 

hippy

Ex-Staff (retired)
Real-time response systems with bus mastering switch-overs are notoriously difficult to design, code, debug and even prove have no flaws. Some massive industrial system failures are a result of race-conditions or deadlocks with cascade and domino effects so the usual approach is not to switch master/slave relationships if you can, avoid race and deadlock whenever possible.

If you are interrupting the 28X2 simply to switch it from I2C Master to Slave and back when done, why not simply use that interrupt to indicate to the Master there's something that needs reading from the Slave ? That's what inglewoodpete is suggesting.

The simpler it can be the more successful it is likely to be.
 

jyb

Senior Member
hello

what i do is just managing the possibility for each cpu to be master (20x2 or 28x2).there is the case when a slave have some data to transmit to other slave : normally ,it is the master who have to monitoring the exchange beetwen slaves :this is an improductive charge to the master and i need to preserve time and speed for all other task
at the beginning all cpu are slaves and it is only when someone have data to transmit to anyone ,at this time only it turn into master, and just after transmit ending it return to the slave state.exchanging short messages this principle could run . a step higher ,if there is too much collisions ,is to use a common flag which must be tested before transmit occurs.If set ,means i2c bus is busy ,after transmit flag is cleared and i2c bus free
this the target to reach, but as i am french, my english is too much bad and i have some difficults to understand the explanations given by manuals .This is my major difficult

regards
jyb
 

jyb

Senior Member
you are right

hippy ,you are right The simpler it can be the more successful it is likely to be
the more an idea is simple and more it will run correctly but where is mind
pleasure ? having an idea and improving it ;i consider programing activity same as playing chess or others "brain storming games"
doing this, i try all possilities offered by each picaxe basic command and much more understand what i could do better with it
the actually step for me is to try 3 picaxes on same bus
in french this is "un mouton a cinq pattes"(five legs shep)
may be you think like ? are you picaxe lover ?
me too

regards
jyb
 

eclectic

Moderator
@jyb

I do not speak French.

Is Google translate good enough?
Code:
mode Master, c'est quand le PICAXE contrôle le bus I2C. Il contrôle d'autres «esclave» 
dispositifs comme les mémoires EEPROM de la mémoire et peut «parler» à n'importe quel appareil sur le bus I2C. 
Mode esclave, c'est quand le PICAXE est contrôlée par un dispositif maître différents (par exemple 
un autre microcontrôleur). Il ne peut pas parler à d'autres périphériques sur le bus I2C. 
- SlaveAddress est l'adresse d'esclave I2C 
- Mode est le mot-clé i2cfast (400kHz) ou i2cslow (100kHz). Notez que ces 
mots-clés doivent changer pour i2cfast_8, i2cslow_8 à 8MHz, etc 
- Addresslen est le mot-clé ou i2cbyte i2cword. Notez que c'est la 'adressage 
méthode »utilisée par le dispositif I2C (soit environ EEPROM utiliser une adresse de l'octet, certains 
utiliser une adresse de mot). Il n'est pas la longueur des données renvoyées par le hi2cin 
commande, qui est toujours un octet. 
Fonction: 
La commande hi2csetup est utilisé pour configurer les broches PICAXE pour une utilisation i2c et à 
définir le type de périphérique I2C à traiter. 
Description: 
L'utilisation de pièces i2c est couvert plus en détail dans la fiche technique des différents "i2c Tutorial". 
hi2csetup - mode esclave (X2 pièces seulement) 
Adresse de l'esclave 
L'adresse de l'esclave est l'adresse qui est utilisée par la puce PICAXE pour l'identification. 
Il peut être un nombre entre 0 et 127, mais il doit être tenu en bits 7 à 1 de la 
adresse (pas les bits 6 - 0) par exemple 1010000x%. Bit0 est la lecture / écriture bit et donc ignorées. 
Si vous n'êtes pas certain de l'adresse à utiliser, nous recommandons la «norme I2C 
adresse de l'EEPROM "qui est 10100000%. Certaines adresses spéciales i2c (0, 1111xxx%, 
0000xxxx%) ont une signification particulière dans le cadre du protocole I2C et ne sont donc pas 
recommandées car elles peuvent provoquer un comportement inattendu sur les périphériques tiers. 
Description: 
En mode esclave toutes les fonctions de la puce i2c PICAXE esclaves sont complètement 
automatique. Un maître I2C peut lire ou écrire à la puce PICAXE esclave comme s'il s'agissait d'un 
128 (X1, 20X2) ou 256 (X2) byte EEPROM série 24LCxx, avec le bloc-notes 
aire de jeu que la zone de transfert de la mémoire. Le maître peut lire les PICAXE esclave 
puce à tout moment. Cela ne veut pas avoir d'effet notable sur le PICAXE esclave 
programme, les commandes cependant que désactiver les interruptions matérielles internes (par exemple 
etc SEROUT) peuvent affecter le fonctionnement. Voir l'annexe 2 pour plus de détails sur d'éventuelles 
conflits.
Manual 2, page 76

e
 

hippy

Ex-Staff (retired)
hippy ,you are right The simpler it can be the more successful it is likely to be the more an idea is simple and more it will run correctly but where is mind pleasure ?
I understand what you are saying but perhaps it's best to look at it another way. While more intellectually challenging to build a house in a non-simple or different way than it is to build in a simple and boring way - if you cannot do the simple and boring then what hope for finishing the more complex ?

You may get some mind pleasure within the different, but ultimately you may not get what you ultimately want. Does that lose or even negate the pleasure ? Hard to say, it depends on perspective and philosophical outlook, what is ultimately to be achieved; mind pleasure or a working project ?

I would argue if you want both, then create the boring and more simple, prove the project, have it working, then build the more complicated in which you can get that mind pleasure as you go.
 

jyb

Senior Member
thanks eclectic

i proved automatic translation some month ago and i find that automatic translation is equal to my own translation : if i understand the global idea ,it is accurateless ,it does not give the deep signification of each word and phrasis.
in fact i think that automatic translators are not specially made for technical languages
so i must try and verify what it seems i understand for each command
it costs me much time !!

thanks for your help
 

eclectic

Moderator
i proved automatic translation some month ago and i find that automatic translation is equal to my own translation : if i understand the global idea ,it is accurateless ,it does not give the deep signification of each word and phrasis.
in fact i think that automatic translators are not specially made for technical languages
so i must try and verify what it seems i understand for each command
it costs me much time !!

thanks for your help
@jyb

In the future, please
ask your questions in French
and again in English.

There are several multilingual people on the Forum.


Ec
 
Top