firmware updates for 18m2

martinn

Member
Has the problem with the 18m2 writing to larger external memory (24LC256/512) been resolved with a firmware update yet?

Martin
 

westaust55

Moderator
Not that I am aware of to date.
Also seems a few other minor bugs have recently come to light so an update encompassing several items may be imminent.
 

Technical

Technical Support
Staff member
You can workaround the 2.A i2c issue without too much trouble as follows:
Code:
ISSUE -  CORRECTED ISSUE WITH 'WORD' MODE IN I2C COMMUNICATION
  Word mode for i2c EEPROM addressing does not work correctly in v2.A 
  Byte mode works correctly. Therefore to workaround this issue emulate word mode manually by use of bytes only.
  This is possible because all word addresses are always transmitted as two separate bytes on the i2c bus anyway.
  Therefore the i2c bus wll see exactly the same byte sequence as would be generated automatically in word mode.
  To do this follow these 3 steps:
  a) Change 'i2cword' to 'i2cbyte' in the  hi2csetup command  
  b) Change hi2cout commands from this
   hi2cout word_address, (data1, data2, etc)
     to
   hi2cout (msb_byte_of_word, lsb_byte_of_word, data1, data2, etc)
        e.g.
     hi2cout w0, (b10, b11, b12)
       to
     hi2cout (b1, b0, b10, b11, b12) ; (as word w0 is made up of the two bytes b1:b0)
  
       e.g.
     hi2cout 100, (b10, b11, b12)
       to
     hi2cout (0, 100, b10, b11, b12) ; (as 100 = 0x256 + 100)
       e.g.
     hi2cout 300, (b10, b11, b12)
       to
     hi2cout (1, 44, b10, b11, b12) ; (as 300 = 1x256 + 44)
   
  c) Change hi2cin commands from this
   hi2cin word_address, (data1, data2, etc)
     to
   hi2cout (msb_byte_of_word, lsb_byte_of_word)
   hi2cin  (data1, data2, etc)
       e.g.
     hi2cin w0, (b10, b11, b12)
       to
     hi2cout (b1, b0)   ; (as word w0 is made up of the two bytes b1:b0)
     hi2cin  (b10, b11, b12)
        e.g.
     hi2in 600, (b10, b11, b12)
       to
     hi2cout (2, 88)   ; (as 600 = 2x256 + 88)
     hi2cin  (b10, b11, b12)
 

martinn

Member
Hi Technical
I am still having troubles trying to modify the Datalogger wizard code to suit the 18m2.
This code is purely from the wizard, would it possible to post an 18M2 version of it?

Also, what effect does the Axe110 Datalogger reset button have on the 18M2?

Thanks
Martin


Code:
'AXE110 PICAXE - New Datalogger Mission Program
'Automatically generated by Wizard

'LED will flash green as readings are taken.

'Data can be retrieved after mission (LED red) by Datalink tool (F9).
'Use Datalink options: Baud rate - 4800, Sensors - 4, Send G - Enabled

' *******************
' ***** Options *****
' *******************

'Title -  
'Date  - 13/12/2010
'Time  - 7:20:52 AM

'Options Selected
'Sensors:
'Sensor 0 - Light
'Sensor 1 - Sensor 1
'Sensor 2 - Sensor 2
'Sensor 7 - Temperature

'Memory:
'No of readings = 4095
'1 x 24LC256

'Outputs:
'Bi-colour LED

'Logging Period:
'DS1307 RTC
'Hours:  1 Mins:  0 Secs:  0 

' ********************
' ***** Symbols  *****
' ********************

'Symbol definitions
symbol data0 = b0
symbol data1 = b1
symbol data2 = b2
symbol data7 = b3
symbol top_address = w2 '(b4 + b5)
symbol address = w3     '(b6 + b7)
symbol temp_word = w4   '(b8 + b9)
symbol temp_byte = b10
symbol hours = b11
symbol mins = b12
symbol secs = b13
symbol day = b0
symbol month = b1
symbol COM = 44         'comma
symbol RET = 13         'carriage return
symbol LFEED = 10          'line feed

'Preload sensor names and title into data memory
EEPROM 0,(0,0)
EEPROM 16,("Light")
EEPROM 32,("Sensor 1")
EEPROM 48,("Sensor 2")
EEPROM 64,("Temperature")
EEPROM 80,(" ")


' ***************************
' ***** Initialisation  *****
' ***************************

init:
	let dirsB = 255 'setup outputs

	high 5 ' write protect eeprom
'reload the last address from data memory
	read 0,b6
	read 1,b7


' *********************************
' ***** Main loop - read data *****
' *********************************

'Now read each sensor
main:
	high 3 ' flash LED

	readadc 0,data0
	readadc 1,data1
	readadc 2,data2
	readtemp 7,data7

	low 3 ' end of flash LED

' *****************************
' ***** Now Save the Data *****
' *****************************

'Now save the data
save_data:
	low 5 ' write enable eeprom

'Single 24LC256. Input0 from address 0, input1 from address 4096
'Single 24LC256. Input2 from address 8192, input7 from address 12288

	if address > 4095 then memory_full
	i2cslave %10100000, i2cslow, i2cword
	writei2c address,(data0)
	pause 10
	readi2c address,(temp_byte)
	if temp_byte <> data0 then ee_error

	temp_word = address + 4096	writei2c temp_word,(data1)
	pause 10
	readi2c temp_word,(temp_byte)
	if temp_byte <> data1 then ee_error

	temp_word = address + 8192	writei2c temp_word,(data2)
	pause 10
	readi2c temp_word,(temp_byte)
	if temp_byte <> data2 then ee_error

	temp_word = address + 12288	writei2c temp_word,(data7)
	pause 10
	readi2c temp_word,(temp_byte)
	if temp_byte <> data7 then ee_error

'increment address and save in data memory
inc_address:
	high 5 ' write protect eeprom

	let address = address + 1
	write 0,b6
	write 1,b7
	if address > 4095 then memory_full


' ***********************
' ***** Time Delays *****
' ***********************

'Now do time delay
'Read time now
read_rtc_now:
	i2cslave %11010000, i2cslow, i2cbyte
	readi2c 0,(secs,mins,hours)

'Convert to decimal then add offset
	gosub bcd_decimal

	let data0 = secs
	let data1 = mins
	let data2 = hours

Add_Secs:
	let data0 = data0 + 0
	if data0 < 60 then Add_Mins
'Secs is now greater than 60 so add 1 to minute instead
	let data0 = data0 - 60
	let data1 = data1 + 1

Add_Mins:
	let data1 = data1 + 0
	if data1 < 60 then Add_Hours
'Mins is now greater than 60 so add 1 to hour instead
	let data1 = data1 - 60
	let data2 = data2 + 1

Add_Hours:
	let data2 = data2 + 1
	if data2 < 24 then read_rtc
'Hours is now greater than 24 so correct
	let data2 = data2 - 24

'Read rtc to test alarm'
read_rtc:
	i2cslave %11010000, i2cslow, i2cbyte
	readi2c 0,(secs,mins,hours)

	gosub bcd_decimal

	if secs <> data0 then read_rtc
	if mins <> data1 then read_rtc
	if hours <> data2 then read_rtc

'now do next reading
	goto main


' *************************
' ***** Error Routine *****
' *************************

'Memory error - flash LED red/green'
ee_error:
	high 2
	low 3
	pause 500
	low 2
	high 3
	pause 500
	goto ee_error

' ***********************
' ***** Memory Full *****
' ***********************

'Memory is full - LED red'
memory_full:
	high 2

' ****************************
' ***** Datalink Routine *****
' ****************************

'Datalink routine to transmit data
read_init:
	high 5 ' write protect eeprom
	let address = 0

'Get top address from data memory (w2=b4+b5)

	read 0,b4
	read 1,b5

'Wait for G character sent from software
	serin 6, N4800, ("G") 'Wait for GO signal

'Transmit the titles
	serout 7,N4800,("Address",COM,"Light",COM,"Sensor 1",COM,"Sensor 2",COM,"Temperature",COM," ",RET,LFEED)

'Now read the data
read_data:
'Single 24LC256. Input0 from address 0, input1 from address 4096
'Single 24LC256. Input2 from address 8192, input7 from address 12288

	if address > 4095 then all_done
	i2cslave %10100000, i2cslow, i2cword
	readi2c address,(data0)

	temp_word = address + 4096
	readi2c temp_word,(data1)

	temp_word = address + 8192
	readi2c temp_word,(data2)

	temp_word = address + 12288
	readi2c temp_word,(data7)

'transmit data 
tx_data:
	serout 7,N4800,(#address,COM,#data0,COM,#data1,COM,#data2,COM,#data7,RET,LFEED)

	let address = address + 1
	if address = top_address then all_done
	goto read_data

'finished so send NULL
all_done:
	serout 7,N4800,(0)
	goto read_init


' **********************************
' ***** Convert BCD to decimal *****
' **********************************

'Convert BCD to decimal
bcd_decimal:
	let temp_byte = secs & %11110000 / 16 * 10
	let secs = secs & %00001111 + temp_byte
	let temp_byte = mins & %11110000 / 16 * 10
	let mins = mins & %00001111 + temp_byte
	let temp_byte = hours & %11110000 / 16 * 10
	let hours = hours & %00001111 + temp_byte
	return
 

hippy

Ex-Staff (retired)
Hi Technical
I am still having troubles trying to modify the Datalogger wizard code to suit the 18m2.
This code is purely from the wizard, would it possible to post an 18M2 version of it?
It should be possible, it would just take some time to go through it by hand. Before anyone considers doing that can you confirm it's the exact code you want ?

Also, what effect does the Axe110 Datalogger reset button have on the 18M2?
None. The old 'reset' pin is simply another input pin on the 18M2 so could be used to read if the 'reset button' is pushed or not. It can't however be used to directly cause a hardware reset. To achieve the equivalent of that you'd have to poll or interrupt on the pin going low and issue the RESET command.

As the pin is input only by silicon design you cannot set it output high and then short that output to 0V by pressing the reset button and damaging the PICAXE.
 

martinn

Member
Thanks Hippy
I don't want someone to spend a lot of time on it, I have it half working I think it is a problem with the addressing.

I would happy if someone could just give me an 18M2 version of just these bits from the wizard code. But a copy of the datalogger wizard in 18M2 format could be useful to people (like me) who just want to 'hack' the code to use the Axe110 datalogger with an 18M2.

Code:
	if address > 4095 then memory_full
	i2cslave %10100000, i2cslow, i2cword
	writei2c address,(data0)
	pause 10
	readi2c address,(temp_byte)
	if temp_byte <> data0 then ee_error

	temp_word = address + 12288	writei2c temp_word,(data7)
	pause 10
	readi2c temp_word,(temp_byte)
	if temp_byte <> data7 then ee_error
and

Code:
	if address > 4095 then all_done
	i2cslave %10100000, i2cslow, i2cword
	readi2c address,(data0)

	temp_word = address + 12288
	readi2c temp_word,(data7)
thanks

Martin
 
Top