Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 16:44 04 Jul 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Mite to Picaxe I2C problem

Author Message
Bizzie
Senior Member

Joined: 06/07/2014
Location: Australia
Posts: 192
Posted: 11:26am 15 Jan 2015
Copy link to clipboard 
Print this post


Background:
I have had a system of Picaxe 20X2’s working as low speed counters for about 4 years.
It consists of one PicAxe acting as the master and up to 5 slave devices. Each of these 5 devices monitor 12 pins for contact closures (reed switches). The slaves write their data to the scratchpad memory and this is then read by the master and transmitted via the serial port to a PC.
The client (well really my son involved in university research) wants to now receive that data by email once a day.

My solution:
Replace the master with a CGColorMax2-B so I can use an ESP8266 to get an internet connection and also have the benefits of the SD card and RTC
My problem: I can not get the MM and a slave PicAxe 20X2 to “talk” via I2C.
I am certain there is no connection problems on the CGColorMax2-B as I can use a MicroMite as a slave successfully using the code on page 55 of the MicroMite 28-pin chip User Manual Ver 4.5 by Geoff Graham.
When I replace the MM28 with the picaxe and use the program below I can not read the data I have placed on the scratchpad of the picaxe (PUT 0,0 PUT 1,1 ….. PUT 9,9). The picaxe has been put into slave mode as I have done successfully for the last 4 years.


Dim a(3)
I2C OPEN 100, 1000
I2C READ &H38, 0, 3, a(0)
For I = 0 to 3
If MM.I2C then
Print “READ failed”
else
Print a(i)
endif
next
I2C CLOSE


Pressing F2 results in :-
0
0
0
0

Picaxe slave I2C methods are quite different to the methods used in the MM’s, there are no interrupt routines defined so I do not know what is going on in the picaxe. As stated above you merely read the portion of memory called the scratchpad!

My questions:

Has anyone set up such a system?
Can anyone suggest where I go from here to find why I do not see actual data?
I would prefer not to have to completely produce an MM only solution.

Rob White
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9586
Posted: 01:27pm 15 Jan 2015
Copy link to clipboard 
Print this post

Hi there.

If MM.I2C then This syntax looks wrong to me. If/Then needs a reference point, such as something like If MM.I2C=0 then kind of thing.
Smoke makes things work. When the smoke gets out, it stops!
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3282
Posted: 01:41pm 15 Jan 2015
Copy link to clipboard 
Print this post

  Grogster said  If MM.I2C then This syntax looks wrong to me. If/Then needs a reference point, such as something like If MM.I2C=0 then kind of thing.

That syntax is OK. The IF command evaluates the expression and treats the result as false if it is zero and true if it is non zero. The simplest expression that you can have is just a variable, so in this case the IF statement will be true if MM.I2C holds a non zero number.

If you choose variable names carefully this syntax makes for very readable code. For example:
IF DoorOpen THEN ...


Geoff
Geoff Graham - http://geoffg.net
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6266
Posted: 02:12pm 15 Jan 2015
Copy link to clipboard 
Print this post

What addres do you have the Picaxe set to?
I have never use I2C on the picaxe but if I read the syntax correctly, Picaxe would need an address double the Maximite address value.

Picaxe includes the R/W bit while Maximite adds it to the address.

This is an area that cause much grief. There isn't any definite 'right way' to describe the chip address. Evert data sheet has a different way of doing it.

Jim
VK7JH
MMedit
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9586
Posted: 02:26pm 15 Jan 2015
Copy link to clipboard 
Print this post

  Geoffg said  
  Grogster said  If MM.I2C then This syntax looks wrong to me. If/Then needs a reference point, such as something like If MM.I2C=0 then kind of thing.

That syntax is OK. The IF command evaluates the expression and treats the result as false if it is zero and true if it is non zero. The simplest expression that you can have is just a variable, so in this case the IF statement will be true if MM.I2C holds a non zero number.


So noted.
I stand corrected.
Smoke makes things work. When the smoke gets out, it stops!
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2932
Posted: 11:37pm 15 Jan 2015
Copy link to clipboard 
Print this post

As TassyJim says, my money is on an 'incorrect' address (assuming hardware is setup correctly).

If you have a logic analyser then this is easy to check - if not then just double check the data sheet / manual to ensure you have the correct address formatted correctly.

Good luck . . . . .

WW
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025