.-------.
SO |--------.-->| I5 O0 |--->
CK |----. .|, | |
/CS |--. | |_| | |
| | _|_ | |
| | | |
SO |--|-|------>| X4 |
CK |--|-{ -.- | |
/CS |--{ | .|. | |
| | |_| | |
| | | | |
SO |--|-|---|-->| I3 |
CK |--|-^---|--<| X2 |
/CS |--^-----^--<| X1 |
`-------'
That is correct. Though if you have more than three sensors it's probably better to use a PICAXE which can handle all sensors so there's only one signal going back to the master PICAXE.So you mean I could have several 08M2's each with 3 MAX6675 and then have them (some how) send there temp data to a Master?
I have included some code at the end, which is pretty similar to your own code, though untested..Interesting idea, this bit-bang stuff is a bit above me so will have to find some reading.
You can send data back with -Then how would you send all the data back to a master and know which one your looking at?
#Picaxe 08M2
#Terminal 4800
#No_Data
Symbol TX = C.0
Symbol CS = C.1
Symbol CK = C.2
Symbol MAX6675_1 = pinC.3
Symbol MAX6675_2 = pinC.4
Symbol MAX6675_3 = pinC.5
Symbol COMMA = ","
Init:
High CS
Low CK
Pause 100
Main:
Do
Gosub ReadSensors
SerOut TX, N4800,( "T=", #w1, COMMA, #w2, COMMA , #w3, CR, LF )
Pause 1000
Loop
ReadSensors:
Low CS
For b0 = 15 To 0 Step -1
High CK
w1 = w1 * 2 + MAX6675_1
w2 = w2 * 2 + MAX6675_2
w3 = w3 * 2 + MAX6675_3
Low CK
Next
High CS
w1 = w1 / 32
w2 = w2 / 32
w3 = w3 / 32
Return
I use these waterproof DS18B20s strapped to boiler hot water supply and return pipes for 3 zones, with heat sink compound:... So the long term project is to have temp sensors local to the wood burner and gas boiler flow/return pipes and in places on the tank, it would all then be displayed on a nextion touch screen.
Yes, and if you use an X2 PICAXE with OWIN and OWOUT support you can have multiple DS18B20 on single I/O lines. That's more complicated but may be worth it.If I didn't need all of my sensors to be high temp thermocouples I take it I could use DS18B20 temp sensors each with there own input?
One Wire comms over weedy cables is a hit and miss affair..... I once used 40' of Dollar Store stereo cable (mini-stereo connector) to run one at 5V, so they can do OK with weedy cables (not recommended, though I had no problems).
This is certainly possible over I2C with a picaxe master and X2 slave. Master puts a code (or codes) to a location in the slave memory, slave retrieves them, zeroes the location, acts on them, and possibly writes a response to another location, which the master monitors.Is it possible to send control signals as well as or instead of data signals i.e. have push buttons on a master to control outputs or actions in a slave picaxe and then possibly have switch/sensor inputs read on a slave sent back to the master?
Yes, this is what I'm doing with my Humidistat project. A 20X2 is the master, while the 14M2 is the slave. They're connected together with two pins each with a 330ohm resistors between them (to protect them from damage should one pull the pin low while the other has it high). I call one pin "COMM", the other pin "RTS" (request to send). The 14M2 monitors the RTS pin. If the RTS is pulled high by the 20X2, the 14M2 sees that and listens for commands on the COMM pin using serin. 20X2 tells it what needs to be done. 14M2 acts on the commands and responds back to the 20X2 at which point the 20X2 pulls the RTS pin back low till it needs the 14M2 to do something again.On a slightly different subject to the temperature stuff we've been talking about but still on the idea of sending data between a master and slave over a cable. Is it possible to send control signals as well as or instead of data signals i.e. have push buttons on a master to control outputs or actions in a slave picaxe and then possibly have switch/sensor inputs read on a slave sent back to the master?
That is correct. Though if you have more than three sensors it's probably better to use a PICAXE which can handle all sensors so there's only one signal going back to the master PICAXE.
I have included some code at the end, which is pretty similar to your own code, though untested..
Because I parallel CS and CK to all MAX6675 chips one can read the data from all sensors when CK is high and that data can be stored in its own word variable.
You can send data back with -
SEROUT <pin>, <baud>, ( "T=", #w1, COMMA, #w2, COMMA, #w3, CR, LF )
And then read that on the master PICAXE with -
SERIN <pin>, <baud>, ( "T=" ), #w1, #w2, #w3
Code:#Picaxe 08M2 #Terminal 4800 #No_Data Symbol TX = C.0 Symbol CS = C.1 Symbol CK = C.2 Symbol MAX6675_1 = pinC.3 Symbol MAX6675_2 = pinC.4 Symbol MAX6675_3 = pinC.5 Symbol COMMA = "," Init: High CS Low CK Pause 100 Main: Do Gosub ReadSensors SerOut TX, N4800,( "T=", #w1, COMMA, #w2, COMMA , #w3, CR, LF ) Pause 1000 Loop ReadSensors: Low CS For b0 = 15 To 0 Step -1 High CK w1 = w1 * 2 + MAX6675_1 w2 = w2 * 2 + MAX6675_2 w3 = w3 * 2 + MAX6675_3 Low CK Next High CS w1 = w1 / 32 w2 = w2 / 32 w3 = w3 / 32 Return
Google gets an answer to just about everything ......... out of interest what are the CR, LF inside the brackets of the SerOut line for?
Carriage Return and Line Feed. They move the cursor in the terminal display back to the start of the line and then down a line. So basically placed wherever you want one line to end and another to start.Hippy, out of interest what are the CR, LF inside the brackets of the SerOut line for?
If you don't want to access the bits by name, you can do something like this:Ok, thanks both. I'll keep reading. I just wondered if it would be possible to have inputs on ether the master and/or the slave unit control say the 8BITs in b0 and then send the whole byte over serial, then have the corresponding master/slave brake that byte back down to its BITs again to di something with, switch an output on or control a motor remotely?
' assume data bits are in b0
b10 = 1
for b11 = 0 to 7
b1 = b0 & b10 ' extract one bit into b1 (zero or nonzero)
if b1 <> 0 then
' do something with it
endif
b10 = b10 * 2 ' shift b10 to next bit
next b11
So, if your data has arrived in b0, you can write code likeIf you send a byte by serial or using i2c, and receive it into b0 (or put it there from the X2 scratchpad), then you have access to bit0-bit7, the constituent bits of b0. You can also access the individual bits in b1, b2, and b3.
if bit0 = 1 then gosub Process0
if bit1 = 1 then gosub Process1
if bit2 = 1 then gosub Process2
etc
b10 = 1 ' initialise to extract bit0
for b11 = 0 to 7 ' loop counts through bits
b1 = b0 & b10 ' "AND" b0 with b1 to get either 0 (corresponding bit in b0 is zero) or value of b1 (bit in b0 is nonzero)
if b1 <> 0 then
branch b11,(Process0,Process1,....)
endif
goto EndLoop
Process0:
<...>
goto EndLoop
Process1:
<...>
goto EndLoop
<...>
EndLoop:
next b11
b10 = 1 ' initialise to extract bit0
for b11 = 0 to 7 ' loop counts through bits
b1 = b0 & b10 ' "AND" b0 with b1 to get either 0 (corresponding bit in b0 is zero) or value of b1 (bit in b0 is nonzero)
if b1 <> 0 then
select case b11
Case 0:
<...>
Case 1:
<...>
<...>
endselect
endif
next b11
The bits in 'b0' are 'bit0' through 'bit7' and the bits in 'b1' are 'bit8' through 'bit15'how would you know which bit0 or bit1 it is as you've got both inside b0 & b1
If you prefer using that style you can do something like it, such as this -I've tried, "if b0 bit0 = 1 then gosub" and so on but the compiler doesn't like it.
Symbol b0.bit0 = bit0
Symbol b0.bit1 = bit1
Symbol b0.bit2 = bit2
etc
Symbol b1.bit0 = bit8
Symbol b1.bit1 = bit9
Symbol b1.bit2 = bit10
etc
If b0.bit0 = 1 Then Gosub Process_b0_0
If b1.bit0 = 1 Then Gosub Process_b1_0
If b0 Bit 0 Set Then Gosub Process_b0_0
If b1 Bit 0 Set Then Gosub Process_b1_0
You could use -Now I've just got to sort the other end out in my head i.e how to for example make input1 control bit1 and I think ill be there.
; .-----------------------------------------------.
; | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
; |-----------------------------------------------|
; | B.7 | C.7 | C.6 | C.5 | C.4 | C.3 | B.1 | B.0 |
; `-----^-----------------------------^-----------^
b0 = pinsC & %11111000 / 2
b0 = pinsB & %00000011 | b0
bit7 = pinB.7