Picaxe 08m - Ds1807

George Sephton

Senior Member
Hi,
Ive been looking at the DS1807 and Im trying to communicate with it by bit-banging but I can't seem to work out how to use it.
I have looked at the Datasheet and can create a START and STOP condition:
Code:
DataSTART:
    high clkpin
    high datpin
    low datpin
    return
DataSTOP:
    high clkpin
    low datpin
    high datpin
    return
And now I need to look at sending pulses to communicate with it. I need to select both potentiometers (10101111) and then change the position depending on a binary number between 0 and 65. But how do I send those pulses: 10101111 to select and then the binary of the value (I have to create a decimal to binary conversion sub)?

I assume its just pulses ie:
P_P_PPPP (P=Pulse, _ = Pause)
Am I right? But which line is that CLK or DAT? and what does the other line do whilst that happens.
Also how long do these pulses last and will my script above to create a START and STOP condition work.
Any help will be appreciated.
George S.
 

westaust55

Moderator
Although different hardware, these pages by Peter Anderson may be of some help to you with bit-banging for i2c comms:

http://www.phanderson.com/picaxe/ds1624_28x.html

http://www.phanderson.com/picaxe/ds1803.html


Keep in mind these examples are for larger PICAXE chips with more program memory than the 08M. Also consider the words Hippy gave to you recently in another thread:
@ George : You can bit-bang I2C from an 08M but it will use up a fair bit of the program code space and will also be considerably slower than on PICAXE's which have I2C command included. The 08M can only control other I2C devices not be an I2C device ( I2C Slave ).
 
Last edited:

hippy

Ex-Staff (retired)
@ George : You need to be meticulous in what you bit-bang out for correct I2C operation or you can be sending things you do not intend. For example, STOP - On entry SCL and SDA must be low then SCL goes high then SDA goes high. If you need to ensure both SCL and SDA are low you need to bring SCL low first then SDA low or you create an undesirable START condition. Thus -

- StopBit:
- Low SCL
- Low SDA
- High SCL
- High SDA
- Return

Also, that's hard-driving the SCL and SDA lines. It's definitely much better to soft-drive the SDA line and the SCL line as well. Soft-drive relies on the pull-up's, Low SCL / Low SDA sets the lines low, Input SCL / Input SDA allows the lines to float high. That is, there should be no High SCL or High SDA commands.

This avoids damaging the PICAXE if the I2C device goes into an unexpected mode and shorts the output line ( SCL or SDA ) to 0V. Unexpected modes can happen if the signal sequence isn't correct.
 

George Sephton

Senior Member
My PICAXE 08M will only use that function controlling a DS1807 by bit-banging i2c and sending pulses to a counter ic and some leds, based on the input of 3 buttons and an ir in module.
I was looking mainly at sending pulses more than anything as no read functions are necessary, its all write. Does that make the code shorter but Ive looked an I take it 1010... are the pulses that need to be sent, I was just wondering how long pauses and pulses should last, which line should do it and what the other line does, based on the confusing diagrams of the DS1807 datasheet.
Thanks.
George S.
 
Top