1. Thermometer Program

This program appears to be an excellent example of using the parallel
port.  I get an error, however, when I run it.  Besides the fact that I
don't have the custom thermometer interface,  I don't have the files that
the program includes at the beginning;
include udelay.e        -- Sligth modification of delay.e. Same but the
include ports.e         --  parameter is in milliseconds
include bitwise.e       -- I miss a fast bitwise SHR SHL here...
include keypress.e      -- Missing in get.e. Keypress() return true if
include graphics.e      --  a key has been pressed, but doesn't get the
include font.e          --  character. (This one is mine!)
include file.e

I do not own a copy of the registered Euphoria.  Do these include files
come withe the full version.  If not, does anyone know where I can get
copies of them.

Here is the whole program:

-- Termometer based upon a Dallas DS1620 chip via parallel port on the PC
-- From an article appeared at Electronique Practique

-- By Jesus Consuegra (jconsuegra at redestb.es)

-- Acknowledgments to Robert Craig for such a nice environment,
--      to Jiri Babor for the font procedures,
--      to Jacques Deschemes for his help in delay.


include udelay.e        -- Sligth modification of delay.e. Same but the
include ports.e         --  parameter is in milliseconds
include bitwise.e       -- I miss a fast bitwise SHR SHL here...
include keypress.e      -- Missing in get.e. Keypress() return true if
include graphics.e      --  a key has been pressed, but doesn't get the
include font.e          --  character. (This one is mine!)
include file.e


-- Globals --

byte PortCommand

constant PowerOn    = #01,  -- We power the termometer on by raising D0
  PowerOff   = #FE,
  ClockOn    = #20,
  ClockOff   = #DF,
  ResetOn    = #BF,
  ResetOff   = #40,
  OutHigh    = #80,
  OutLow     = #7F,
  OutPort    = #378,     -- Change this if you are using LPT2 or 3
  InPort     = OutPort + 1
-- ---------------------------------------
procedure InitPort()
    Output(PowerOn, OutPort)
    uDelay(1000)
end procedure
-- ---------------------------------------
procedure ClosePort()
    Output(PowerOff, OutPort)
    uDelay(1000)
end procedure
-- ---------------------------------------
procedure SendControl(byte ControlData)
byte Control
Control = ControlData
for i=0  to 7 do
    PortCommand = AND(PortCommand, ClockOff)
    Output(PortCommand, OutPort)
    if (remainder(Control,2)=0) then
 PortCommand = AND(PortCommand, OutLow)
    else
 PortCommand = OR(PortCommand, OutHigh)
    end if
    Output(PortCommand, OutPort)
    Control = floor (Control / 2)
    uDelay(5)
    PortCommand = OR(PortCommand, ClockOn)
    Output(PortCommand, OutPort)
    uDelay(5)
end for
end procedure
-- --------------------------------------
procedure Reset()
    PortCommand = AND(PortCommand, ResetOn)
    Output(PortCommand, OutPort)
    uDelay(5)
    PortCommand = OR(PortCommand, ResetOff)
    Output(PortCommand, OutPort)
    uDelay(5)
end procedure
-- --------------------------------------
function ReadChip()
integer DataIn
byte    temp
    PortCommand = 0
    Reset()
    SendControl(#0C)
    SendControl(#03)
    Reset()
    SendControl(#EE)
    SendControl(#00)
    Reset()
    SendControl(#AA)
    PortCommand = OR(PortCommand, OutHigh)
    Output(PortCommand, OutPort)
    DataIn = 0
    for i=0  to 8 do
 PortCommand = AND(PortCommand, ClockOff)
 Output(PortCommand, OutPort)
 uDelay(5)
 temp = Input(InPort)
 DataIn = DataIn + (AND(floor(temp/64), #01) * power(2,i))
 PortCommand = OR(PortCommand, ClockOn)
 Output(PortCommand, OutPort)
 uDelay(5)
    end for
    return DataIn
end function
-- --------------------------------------
--
-- Main body
--
-- --------------------------------------

integer Temp1
atom    TempE
sequence f

integer Xt,Yt,X0,Y0,
 Xr, Yr

InitPort()
if graphics_mode(18) then
end if

    X0 = 0
    Y0 = 0
    Xt = 276
    Yt = 46
    set_rand(12345)

    fy  = 10
    fsc = 0
    ftc = 14
    f   ={}
    f   = f&fload("Modern28.f")
    fx  = 10

while (not keypressed()) do
    Temp1 = ReadChip()
    if (Temp1 >= 256) then
 Temp1 = Temp1 - 512
    end if
    TempE = Temp1/2
--  printf(1, "La temperatura es %f grados\n", TempE)

    Xr = rand(639-Xt)
    Yr = rand(479-Yt)
    fx = Xr + 10
    fy = Yr + 10
    fprint(sprintf("La temperatura es: %-5.1f", TempE))
    fp[1] = 0
    fp[6] = 0
    fx=10
    fy=10
    ftc=14
    uDelay(1000)
end while
ClosePort()
if graphics_mode(-1) then
end if
-- Freeports()

new topic     » topic index » view message » categorize

2. Re: Thermometer Program

----- Original Message -----
From: Andy Briggs <briggsan at HOTMAIL.COM>
To: <EUPHORIA at LISTSERV.MUOHIO.EDU>
Sent: Wednesday, January 05, 2000 6:09 AM
Subject: Thermometer Program


> This program appears to be an excellent example of using the parallel
> port.  I get an error, however, when I run it.  Besides the fact that I
> don't have the custom thermometer interface,  I don't have the files that
> the program includes at the beginning;
> include udelay.e        -- Sligth modification of delay.e. Same but the
> include ports.e         --  parameter is in milliseconds
> include bitwise.e       -- I miss a fast bitwise SHR SHL here...
> include keypress.e      -- Missing in get.e. Keypress() return true if
> include graphics.e      --  a key has been pressed, but doesn't get the
> include font.e          --  character. (This one is mine!)
> include file.e
>
> I do not own a copy of the registered Euphoria.  Do these include files
> come withe the full version.  If not, does anyone know where I can get
> copies of them.

Yes, they are all in one zip file on the Eu archives page. However, all the
files seem to prefer dos,, i can't get a one of them to run in win95, and i
do have the complete edition. I haven't tried those files in dos, since i
can write dos code easily, what i wanted was code that peacefully co-exists
with windoze. The code as supplied gives me a dozen error msgs, from "can't
load whatever.bmp" to "attempt to redefine something",, and of course, "out
of bounds in win32lib" (caused no doubt by an ancient win32lib). Hardtst
prints out some Spanish and "-0.5" on a dos screen, but since it's a exe or
com file (i didn't bother checking which), it's impossible to interface it
to anything well.

I hope you have better luck than i do,

Kat

new topic     » goto parent     » topic index » view message » categorize

3. Re: Thermometer Program

Andy:
The thermometer was fully functional and is still being used at the
Pharmeceutical laboratory where I was working a year or so ago. I did
several improvements, a Windows version, more accuracy and lately added the
ability to save a temperature log.

Even without the temp probe connected, you should get a -0.5 C degree
reading.

Up to my knowledge, the version at the Euphoria web site was complete, with
all the .e files needed.
Udelay (microdelay) and the other routines could probably be replaced by new
features of the language.
My current job is taking me most of my whole time (including nights and
holidays), so I cannot promise to check the program soon, but I'll try.
Most of the additional routines to manage ports, etc. were taken from the
excelent Jiri Barbor libraries.
Jesus.

Asunto: Thermometer Program


>This program appears to be an excellent example of using the parallel
>port.  I get an error, however, when I run it.  Besides the fact that I
>don't have the custom thermometer interface,  I don't have the files that
>the program includes at the beginning;
>include udelay.e        -- Sligth modification of delay.e. Same but the
>include ports.e         --  parameter is in milliseconds
>include bitwise.e       -- I miss a fast bitwise SHR SHL here...
>include keypress.e      -- Missing in get.e. Keypress() return true if
>include graphics.e      --  a key has been pressed, but doesn't get the
>include font.e          --  character. (This one is mine!)
>include file.e
>
>I do not own a copy of the registered Euphoria.  Do these include files
>come withe the full version.  If not, does anyone know where I can get
>copies of them.
>
>Here is the whole program:
>
>-- Termometer based upon a Dallas DS1620 chip via parallel port on the PC
>-- From an article appeared at Electronique Practique
>
>-- By Jesus Consuegra (jconsuegra at redestb.es)
>
>-- Acknowledgments to Robert Craig for such a nice environment,
>--      to Jiri Babor for the font procedures,
>--      to Jacques Deschemes for his help in delay.
>
>
>include udelay.e        -- Sligth modification of delay.e. Same but the
>include ports.e         --  parameter is in milliseconds
>include bitwise.e       -- I miss a fast bitwise SHR SHL here...
>include keypress.e      -- Missing in get.e. Keypress() return true if
>include graphics.e      --  a key has been pressed, but doesn't get the
>include font.e          --  character. (This one is mine!)
>include file.e
>
>
>-- Globals --
>
>byte PortCommand
>
>constant PowerOn    = #01,  -- We power the termometer on by raising D0
>  PowerOff   = #FE,
>  ClockOn    = #20,
>  ClockOff   = #DF,
>  ResetOn    = #BF,
>  ResetOff   = #40,
>  OutHigh    = #80,
>  OutLow     = #7F,
>  OutPort    = #378,     -- Change this if you are using LPT2 or 3
>  InPort     = OutPort + 1
>-- ---------------------------------------
>procedure InitPort()
>    Output(PowerOn, OutPort)
>    uDelay(1000)
>end procedure
>-- ---------------------------------------
>procedure ClosePort()
>    Output(PowerOff, OutPort)
>    uDelay(1000)
>end procedure
>-- ---------------------------------------
>procedure SendControl(byte ControlData)
>byte Control
>Control = ControlData
>for i=0  to 7 do
>    PortCommand = AND(PortCommand, ClockOff)
>    Output(PortCommand, OutPort)
>    if (remainder(Control,2)=0) then
> PortCommand = AND(PortCommand, OutLow)
>    else
> PortCommand = OR(PortCommand, OutHigh)
>    end if
>    Output(PortCommand, OutPort)
>    Control = floor (Control / 2)
>    uDelay(5)
>    PortCommand = OR(PortCommand, ClockOn)
>    Output(PortCommand, OutPort)
>    uDelay(5)
>end for
>end procedure
>-- --------------------------------------
>procedure Reset()
>    PortCommand = AND(PortCommand, ResetOn)
>    Output(PortCommand, OutPort)
>    uDelay(5)
>    PortCommand = OR(PortCommand, ResetOff)
>    Output(PortCommand, OutPort)
>    uDelay(5)
>end procedure
>-- --------------------------------------
>function ReadChip()
>integer DataIn
>byte    temp
>    PortCommand = 0
>    Reset()
>    SendControl(#0C)
>    SendControl(#03)
>    Reset()
>    SendControl(#EE)
>    SendControl(#00)
>    Reset()
>    SendControl(#AA)
>    PortCommand = OR(PortCommand, OutHigh)
>    Output(PortCommand, OutPort)
>    DataIn = 0
>    for i=0  to 8 do
> PortCommand = AND(PortCommand, ClockOff)
> Output(PortCommand, OutPort)
> uDelay(5)
> temp = Input(InPort)
> DataIn = DataIn + (AND(floor(temp/64), #01) * power(2,i))
> PortCommand = OR(PortCommand, ClockOn)
> Output(PortCommand, OutPort)
> uDelay(5)
>    end for
>    return DataIn
>end function
>-- --------------------------------------
>--
>-- Main body
>--
>-- --------------------------------------
>
>integer Temp1
>atom    TempE
>sequence f
>
>integer Xt,Yt,X0,Y0,
> Xr, Yr
>
>InitPort()
>if graphics_mode(18) then
>end if
>
>    X0 = 0
>    Y0 = 0
>    Xt = 276
>    Yt = 46
>    set_rand(12345)
>
>    fy  = 10
>    fsc = 0
>    ftc = 14
>    f   ={}
>    f   = f&fload("Modern28.f")
>    fx  = 10
>
>while (not keypressed()) do
>    Temp1 = ReadChip()
>    if (Temp1 >= 256) then
> Temp1 = Temp1 - 512
>    end if
>    TempE = Temp1/2
>--  printf(1, "La temperatura es %f grados\n", TempE)
>
>    Xr = rand(639-Xt)
>    Yr = rand(479-Yt)
>    fx = Xr + 10
>    fy = Yr + 10
>    fprint(sprintf("La temperatura es: %-5.1f", TempE))
>    fp[1] = 0
>    fp[6] = 0
>    fx=10
>    fy=10
>    ftc=14
>    uDelay(1000)
>end while
>ClosePort()
>if graphics_mode(-1) then
>end if
>-- Freeports()

new topic     » goto parent     » topic index » view message » categorize

4. Re: Thermometer Program

Jesus just wrote:

>Most of the additional routines to manage ports, etc. were taken from the
>excelent Jiri Barbor libraries.

What he really meant were Jacques Deschenes' libraries. jiri

new topic     » goto parent     » topic index » view message » categorize

5. Re: Thermometer Program

Jiri Babor wrote:

> Jesus just wrote:
>

Sorry for the off topic post, and I know most people want this list to be as
non-sectarian as possible, but that just strikes me a damned funny.

Greg

new topic     » goto parent     » topic index » view message » categorize

6. Re: Thermometer Program

Thanks, Greg. At least one of you noticed. jiri

new topic     » goto parent     » topic index » view message » categorize

7. Re: Thermometer Program

Hi, I found Ports.e by doing a search.  I included it into my program, and with
only one line of code [    Output(pos,#378)    ] was able to write to the
parallel port.  How easy is that!!!!?  I had no errors or anything; worked the
first try.  Thank you everyone for all your help...

new topic     » goto parent     » topic index » view message » categorize

8. Re: Thermometer Program

Right!. More that one year away, memory fails...
The nice routines I used in the Thermometer program from Jiri were the font
ones...
Sincere apologies to Jacques.
Jesus.

-----Mensaje original-----
De: Jiri Babor <J.Babor at GNS.CRI.NZ>
Para: EUPHORIA at LISTSERV.MUOHIO.EDU <EUPHORIA at LISTSERV.MUOHIO.EDU>
Fecha: jueves 6 de enero de 2000 1:22
Asunto: Re: Thermometer Program


>Jesus just wrote:
>
>>Most of the additional routines to manage ports, etc. were taken from the
>>excelent Jiri Barbor libraries.
>
>What he really meant were Jacques Deschenes' libraries. jiri
>

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu