Sim with DSB1820

davidwf

Senior Member
How do I "adjust" the temperature values of a DSB1820 when running the simulator ?

Do I also need to tell it that the DSB is connected to C.4 or is that the only pin I can use ?

Thanks
 

Technical

Technical Support
Staff member
Commands such as readtemp which receive a byte value use the 'byte' column in the Values tab on the simulation panel.

You can also adjust this by right clicking over the pin in the Simulation diagram and using the radial slider.
 

davidwf

Senior Member
Again, thanks.

So, right clicking the pin is a really useful function..

But when I sertxd this back to the screen I am not geting the figure I expected.....(I was expecting the "value" set on the pin e.g. 150 etc.)

readtemp 4, b1

sertxd ("line 41 read temp ", b1,cr,lf)

if b1> setpoint then gosub do something
 

Snowghost

New Member
i am trying the same thing but with an LCD.
it works physicaly, but i can not get it to simulate, im not sure why.
im using the readtemp comand.
in the sim, changing the values on the side arnt doing anything.
there is no preset values either.

18x
editor 6

thanks
 

hippy

Technical Support
Staff member
@ Snowhost : Perhaps post your code so others can simulate it and see if they have the same problem as you do or if it works for them.
 

Snowghost

New Member
code as suggested as follows:
Code:
#picaxe 18x            'makes it for the 18x chip only.
                    'to use another chip would mean changing the input and output pins.
                    
init:                    'here are the innital set of instructions, run through once.

'symbol                'symbol is to rename a varable(storage byte) or input/output pin
symbol ROOFsensor = C.0    'Roofsensor is the name of the input C.0,(pin17) connected to the temp sensor in the ceiling space
symbol ROOMsensor = C.1    'Roomsensor is the name of the input C.1,(pin18) connected to the temp sensor in the room
symbol Display    = B.2    'Display is the name of the output B.2, (pin 2) connected to the 16x2 serial LCD Display

                    'varable/storage byte/word/ same thing
symbol RoofTemp    = b0    'RoofTemp becomes the name for the storage byte b0
symbol RoomTemp    = b1    'RoomTemp becomes the name for the storage byte b1
symbol SetTemp    = b2    'SetTemp becomes the name of the storage byte b2 
symbol LoadCount    = b3    'LoadCount becoumes the name of the varable we will use in the loading program
symbol RoofMax    = b4    'RoofMax becomes the name of the storage byte b4
symbol RoomMax    = b5    'RoomMax becomes the name of the storage byte b5
symbol RoofMin    = b6    'RoomMin becomes the name of the storage byte b6
symbol RoomMin    = b7    'RoomMin becomes the name of the storage byte b7
symbol RoofNeg    = b8    'RoomNeg becomes the name of the storage byte b8
symbol RoomNeg    = b9    'RoomNeg becomes the name of the storage byte b9

readtemp Roofsensor,RoofTemp            '"readtemp" is the command, 
Let RoofMax = RoofTemp                'read the temp of Roofsensor pin, put the value in RoofTemp
let RoofMin = RoofTemp                ' go through once and put the temp into max and min to have somewhere to start.
readtemp Roomsensor,RoomTemp            '"readtemp" is the command, 
Let RoomMax = RoomTemp                'read the temp of roomsensor pin, put the value in RoomTemp
let RoomMin = RoomTemp                ' go through once and put the temp into max and min to have somewhere to start.

serout Display,N2400,( 254,1 )    'Clear the LCD Display
                        'serial output on "Display" (output B.2 or pin 2 ,as noted under symbol)
                        'N2400 is the Baudrate
                        '"( 254,1 )" is the command to clear the display
pause 30                    'Clear command must be followed by a 30msec pause




`loading:                'this is the loading program, its just for fun
`Pause 3000                    'wait one second
`serout Display,N2400,( "Loading" )    'display the text "loading"
`Pause 1000                    'wait one second
`for LoadCount = 1 to 5            'the code between this "for" command and the the "next" command will
                        'run through five time, each time adding the value of one to the varable "LoadCount"
                        '(untill it reaches 5)    
`serout Display,N2400,( "." )        'adds "." to the text because the cursor has not been told to move
`Pause 1000                    'pause one second
`next LoadCount                'back to "for" command unless "loadcount" equals 5

`Pause 1000                    'pause another second(for effect)
`serout Display,N2400,( 254,1 )    'Clear the LCD Display
`pause 30                    'Clear command must be followed by a 30msec pause


GetRealTemps:            'this will contain the process for getting the true tempratures


debug
Pause 500                    'pause half a second

readtemp Roofsensor,RoofTemp            '"readtemp" is the command, 
                            'read the temp of Roofsensor pin, put the value in RoofTemp
if RoofTemp > 127 then gosub RoofNegSub    'if the roof temp value is more than 127 then its ment to be a negitive,
                            'so jump to subroutein to deal with it
if RoofTemp < 127 then let RoofNeg = 0    'but if its not, make sure the roofneg "flag" = 0
end if                        'end of if statment
if RoofTemp > RoofMax then gosub NewRoofMax
if RoofTemp < RoofMin then gosub NewRoofMin



readtemp Roomsensor,RoomTemp            '"readtemp" is the command, 
                            'read the temp of roomsensor pin, put the value in RoomTemp
if RoomTemp > 127 then gosub RoomNegSub    'if the room temp value is more than 127 then its ment to be a negitive,
                            'so jump to subroutein to deal with it                    
if RoomTemp < 127 then let RoomNeg = 0    'but if its not, make sure the roofneg "flag = 0
end if                        'end of if statment    
if RoomTemp > RoomMax then gosub NewRoomMax
if RoomTemp < RoomMin then gosub NewRoomMin


gosub OutputRoofTemp                'gosub jumps to a "sub routine", and will return to here at the end of that sub
gosub OutputRoomTemp                'the displays are split up so they can be updated independently, and altered
                            '(like in the case of negitave tempratures)
                        
goto GetRealTemps                'go back to the begining of getting the temps, at the moment




OutputRoofTemp:            'display the roof temprature    
                                
pause 500                    'wait half a second
Serout Display,N2400, (254,128)    '"(254,125)" sets the cursor to the first line                    
Serout Display,N2400, ("Roof=")    'display the text "Roof="
if RoofNeg = 1 then            'then it must be a negitive value
Serout Display,N2400, ("-")        'display the "-" sign
end if
Serout Display,N2400, (#RoofTemp)    'followed by displaying the value in varable Rooftemp
Serout Display,N2400, ("C")        'followed by a "C"
Pause 30                    'pause 30ms

Return                    'jump back to "gosub" in the "GetRealTemp" process


OutputRoomTemp:            'display the room temprature
Serout Display,N2400, (254,192)    '"(254,192)" sets the cursor to the second line
Serout Display,N2400, ("Room=")    'display the text "Room="
if RoomNeg = 1 then            'then it must be a negitive value
Serout Display,N2400, ("-")        'display the "-" sign
end if
Serout Display,N2400, (#RoomTemp)    'followed by displaying the value in varable Roomtemp
Serout Display,N2400, ("C")        'followed by a "C"
Pause 30                    'pause 30ms

Return                    'jump back to "gosub" in the "GetRealTemp" process


    RoofNegSub:                    'done here so the negative sign can be in the right place
    let RoofTemp = RoofTemp - 128        'the math required to show the negitive temprature corectly
    let RoofNeg = 1

    return


    RoomNegSub:                    'done here so the negative sign can be in the right place
    let RoomTemp = RoomTemp - 128        'the math required to show the negitive temprature corectly
    let RoofNeg = 1
    return


    NewRoofMax:
    Let RoofMax = RoofTemp 
    return

    NewRoofMin:
    let RoofMin = RoofTemp
    Return

    NewRoomMax:
    Let RoomMax = RoomTemp 
    return

    NewRoomMin:
    let RoomMin = RoomTemp
    Return
if someone could just plug that in and see if it works, that would be great.
thanks
 
Last edited by a moderator:
Top