Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

1wire multi bus

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive
View previous topic :: View next topic  
Author Message
mmarlette

Bascom Member



Joined: 30 Nov 2007
Posts: 307
Location: Delano, MN

usa.gif
PostPosted: Tue Feb 10, 2009 5:06 am    Post subject: 1wire multi bus Reply with quote

Version 1.11.9.3

ATmega128

No Config 1wire command used.

The below function is called from a main routine with the bus number passed to it as 1 or 2.

My test case is simple.

No sensor plug in, both buses report no sensor, CORRECT.
Sensor in bus 1 ONLY, BOTH buses reports &h10, WRONG s/b only on bus 1.
Move sensor to bus 2 ONLY, and reports &h10 on bus 2, 0 on one. CORRECT.

Read in the Config 1Wire extended but that doesn't seem to work either.

At a loss here......I removed some of the function code so that it is easier to read. IE: parameter return, etc....

function DS18S20_FindDevice(byval byt_BusNumber as byte) as byte

local byt_tempDSF as Byte 'temp var for FUNCTION return value

Select Case byt_BusNumber
Case 1:
1wreset pina,0
print #2, "Bus 1=";
DSid1(1) = 1wsearchfirst(pina,0) 'if zero returned, no devices
print #2, DSid1(1) ;
Case 2:
1wreset pina,1
print #2, "Bus 2=";
DSid2(1) = 1wsearchfirst(Pina,1) 'if zero returned, no devices
print #2, DSid2(1);
End SELECT
print #2, " Exit"

end function
Back to top
View user's profile
Evert :-)

Bascom Expert



Joined: 18 Feb 2005
Posts: 2129

netherlands.gif
PostPosted: Tue Feb 10, 2009 8:45 am    Post subject: Reply with quote

Better post the complet sub_routine.
Is your stack large enough?

_________________
www.evertdekker.com Bascom code vault
Back to top
View user's profile Visit poster's website
mmarlette

Bascom Member



Joined: 30 Nov 2007
Posts: 307
Location: Delano, MN

usa.gif
PostPosted: Tue Feb 10, 2009 7:25 pm    Post subject: Reply with quote

Ok, simplified the problematic code so I can post it here. Same results.

No sensor in bus1 or bus2, program reports 0 on both buses, CORRECT.

Plug Sensor in to Bus1, press reset on STK500.....

Program reports the same device on both ports. WRONG!!!!!!

Move sensor from bus1 to bus2, press rest on STK500.

Program reports no sensor on bus1, sensor on bus2. CORRECT!

Here is the single module code, minus the serial code which does nothing more than setup the COM2 of the ATmega128 to 115.2, hardware handshake.

Any ideas????


Const 1W_version = " v1.00"
Const True = 1
Const False = 0
Const Debugflag = true 'turn off/on serial debug monitor
Const bit0 = 1
Const bit1 = 2
Const bit2 = 4
Const bit3 = 8
Const bit4 = &h10
Const bit5 = &h20
Const bit6 = &h40
Const bit7 = &h80
'
'Version Date Description
'----------------------------------------------------------------------------
' V1.00 2/10/2009 1. Genesis.
'
'Hardware Connections:
'
'Port A.0 = 1 Wire Comm Channel #1
'Port A.1 = 1 Wire Comm Channel #2
'
'Port D.2 = RXD \ On STK501
'Port D.3 = TXD /
'
'Port C.0 = RTS\ On STK501
'Port C.1 = CTS/
'Port C.2 = 1 Wire Comm Channel #3
'
$regfile = "m128def.dat"
$hwstack = 250 ' over ride default of 32 for the hardware stack
$swstack = 250 ' over ride default of 8 for the SW stack
$framesize = 250 ' over ride default of 24 for the frame space
$crystal = 7372800 'using PS2 Xtal, full swing mode or
'
'Main Variable Declaration Section
'
Dim DSid1(Cool As Byte 'Dallas ID 64 bits incl CRC
Dim DSid2(Cool As Byte 'Dallas ID 64 bits incl CRC
'
'************************************************************
'* Progam Startup
'************************************************************
$include "..\..\..\commonroutines\Serial_config.bas"

#if Debugflag
Call Serial_debugbanner(1W_version)
Call Serial_bell
#endif '
'
'*********************************************
'* *
'* MAIN LOOP *
'* *
'**********************************************
'
'Initialize 1-Wire Devices now....
'
1wreset pina,0 '1Wire bus #1 pin
print #2, "Bus 1=";
waitms 100
DSid1(1) = 1wsearchfirst(pina,0) 'if zero returned, no devices
print #2, DSid1(1)

1wreset pina,1 '1Wire bus #1 pin
print #2, "Bus 2=";
waitms 100
DSid2(1) = 1wsearchfirst(Pina,1) 'if zero returned, no devices
print #2, DSid2(1)
Do
'wait forever, press reset
Loop

$include "..\..\..\commonroutines\Serial.bas"
Back to top
View user's profile
Evert :-)

Bascom Expert



Joined: 18 Feb 2005
Posts: 2129

netherlands.gif
PostPosted: Tue Feb 10, 2009 7:52 pm    Post subject: Reply with quote

Hello,
I don't have real 1W hardware here, so what i'm suggest is only theoretically.

Try reset the first bus before using the second bus.
Code:

'Initialize 1-Wire Devices now....
'
1wreset pina,0 '1Wire bus #1 pin
print #2, "Bus 1=";
waitms 100
DSid1(1) = 1wsearchfirst(pina,0) 'if zero returned, no devices
print #2, DSid1(1)
1wreset pina,0   '<=============

1wreset pina,1 '1Wire bus #1 pin
print #2, "Bus 2=";
waitms 100
DSid2(1) = 1wsearchfirst(Pina,1) 'if zero returned, no devices
print #2, DSid2(1)
1wreset pina,1   '<=============
Do
'wait forever, press reset
Loop
 

_________________
www.evertdekker.com Bascom code vault
Back to top
View user's profile Visit poster's website
mmarlette

Bascom Member



Joined: 30 Nov 2007
Posts: 307
Location: Delano, MN

usa.gif
PostPosted: Tue Feb 10, 2009 8:21 pm    Post subject: Reply with quote

Good idea, but the results are the same.
Back to top
View user's profile
mmarlette

Bascom Member



Joined: 30 Nov 2007
Posts: 307
Location: Delano, MN

usa.gif
PostPosted: Tue Feb 10, 2009 8:34 pm    Post subject: Reply with quote

I also tried PortE and Port A and all combinations ther eof.

Results are consistent and the same.
Back to top
View user's profile
Evert :-)

Bascom Expert



Joined: 18 Feb 2005
Posts: 2129

netherlands.gif
PostPosted: Tue Feb 10, 2009 9:30 pm    Post subject: Reply with quote

Next try,
Make the first port the "original" 1w (the one with config 1wire=...) and the second as it is now.
In the beginning of Bascom there was only the 1W commands in combination with the "Config 1wire =" , therefore only 1 bus was possible. In a later stage Mark has add the option for the port, pin option for the second bus.
In the helpfile he also calls it "'use this port and pin for the second device", it's how you read it but it's possible that the first bus must be the original one.

Code:

Config 1wire = Porta.0

1wreset   '1Wire bus #1 pin
print #2, "Bus 1=";
waitms 100
DSid1(1) = 1wsearchfirst()  'if zero returned, no devices
print #2, DSid1(1)

1wreset pina,1 '1Wire bus #1 pin
print #2, "Bus 2=";
waitms 100
DSid2(1) = 1wsearchfirst(Pina,1) 'if zero returned, no devices
print #2, DSid2(1)
1wreset pina,1   '<=============
 

_________________
www.evertdekker.com Bascom code vault
Back to top
View user's profile Visit poster's website
mmarlette

Bascom Member



Joined: 30 Nov 2007
Posts: 307
Location: Delano, MN

usa.gif
PostPosted: Tue Feb 10, 2009 10:12 pm    Post subject: Reply with quote

use of the config 1wire command per your example yields the same results.

No go yet.
Back to top
View user's profile
mmarlette

Bascom Member



Joined: 30 Nov 2007
Posts: 307
Location: Delano, MN

usa.gif
PostPosted: Tue Feb 10, 2009 10:31 pm    Post subject: Reply with quote

Tried an example right out of the HELPfile and it produces different results with NO SENSOR on the one wire bus.

This si the output for the code below. I would expect both to be the same with no sensor installed.

0000000000000000
FFFFFFFFFFFFFFFF

dim i as Byte
dim a as Byte

For I = 0 To 1 'for pin 0-1
1wreset Pina , I
1wwrite &H33 , 1 , Pina , I
DSid1(1) = 1wread(8 , Pina , I)
For A = 1 To 8
Print #2, Hex(dsid1(a));
Next
Print #2, " "
Next
Back to top
View user's profile
AdrianJ

Bascom Expert



Joined: 16 Jan 2006
Posts: 2484
Location: Queensland

australia.gif
PostPosted: Tue Feb 10, 2009 11:10 pm    Post subject: Reply with quote

This might not be relevant, but I would ask why you need two pins assigned to different 1 wire busses ? The Dallas chips are individually readable, so just put them both on the same bus.

While I agree the code you have should separately work on each pin, and there is a problem if it does not, maybe you could just sidestep the problem.

_________________
Adrian Jansen
Computer language is a framework for creativity
Back to top
View user's profile Visit poster's website
mmarlette

Bascom Member



Joined: 30 Nov 2007
Posts: 307
Location: Delano, MN

usa.gif
PostPosted: Tue Feb 10, 2009 11:24 pm    Post subject: Reply with quote

Adrian,

As you can place multiple sensors on the bus, the problem is identifying which temperature sensor is where. The system I am creating is an energy managment system that calculates the heat loss of your house and controls the 20KW dual fuel furnace based upon input from sensors. The sensors being the DS18S20 digital thermometers. Inside, outside, room, duct temp above power resistors to close the desired temp loop, etc. There is NO margin for error.

Unless you have some sort of fancy way of cataloging the sensor ROM code to a physical location you could get the sensor swapped as you physically don't know which one is which.

You would have to have some sort of system maintenance menu that you would add each sensor to the bus, read it's ID, save it to a location to denote physical location, then add the next sensor until all sensors ID are associated with a physical location. Not impossible. Just seems like it would be easier to have a port dedicated to sensors and only have one temp sensor on the bus. You could add other devices, if needed.

Using an ATmega128, has many ports.... Smile

A better idea???
Back to top
View user's profile
AdrianJ

Bascom Expert



Joined: 16 Jan 2006
Posts: 2484
Location: Queensland

australia.gif
PostPosted: Tue Feb 10, 2009 11:49 pm    Post subject: Reply with quote

Hmm, I see your point. But if its a fixed physical layout, with no possibility the sensors can be swapped except by someone who also keeps the physical map updated, then I dont see it as a big issue. Can you put incompatible connectors on each sensor, so they cant be swapped ? Eg use a 25 pin connector, but different single pins for each sensor at each location. Even with multiple busses, you still need to keep the map updated, although I agree you get a chance to check that the correct sensor ID is on the right bus.

At least you have an ID assigned to each sensor. Back in the old days I did tunnel kiln monitoring with just thermocouples ( 100 or so ). Keeping track of which thermocouple was where was fun, especially when the night shift would swap them ( and their wiring ) from kiln to kiln.

_________________
Adrian Jansen
Computer language is a framework for creativity
Back to top
View user's profile Visit poster's website
mmarlette

Bascom Member



Joined: 30 Nov 2007
Posts: 307
Location: Delano, MN

usa.gif
PostPosted: Wed Feb 11, 2009 12:00 am    Post subject: Reply with quote

Adrian,

I would not have a problem keeping the straight but remember, no offense meant here, you are dealing with plumbers and electricians. My experience is that it will get messed up. Forgot to add that there is also a heat pump in the system as well.

Any sensor can go anywhere and the plugs are all the same. We do not wan t to have separate part numbers for each sensor when they are the same. Plug a sensor in this location, it is xxxxx sensor now. They can handle that. Smile

I believe this call is broken. I have sent in bug reports with almost NO response from the makers of Bascom, which I am not even sure who that is. Or fleet of people.

I have many hours in to this task, trying to find a work around.

I suppose I could pay for support but am a bit concerned that if I do pay that the response will be yep, problem noted, you are the only one, so it is not a real high priority to repair it. I can see their point but that doesn't help me. Smile

Hmmmmm, what next.....
Back to top
View user's profile
AdrianJ

Bascom Expert



Joined: 16 Jan 2006
Posts: 2484
Location: Queensland

australia.gif
PostPosted: Wed Feb 11, 2009 1:04 am    Post subject: Reply with quote

I always had good response from Mark Alberts, the designer of Bascom, on any support request.

Yah I know about non-tech people handling installations.

I cant see any easy way of associating each cable end with a sensor, unless you can somehow ID the end, and be sure that end has a particular sensor ID attached. In fact, your problem is not reading the sensor IDs, its making sure some sensor is attached at a specific cable end location. I am out of time, but maybe you can think about this a bit more.

Edit:
One more thought, can you use some other port pins on the processor to gate the 1 wire signals through a selector switch like a 4051. Then you just select up which star bus line you pass the 1 wire signal through.

_________________
Adrian Jansen
Computer language is a framework for creativity
Back to top
View user's profile Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum