Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 13:47 29 Nov 2024 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 : Problem: Maximite and 1-wire

Author Message
f.master
Newbie

Joined: 11/07/2013
Location: Germany
Posts: 4
Posted: 06:49pm 04 May 2014
Copy link to clipboard 
Print this post

I am learning to use the 1-wire interface of the maximite.
Hardware: B/W Maximite with firmware 4.4B mono
One sensor connected to pin 19

1. the presence flag is not usable. It always shows "present" wether there is a sensor connected or not.
2. The CRC function description is wrong or the function itself is faulty.

Example 1 runs and gives the expected result (CRC=0)
The CRC8 is calculated from array variables.


' Evaluate 1-wire DS18B20 Temperature sensor
'
Cls
S1=19 'pin number
Skip=&HCC 'code skip address
Convert=&H44 'code start conversion
RScratch=&HBE 'code read scratch registers
Dim C(9) 'data array for CRC calculation
'
OWWrite S1,1,2,Skip,Convert
Pause 800
'
OWWrite S1,1,2,Skip,RScratch
OWRead S1,2,9,A1,A2,A3,A4,A5,A6,A7,A8,A9
'
Negative = 0
If (A2 And &H80) Then Negative = 128
T1=((A1 And &H0F)*0.0625)+((A1 And &HF0)/16)+((A2 And &H07)*16)-Negative
Print "Degrees C = ";T1
'
' Calculate CRC
'
C(0)=A1
C(1)=A2
C(2)=A3
C(3)=A4
C(4)=A5
C(5)=A6
C(6)=A7
C(7)=A8
C(8)=A9
Check=OWCRC8(9,C(0))
'
Print "CRC = ";Check
'
End


Example 2 will result in a reseted Maximite, runtime firmware crashed.
The CRC8 is calculated from descrete variables.
According the manual this is also a way to go.


' Evaluate 1-wire DS18B20 Temperature sensor
'
Cls
S1=19 'pin number
Skip=&HCC 'code skip address
Convert=&H44 'code start conversion
RScratch=&HBE 'code read scratch registers
'
OWWrite S1,1,2,Skip,Convert
Pause 800
'
OWWrite S1,1,2,Skip,RScratch
OWRead S1,2,9,A1,A2,A3,A4,A5,A6,A7,A8,A9
'
Negative = 0
If (A2 And &H80) Then Negative = 128
T1=((A1 And &H0F)*0.0625)+((A1 And &HF0)/16)+((A2 And &H07)*16)-Negative
Print "Degrees C: ";T1
'
' Calculate CRC
'
Check=OWCRC8(9,A1,A2,A3,A4,A5,A6,A7,A8,A9)
Print "CRC: ";Check
Print
'
End


Additional info:
I tried also older Basic versions:
V3.1 -> crash
V3.2C -> Error: Expecting closing bracket (at line Check=OWCRC8(..)
V4.1 -> Error: Expecting closing bracket (at line Check=OWCRC8(..)
V4.3mono -> Invalid syntax (at line Check=OWCRC8(..)
V4.4B mono -> crash

The presence flag is not useable in all the versions.

f.master
Edited by f.master 2014-05-06
 
f.master
Newbie

Joined: 11/07/2013
Location: Germany
Posts: 4
Posted: 12:45am 09 May 2014
Copy link to clipboard 
Print this post

It seems, the Maximite is phased out already.
Lets look out for something else then.

f.master

 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3816
Posted: 02:44am 09 May 2014
Copy link to clipboard 
Print this post

I guess you didn't notice how very busy things have been (I cannot imagine how you cannot know!) and yours was just one post that I guess Geoff missed. Did you try emailing him or a PM?

I have no way to test your samples so for all I know they are bad syntax. Maybe someone else can...

John
 
f.master
Newbie

Joined: 11/07/2013
Location: Germany
Posts: 4
Posted: 02:42pm 09 May 2014
Copy link to clipboard 
Print this post

  JohnS said   I guess you didn't notice how very busy things have been (I cannot imagine how you cannot know!)


I noticed this. I am busy too.

  JohnS said   and yours was just one post that I guess Geoff missed.


My second post was more a reminder then a complaint. Should set a Smily there.

  JohnS said   Did you try emailing him or a PM?


No. I used just this communication channel. Because Geoff is very busy I avoided to place nore than one message.

  JohnS said  I have no way to test your samples so for all I know they are bad syntax. Maybe someone else can...


Everybody with the right equipment can test this. A sensor is not required, the port can be left open. The result is always the same.

With an open port, the presence flag should show "not present', but it shows "present". It would be nice if the presence flag could be fixed because it is an important item in this system.

The bug in the CRC function is may be not a bug. Just the manual has to be corrected in that way, only Array Vars are allowed.

f.master
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6102
Posted: 08:02pm 09 May 2014
Copy link to clipboard 
Print this post

I don't have a to test with but running the code without any sensor gave the expected results. Do you have the pullup resistor connected? Without it the result will be '1' without any sensor. With the pullup, the result for Presence and MM.OW is '0'

The presence variable is only valid after a RESET.
The MM.OW is valid after most OW commands.

I added a couple of PRINT statements:
' Evaluate 1-wire DS18B20 Temperature sensor
'
Cls
S1=12 'pin number
Skip=&HCC 'code skip address
Convert=&H44 'code start conversion
RScratch=&HBE 'code read scratch registers
Dim C(9) 'data array for CRC calculation
'
owreset s1, p
print "Presence = ";p
OWWrite S1,1,2,Skip,Convert
print "MM.OW = ";MM.OW
Pause 800

'
OWWrite S1,1,2,Skip,RScratch
OWRead S1,2,9,A1,A2,A3,A4,A5,A6,A7,A8,A9
print "MM.OW = ";MM.OW
'
Negative = 0
If (A2 And &H80) Then Negative = 128
T1=((A1 And &H0F)*0.0625)+((A1 And &HF0)/16)+((A2 And &H07)*16)-Negative
Print "Degrees C = ";T1
'
' Calculate CRC
'
C(0)=A1
C(1)=A2
C(2)=A3
C(3)=A4
C(4)=A5
C(5)=A6
C(6)=A7
C(7)=A8
C(8)=A9
Check=OWCRC8(9,C(0))
'
Print "CRC = ";Check
'
End


The results I get without a sensor are:
Presence = 0
MM.OW = 0
MM.OW = 0
Degrees C = -0.0625
CRC = 99


I agree that the is a problem with the CRC code. It works with arrays and string variables but not a set of numeric variables.

JimEdited by TassyJim 2014-05-11
VK7JH
MMedit   MMBasic Help
 
f.master
Newbie

Joined: 11/07/2013
Location: Germany
Posts: 4
Posted: 02:49am 10 May 2014
Copy link to clipboard 
Print this post

  TassyJim said   Do you have the pullup resistor connected? Without it the result will be '1' without any sensor. With the pullup, the result for Presence and MM.OW is '0'
Jim


Thats it. In my prototyp curcuit the pullup resistor is located near the sensor. Cutting the line to test the presence flag also removed the pullup and gave this result. Shame on me, not had seen this. The pullup has to be placed near the Maximite port, before the first cable connection going to the outside world.

Thanks for the hint.

f.master
Edited by f.master 2014-05-11
 
Print this page


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

© JAQ Software 2024