1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

1 Wire comunication

Discussion in 'Oshonsoft' started by fricciardiuk, Jul 18, 2015.

  1. fricciardiuk

    fricciardiuk New Member

    Joined:
    Jul 18, 2015
    Messages:
    1
    Likes:
    0
    Hello everyone, I am new to the forum and also in the use of oshonsoft. I need help in using the picsimulation as communication codes in 1Wire help just found a small example using a temperature sensor. what I need is to communicate with a DS2432 memory and not found anything about the commands that memory. I appreciate any help that you have. thank you
     
  2. atferrari

    atferrari Well-Known Member

    Joined:
    Oct 8, 2003
    Messages:
    2,816
    Likes:
    121
    Location:
    Buenos Aires - Argentina
    Have you read the datasheet?
     
  3. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,240
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    ONLINE
    hi,
    The closest option on Oshonsoft is the SERVO command.
    I have used it with DHT11 and DHT22, temperature/humidity sensors
    E
    This is a clip from the Oshonsoft Basic Manual.

    Interfacing Radio Control (R/C) servos

    ServoIn,ServoOut,

    For writing applications to interface R/C servos there are two statements available: SERVOIN and SERVOOUT. R/C servo is controlled by a train of pulses (15-20 pulses per second) whose length define the position of the servo arm. The valid length of pulses is in the range 1-2ms. These two statements have two arguments. The first argument of both statements is the microcontroller pin where the servo signal is received or transmitted. For SERVOIN statement that pin should be previously setup as an input pin and for SERVOOUT statement the pin should be setup for output. The second argument of SERVOIN statement must be a Byte variable where the length of the pulse will be saved. The pulses are measured in 10us units, so it is possible to measure pulses in the range 0.01-2.55ms. The value stored in the variable for normal servos should be in the range 100-200. The second argument of the SERVOOUT statement should be a Byte variable or constant that determines the length of the generated pulse. For proper operation of the target servo SERVOOUT statement should be executed 15-20 times during one second. Here is an example of the servo reverse operation:
    Dim length As Byte
    TRISB.0 = 1
    TRISB.1 = 0
    loop:
    ServoIn PORTB.0, length
    If length < 100 Then length = 100
    If length > 200 Then length = 200
    length = length - 100
    length = 100 - length
    length = length + 100
    ServoOut PORTB.1, length
    Goto loop


    Bit of my code:

    Code (text):

    dht11 = 1  'make this 0 For DHT22 OR use this next bit of code

    If PORTA.5 = 0 Then  'for compare 11/22 only! Insert correct DHT11/22 first!!
    dht11 = 0
    Else
    dht11 = 1
    Endif

    Lcdinit
    WaitMs 1

    Lcdcmdout LcdClear

    If dht11 = 0 Then
    Lcdout "DHT22"
    Else
    Lcdout "DHT11"
    Endif

    rd_dht:
    WaitMs 1500  'wait for DHT
    TRISC.0 = 0  'pin to output
    PORTC.0 = 0  'init DHT
    WaitMs 20
    PORTC.0 = 1
    WaitUs 30
    TRISC.0 = 1  'set data pin

    'read DHT bit string
    ServoIn PORTC.0, dta(0)  'Wait for dht
    For bfr = 31 To 0 Step -1  'number of humidity and temp 10uSec periods/DHT bit
    ServoIn PORTC.0, dta(bfr)
    Next bfr

    For bfr = 7 To 0 Step -1  'humid HB
    rxi = bfr + 24
    If dta(rxi) > 5 Then tmpval.bfr = 1 Else tmpval.bfr = 0  'if > 50uSec its a '1'
    Next bfr
    humid.HB = tmpval

    For bfr = 7 To 0 Step -1  'humid LB
    rxi = bfr + 16
    If dta(rxi) > 5 Then tmpval.bfr = 1 Else tmpval.bfr = 0
    Next bfr
    humid.LB = tmpval

     
    Added the 1, 0 decode code fragment.
     
    Last edited: Jul 19, 2015
    • Agree Agree x 1
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,310
    Likes:
    914
    Location:
    Rochdale UK

    I have tried several times to get the DS2431 to work in Oshonsoft... I have never succeeded... For some reason the DS will not respond with the interface Vladimir has... I was actually going to write my own...

    ericgibbs .. Never thought of using the servo commands... I might try that one..
     

Share This Page