Author Topic: de'tokenising'  (Read 5873 times)

Offline DavidA

  • Hero Member
  • *****
  • Posts: 1219
  • Country: gb
de'tokenising'
« on: October 20, 2014, 07:00:01 AM »
Here is one for the programers.

Many years ago I purchased a small device that plugs into my serial port and takes temperature readings every second.

The problem is that once a second is too frequent.  I only need one per minute.

Now,  the obvious thing to me is to look at the program that came with it,  find the timing loop and change it.
But when I look at it using DOS Edit it appears as a list of 'tokenised' text. Might as well be hieroglyphs.   So it is not readable.

Can anyone tell me how I find out what language the program was written in ?

And how to set about making it readable.  I suppose it means getting hold of a de-compiling program of some sort.  But I'm only used to BASIC and some x86 Assembler.

Dave. :scratch:

Offline Joules

  • Hero Member
  • *****
  • Posts: 1271
  • Country: gb
Re: de'tokenising'
« Reply #1 on: October 20, 2014, 07:06:56 AM »
How does it present its output ? ascii or a way of getting the reading into a spreadsheet ?

Anymore details on the hardware or the software it came with ?
Honour your mentors, and pay it forward.

Offline RussellT

  • Hero Member
  • *****
  • Posts: 520
  • Country: gb
Re: de'tokenising'
« Reply #2 on: October 20, 2014, 11:38:16 AM »
It sounds to me as though it might be easier to write a new program.

If the timing is controlled from the software then presumably it's sending a few bytes to the serial port and then reading the reply.

Is it a common device?  If so it's quite likely that the protocol will be cocumented somewhere on the internet.

Russell
Common sense is unfortunately not as common as its name suggests.

Offline awemawson

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8966
  • Country: gb
  • East Sussex, UK
Re: de'tokenising'
« Reply #3 on: October 20, 2014, 12:36:58 PM »
David,

It could be machine code. Can you save it as a binary file and post  it here for us to look at?

Possibly also a picture of the device - (may be able to deduce something from any markings on it)
Andrew Mawson
East Sussex

Offline DavidA

  • Hero Member
  • *****
  • Posts: 1219
  • Country: gb
Re: de'tokenising'
« Reply #4 on: October 20, 2014, 03:26:22 PM »
The item comes as a kit and takes four Dallas DS18S20 temperature sensors.

It then uses a programed 12C509/P04 chip to convert these four inputs and pass them via rs232 serial to the computer.

The computer runs a program called TERM and this pols each input in turn once a second and displays the results on the screen as degrees centigrade.

I'm not sure how much of the processing is done with the Eprom,  whether it is just a multiplexor and A to D convertor.

I recently bought another of these devices and have just opened the packet to see what is there.

Just having a look at the paper work.

As well as saying that the TERM.EXE program is available from their website (Quasarelectronics.com) it also refers to the designer having provided the C source code. Must try and find that.

Also a reference to using BASIC's INPUT command to capture the data as it comes in. That may be my best bet.

I'm going off to search for this source code.

Back later.

Dave.

Quasar project kit # 3145v2.3  temperature data logger.

New code.

www.quasarelectronics.co.uk/Item/3145-ds18s20-computer-serial-temperature-data-logger

 

Offline awemawson

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8966
  • Country: gb
  • East Sussex, UK
Re: de'tokenising'
« Reply #5 on: October 20, 2014, 04:41:16 PM »
David,

From the web site description:

The output data is a continuous stream in simple text format (sensor number followed by temperature reading to 2 decimal places). Simply capture the data to a text file and then import it into Excel to produce tables and charts of temperature readings over time.

Write a diddy to capture the data, and either average sixty readings and use the result, or only save one reading in sixty, to get your 1 reading per minute requirement
Andrew Mawson
East Sussex

Offline RussellT

  • Hero Member
  • *****
  • Posts: 520
  • Country: gb
Re: de'tokenising'
« Reply #6 on: October 20, 2014, 05:49:03 PM »
If it outputs a continuous data stream then your "term" program is presumably just sampling the input 60 times a minute - there could be a lot more data than that.  I still think writing a new program to sample the port data would be straightforward - but if you have the source code for the existing program it should be even easier.

Russell
Common sense is unfortunately not as common as its name suggests.

Offline DavidA

  • Hero Member
  • *****
  • Posts: 1219
  • Country: gb
Re: de'tokenising'
« Reply #7 on: October 21, 2014, 06:18:42 AM »
Thinking about this.
The way to go for me seems to be to,  as suggested,  write a short BASIC program that takes a reading every minute then stores the reading to a sequential file.
As the readings are to be part of a continually running data gathering exercise,  and I don't want this single aspect hogging the computer,  I am going to try set it up using the clock (Time string) to trigger the read program. If I allow half a second every time the seconds section of the string (A$=time$: b$=a$(right$,2) or something similar  reaches 00 then I will have fifty nine and a half seconds free for other things.  A long time even for an old 486.

Thanks for the help on this one.

Dave.

Offline porker

  • Jr. Member
  • **
  • Posts: 22
  • Country: england
Re: de'tokenising'
« Reply #8 on: October 21, 2014, 04:31:19 PM »
I guess you have found that the C source code is linked to at the bottom of the page under Software options. The simplest way would be to modify that program but I took a look and it looks like it runs in a tight infinite loop so not letting another process come in as you want (I'm more of a Linux person so not sure whether programs are allowed to 'hog' all the CPU time or not - I know older versions of Windows they could).
I don't know whether there is a CRON equivalent for Windows to allow you to easily schedule your program to execute every 60s, capture a temp reading and append to a file. That's how I would do it.
Interesting to see the sensor itself outputs a digital signal and the PIC is just sending out on the RS232 line. Neat.

Offline DavidA

  • Hero Member
  • *****
  • Posts: 1219
  • Country: gb
Re: de'tokenising'
« Reply #9 on: October 22, 2014, 06:49:39 AM »
Porker,

Yes,  you are right .  The original is more or less a stand alone program that hogs the machine it is running on.  Not what I want at all.
I'm going to go with the idea of creating a BASIC prog that I can use as a sub-routine and call it every minute from the main program  to take one set of readings from each of the four inputs. Then save these to a file.

What I do at the moment (or when I use the device) is to let it run for a while,  then use a small BASIC program to create a new file from every sixtieth reading of the original.  Much more manageable when I pass this to my spreadsheet for graphing.

Those sensors are quite nifty,  and relatively expensive.

At the moment I am getting my 'den' ready for the coming cold weather.  I just won a set of six driving wheel castings on Ebay,  so I will have to get back into the modelling frame of mind,
What with that and the car,  there isn't even time to think about getting old.

Dave.

Offline around

  • Jr. Member
  • **
  • Posts: 8
  • Country: ca
Re: de'tokenising'
« Reply #10 on: October 24, 2014, 01:08:11 AM »
David,

It looks from the website that the 12C509A is socketed and can be removed.  I had a quick rummage through my parts bins and found some spare 12F683 chips.  They are a pin for pin replacement for the 12C509A (albeit rather more capable).  I have done several Dallas one-wire projects and would be happy to flash one of the 12F683 chips with code that would output the four temperature measurements once a minute or at what ever interval would work for you.  Let me know if your are interested.

Cheers,

Adrian



 

Offline DavidA

  • Hero Member
  • *****
  • Posts: 1219
  • Country: gb
Re: de'tokenising'
« Reply #11 on: October 24, 2014, 06:03:30 AM »
Adrian,

Sounds good to me.

PM follows.

Dave.